MD set Mobile Data tile off but connection still on

solquest

Member
Hey there.
On my new Motorola Edge 2 Lite with Android 12 (not rooted) I have run all MD adb hacks and I have also separated Mobile Data and Wi-Fi tile with

adb shell settings put global settings_provider_model false
adb shell settings put secure sysui_qs_tiles 'wifi,cell,$(settings get secure sysui_qs_tiles)'

cause I don't want wifi to be on all the day while mobile data should stay on.

I have a macro for turning mobile data off when I plug phone to my alarm (via aux) in the night.
After that macro fires, I do see Mobile Data Tile off, but mobile connection is still there and for turning it off I have to manually click to Data Tile for enabling it and to click again for finally disabling it.

Is there a way for avoiding these manual steps?

I've found this thread
but maybe there's an easier way...

Thanks.
Luigi.
 

Endercraft

Moderator (& bug finder :D)
As said when using them action it may just not work on some devices. The thread you linked to describes a way to change his using adb commands through TCP (just technical stuff but it works).
 

solquest

Member
As said when using them action it may just not work on some devices. The thread you linked to describes a way to change his using adb commands through TCP (just technical stuff but it works).
Thanks.
I have done it all, but now I don't know how to turn mobile data on and off.
I've read: " Then using the ADB shell Tasker plugin you can use svc data enable and svc data disable to enable and disable mobile data."
But ADB shell Tasker plugin is not compatible with Android 12.
How can I run those commands?
Thanks.
 

solquest

Member
Oh thanks, I could install it now.
But there seems to be something wrong.
In Settings/developer/Wireless debug I have IP and port 100.93.14.153:35621
1684597712056.png

So in MD action/ADB shell command I've set

1684597769107.png
1684597793740.png
but when I test this macro action, Mobile data keep staying on (and those adb output and adb errors remain empty).

Running 'adb_tcpip_5555' macro I get the success popup...
What am I missing?

Plus, I'm not always connected to wi-fi...does this mean I can't use this way for disabling mobile data when I don't have wi-fi?

Thanks again.
Luigi.
 

Endercraft

Moderator (& bug finder :D)
In IP address use localhost. localhost means yourself.
In port use 5555.
The ip and port you are using are for wireless debugging but in this case we want to connect to the TCP port with is 5555 (you can use other ports but 5555 is Android default).
 

solquest

Member
Hmmm there still something I don't get...
In the night I turn Wifi and mobile data off. Last night this macro didn't work, so I changed mobile daa manually.
This morning I had a test:
- at 23-05-23 07:57:07.828 I've run 'adb_tcpip_5555' macro and got the 'success' popup.
- at 23-05-23 07:57:47.282 I've run the macro for setting data off 'toggle mobile data' but nothing changed.

Here's what I found in MD system logs:

Code:
23-05-23 07:57:07.828 - TESTING MACRO:adb tcpip 5555 (adb tcpip 5555)

23-05-23 07:57:07.829 - Invoking Macro: adb tcpip 5555 (adb tcpip 5555)

23-05-23 07:57:07.829 - A: Clean variables (adb tcpip 5555)

23-05-23 07:57:07.829 - Value updated from * daemon not running; starting now at tcp:5037

* daemon started successfully

 to  (adb tcpip 5555)

23-05-23 07:57:07.830 - Value updated from connected to localhost:44845

adb tcpip 5555

restarting in TCP mode port: 5555

 to  (adb tcpip 5555)

23-05-23 07:57:07.831 - A: System settings ([Global] adb_wifi_enabled = 0) (adb tcpip 5555)

23-05-23 07:57:07.833 - Calling helper file to set system setting. (adb tcpip 5555)

23-05-23 07:57:07.834 - A: System settings ([Global] adb_wifi_enabled = 1) (adb tcpip 5555)

23-05-23 07:57:07.836 - Calling helper file to set system setting. (adb tcpip 5555)

23-05-23 07:57:07.838 - A: Termux (nmap.sh


Working Directory ✕

Stdin ✕

Custom Log Level null

Terminal Session ✕

Wait For Result ✓) (adb tcpip 5555)

23-05-23 07:57:36.973 - Value updated from  to * daemon not running; starting now at tcp:5037

* daemon started successfully

 (adb tcpip 5555)

23-05-23 07:57:36.975 - Value updated from  to connected to localhost:43545

adb tcpip 5555

restarting in TCP mode port: 5555

 (adb tcpip 5555)

23-05-23 07:57:36.976 - A: If (termux_output contiene adb tcpip 5555) (adb tcpip 5555)

23-05-23 07:57:36.986 - A: Popup Message 'success' (adb tcpip 5555)

23-05-23 07:57:47.282 - TESTING MACRO:toggle mobile data (toggle mobile data)

23-05-23 07:57:47.283 - Invoking Macro: toggle mobile data (toggle mobile data)

23-05-23 07:57:47.283 - A: If (mobile data on = True) (toggle mobile data)

23-05-23 07:57:47.283 - A: If (mobile data on = True) If condition failed: Variabile MacroDroid (toggle mobile data) (toggle mobile data)

23-05-23 07:57:47.284 - A: ADB Shell Command (localhost:5555

svc data disable

50 ms

) (toggle mobile data)

23-05-23 07:58:23.810 - Value updated from keyfiles paths: /data/user/0/com.ADBPlugin/files/pub.key, /data/user/0/com.ADBPlugin/files/priv.key

Loaded existing keypair

Socket connecting at localhost:5555

java.lang.Exception: Device at localhost:5555 has no adb enabled or connection is refused

    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:85)

    at com.ADBPlugin.Constants.handleFireMessage(Constants.kt:189)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:45)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:34)

    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5555) from /:: (port 52470): connect failed: ETIMEDOUT (Connection timed out)

    at libcore.io.IoBridge.connect(IoBridge.java:187)

    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)

    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)

    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)

    at java.net.Socket.connect(Socket.java:646)

    at java.net.Socket.connect(Socket.java:595)

    at java.net.Socket.<init>(Socket.java:475)

    at java.net.Socket.<init>(Socket.java:243)

    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:81)

    ... 4 more

Caused by: android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)

    at libcore.io.Linux.connect(Native Method)

    at libcore.io.ForwardingOs.connect(ForwardingOs.java:201)

    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:158)

    at libcore.io.ForwardingOs.connect(ForwardingOs.java:201)

    at libcore.io.IoBridge.connectErrno(IoBridge.java:201)

    at libcore.io.IoBridge.connect(IoBridge.java:179)

    ... 14 more

 to keyfiles paths: /data/user/0/com.ADBPlugin/files/pub.key, /data/user/0/com.ADBPlugin/files/priv.key

Loaded existing keypair

Socket connecting at localhost:5555

java.lang.Exception: Device at localhost:5555 has no adb enabled or connection is refused

    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:85)

    at com.ADBPlugin.Constants.handleFireMessage(Constants.kt:189)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:45)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:34)

    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5555) from /:: (port 53344): connect failed: ETIMEDOUT (Connection timed out)

    at libcore.io.IoBridge.connect(IoBridge.java:187)

    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)

    at java.net.AbstractPlainSo (toggle mobile data)

23-05-23 07:58:29.960 - Value updated from keyfiles paths: /data/user/0/com.ADBPlugin/files/pub.key, /data/user/0/com.ADBPlugin/files/priv.key

Loaded existing keypair

Socket connecting at localhost:5555

java.lang.Exception: Device at localhost:5555 has no adb enabled or connection is refused

    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:85)

    at com.ADBPlugin.Constants.handleFireMessage(Constants.kt:189)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:45)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:34)

    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5555) from /:: (port 53344): connect failed: ETIMEDOUT (Connection timed out)

    at libcore.io.IoBridge.connect(IoBridge.java:187)

    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)

    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)

    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)

    at java.net.Socket.connect(Socket.java:646)

    at java.net.Socket.connect(Socket.java:595)

    at java.net.Socket.<init>(Socket.java:475)

    at java.net.Socket.<init>(Socket.java:243)

    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:81)

    ... 4 more

Caused by: android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)

    at libcore.io.Linux.connect(Native Method)

    at libcore.io.ForwardingOs.connect(ForwardingOs.java:201)

    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:158)

    at libcore.io.ForwardingOs.connect(ForwardingOs.java:201)

    at libcore.io.IoBridge.connectErrno(IoBridge.java:201)

    at libcore.io.IoBridge.connect(IoBridge.java:179)

    ... 14 more

 to keyfiles paths: /data/user/0/com.ADBPlugin/files/pub.key, /data/user/0/com.ADBPlugin/files/priv.key

Loaded existing keypair

Socket connecting at localhost:5555

java.lang.Exception: Device at localhost:5555 has no adb enabled or connection is refused

    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:85)

    at com.ADBPlugin.Constants.handleFireMessage(Constants.kt:189)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:45)

    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:34)

    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)

Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5555) from /:: (port 53350): connect failed: ETIMEDOUT (Connection timed out)

    at libcore.io.IoBridge.connect(IoBridge.java:187)

    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)

    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)

    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)

    at java.net.AbstractPlainSo (toggle mobile data)

Why is it saying 'Device at localhost:5555 has no adb enabled or connection is refused' if I got the 'success' popup?

Thanks.
Luigi.
 

Endercraft

Moderator (& bug finder :D)
Weird, maybe the device does not understand it is connected ? Have you enabled all USB debugging options (I think it's not related to only USB adb) ?
 

Dimlos

Well-known member
@solquest
I guess I should first make sure to run adb tcpip 5555 to see if I can turn mobile data on and off with the ADB command.
Do you not have a PC?
 

Dimlos

Well-known member
If you have finished setting up termux, try running the command manually.

adb connect xxx.xxx.xxx.xxx:xxxxx
adb tcpip 5555

If you see "resterting in tcp mode port: 5555", you have succeeded.
 

Attachments

  • Developer options.jpg
    Developer options.jpg
    313.4 KB · Views: 6
  • Termux.jpg
    Termux.jpg
    435.1 KB · Views: 6

solquest

Member
Thanks.
Actually I already set ADB shell Tasker plugin/Additionnal Settings = off, cause the first time it didn't work with that on.
I also had USB debug = True, tried setting it to False but nothing changed.
So now I've got IP and port from Developer options

1684953528319.png
and run those commands in Termux:

1684953585164.png

and the weird thing is that the last '5' disappeared when I've clicked enter.
Then I've gone back in Developer options and port was changed

1684953667274.png



Then I've run 'adb_tcpip_5555' macro and after two 'failed' I got 'success' popup.
I went back to Termux and run adb tcpip 5555 again and I got the message 'device is offline':

1684953771363.png

Something that may help: the wi-fi I'm connected to is not a private one.

For my understanding: for running 'svc data disable' should I be connected to a wifi (I was in all my test by the way, it's just for knowing)?
And yes, I do have a pc.
 

Attachments

  • 1684952541592.png
    1684952541592.png
    217.4 KB · Views: 4

solquest

Member
Thanks.
So after my previous post (at 24-05-23 20:55:16.253) I tried to disable mobile data with that macro but didn't work:

Code:
24-05-23 20:55:16.253 - TESTING MACRO:toggle mobile data (toggle mobile data)
24-05-23 20:55:16.253 - Invoking Macro: toggle mobile data (toggle mobile data)
24-05-23 20:55:16.254 - A: If (mobile data on = True) (toggle mobile data)
24-05-23 20:55:16.254 - A: If (mobile data on = True) If condition failed: Variabile MacroDroid (toggle mobile data) (toggle mobile data)
24-05-23 20:55:16.255 - A: ADB Shell Command (localhost:5555
svc data disable
50 ms
) (toggle mobile data)
24-05-23 20:55:16.428 - Value updated from keyfiles paths: /data/user/0/com.ADBPlugin/files/pub.key, /data/user/0/com.ADBPlugin/files/priv.key
Loaded existing keypair
Socket connecting at localhost:5555
java.lang.Exception: Device at localhost:5555 has no adb enabled or connection is refused
    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:85)
    at com.ADBPlugin.Constants.handleFireMessage(Constants.kt:189)
    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:45)
    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:34)
    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5555) from /:: (port 58706): connect failed: ECONNREFUSED (Connection refused)
    at libcore.io.IoBridge.connect(IoBridge.java:187)
    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
    at java.net.Socket.connect(Socket.java:646)
    at java.net.Socket.connect(Socket.java:595)
    at java.net.Socket.<init>(Socket.java:475)
    at java.net.Socket.<init>(Socket.java:243)
    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:81)
    ... 4 more
Caused by: android.system.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
    at libcore.io.Linux.connect(Native Method)
    at libcore.io.ForwardingOs.connect(ForwardingOs.java:201)
    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:158)
    at libcore.io.ForwardingOs.connect(ForwardingOs.java:201)
    at libcore.io.IoBridge.connectErrno(IoBridge.java:201)
    at libcore.io.IoBridge.connect(IoBridge.java:179)
    ... 14 more
 to keyfiles paths: /data/user/0/com.ADBPlugin/files/pub.key, /data/user/0/com.ADBPlugin/files/priv.key
Loaded existing keypair
Socket connecting at localhost:5555
java.lang.Exception: Device at localhost:5555 has no adb enabled or connection is refused
    at com.ADBPlugin.SendSingleCommand.<init>(SendSingleCommand.kt:85)
    at com.ADBPlugin.Constants.handleFireMessage(Constants.kt:189)
    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:45)
    at com.ADBPlugin.receiver.FireReceiver$onReceive$1.invoke(FireReceiver.kt:34)
    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5555) from /:: (port 58708): connect failed: ECONNREFUSED (Connection refused)
    at libcore.io.IoBridge.connect(IoBridge.java:187)
    at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
    at java.net.AbstractPlai (toggle mobile data)

So at 24-05-23 20:55:48.275 I've run 'adb tcpip 5555' macro and after that tried again to disable mobile data with that macro and it finally worked
Code:
24-05-23 20:55:48.275 - TESTING MACRO:adb tcpip 5555 (adb tcpip 5555)
24-05-23 20:55:48.275 - Invoking Macro: adb tcpip 5555 (adb tcpip 5555)
24-05-23 20:55:48.275 - A: Clean variables (adb tcpip 5555)
24-05-23 20:55:48.275 - Value updated from connected to localhost:33099
adb tcpip 5555
 to  (adb tcpip 5555)
24-05-23 20:55:48.276 - A: System settings ([Global] adb_wifi_enabled = 0) (adb tcpip 5555)
24-05-23 20:55:48.281 - Calling helper file to set system setting. (adb tcpip 5555)
24-05-23 20:55:48.282 - A: System settings ([Global] adb_wifi_enabled = 1) (adb tcpip 5555)
24-05-23 20:55:48.284 - Calling helper file to set system setting. (adb tcpip 5555)
24-05-23 20:55:48.286 - A: Termux (nmap.sh

Working Directory ✕
Stdin ✕
Custom Log Level null
Terminal Session ✕
Wait For Result ✓) (adb tcpip 5555)
24-05-23 20:55:55.706 - Value updated from  to connected to localhost:40277
adb tcpip 5555
 (adb tcpip 5555)
24-05-23 20:55:55.709 - A: If (termux_output contiene adb tcpip 5555) (adb tcpip 5555)
24-05-23 20:55:55.723 - A: Popup Message 'success' (adb tcpip 5555)
24-05-23 20:56:05.974 - TESTING MACRO:toggle mobile data (toggle mobile data)
24-05-23 20:56:05.974 - Invoking Macro: toggle mobile data (toggle mobile data)
24-05-23 20:56:05.974 - A: If (mobile data on = True) (toggle mobile data)
24-05-23 20:56:05.975 - A: If (mobile data on = True) If condition failed: Variabile MacroDroid (toggle mobile data) (toggle mobile data)
24-05-23 20:56:05.976 - A: ADB Shell Command (localhost:5555
svc data disable
50 ms
) (toggle mobile data)
24-05-23 20:56:06.313 - Value updated from [svc data enable, ^@kyoto:/ $ svc data enable, kyoto:/ $] to [svc data disable, ^@kyoto:/ $ svc data disable, kyoto:/ $] (toggle mobile data)

The problem is that I haven't understood what has make it working now and why it was not before...
 

solquest

Member
And now I've run that macro for enabling mobile data again and it didn't work.
So I've run again 'adb tcpip 5555' macro and then mobile data enabling worked
 

Dimlos

Well-known member
Running adb tcpip 5555 will restart the connection, so it is normal behavior to lose Wi-Fi debugging.
Are MacroDroid, Termux, Termux:Tasker and ADB Shell [Tasker Plugin] set to not taskkill?
Also, what happens when I test ADB Shell [Tasker Plugin] with Port555 after manually executing a command in Termux?
 

solquest

Member
Also, what happens when I test ADB Shell [Tasker Plugin] with Port555 after manually executing a command in Termux?
How can I do this?
Actually Termux, Termux:Tasker and ADB Shell [Tasker Plugin] had battery optimization...I've just changed them
 
Top