How to add extra permission to a prebuilt application (no source code) in AOSP

流过昼夜 提交于 2019-11-30 23:39:02

You can modify the main framework manifest in :

frameworks\base\core\res\Manifest.xml

And change the permission protectionLevel: value to "normal", that way as a priv-app (Even if not built with the framework key) you should automatically grant all normal permissions, just bear in mind you causing a security bridge for that specific permission.

In shell script file, you have to use:

pm grant com.example.myapp android.permission.CHANGE_CONFIGURATION

and copy shell script to /system/bin/

and in init.rc, you execute shell after boot completed:

on property:sys.boot_completed=1
   exec /system/bin/preinstall.sh

I've successed with this

To be eligible for system permissions, you should put your APKs in /system/priv-app folder.
Note: Prior to Kitkat, all APKs on the system partition could use those permissions.

The sample snippet code to copy APK to /system/priv-app:

include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := apkname.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_PRIVILEGED_MODULE := true
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_PATH := $(TARGET_OUT)/priv-app
LOCAL_SRC_FILES := apkname.apk
include $(BUILD_PREBUILT)

For more information:

Some system apps are more system than others "signatureOrSystem" permissions are no longer available to all apps residing en the /system partition. Instead, there is a new /system/priv-app directory, and only apps whose APKs are in that directory are allowed to use signatureOrSystem permissions without sharing the platform cert. This will reduce the surface area for possible exploits of system- bundled applications to try to gain access to permission-guarded operations.

The ApplicationInfo.FLAG_SYSTEM flag continues to mean what it is said in the documentation: it indicates that the application APK was bundled on the /system partition. A new hidden flag FLAG_PRIVILEGED has been introduced that reflects the actual right to access these permissions.

[ Source: https://stackoverflow.com/a/20104400/421467 ]

Update:
Walkthrough: https://github.com/Drjacky/Install-Google-Play-Manually

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!