How to toggle turn on/off mobile data with adb command - android

I looking for toggle my android phone mobile data with adb command. that is usually i do it with touch my mobile data icon in settings.
i found many reference to do it, for example this question , but nothing work for me, i try use:
$ adb shell svc data enable
$ adb shell svc data disable
when i look to my android phone nothing happen.
my android is KitKat 4 and i sure have rooted
Thanks.

Related

ADB debugging not restarting on reboot

I am running lineageOS on a rooted firestick. I am using ADB on the Firestick to control it via Homeassistant. The problem is that the adb debugging does not automatically work on reboot. Everytime i reboot i have to manually go to the menu turn off the ADB debugging and then turn in back on. After doing this i am able to reconnect adb via network (i.e, on homeassistant).
I want to ask is there any way i can use a script to automatically do this on restart of firestick. I have tried creating a script in init.d with the following contents but it doesn't seem to work.
adb tcpip 5555
I have added the following line to build.prop but this doesn't seem to work too
service.adb.tcp.port=5555
On restart the adb debugging is on in the developer tools but somehow it doesn't connect (either to Homeassistant or to my laptop), what seems to make it work is toggling it off and then back on.

Is there command to show all bluetooth devices ever conencted to my mobile phone?

So i lost my bluetooth ear buds and wonder if there is any way i can see where i was lastly connected to them. I had already tried using command adb shell dumpsys bluetooth_manager but the command only showed bluetooth devices from this day. Is there any command that can show at least 3 days back?

AndroidTV: Turn display off/on via adb without loosing wifi?

I have an Android TV for which I want to turn the display on and off based on a motion sensor. I have connected the tv to a raspberry pi via Wifi and I'm trying now via adb commands to turn off the display of the Android TV.
As far as I've seen, I need to execute the following command:
./adb shell input keyevent 26
Unfortunately, this also turns down the device and most importantly Wifi. After this the TV is offline and not reachable anymore via the IP address. So I have to use the remote to turn it on again.
So I need a way to keep the Wifi active. I've already tried the following commands without luck:
adb shell svc power stayon true
adb shell settings put global stay_on_while_plugged_in 3
I've also sideloaded a Wakelock app, but that also didn't work. After keyevent 26, the device is always offline.
The TV is a TCL 43P615.
Any ideas how I could achieve this?
Thanks
There would not be a standard way of turning off the screen (https://support.google.com/androidtv/thread/58069060/is-it-possible-to-turn-screen-off?hl=en-GB) but perhaps your TV provides one in settings or eco-mode.
Perhaps you best bet is to disable the screensaver and create a completely black fullscreen Activity that you can start and stop from adb.

Remotely turning on display and opening Apps

I have a tablet connected to my home automation system. I would like my tablet to open an app when specific conditions are met.
My idea was to install some sort of SSH server on the tablet. When my server wants the tablet to open the App, it logins into the tablet and executes a command turn on the display and open the App.
In theory this works but I haven't been able to find any documentation on the web on how to do this.
I've got as far as installing SSHDroid however when the tablet locks, the SSH disconnects. I'm also unable to find any commands which turn on the display and open apps.
From a computer, if you have USB access already (no root required), check this answer more details.
Connect your tablet with computer(has adb installed) and run
adb tcpip 5555
Then you can control your tablet over wifi by run
adb connect 192.168.0.101:5555 // you can use port forward in you gateway to enable you connect over internet.
Now after connected with tablet you are able to use adb shell commands.
Turn Screen On
adb shell input keyevent KEYCODE_POWER
Start an Application
adb shell am start -n com.package.name/com.package.name.ActivityName

use adb to get the device name of android device

I want to use the adb shell to find out the camera device name of my android device. Usually the name can be dev/video1, however, tablets of NEXUS and Smsung don't work that way.
Could anyone give me hint? About the procedure? How to use the adb shell?
THX!
You can get shell access to your Android device via the following command.
adb shell
The application data is stored in the directory "/data/data/package_of_your_app".
// Assume the gesture file exists on your Android device
adb pull /sdcard/gestures ~/test
// Now copy it back
adb push ~/test/gesture /sdcard/gestures2
It will work for you.

Categories

Resources