[RK3288][Android6.0] 调试笔记 --- 替换系统签名

Posted 请给我倒杯茶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[RK3288][Android6.0] 调试笔记 --- 替换系统签名相关的知识,希望对你有一定的参考价值。

本文转载自:http://blog.csdn.net/kris_fei/article/details/55100299

Platform: RK3288
OS: android 6.0
Kernel: 3.10.92

由于项目的apk安装需要shareid为system的权限(不需要高权限的apk是可以正常安装的),
一开始我用的是releasekey,导致签名文件不匹配无法安装,因此就替换系统默认platform签名文件.

生成新的签名文件
方法参考rk3288/build/target/product/security/README
[[email protected]:~/rk3288]$./development/tools/make_key platform ‘/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]
后面参数可自行修改,参见:
http://blog.csdn.net/jscese/article/details/24243171

会生成两种文件:
公钥: platform.x509.pem
私钥: platform.pk8

系统端修改:
不管编译版本(项目需求),都改成platform签名文件.
build/core/Makefile:
ifeq ($(TARGET_BUILD_VARIANT),user)
BUILD_KEYS := release-keys
endif
#Kris, 170214, use our platform key.
+ BUILD_KEYS := platform-keys

build/core/config.mk:
# The default key if not set as LOCAL_CERTIFICATE
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
  DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
  DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
endif
#Kris, 170214, use our platform key.
+ DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/platform

这样build systemimage就会用名字为platform的签名文件.

APK端:
这里拿Music app作测试.
[[email protected]:~/rk3288/packages/apps/Music]$ g df
diff --git a/Android.mk b/Android.mk
index d2b7691..c6aa64c 100644
--- a/Android.mk
+++ b/Android.mk
@@ -7,7 +7,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) \
        src/com/android/music/IMediaPlaybackService.aidl
 
 LOCAL_PACKAGE_NAME := Music
-
+LOCAL_CERTIFICATE := platform
 LOCAL_SDK_VERSION := current
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2db6259..2dbd79b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -15,7 +15,9 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.android.music">
+        package="com.android.music"
+        coreApp="true"
+        android:sharedUserId="android.uid.system">
 
     <original-package android:name="com.android.music" />
     <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="9"/>


如果没定义LOCAL_CERTIFICATE, 或者LOCAL_CERTIFICATE的签名和系统签名不一致,安装会不成功,有如下提示:
[[email protected]:~/rk3288/out/target/product/rk3288/system/app/Music]$ adb install Music.apk
4318 KB/s (904296 bytes in 0.204s)
    pkg: /data/local/tmp/Music.apk
Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]

logcat中会有:
01-21 14:51:37.101  2215  2215 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
01-21 14:51:37.160  2175  2188 D DefContainer: Copying /data/local/tmp/Music.apk to base.apk
01-21 14:51:37.677   517   572 W PackageManager: Package com.android.music signatures do not match the previously installed version; ignoring!

 

参考:
http://blog.csdn.net/jscese/article/details/24243171
http://blog.csdn.net/jimbo_lee/article/details/39183831
http://blog.csdn.net/jingwen3699/article/details/8024900
http://blog.csdn.net/jiangwei0910410003/article/details/51316688

以上是关于[RK3288][Android6.0] 调试笔记 --- 替换系统签名的主要内容,如果未能解决你的问题,请参考以下文章

[RK3288][Android6.0] 调试笔记 --- hwclock命令无法使用

[RK3288][Android6.0] 调试笔记 --- pmu(rk818)寄存器读写

[RK3288][Android6.0] 调试笔记 --- /data/app/预置apk安装失败

[RK3288][Android6.0] 调试笔记 --- 系统识别不同硬件版本方法

[RK3288][Android6.0] 调试笔记 --- 通用GPIO驱动控制LED

[RK3288][Android6.0] 调试笔记 --- 录音音量从HAL到APP层会变小问题