I need to grant the Permission android.permission.INSTALL_PACKAGES to an Android App, which is not made by me. My Device is running on LineageOS and is rooted, but the Command
pm grant <package> android.permission.INSTALL_PACKAGES
returns
Operation not allowed: java.lang.SecurityException: Permission android.permission.INSTALL_PACKAGES is not a changeable permission type.
Is there any way to bypass this?
Ok, I found a solution: Copying the app to the /system/app folder through TWRP works fine
Related
I'm trying the new android 10 and checking its differences with previous versions. I tried to grant some permissions through ADB that used to work on Android 9 but to no avail.
Since it is ADB related, I'm not sure where to check it documentation, but here is what I tried:
pm grant my.package.app android.permission.ACCESS_BACKGROUND_LOCATION // permission granted
pm grant my.package.app android.permission.READ_PHONE_STATE // no error no permission granted
pm grant my.package.app android.permission.RECORD_AUDIO // no error no permission granted
pm grant my.package.app android.permission.WRITE_EXTERNAL_STORAGE // no error no permission granted
pm revoke my.package.app android.permission.READ_PHONE_STATE // permission revoked
pm revoke my.package.app android.permission.RECEIVE_SMS // permission revoked
Those are all permissions declared in the AndroidManifest.xml file, it is strange that only the new ACCESS_BACKGROUND_LOCATION worked but none of the existing permissions did.
I believe the permission's names are correct because it works when revoking it.
Alternatively, I tried to find the string for those permissions and use the appops command but it didn't work either.
Any help appreciated.
EDIT:
After further investigation, I noticed that when an app is Freshly installed then I use pm grant every thing works as expected. However after denying the permission manually (from settings) pm grant is not working anymore
Maybe this will help other coming across this question.
As mentioned on my edit:
After further investigation, I noticed that when an app is Freshly installed then I use pm grant every thing works as expected. However after denying the permission manually (from settings) pm grant is not working anymore
A solution (that worked for me) is to reset the permissions before trying to set them again. Call:
cmd appops reset my.package.app
Then:
pm grant my.package.app android.permission.ACCESS_BACKGROUND_LOCATION
pm grant my.package.app android.permission.READ_PHONE_STATE
pm grant my.package.app android.permission.RECORD_AUDIO
pm grant my.package.app android.permission.WRITE_EXTERNAL_STORAGE
I came across the privacy changes document for Android 10. Seams that Android stop supporting to read phone state starting with Android 10.
Copped from Android Website
If your app targets Android 10 or higher, a SecurityException occurs.
If your app targets Android 9 (API level 28) or lower, the method
returns null or placeholder data if the app has the READ_PHONE_STATE
permission. Otherwise, a SecurityException occurs.
Please refer bellow link for more details.
https://developer.android.com/about/versions/10/privacy/changes#proc-net-filesystem
On my rooted android device, how can I grant "Signature level" (INTERNAL_SYSTEM_WINDOW) permission to a third party app.
What I have tried already is
rooted my device using magisk
in adb shell, used pm grant com.example.app android.permission.INTERNAL_SYSTEM_WINDOW
After this, I am getting below error:
java.lang.SecurityException: Permission android.permission.INTERNAL_SYSTEM_WINDOW requested by com.example.app is not a changeable permission type
at com.android.server.pm.permission.BasePermission.enforceDeclaredUsedAndRuntimeOrDevelopment(BasePermission.java:429)
at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:2114)
at com.android.server.pm.permission.PermissionManagerService.access$900(PermissionManagerService.java:121)
at com.android.server.pm.permission.PermissionManagerService$PermissionManagerServiceInternalImpl.grantRuntimePermission(PermissionManagerService.java:3018)
at com.android.server.pm.PackageManagerService.grantRuntimePermission(PackageManagerService.java:5735)
at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:1955)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:230)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21745)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4015)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
Was looking for a way such that I can grant all types of permissions to the app (since I have root access).
I am creating an android app for media box. The box is rooted. I have to bypass permissions (run time permission too) because user will not be interacting with the device. I tried to push the apk in system/priv-app folder also to make it system app. Still, whenever my app is launched, it asks for permissions. Is there any way to bypass permissions in rooted device? I have used following commands to push the APK to priv-app folder.
adb remount
adb push apk-filename-here /system/app/
adb shell chmod 644 /system/app/apk-filename-here
adb reboot
App seems to be like system app because it is not uninstallable now. But permission problem is still there. Is anything extra required to be done to grant all permissions? Please help.
I tried bypass android usb host permission confirmation dialog also but this seems to be a very old story now.
Some permissions are signature-level, meaning they can't be granted unless your app is signed with the same key used to sign the rest of the system. If you need any of these, there's very little you can do, unless the relevant APIs have shell-command alternatives.
Other permissions are privileged-level, meaning they're only granted if the app is located in /system/priv-app/. You haven't mentioned which permissions you're using, but I recommend putting your app in priv-app instead of app anyway. If this device is on Lollipop or later, apps should have a sub-folder inside priv-app (eg /system/priv-app/SomeApp/SomeApp.apk).
The third type is app-op permissions. These aren't runtime permissions, but they can be granted with a shell command:
cmd appops set <PACKAGE> <OP> <MODE>
For example, to grant the SYSTEM_ALERT_WINDOW permission:
cmd appops set com.some.package android:system_alert_window allow
The fourth type is runtime/development permissions. Both can be granted with the following:
pm grant <PACKAGE> <PERMISSION>
For example, to grant WRITE_EXTERNAL_STORAGE:
pm grant com.some.package android.permission.WRITE_EXTERNAL_STORAGE
You can check which type your permissions are by looking at the platform AndroidManifest.xml. Find your permission and check the protectionLevel field.
signature means signature
privileged means privileged
development means development
dangerous means runtime
normal permissions will be automatically granted
Certain permissions, like WRITE_SECURE_SETTINGS have multiple protection levels: signature|privileged|development.
If any of those conditions is met, Android will grant the permission to your app. With WSS, you could either put the app in priv-app or use pm grant. Either way will get you access.
If a permission's protection levels have both appops and development, such as PACKAGE_USAGE_STATS, be careful. Using cmd appops will grant that permission for certain functions, while pm grant will for others.
While migrating one of my apps to use the Android 6.0 permissions system, I found it very hard to debug permissions using the emulator.
Findings:
Disabling a permission in the app info screen doesn't re-show the grant permission dialog when using the requestPermissions() method.
Reinstalling the app seems to be the only way to make the app show the grant permission dialog again.
What is the proper method to debug permission using the Android emulator?
It’s actually very easy to debug Android 6.0 permissions. You can reset the permissions to the "install state" for the current foreground app all apps using the following ADB shell command:
adb shell pm reset-permissions
Note: Currently you can't reset the runtime permissions for a specific package, the package manger (pm) tool help section states:
revert all runtime permissions to their default state.
You can easily execute the reset-permissions command using the terminal interface in Android Studio. Note that ADB commands only works if the ADB directory is added to the PATH system environment variable (see: add ADB to path variable).
You can also reset/revoke a specific permissions using:
adb shell pm revoke com.your.package android.permission.WRITE_EXTERNAL_STORAGE
A downside of this command is that it will restart your app, but this doesn't reset the runtime permissions for all apps. To grant a permission replace revoke with grant.
When trying to execute shell commands on Lollipop I am getting permission denied error.
Runtime.getRuntime().exec("su")
I do have super user permission in the manifest
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
The device is rooted.
Since your device is rooted, you can try installing the apk in the system directory:
system/app
Certain 'serious' permissions are granted only to apks in this directory. (On your rooted device, browse to this directory in your file browser, and you will find all pre-installed apks here).