ADB Hack - Granting extra capabilities via the ADB tool

MacroDroidDev

Administrator
Staff 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 ADB 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" or "USB debugging (Security settings)" or anything similar and enable/disable it as appropriate.

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
 
Last edited by a moderator:

chaoscreater

Active member
Same problem here, i have Redmi Note 10 Pro, i have success to grant permission for wifi toggle, bluetooth, nfc, but i didn't reach the mobile data connection switch. I did all the guide for adb hack
Anyone can explain why it's impossible to switch connection data?

Use Termux instead. You can use MacroDroid to call a Termux script and inside that script, just call this adb command:

adb shell data disable

Google how to set up Termux or check one of the threads here. I think I wrote a guide on setting up Termux and you can just change follow it to set it up, then change the Termux script to run the command above.
 

Jacob L

Moderator (Lawsonator)
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?
 

Endercraft

Moderator
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.
It can also be caused by not enabling USB debugging (secure settings)
 

RicMck

New member
Samsung S21 Helper ADB hack does not work? I have done the ADB programing twice per the instructions and MacroDroid does not connect to the helper app? I'm trying to get the S21 to toggle the WiFi. Any suggestions- recommendations?
 

santhu

New member
Do you mean the download link is broken? That's because my storage decided to delete everything due to a sync error. It has been restored but now needs a new link. Here: https://mega.nz/folder/Lzok1SyR#hZ4a3qfF5ehFcbUEK6Zldw
First of all i want to thank you for the support.

The tool in the old link worked.

The issue is, i forgot to enable the option 'Disable permission monitoring' before running this tool.

BTW, is the tool present in the above new link is a updated one compared to the one present in the old link ?

Thanks again.
 

Dimlos

Well-known member
Is wireless ADB debugging possible for this process?
See this thread for ADB hacks in wireless debugging.
 
Top