If a third-party application wants to obtain system permissions, it needs to declare its UID as a system process in the AndroidManifest.xml
file, and the application needs to be signed with the platform key (signature).
Declare UID as a System Process
The third-party application’s AndroidManifest.xml must include:
1 | android:sharedUserid="android.uid.system" |
Sign APP with Platform Key
APP Signing for SDK Source Code
Put the APK in the application directory, and create an
Android.mk
file containing the following contents:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# module name should match the apk name
LOCAL_MODULE := XXXX
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_PRIVILEGED_MODULE := true
# use the application's own signature
# LOCAL_CERTIFICATE := PRESIGNED
# sign with the platform key
LOCAL_CERTIFICATE := platform
include $(BUILD_PREBUILT)Add the name of your APK
XXXX
into the compile file.1
2
3PRODUCT_PACKAGES +=\
Bluetooth \
XXXXRecompile the SDK, and the APK file will be generated in the
out
directory, containing the platform key.
APP Signing for Windows & Linux PC
According to your SBC model and system version, download the two platform key files platform.x509.pem and platform.pk8.
Download the Java Signing Tool signapk.jar.
Download the library-dependency libconscrypt_openjdk_jni.so and put it in the
signlib
directory.Install the JDK Tool.
Execute the shell command:
1
java -Djava.library.path=signlib -jar signapk.jar platform.x509.pem platform.pk8 unsigned.apk signed.apk