- 不试图改变项目本身的目录结构
- 通过添加额外的配置和依赖构建Gradle环境支持
- 会使用脚本移除一些AS不支持的属性和字段,然后利用git本地忽略
- 修改少量代码,但是总体不影响其作为AOSP的子项目进行mm编译
- 运行的效果会与原生的还是有些许差异,这是由于脱离源码之后,引用private属性失败所导致的样式差异
adb push Settings.apk /system/system_ext/priv-app/Settings/
adb shell killall com.android.settings
adb reboot
// AOSP/android-11/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-header.jar
compileOnly files('libs/framework.jar')
// AOSP/android-11/out/soong/.intermediates/libcore/core-all/android_common/javac/core-all.jar
compileOnly files('libs/core-all.jar')
// AOSP/android-11/out/soong/.intermediates/frameworks/opt/telephony/telephony-common/android_common/javac/telephony-common.jar
compileOnly files('libs/telephony-common.jar')
// AOSP/android-11/out/soong/.intermediates/frameworks/opt/net/ims/ims-common/android_common/javac/ims-common.jar
compileOnly files('libs/ims-common.jar')
// AOSP/android-11/out/soong/.intermediates/tools/platform-compat/java/android/compat/annotation/app-compat-annotations/android_common/turbine/app-compat-annotations.jar
compileOnly files('libs/app-compat-annotations.jar')
// AOSP/android-11/prebuilts/sdk/current/androidx/m2repository/androidx/preference/preference/1.2.0-alpha01/preference-1.2.0-alpha01.aar
implementation(name: 'preference-1.2.0-alpha01', ext: 'aar')
## implementation 'androidx.preference:preference:1.2.0-alpha01'
//项目自带aar,不需要从其他地方引入
implementation(name: 'contextualcards', ext: 'aar')
// AOSP/android-11/out/soong/.intermediates/packages/apps/Settings/settings-logtags/android_common/javac/settings-logtags.jar
implementation files('libs/settings-logtags.jar')
// AOSP/android-11/out/soong/.intermediates/packages/apps/Settings/statslog-settings/android_common/javac/statslog-settings.jar
implementation files('libs/statslog-settings.jar')
// AOSP/android-11/out/soong/.intermediates/external/zxing/core/zxing-core-1.7/android_common/combined/zxing-core-1.7.jar
implementation files('libs/zxing-core-1.7.jar')
// AOSP/android-11/out/soong/.intermediates/external/guava/guava/android_common/turbine-combined/guava.jar
implementation files('libs/guava.jar')
// AOSP/android-11/out/soong/.intermediates/hardware/interfaces/dumpstate/1.0/android.hardware.dumpstate-V1.0-java/android_common/javac/android.hardware.dumpstate-V1.0-java.jar
implementation files('libs/android.hardware.dumpstate-V1.0-java.jar')
// AOSP/android-11/out/soong/.intermediates/hardware/interfaces/dumpstate/1.1/android.hardware.dumpstate-V1.1-java/android_common/javac/android.hardware.dumpstate-V1.1-java.jar
implementation files('libs/android.hardware.dumpstate-V1.1-java.jar')
// AOSP/android-11/out/soong/.intermediates/system/libhidl/transport/base/1.0/android.hidl.base-V1.0-java/android_common/javac/android.hidl.base-V1.0-java.jar
implementation files('libs/android.hidl.base-V1.0-java.jar')
将具体路径下的代码直接导入到项目中作为Module依赖, 构建的时候可以直接通过implementation project引用,或者也可以gradle build生成aar,再放置到libs文件夹中,作为静态包使用。
// AOSP/android-11/frameworks/libs/systemui/iconloaderlib
implementation project(':iconloaderlib')
// AOSP/android-11/frameworks/opt/net/wifi/libs/WifiTrackerLib
implementation project(':WifiTrackerLib')
// AOSP/android-11/external/setupcompat
implementation project(':setupcompat')
// AOSP/android-11/external/setupdesign
implementation project(':setupdesign')
// AOSP/android-11/frameworks/base/packages/SettingsLib
implementation project(':SettingsLib')
implementation project(':SettingsLib:ActionBarShadow')
implementation project(':SettingsLib:RestrictedLockUtils')
implementation project(':SettingsLib:ActionButtonsPreference')
implementation project(':SettingsLib:HelpUtils')
implementation project(':SettingsLib:SettingsSpinner')
implementation project(':SettingsLib:Tile')
implementation project(':SettingsLib:LayoutPreference')
implementation project(':SettingsLib:AppPreference')
implementation project(':SettingsLib:RadioButtonPreference')
implementation project(':SettingsLib:search')
implementation project(':SettingsLib:SearchWidget')
implementation project(':SettingsLib:EntityHeaderWidgets')
implementation project(':SettingsLib:AdaptiveIcon')
implementation project(':SettingsLib:DisplayDensityUtils')
在AOSP/android-11/build/target/product/security路径下找到签名证书,并使用 keytool-importkeypair 生成keystore, 执行如下命令:
./keytool-importkeypair -k platform.keystore -p 123456 -pk8 platform.pk8 -cert platform.x509.pem -alias platform
并将以下代码添加到gradle配置中:
signingConfigs {
platform {
storeFile file("platform.keystore")
storePassword '123456'
keyAlias 'platform'
keyPassword '123456'
}
}
buildTypes {
release {
debuggable false
minifyEnabled false
signingConfig signingConfigs.platform
}
debug {
debuggable true
minifyEnabled false
signingConfig signingConfigs.platform
}
}
git ls-files -v | grep '^h\ '
git update-index --assume-unchanged $path
git update-index --no-assume-unchanged $path
git ls-files -v | grep '^h' | awk '{print $2}' |xargs git update-index --no-assume-unchanged