Force Permissions with Rooted Device - Android Q&A, Help & Troubleshooting

I'm trying to enable certain features of my custom app that require "dangerous" permissions. Is it possible to force the permissions instead of asking the user for the permissions? We are selling a prepackaged device and don't want to force the users to have to accept the permissions manually. Anything is in the realm of access; the devices are rooted and using adb, side loaded apps, etc are all acceptable solutions.

root permission is the ultimate permission as far as I know.

kouseralamin said:
root permission is the ultimate permission as far as I know.
Click to expand...
Click to collapse
The device is rooted, but the application is not running as "root".

bennycatalyst said:
I'm trying to enable certain features of my custom app that require "dangerous" permissions. Is it possible to force the permissions instead of asking the user for the permissions? We are selling a prepackaged device and don't want to force the users to have to accept the permissions manually. Anything is in the realm of access; the devices are rooted and using adb, side loaded apps, etc are all acceptable solutions.
Click to expand...
Click to collapse
Typically an app will send a notification to ask for permission to use features on user's phone, which user can Allow or Deny. And that for good reason. . Wondering why you want to bypass this mechanism?
From the user's point of view there are the following high risk ( dangerous ) permissions:
Make phone calls
Send SMS or MMS
Read sensitive logs
Display system-level alerts
Kill background processes
Process outgoing calls
Write secure settings
Authenticate Accounts
Read email attachments
Add system service
Read instant messages (IM)
Full list of permissons here.
An app's permissions must be defined in app's Manifest.xml. Only optional permissions the app has declared can be granted and/or revoked. If Android is rooted then granting and/ or revoking an app's optional permissions is done by PM.
ADB Examples:
Code:
adb devices
adb shell "su -c 'pm grant <packageName> <permissionName >.READ_PROFILE'"
and/or
Code:
adb devices
adb shell "su -c 'pm revoke <packageName> <permissionName >.READ_PROFILE'"

Related

[Q] How UID of an app determined during install in Android?

The following link gives a brief description about package installation process in android.
java,dzone,com/articles/depth-android-package-manager
I'm curious to know how the UID of an app is determined during its installation based on set the permissions present in its manifest file.
Also there is the platform.xml (in /frameworks/base/data/etc directory for 4.0 ICS Source code)file which contains list of permissions with gid associated with them. The description says
The following tags are associating low-level group IDs with permission names. By specifying such a mapping, you are saying that any application process granted the given permission will also be running with the given group ID attached to its process, so it can perform any filesystem (read, write, execute) operations allowed for that group.
In a similar way there is a list of high level permissions assigned to specific uid's as well.
My question is when an app is installed with permissions X,Y, Z how does its access specified is it from the mapping from this platform.xml
Also everytime the app is run does the mapping take place at every instant (that doesn't seem right from the initial design of android where the app permissions cannot be changed unless there is an update). So if that is the case where does it store saying this app should run with such and such access or such and such uid.
I hope I made my question clear, let me know if you need more information. I'm just trying to learn more on how the internals of the Android OS work.
Thanks

adb shell in recovery: 'pm list packages' fails from console

I wasn't paying attention to what I was doing after updating some apps, and froze some some application that is necessary, now my CATS60 will not boot. The app likely just uses the disable or hide command, but I am not sure what I misclicked, so I need to get a list or currently disabled apps or reenable all apps. I entered TWRP recovery, mounted all partitions, and connected through ADB shell.
This is what I get when I try to find out what's enabled/disabled:
Code:
# pm list packages
CANNOT LINK EXECUTABLE: library "libqc-opt.so" not found
page record for 0x7fb1658010 was not found (block_size=64)
adbd is running as root, and the file does exist:
Code:
~ # find / -name 'libqc-opt.so'
/system/vendor/lib/libqc-opt.so
/system/vendor/lib64/libqc-opt.so
I am using TWRP as recovery, and recovering system, data, and boot from backup does not fix this.
Does anyone know either
How can I make pm command work from recovery?
Where is the list of disabled apps stored, so I can manually edit it?
Thank you.
I found the list as used by the app (com.ramdroid.appquarantine), and it appears I blocked Google Calendar. However I have not found any way to "unfreeze" the app through recovery, this is simply a tracking file the app uses, not the actual enable/disable for Google Calendar.
Setting PATH and LD_LIBRARY_PATH environment variables does not help. Running it from inside the folder containing libqc-opt.so causes it to fail on a different external link.
Copying it to a second file called pm2, opening in vi and adding exports gets me as far as:
Code:
CANNOT LINK EXECUTABLE: cannot locate symbol "__android_log_close" referenced by "/system/lib64/libandroid_runtime.so"
Is it possible to chroot inside adb, and what do I need to mount first in order to do so? I don't know enough about Android to know which parts of the system I actually need.

How To Guide Force 120Hz MIUI 13 & MIUI 14

This is a thread for those who don't want to root their device to force 120Hz on every app.​If you are looking for a root solution, then use the LSPosed module called MIUI Performance Saver - Download here
In this way, you can force 120Hz in applications such as: YouTube, MX Player, Google Maps and many others that run at 60Hz by default in MIUI.
You will notice the changes, but you can check it by turning on the refresh rate counter in developer options and check the changes before and after.
​First method via ADB
1. In your device, in developer options, enable usb debugging and usb debugging (security settings) and connect your phone to the PC.
2. Download platform tools and extract to a folder
3. Open console in the platform tools folder
4. Enter the following command:
For MIUI 13:
Code:
adb shell settings put system user_refresh_rate 1
For MIUI 14:
Code:
adb shell settings put secure user_refresh_rate 1
If first method doesn't work for you, then try second method.
Second method via Settings Database Editor app
Download this app from the Play Store and for it to work properly, download and install this file from github (settings-database-provider.apk).
For MIUI 13:
1. Open Settings Database Editor app
2. Search "user_refresh_rate"
3. Cick on it to edit the value and replace 120 with 1 and save changes
4. Done
For MIUI 14:
MIUI 14 requires you to grant permissions to the Settings Database Provider app via ADB
1. In your device, in developer options, enable usb debugging and usb debugging (security settings) and connect your phone to the PC.
2. Download platform tools and extract to a folder
3. Open console in platform tools folder
4. Enter the following command:
Code:
adb shell pm grant com.netvor.settings.database.provider android.permission.WRITE_SECURE_SETTINGS
5. Open Settings Database Editor app
6. Search "user_refresh_rate"
7. Cick on it to edit the value and replace 120 with 1 and save changes
8. Done
Keep in mind that it may not work because Xiaomi changes something under the hood of the updates.
I dont know what to say, force fps can cause useless battery drain on app that dont really need ... Do you really need 120hz when you send sms or making call or even messenger ... All do what they want but i wont use it
snx413 said:
I dont know what to say, force fps can cause useless battery drain on app that dont really need ... Do you really need 120hz when you send sms or making call or even messenger ... All do what they want but i wont use it
Click to expand...
Click to collapse
I've been using this method since I had the Poco F3 and I've never noticed that the battery was draining much because of it. I'm used to 120Hz and find it irritating to suddenly switch to 60Hz when scrolling in YouTube or some other app. I am not forcing anyone to force 120Hz on their devices.
Yeah but its most of the time at 120 btw, only you tube and tik tok seems to lower it at 60,
I miss my poco f3... They have all custom rom they want pfff, i sold to my brother ...
root and non root method doesnt work for my poco f3 with xiaomi.eu, i tried global too
HappyTrix said:
root and non root method doesnt work for my poco f3 with xiaomi.eu, i tried global too
Click to expand...
Click to collapse
Can you provide more information? Any errors when executing commands in ADB? Can't find user_refresh_rate in setedit app? It's impossible that it wouldn't work on Poco F3, because I had this device until recently (now I don't have it anymore) and both methods worked perfectly in global ROMs and xiaomi.eu.
is there any way to force it from 120hz to 60hz instantly when i stop swiping? it only works when brightness is above 50%, if below 50% it's always 120hz
nhquocnam said:
is there any way to force it from 120hz to 60hz instantly when i stop swiping? it only works when brightness is above 50%, if below 50% it's always 120hz
Click to expand...
Click to collapse
This is MIUI, nothing can be done about it. You can try Magisk root + LSPosed "MIUI Performance Saver" module and force 120hz, which "maybe" will solve your problem, or you can wait for some custom rom that will hopefully come out for the Xiaomi 12T Pro someday, as long as Xiaomi releases kernel source code for this device.
I cant seem to get my ADB to work u have any guides? and there is no "console" in the platform tools folder please help me
uvzen said:
This is a thread for those who don't want to root their device to force 120Hz on every app.​If you are looking for a root solution, then use the LSPosed module called MIUI Performance Saver - Download here
In this way, you can force 120Hz in applications such as: YouTube, MX Player, Google Maps and many others that run at 60Hz by default in MIUI.
You will notice the changes, but you can check it by turning on the refresh rate counter in developer options and check the changes before and after.
​First method via ADB
1. In your device, in developer options, enable usb debugging and usb debugging (security settings) and connect your phone to the PC.
2. Download platform tools and extract to a folder
3. Open console in the platform tools folder
4. Enter the following command:
For MIUI 13:
Code:
adb shell settings put system user_refresh_rate 1
For MIUI 14:
Code:
adb shell settings put secure user_refresh_rate 1
Second method via SetEdit app
Download this app from Play Store
For MIUI 13:
1. Open Setedit app and scroll down to the end
2. Find "user_refresh_rate" "120"
3. Cick on it to edit the value and replace 120 with 1 and save changes
4. Done
For MIUI 14:
MIUI 14 requires you to grant permissions to the Setedit app via ADB
1. In your device, in developer options, enable usb debugging and usb debugging (security settings) and connect your phone to the PC.
2. Download platform tools and extract to a folder
3. Open console in the platform tools folder
4. Enter the following command:
Code:
adb shell pm grant by4a.setedit22 android.permission.WRITE_SECURE_SETTINGS
5. Open Setedit app
6. In the right corner, change the "System Table" tab to "Secure Table"
7. Scroll down to the end and find "user_refresh_rate" "120"
8. Cick on it to edit the value and replace 120 with 1 and save changes
9. Done
Click to expand...
Click to collapse
Thank you, useful af
I'm getting an error while running the adb command :
Exception occurred while executing 'put':
java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2331)
at com.android.providers.settings.SettingsProvider.mutateSecureSetting(SettingsProvider.java:1768)
at com.android.providers.settings.SettingsProvider.insertSecureSetting(SettingsProvider.java:1719)
at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:467)
at android.content.ContentProvider.call(ContentProvider.java:2533)
at android.content.ContentProvider$Transport.call(ContentProvider.java:530)
at com.android.providers.settings.SettingsService$MyShellCommand.putForUser(SettingsService.java:382)
at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:278)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:50)
at android.os.Binder.shellCommand(Binder.java:1054)
at android.os.Binder.onTransact(Binder.java:882)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
SooRaj SuResh said:
I'm getting an error while running the adb command :
Exception occurred while executing 'put':
java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2331)
at com.android.providers.settings.SettingsProvider.mutateSecureSetting(SettingsProvider.java:1768)
at com.android.providers.settings.SettingsProvider.insertSecureSetting(SettingsProvider.java:1719)
at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:467)
at android.content.ContentProvider.call(ContentProvider.java:2533)
at android.content.ContentProvider$Transport.call(ContentProvider.java:530)
at com.android.providers.settings.SettingsService$MyShellCommand.putForUser(SettingsService.java:382)
at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:278)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:50)
at android.os.Binder.shellCommand(Binder.java:1054)
at android.os.Binder.onTransact(Binder.java:882)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
Click to expand...
Click to collapse
Changing refresh rate via ADB doesn't work for me either. Xiaomi changed something in the permissions again during one of the updates. I just updated my thread, so try second method through the Settings Database Editor app, because I checked and it works for me on Xiaomi.eu weekly 23.5.22.
Very good find! I had it working on MIUI 13 but I had been waiting to get it working on MIUI 14 since forever, didn't know we had to modify the secure table for this. Also, do you know any more efficient ways to do this with root? I am always rooted.
SooRaj SuResh said:
I'm getting an error while running the adb command :
Spoiler: Code
Exception occurred while executing 'put':
java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS
at com.android.providers.settings.SettingsProvider.enforceWritePermission(SettingsProvider.java:2331)
at com.android.providers.settings.SettingsProvider.mutateSecureSetting(SettingsProvider.java:1768)
at com.android.providers.settings.SettingsProvider.insertSecureSetting(SettingsProvider.java:1719)
at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:467)
at android.content.ContentProvider.call(ContentProvider.java:2533)
at android.content.ContentProvider$Transport.call(ContentProvider.java:530)
at com.android.providers.settings.SettingsService$MyShellCommand.putForUser(SettingsService.java:382)
at com.android.providers.settings.SettingsService$MyShellCommand.onCommand(SettingsService.java:278)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.providers.settings.SettingsService.onShellCommand(SettingsService.java:50)
at android.os.Binder.shellCommand(Binder.java:1054)
at android.os.Binder.onTransact(Binder.java:882)
at android.os.Binder.execTransactInternal(Binder.java:1290)
at android.os.Binder.execTransact(Binder.java:1249)
Click to expand...
Click to collapse
Try with granting permission to the app. Even with that you will get an error which you can solve as follows:
How can I use adb to grant permission without root?
Background I'm trying to create an app that can grant and revoke permissions of other apps. To do this I'm using adb commands: pm grant packageName permissionName This works great if I call it
stackoverflow.com
Unknown.Guy said:
Also, do you know any more efficient ways to do this with root? I am always rooted.
Click to expand...
Click to collapse
If you have root then use LSPosed module MIUI Performance Saver.

I will pay for this app:

I need an app that every Friday at 4PM will turn on (=Allday) the "Always On" display and turn off the "Wake on Wrist Raise". And on Saturday at 8PM will reverse the 2 settings.
crontab with correct shell commands should do. will probably need root and busybox.
(google crontab android)
or maybe without root according to this (lower half of the page)
How to use crontab in Android?
I can't find answer to my question: Is it possible to run crontab to reboot Android using busybox (or other means) Tried to run crontab, and it complain about unknown uid 0. Tried to run reboot, ...
stackoverflow.com
then google adb commands for things you need to do "always on display" etc..
test with adb to make sure your commands work .
then implement without adb shell in crontab, since it will be executed from within android not adb.
If you are talking about zeppos based watch then only first condition (AOD) is reachable.

What are MIUIOP?

If anyone knows descriptions to miuiop please share, I'm curious what they do.
What App Ops does is allow a user to revoke an individual permission for an app. When the app then starts and tries to make an Android system call to access something that the user has now forbidden then Android will return an error and won’t grant access to that data or functionality.
As you can see there are several numbers starting with 100xx. These are the app IDs (UID = user IDs) the system is dealing with. Every app has a corresponding UID which is needed for file permission rights. Example: If only a certain app (UID 10666) has the permission to open a certain folder, the folder will be restricted to u0_a666 (=user 0, that's you, + app UID 10666)
Usually the first UID slots 10001, 10002, ... are system apps since they get started first upon an initial boot of your device. I assume that MIUIOP belongs to the MIUI optimization, but not sure about that. But you can figure it out with the help of the UIDs:
Apk Analyzer - Apps on Google Play
Detailed reports of the applications on your device. 📱
play.google.com
Selecting an app shows you its UID. Unfortunately it doesn't show you the UID in the app's list directly.
So the uid number could be different across different miui versions… unlike standard appops which are the same regardless of device?
Posting a list of the apps just because:
10008 com.miui.core.internal.editor.services
10017 - com.miui.systemui.overlay.devices.android
10020 - com.android.theme.font.notoserifsource (Noto Serif / Source Sans Pro)
10026 - com.android.internal.systemui.onehanded.gestural (One Handed Mode)
10033 - com.android.overlay.gmstelephony
10036 - com.android.systemui.gesture.line.overlay
10037 - com.miui.systemui.carriers.overlay
The app UIDs are assigned ongoing by your system on first boot (for system apps) or after installation (for user apps). Example: The first app you install on your device gets the UID 10201 then the second one gets 10202 and so on. It doesn't depend on your MIUI version or sth like this.

Categories

Resources