anestisb / android-prepare-vendor

Set of scripts to automate AOSP compatible vendor blobs generation from factory images
348 stars 155 forks source link

API 28 support (Android 9.0) #127

Closed dan-v closed 6 years ago

dan-v commented 6 years ago

Google released Android 9.0 on August 6th with a new API version 28.

I've compiled new version of tools (oatdump), built standard AOSP 9.0 and compared to stock factory image, updated scripts and config files (mostly copy and paste of version 27 config with some file additions/removals based on diff of AOSP vs stock image) and have so far made unsuccessful builds that don't boot on my Pixel XL. It's unfortunately not getting far enough along in the boot process for me to see anything with ADB and I don't have a serial cable built yet for debugging further.

I'm not entirely certain what process you follow to determine if a file that exists in stock image but not in AOSP is required and should be added to a specific section of config. Any tips would be appreciated.

# execute-all.sh --device marlin --buildID ppr1.180610.009 --output "${BUILD_DIR}/vendor/android-prepare-vendor"
[*] Extracting '/home/ubuntu/rattlesnake-os/vendor/android-prepare-vendor/marlin/ppr1.180610.009/marlin-ppr1.180610.009-factory-90a4fa8b.zip'
[*] Unzipping 'image-marlin-ppr1.180610.009.zip'
[*] Processing with 'API-28 naked' configuration
[*] '2' bytecode archive files will be repaired
[*] Repairing bytecode under /system partition using oatdump method
[!] '/priv-app/CNEService/CNEService.apk' not pre-optimized with sanity checks passed - copying without changes
[!] '/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk' not pre-optimized with sanity checks passed - copying without changes
[*] System partition successfully extracted & repaired at '/home/ubuntu/rattlesnake-os/vendor/android-prepare-vendor/marlin/ppr1.180610.009/factory_imgs_repaired_data'
[*] Generating 'marlin' vendor blobs
[*] Copying radio files '/home/ubuntu/rattlesnake-os/vendor/android-prepare-vendor/marlin/ppr1.180610.009/vendor/google_devices/marlin'
[*] Copying product files & generating 'marlin-vendor-blobs.mk' makefile
[*] Generating 'device-vendor-marlin.mk'
[*] Generating 'AndroidBoardVendor.mk'
  [*] Bootloader:8996-012001-1804121206
  [*] Baseband:8996-130181-1806061856
[*] Generating 'BoardConfigVendor.mk'
[*] Generating 'vendor-board-info.txt'
[*] Generating 'Android.mk'
[*] Gathering data from 'vendor/app' APK/JAR pre-builts
[*] Gathering data from 'vendor/framework' APK/JAR pre-builts
[*] Gathering data from 'vendor/overlay/Pixel' APK/JAR pre-builts
[*] Gathering data from 'proprietary/priv-app' APK/JAR pre-builts
[!] Orphan bytecode file detected 'DisplayCutoutEmulationCornerOverlay.apk' & removed
[!] Orphan bytecode file detected 'DisplayCutoutEmulationDoubleOverlay.apk' & removed
[!] Orphan bytecode file detected 'DisplayCutoutEmulationTallOverlay.apk' & removed
[!] Orphan bytecode file detected 'framework-res__auto_generated_rro.apk' & removed
[!] Orphan bytecode file detected 'SysuiDarkThemeOverlay.apk' & removed
[*] Processing standalone symlinks
[*] Generating signatures file
[*] Generating build_id file
[*] Import '/home/ubuntu/rattlesnake-os/vendor/android-prepare-vendor/marlin/ppr1.180610.009/vendor' vendor blobs to AOSP root
[*] Import '/home/ubuntu/rattlesnake-os/vendor/android-prepare-vendor/marlin/ppr1.180610.009/vendor_overlay' vendor overlays to AOSP root
[*] All actions completed successfully
dan-v commented 6 years ago

Here is a file list diff of latest AOSP (android-9.0.0_r1) vs stock 9.0 (ppr1.180610.009) for Pixel XL:

Note there are a few apps that I forgot to remove from AOSP build that can be ignored (e.g. F-Droid, Updater app, Chromium).

mydongistiny commented 6 years ago

Here is what I did to get marlin/sailfish to boot.

marlin https://hastebin.com/limukijeti.json

sailfish https://hastebin.com/ilomabovaw.json

You also need:

system/lib64/vendor.qti.atcmdfwd@1.0 system/lib64/vendor.qti.qcril.am@1.0.so system/framework/qcrilhook.jar

Also, it's not needed to boot, but I added this to the Makefile to get SSRestartDetector in the build.

include $(CLEAR_VARS) LOCAL_MODULE := SSRestartDetector LOCAL_MODULE_TAGS := optional LOCAL_BUILT_MODULE_STEM := package.apk LOCAL_MODULE_OWNER := google LOCAL_MODULE_PATH := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_PRODUCT)/app LOCAL_SRC_FILES := proprietary/app/SSRestartDetector/SSRestartDetector.apk LOCAL_CERTIFICATE := platform LOCAL_PRODUCT_MODULE := true LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) include $(BUILD_PREBUILT)

dan-v commented 6 years ago

@mydongistiny - thanks for posting this! Are you building naked or full configuration? My naked configuration looks fairly similar but after booting a bunch of the underlying services are crashing constantly. I'll do a build with your exact configuration and see what happens.

mydongistiny commented 6 years ago

I built with both naked and full. I'm using full all the time now though.

Oh and to stop the crashing try this:

https://github.com/BenzoRom/device_google_marlin/commit/68a21d941282b8f00e4210421988317b212c2f34

I forgot, but that was causing crashing because of the enforce being enabled on priv-app permissions.

dan-v commented 6 years ago

Ah yeah, I did already add a workaround for that. My device was just hanging on the splash screen and I saw messages about that over logcat.

I'm currently building naked with your config and I'll see if there are any improvements.

dan-v commented 6 years ago

@mydongistiny - I'm up and running with your config and I don't see all of the previous issues I was seeing! I think the difference was 'system/framework/qcrilhook.jar', which didn't make it into my previous build. Is there any nice way to add that into existing config? I added it to system-bytecode section and then just modified system-img-repair.sh to just copy the jar as is, but I'm guessing there's a better way to handle that..

mydongistiny commented 6 years ago

Without qcrilhook.jar and the vendor.qti* libs the radio wouldn't work. I believe @anestisb has to update his tools to get qcrilhook.jar fixed and to copy successfully so until then I guess just do it how you're doing it. Hopefully he sees this and can add the configs to save him some time when he does get around to it.

anestisb commented 6 years ago

Have started upgrading my build env today with the Android 9 material. Will have the first builds later today, so hopefully a stable naked config will be ready the next couple of days.

dan-v commented 6 years ago

Thanks so much @anestisb !!

anestisb commented 6 years ago

Xmm, support might not be as fast as we hoped (https://twitter.com/anestisb/status/1028568907542671360).

[!] '/priv-app/LLKAgent/LLKAgent.apk' not pre-optimized with sanity checks passed - copying without changes
[-] '1' DEX files exported, although only '0' repaired
[-] 'VerizonUnifiedSettings' bytecode repair failed (most probably due to CDEX)
[-] System partition bytecode repair failed

Will have to create some tool (or oatdump patches) to extract DEX from CDEX, since it appears to be used in Pie factory images.

dan-v commented 6 years ago

@anestisb - in the naked configuration for marlin/sailfish, the only file I had issue with including is 'system/framework/qcrilhook.jar'. I ended up just copying it as is and it seems to work. Maybe we could push out support for just naked configs for the time being?

anestisb commented 6 years ago

Indeed the naked config in sailfish does not hit the CDEX case. Have already made a build with a baseline config. Will diff/flash/test later today and commit a functional version soon.

anestisb commented 6 years ago

sailfish support for naked config is up. Have already flashed and tested some basic components (WiFI, mobile, 3g/4g, fingerprint, bluetooth).

Still a few minor issues that will iron out soon.

Next in the list is Pixel XL.

anestisb commented 6 years ago

Also pushed Pixel XL config. Unfortunately, don't have an available device atm so no runtime testing yet. Please open a new issue if you spot something.

Next in the list is Pixel 2.

anestisb commented 6 years ago

@mydongistiny btw the SSRestartDetector cannot be added since it's optimised as a CDEX (see https://github.com/anestisb/android-prepare-vendor/issues/130). Will add them as soon as the CDEX issue is resolved (probably by patching oatdump).

mydongistiny commented 6 years ago

@anestisb Yeah, I just added the one from 8.1.0 for now. I'm going to build for the XL using your config. I'll update this post if there's no problems and open an issue if there is. Thanks for the update.

dan-v commented 6 years ago

@anestisb - also kicking off a build for Pixel XL with your new config. Thanks for the updates!

mydongistiny commented 6 years ago

XL config works like it should. I used the full and tested wifi/radio/bt/fpc and everything I could think of.

dan-v commented 6 years ago

Tested naked config for Pixel XL and it also is working fine.

dan-v commented 6 years ago

@anestisb - I didn't actually test this myself, but there was a successful report of taimen build for RattlesnakeOS which uses the recently committed api-28 naked config.

anestisb commented 6 years ago

@dan-v appreciate the update. Also did some taimen testing yesterday with the naked config and haven't spotted any issues.

Hopefully, will resolve the CDEX issue with an oatdump patch within the next few days so the missing packages & the full-config can be added.

anestisb commented 6 years ago

Pixel 2/Pixel 2 XL are not stable with the naked config. The model service is crashing due to some missing classes from "vendor.qti.qcril.am-V1.0-java.jar" which cannot be added due to CDex issue (tracked from https://github.com/anestisb/android-prepare-vendor/issues/130).

08-21 15:24:09.303  6834  6834 E AndroidRuntime: Process: com.qualcomm.qti.telephonyservice, PID: 6834
08-21 15:24:09.303  6834  6834 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/qualcomm/qcrilhook/QcRilHook;
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at com.qualcomm.qti.telephonyservice.QtiTelephonyService.onCreate(QtiTelephonyService.java:34)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at android.app.ActivityThread.access$1300(ActivityThread.java:199)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:193)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6669)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-21 15:24:09.303  6834  6834 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
dan-v commented 6 years ago

@anestisb - appreciate this update as well. Let me know if there is anything I can do to help out with CDEX issue.

anestisb commented 6 years ago

The blocking Cdex issue has been resolved. I've made fresh builds for sailfish and taimen and so far everything appears to work like a charm. Closing this thread since API-28 is officially stable enough. Please open a separate issue if you notice any problems.

Will do more full-config testing when OpenGApps adds stable support for Android 9.