Troubles with mobile data toggle - basic solutions do not work

Karls

New member
Hi! It's my very first post here. I encountered a problem with mobile data toggle. My phone runes MIUI 12.5 (Android 11), and has locked bootloader, so in consequence it is not rooted. Obliviously I have to use ADB to theoretically makes it work, so like this comment suggest:
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
I run this two commands. The are correctly applied, as some other function, which also require ADB works fine. But the mobile data toggle does not work at all. The best I can do is set mobile_data0 to 0, but the change is only graphical - the data shows off in status bar, but I still have connection. So what's more I have to do to make it works? Tasker can handle it, but I much more prefer Macrodroid interface. Could you help me make it works, like a Tasker do?
 

MacroDroidDev

Administrator
Staff member
There is a warning in the app that this does not work reliably on ADB for all devices. Unfortunately it does work on all devices I have tried so it's pretty hard for me to diagnose why this doesn't work. I can try and reverse engineer what Tasker is doing but this is hit and miss if I can work out what it's doing in enough detail to be useful. I will make a note of this for a future task.
 

Karls

New member
AFAIK Tasker use fake ADB over wifi signal to run the command. The disadvantage is that it requires repeating ADB command after every reboot of the phone. Regarding the currently implemented option in the Macrodroid, can I provide any log to solve the puzzle why it works on some phones and not on my?
 

dhj49er

Well-known member
AFAIK Tasker use fake ADB over wifi signal to run the command. The disadvantage is that it requires repeating ADB command after every reboot of the phone. Regarding the currently implemented option in the Macrodroid, can I provide any log to solve the puzzle why it works on some phones and not on my?
Isn't ADB over WiFi only available from Android 11?
So not a solution for the users with phones on Android 10 or lower.
I have a Huawei P30 Pro New Edition running Android 10 and the mobile Data On (MD action or MD system setting) doesn't work. Although Mobile data off does work.
My workaround is to use UI integration to click on the status bar icon to turn on Mobile data.
 
Isn't ADB over WiFi only available from Android 11?
So not a solution for the users with phones on Android 10 or lower.
I have a Huawei P30 Pro New Edition running Android 10 and the mobile Data On (MD action or MD system setting) doesn't work. Although Mobile data off does work.
My workaround is to use UI integration to click on the status bar icon to turn on Mobile data.
Right, but does the interaction through the system's Ui work with the screen off and locked? because my intention is that when I leave my work (with my cell phone in my pocket), it switches from the wifi network to the mobile data network automatically.
 

dhj49er

Well-known member
Right, but does the interaction through the system's Ui work with the screen off and locked? because my intention is that when I leave my work (with my cell phone in my pocket), it switches from the wifi network to the mobile data network automatically.
But there is a solution.... If the screen is off, turn on screen, put in pin code (via a secure macro), open status bar and click on Mobile data icon, close status bar and turn screen off. The whole sequence takes a couple of seconds.
My phone is on Android 10, so adb over WiFi is not available. So no solution.
My macro is configured to work with screen on or off and works well.
 
Last edited:

Dimlos

Well-known member
It may be easier to use the ADB command.
ADB Shell [Tasker Plugin] worked on Android 10.
 

Attachments

  • mobile data eneble.jpg
    mobile data eneble.jpg
    197.1 KB · Views: 21
  • mobile data disabele.jpg
    mobile data disabele.jpg
    197.5 KB · Views: 20

dhj49er

Well-known member
I installed adb Shell plugin and tried the wifi shell action and it didn't work.
I turned on usb Debugging. Does this turn adb or is there something else to do?
 

Dimlos

Well-known member
USB connection of the Android device to PC and adb command to put the ADB daemon into TCP/IP connection mode is required.

adb tcpip 5555

This command is valid until the Android device is rebooted.

We have tested this on Redmi 9T / Android 10.
 

dhj49er

Well-known member
Thanks... I'll give it a try when I have my laptop with me.
Will still need to keep my UI based macros.. to be used after the phone is rebooted and until the PC adb command is run.
 

dhj49er

Well-known member
I've tried it and both WiFi and data enabled and disabled work.
Is there an equivalent adb command for Bluetooth?
I've tried using Bluetooth and BT but neither worked.
 

dhj49er

Well-known member
I'm having an issue.
The commands wifi on and off both work with the screen on. However, I can't get the command to work when the screen is off.
At night I turn on WiFi when the phone is unlocked (screen on) and this works. When the screen goes off after a few seconds delay I turn off WiFi. This does not work. Interestingly if I enable in the adb shell command block until completed, wifi turns off when I next turn on the screen.
Is this the expected behaviour or a I doing something wrong?
 

dhj49er

Well-known member
I'm having an issue.
The commands wifi on and off both work with the screen on. However, I can't get the command to work when the screen is off.
At night I turn on WiFi when the phone is unlocked (screen on) and this works. When the screen goes off after a few seconds delay I turn off WiFi. This does not work. Interestingly if I enable in the adb shell command block until completed, wifi turns off when I next turn on the screen.
Is this the expected behaviour or a I doing something wrong?
I've successfully resolved the issue.
I needed to enable app launch and disable battery optimisation for ADB Shell.
 

Dimlos

Well-known member

dhj49er

Well-known member
1
I have confirmed the Bluetooth adb command, but a confirmation dialog appears.
If you want to switch without the dialog, you need to use io.appium.settings.
I've never used gtihub and looks way beyond anything I can do. So I looked for the app but couldn't find it.
Do you have a URL for the app?
 

Dimlos

Well-known member
Please try this macro, I have tried it on multiple devices and it works without a confirmation dialog.
 

Attachments

  • Bluetooth_Enable.macro
    2.8 KB · Views: 6
  • Bluetooth_Disable.macro
    2.8 KB · Views: 2

dhj49er

Well-known member
Please try this macro, I have tried it on multiple devices and it works without a confirmation dialog.
I've tried the macros.
Unfortunately the confirmation dialog still shows - see attached screenshot
 

Attachments

  • Screenshot_20220504_102029_com.android.settings.jpg
    Screenshot_20220504_102029_com.android.settings.jpg
    231.2 KB · Views: 16
Top