I'm building an android app and made it as system app by placing it under /system/priv-app (building AOSP) Android OS version : 6.0.1 (api 23)
ApplicationInfo ai = packageManager.getApplicationInfo(
packageName, 0);
// Check if FLAG_SYSTEM or FLAG_UPDATED_SYSTEM_APP are set.
if (ai != null
&& (ai.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) {
return true;
}
This code retuns true (for system app)
I've read that system apps will have all the runtime permissions like location, storage, etc.
But it is still asking for permissions (system dialog) for location and storage.
What i've tried ?
1) used this permission in manifest "android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS"
2) added few lines of code in framework
services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
as mentioned here
but still app is asking for permissions.
note* : i'm also looking to get permissions for android.permission.WRITE_SETTINGS
, WRITE_SECURE_SETTINGS
and Draw over other apps
without asking/prompting the user
One more note :*
This app is for a custom hardware with custom OS, i have access to all of framework code
At first, dump your package service and inspect the package has correct flag and permissions. If your app is privileged, privateFlags must have PRIVILEGED . If your app is privileged, all Runtime permissions are granted if it is requested in the manifest. However I'm not sure this is true on Android 6.0.
adb shell dumpsys package
Packages:
Package [com.android.systemui] (4dfb5a):
....
flags=[ SYSTEM HAS_CODE PERSISTENT ]
privateFlags=[ PRIVILEGED DEFAULT_TO_DEVICE_PROTECTED_STORAGE DIRECT_BOOT_AWARE RESIZEABLE_ACTIVITIES ]
dataDir=/data/user_de/0/com.android.systemui
....
pkgFlags=[ SYSTEM HAS_CODE PERSISTENT ]
declared permissions:
com.android.systemui.permission.SELF: prot=signature, INSTALLED
requested permissions:
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.READ_EXTERNAL_STORAGE
....
install permissions:
android.permission.REAL_GET_TASKS: granted=true
android.permission.REMOTE_AUDIO_PLAYBACK: granted=true
And please have a look this answer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.