[Pixel C Android Development] followmsi:
Again some time for Pixel C :)

And we still have the nice Pixel C AOSP build-tree .. but synced on r32.

If you have a look here ... https://source.android.com/source/build-numbers.html#source-code-tags-and-builds

There is already a version r43 - which is supposed for the Nexus 7.

Let´s build a r43 AOSP system.img now .. but for Pixel C. :)

First we backup the existing folder /device/google/dragon and dragon_kernel.

We backup the changed "HOST_x86_common.mk" file, which we changed before, for the r32 build.

Once backuped .. just the remove the changed file and the /device/google/dragon (kernel) folders completely.

As well we replace TWRP recovery with stock recovery folder. (/bootable/recovery)

The /external/busybox folder you can keep.

It´s better to clean up before we change the version number .. like this now ..

repo init -u [url]https://android.googlesource.com/platform/manifest[/url] -b android-6.0.1_r43
repo sync

Once done .. we do restore from backup - the same vice versa.

Replace TWRP with stock recovery

Overwrite the new "HOST_x86_common.mk" with changed one from backup ..

Copy the both Dragon folders into the /device/google/ folder .. same location as in r32.

Time for the first run ...

. build/envsetup.sh
lunch aosp_dragon-userdebug

make -j8

compiling .. compiling .......

device/google/dragon/DragonKeyboard/res/xml/keyboard_layouts.xml:5: error: No resource identifier found for attribute 'vendorId' in package 'android'
device/google/dragon/DragonKeyboard/res/xml/keyboard_layouts.xml:5: error: No resource identifier found for attribute 'productId' in package 'android'
device/google/dragon/DragonKeyboard/res/xml/keyboard_layouts.xml:5: error: No resource identifier found for attribute 'locale' in package 'android'
.. .. ..

The error messages you will see .. approx. 50 min after start of compilation - just before the end. :)

The compilation is not able to make the "DragonKeyboard.apk" - same sources are working fine on r32.

Should be fixed easy .. some schemas manifest.xml related stuff .. but it was not that easy to fix - at least not for me. :)

Now we do it "dirty" - again ;)

Inside the dragon folder is a file called .. device.mk

https://android.googlesource.com/device/google/dragon/+/android-6.0.1_r32/device.mk

We just remove the "problem app" ..

Original:

# for keyboard key mappings
PRODUCT_PACKAGES += \
DragonKeyboard

Changed:

# for keyboard key mappings
# PRODUCT_PACKAGES += \
# DragonKeyboard

The .apk itself will be taken from r32 build, where the same code is compiling fine :)

And let´s start the new compilation ... with changed device.mk inside dragon device folder.

Running: mkuserimg.sh -s out/target/product/dragon/system out/target/product/dragon/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 3728470016 -D out/target/product/dragon/system -L system out/target/product/dragon/root/file_contexts
make_ext4fs -s -T -1 -S out/target/product/dragon/root/file_contexts -L system -l 3728470016 -a system out/target/product/dragon/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/dragon/system out/target/product/dragon/system
Creating filesystem with parameters:
Size: 3728470016
Block size: 4096
Blocks per group: 32768
Inodes per group: 8128
Inode size: 256
Journal blocks: 14222
Label: system
Blocks: 910271
Block groups: 28
Reserved block group size: 223
Created filesystem with 1923/227584 inodes and 145079/910271 blocks
build_verity_tree -A aee087a5be3b982978c923f566a94613496b417f2af592639bc80d141e34dfe7 out/target/product/dragon/obj/PACKAGING/systemimage_intermediates/system.img /tmp/tmpbSWjwE_verity_images/verity.img
system/extras/verity/build_verity_metadata.py 3728470016 /tmp/tmpbSWjwE_verity_images/verity_metadata.img 5ad53d5c021a110f0985e307748975b2a3952d55ec2b83cdc645fbf14bc5b016 aee087a5be3b982978c923f566a94613496b417f2af592639bc80d141e34dfe7 /dev/block/platform/700b0600.sdhci/by-name/APP out/host/linux-x86/bin/verity_signer build/target/product/security/verity.pk8
append2simg out/target/product/dragon/obj/PACKAGING/systemimage_intermediates/system.img /tmp/tmpbSWjwE_verity_images/verity_metadata.img
append2simg out/target/product/dragon/obj/PACKAGING/systemimage_intermediates/system.img /tmp/tmpbSWjwE_verity_images/verity.img
Install system fs image: out/target/product/dragon/system.img
out/target/product/dragon/system.img+out/target/product/dragon/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=3836777472 blocksize=4224 total=565176413 reserve=38759424

#### make completed successfully (01:11:15 (hh:mm:ss)) ####

out/target/product/dragon# ll
total 743176
drwxr-xr-x 13 root root 4096 May 30 17:25 ./
drwxr-xr-x 3 root root 4096 May 30 16:14 ../
-rw-r--r-- 1 root root 21 May 30 16:16 android-info.txt
-rw-r--r-- 1 root root 9072640 May 30 17:08 boot.img
-rw-r--r-- 1 root root 1208 May 30 17:08 boot.img.keyblock
-rw-r--r-- 1 root root 8992768 May 30 17:08 boot.img.unsigned
drwxr-xr-x 2 root root 4096 May 30 17:04 cache/
-rw-r--r-- 1 root root 8388912 May 30 17:04 cache.img
-rw-r--r-- 1 root root 73752 May 30 16:14 clean_steps.mk
drwxr-xr-x 4 root root 4096 May 30 17:07 data/
drwxr-xr-x 2 root root 4096 May 30 17:10 fake_packages/
drwxr-xr-x 5 root root 4096 May 30 16:39 gen/
-rw-r--r-- 1 root root 83453 May 30 17:24 installed-files.txt
-rw-r--r-- 1 root root 7628648 May 30 16:39 kernel
drwxr-xr-x 16 root root 4096 May 30 17:24 obj/
drwxr-xr-x 6 root root 4096 May 30 16:15 obj_arm/
-rw-r--r-- 1 root root 807 May 30 16:14 previous_build_config.mk
-rw-r--r-- 1 root root 1360384 May 30 17:07 ramdisk.img
-rw-r--r-- 1 root root 5895142 May 30 17:17 ramdisk-recovery.img
drwxr-xr-x 3 root root 4096 May 30 16:16 recovery/
-rw-r--r-- 1 root root 13606912 May 30 17:17 recovery.img
-rw-r--r-- 1 root root 1208 May 30 17:17 recovery.img.keyblock
-rw-r--r-- 1 root root 13527040 May 30 17:17 recovery.img.unsigned
drwxr-xr-x 10 root root 4096 May 30 17:07 root/
drwxr-xr-x 7 root root 4096 May 30 17:08 symbols/
drwxr-xr-x 14 root root 4096 May 30 17:17 system/
-rw-r--r-- 1 root root 561085260 May 30 17:25 system.img
drwxr-xr-x 5 root root 4096 May 30 17:17 vendor/
-rw-r--r-- 1 root root 131197404 May 30 16:39 vendor.img

As you can see .. a new TWRP recovery.img based on r43 and the new system.img ..

Now we need to "loop mount" both system.img. (r32 + r43)

To convert a system.img into ext4 file system you just use this command ..

simg2img system.img system.ext4.img

loop mount:

mkdir system
mount -o loop system.ext4.img system/

Now we copy the /app/DragonKeyboard/ folder from one system.img (r32) into the other system.img (r43).

umount system/

The system.img is quite large .. this the actual size of the partiton inside Pixel C.

Let´s shrink it ..

e2fsck -f system.ext4.img
resize2fs -M system.ext4.img

Now we have a new AOSP ROM for Pixel C - but based on r43 - the latest sources tagged by google.

This is an ext4 system.img now .. TWRP is not able to flash ext4 system.img via UI ..

But via edify scripts, like I do it in my Update.zip packages.

Of course you can repack an ext4 system.img back into "simg2" format ...

img2simg system.ext4.img system.img

Here is the image .. for further playing ...

Update.ZIP_PixelC_Ryu_AOSP_6.0.1_r43_system.img_v160530.zip

To be installed via TWRP using the Update.ZIP.

And if you don´t like the Update.zip .. now you know how to build simg2 system.img for fastboot flashing. :)

The next AOSP compilation will be done on Android N sources ... :)

Cheers