ADB Hack - Granting extra capabilities via the ADB tool

MacroDroidDev

Administrator
Staff member
I don't remember to be quite honest and the history seems to have got lost for that post. You shouldn't worry in any case because if at any point you are lacking a permission and it needs to be granted you will be prompted in the app.
 

Pallovittor

New member
Starting with MacroDroid V3.16.11 (with some effort) you can now invoke the following features on a non-rooted device:

Battery Saver Action
Location Mode Action
NFC Enable/Disable Action
Set Language Action
Logcat Trigger
+ others as shown within the app.

In order to do this you will need a Windows/Linux based PC or a Mac plus Google's ADB tool which can be downloaded from the links below:

Windows - https://dl.google.com/android/repositor ... indows.zip
Linux - https://dl.google.com/android/repositor ... -linux.zip
Mac - https://dl.google.com/android/repositor ... darwin.zip

For instructions on configuring your device to connect via adb please see the following information:

https://developer.android.com/studio/co ... e/adb.html

Once you have a working adb connection, you need to run the following command from the command line/terminal on your computer:

adb shell pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS

followed by:

adb shell pm grant com.arlosoft.macrodroid android.permission.CHANGE_CONFIGURATION

If you are using the demo mode action you will also need the following permission:

adb shell pm grant com.arlosoft.macrodroid android.permission.DUMP

If you are using the volume button long press trigger you will need the following permission:

adb shell pm grant com.arlosoft.macrodroid android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER

If you are using the Logcat trigger you will need the following permission:

adb shell pm grant com.arlosoft.macrodroid android.permission.READ_LOGS

These commands will give MacroDroid permission to write to some restricted device settings that can normally only be done by system apps (or using root hacks).
It's a little bit of work but hopefully a nice solution for users who are unable to or don't want to root their device.

The features above are currently the only features that can be utilised by this adb permission hack, but I hope in the future I can expand the capability to allow additional features.

Permission error when granting

On some devices there can be an error granting ABD permission that looks like this:

Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS

In this case please check your phone's developer options and look for a setting called "Disable permission monitoring" and disable it.

Additional information for Helper File

Starting with MacroDroid v5.8 a new helper file is available to perform some limited functionality that cannot be done directly in the app. In order to grant ADB access to this helper file please use the following command:

adb shell pm grant com.arlosoft.macrodroid.helper android.permission.WRITE_SECURE_SETTINGS
Se eu fizer isso eu perco a garantia do meu celular?
E alguém aí já fez isso no OnePlus 7T Pro?
Gostaria muito da permissão, mas não quero root.



If I do this will I lose my phone's warranty?

And has anyone done this on the OnePlus 7T Pr

I would love the permission, but I don't want root.
 

dsnz

Well-known member
Se eu fizer isso eu perco a garantia do meu celular?
E alguém aí já fez isso no OnePlus 7T Pro?
Gostaria muito da permissão, mas não quero root.



If I do this will I lose my phone's warranty?

And has anyone done this on the OnePlus 7T Pr

I would love the permission, but I don't want root.
this is not "root"
you will have absolutely no problem with warranty
 

jooohnnn

New member
Hi, on a OnePlus 9 Pro with Android 11, everything is OK. DATA and NFC do not work on Android 12. Is there a solution? Thank you!
I enclose screenshots::
 

Attachments

  • NFC_on_off_1.jpg
    NFC_on_off_1.jpg
    579.1 KB · Views: 35
  • NFC_on_off_2.jpg
    NFC_on_off_2.jpg
    539.1 KB · Views: 37
  • ADB_Tool.jpg
    ADB_Tool.jpg
    751.8 KB · Views: 38
Last edited:

winday

New member
Hi all

Can't do anything with adb (of course, adb is installed correctly - I used it a lot with my previous phone). Now all I get is this error anytime I open a new connection and run the 1st ADB hack:

"Exception occurred while executing 'grant':
java.lang.SecurityException: grantRuntimePermission: Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS.
at android.app.ContextImpl.enforce(ContextImpl.java:2028)
at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:2056)
at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermissionInternal(PermissionManagerService.java:1445)
at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:1426)
at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:2287)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:249)
at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98)
at android.os.ShellCommand.exec(ShellCommand.java:44)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22238)
at android.os.Binder.shellCommand(Binder.java:932)
at android.os.Binder.onTransact(Binder.java:816)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4687)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4427)
at android.os.Binder.execTransactInternal(Binder.java:1162)
at android.os.Binder.execTransact(Binder.java:1126)"

That's it! Looks like I can't grant permissions...
hi, guy
how did you do that?
i got the error info like you when I grant permission everytime. My phone is OPPO K7, already disabled permission monitoring
 
The new Android 12 version of Oneplus 8T broke something : setting screen off delay, or AOD settings, no longer work for example. I had trouble following the procedure described here ("neither user 2000...") but still managed to do it, but apparently it doesn't work properly...

EDIT : OK, dealing with volumes doesn't work either (ex : "when connected to home wifi then set media volume to 50" etc...)

I have so many macros that don't work as expected since the update, i wish I hadn't updated my phone :)

EDIT 2 : volume now work.
 
Last edited:
R

rusalex2k8

Guest
hi , popup message is not possible to get during incomeing call, android 10 , huawei p40 . is there any adb command to give more extra rights for popup message to be above the incoming call screen ? thank you in advance
 

Pseudocyclic

Well-known member
hi , popup message is not possible to get during incomeing call, android 10 , huawei p40 . is there any adb command to give more extra rights for popup message to be above the incoming call screen ? thank you in advance
Are popup messages able to appear over other apps?
 
R

rusalex2k8

Guest
it works during outgoing and incoming but when screen is still on . not in sleeping mode , i assume it hasn't enough right to be over the call screeen .
 
R

rusalex2k8

Guest
i can't swipe out screen during incomeing . i can asnwer or decline incoming call . after i answered or declined call i can see notification in status bar
 

drdedus

New member
Permission error when granting

On some devices there can be an error granting ABD permission that looks like this:

Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS

In this case please check your phone's developer options and look for a setting called "Disable permission monitoring" and disable it.
hello i Disabled the "permission monitoring " but i still get the error .
i have a Realme UI3 Android 12 and i am trying through windows 10 PowerShell or CMD running as Administrator.



C:\platform-tools> .\adb shell pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS

Exception occurred while executing 'grant':
java.lang.SecurityException: grantRuntimePermission: Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS.
 

Ansem

New member
Hi,
it's the first time I use ADB so maybe I miss something :( I have a Samsung galaxy s21 with Android 12.
I downloaded the zip with the bat file and the run it, I gave permission from my phone but after running the script I recieve this errors:
Code:
Granting ADB permissions to MacroDroid's helper
Granting MacroDroid permissions
Failure [not installed for 0]

Exception occurred while executing 'disable-user':
java.lang.IllegalArgumentException: Unknown package: com.evenwell.powersaving.g3
        at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:28878)
        at com.android.server.pm.PackageManagerService.setApplicationEnabledSetting(PackageManagerService.java:28637)
        at com.android.server.pm.PackageManagerShellCommand.runSetEnabledSetting(PackageManagerShellCommand.java:2258)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:254)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:29805)
        at android.os.Binder.shellCommand(Binder.java:986)
        at android.os.Binder.onTransact(Binder.java:860)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5411)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:9925)
        at android.os.Binder.execTransactInternal(Binder.java:1220)
        at android.os.Binder.execTransact(Binder.java:1179)

Exception occurred while executing 'disable-user':
java.lang.IllegalArgumentException: Unknown package: com.evenwell.emm
        at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:28878)
        at com.android.server.pm.PackageManagerService.setApplicationEnabledSetting(PackageManagerService.java:28637)
        at com.android.server.pm.PackageManagerShellCommand.runSetEnabledSetting(PackageManagerShellCommand.java:2258)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:254)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:29805)
        at android.os.Binder.shellCommand(Binder.java:986)
        at android.os.Binder.onTransact(Binder.java:860)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5411)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:9925)
        at android.os.Binder.execTransactInternal(Binder.java:1220)
        at android.os.Binder.execTransact(Binder.java:1179)

Exception occurred while executing 'grant':
java.lang.SecurityException: Permission android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS requested by com.arlosoft.macrodroid is not a changeable permission type
        at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermissionInternal(PermissionManagerService.java:1565)
        at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:1493)
        at android.permission.PermissionManager.grantRuntimePermission(PermissionManager.java:378)
        at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:2448)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:272)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:29805)
        at android.os.Binder.shellCommand(Binder.java:986)
        at android.os.Binder.onTransact(Binder.java:860)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5411)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:9925)
        at android.os.Binder.execTransactInternal(Binder.java:1220)
        at android.os.Binder.execTransact(Binder.java:1179)
Service not stopped: was not running.

It still installed correctly Macrodroid Helper 1.7.
I tryied to create a Macro to enable GPS/location but it doesn't work.. I have GPS off and when I open google Maps or connect to a bluetooth device it isn't turned on.
 
Last edited:

Jacob L

Moderator
Hi,
it's the first time I use ADB so maybe I miss something :( I have a Samsung galaxy s21 with Android 12.
I downloaded the zip with the bat file and the run it, I gave permission from my phone but after running the script I recieve this errors:
Code:
Granting ADB permissions to MacroDroid's helper
Granting MacroDroid permissions
Failure [not installed for 0]

Exception occurred while executing 'disable-user':
java.lang.IllegalArgumentException: Unknown package: com.evenwell.powersaving.g3
        at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:28878)
        at com.android.server.pm.PackageManagerService.setApplicationEnabledSetting(PackageManagerService.java:28637)
        at com.android.server.pm.PackageManagerShellCommand.runSetEnabledSetting(PackageManagerShellCommand.java:2258)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:254)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:29805)
        at android.os.Binder.shellCommand(Binder.java:986)
        at android.os.Binder.onTransact(Binder.java:860)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5411)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:9925)
        at android.os.Binder.execTransactInternal(Binder.java:1220)
        at android.os.Binder.execTransact(Binder.java:1179)

Exception occurred while executing 'disable-user':
java.lang.IllegalArgumentException: Unknown package: com.evenwell.emm
        at com.android.server.pm.PackageManagerService.setEnabledSetting(PackageManagerService.java:28878)
        at com.android.server.pm.PackageManagerService.setApplicationEnabledSetting(PackageManagerService.java:28637)
        at com.android.server.pm.PackageManagerShellCommand.runSetEnabledSetting(PackageManagerShellCommand.java:2258)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:254)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:29805)
        at android.os.Binder.shellCommand(Binder.java:986)
        at android.os.Binder.onTransact(Binder.java:860)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5411)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:9925)
        at android.os.Binder.execTransactInternal(Binder.java:1220)
        at android.os.Binder.execTransact(Binder.java:1179)

Exception occurred while executing 'grant':
java.lang.SecurityException: Permission android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS requested by com.arlosoft.macrodroid is not a changeable permission type
        at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermissionInternal(PermissionManagerService.java:1565)
        at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:1493)
        at android.permission.PermissionManager.grantRuntimePermission(PermissionManager.java:378)
        at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:2448)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:272)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:29805)
        at android.os.Binder.shellCommand(Binder.java:986)
        at android.os.Binder.onTransact(Binder.java:860)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:5411)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:9925)
        at android.os.Binder.execTransactInternal(Binder.java:1220)
        at android.os.Binder.execTransact(Binder.java:1179)
Service not stopped: was not running.

It still installed correctly Macrodroid Helper 1.7.
I tryied to create a Macro to enable GPS/location but it doesn't work.. I have GPS off and when I open google Maps or connect to a bluetooth device it isn't turned on.
Don't worry about those errors. The GPS action is root only but location should still work. Are the logs saying anything?
 
Top