1.编译生成系统架包
- 下载LKD3568源码并编译,参考Android11系统编译
- 生成的系统架包路径:
LKD3568-SDK-Android/out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/combined/framework-minus-apex.jar
2.Android Studio如何使用系统架包
2.1.拷贝架包
framework-minus-apex.jar
拷贝至Project/app/libs
目录,重命名成framework.jar
2.2.添加依赖
compileOnly
只参与编译,不会打包进应用,修改Project/app/src/build.gradle
dependencies {
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
compileOnly files('libs/framework.jar')
...
}
```
### 2.3.配置IDE
优先使用`framework.jar`,修改`Project/app/src/build.gradle`
``` shell
android {
...
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
Set<File> fileSet = options.bootstrapClasspath.getFiles()
List<File> newFileList = new ArrayList<>();
newFileList.add(new File("libs/framework.jar"))
newFileList.addAll(fileSet)
options.bootstrapClasspath = files(newFileList.toArray())
}
}
}
```
### 2.4.系统应用声明
修改`Project/app/src/main/AndroidManifest.xml`
``` shell
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
android:sharedUserId="android.uid.system"
3.编译应用
- 执行
Make Project
或F9
- 生成的app路径:
Project/app/build/outputs/apk/debug/app-debug.apk
4.系统签名
5.安装应用
调试阶段应用可以直接push至设备/system/app
目录,后续需内置到ROM中
adb root
adb remount
adb push FrameworkApiTest.apk /system/app/
adb reboot
6.系统API如何使用
以获取当前以太网名称为例
EthernetManager mEthManager = (EthernetManager) getSystemService("ethernet");
//See LKD3568-SDK-Android/packages/apps/Settings/src/com/android/settings/ethernet/EthernetSettings.java
String[] ifaces = mEthManager.getAvailableInterfaces();
if (ifaces.length > 0) {
mIfaceName = ifaces[0];//"eth0";
String ifaceNameDebug = String.format("mIfaceName:%s ", mIfaceName);
Log.d(TAG, ifaceNameDebug);
}
7.Demo下载
LKD3568-Android11-Framework-api