This directory contains code for the AOSP Nearby mainline module.
##Directory Structure
apex
framework
jni
native
service
tests
$ source build/envsetup.sh && lunch <TARGET> $ cd packages/modules/Nearby $ aidegen . # This will launch Intellij project for Nearby module.
Note, the setup above may fail to index classes defined in proto, such that all classes defined in proto shows red in IDE and cannot be auto-completed. To fix, you can mannually add jar files generated from proto to the class path as below. First, find the jar file of presence proto with
ls $ANDROID_BUILD_TOP/out/soong/.intermediates/packages/modules/Connectivity/nearby/service/proto/presence-lite-protos/android_common/combined/presence-lite-protos.jar
Then, add the jar in IDE as below.
Build unbundled module using banchan $ source build/envsetup.sh $ banchan com.google.android.tethering mainline_modules_arm64 $ m apps_only dist $ adb install out/dist/com.google.android.tethering.apex $ adb reboot Ensure that the module you are installing is compatible with the module currently preloaded on the phone (in /system/apex/com.google.android.tethering.apex). Compatible means: 1. Same package name 2. Same keys used to sign the apex and the payload 3. Higher version See go/mainline-local-build#build-install-local-module for more information
When build and flash the APEX from tm-mainline-prod, you may see the error below.
[INSTALL_FAILED_VERSION_DOWNGRADE: Downgrade of APEX package com.google.android.tethering is not allowed. Active version: 990090000 attempted: 339990000])
This is because the device is flashed with AOSP built from master or other branches, which has prebuilt APEX with higher version. We can use root access to replace the prebuilt APEX with the APEX built from tm-mainline-prod as below.
If you need to flash the APEX to different devices, Pixel 6, Pixel 7, or even devices from OEM, you can share the APEX by source build/envsetup.sh && lunch aosp_arm64-userdebug
. This can avoid re-compiling for different targets.