I modified android phone hdmi output properties using ADB commands below
adb shell setprop persist.demo.rotationlock false
adb shell setprop persist.demo.singledisplay true
In order to see the change,
I will have to do either one of the following.
turn off phone screen, then turn on phone screen.
restart the phone or tv
unplug the phone to monitor, then plug the phone to monitor.
What I want:
Is there any command to do a quick reload/reset/refresh phone screen or video output connection? so I don't have to do any of the above to see the change.
Any help is appreciated
To "turn off phone screen, then turn on phone screen":
adb shell input keyevent 26
Run the above command twice.
26 is the keyevent code for power button.
To "restart phone":
adb reboot
Related
I am running an application from ADB commands as follow:
adb shell am start -n com.example.someapp.app/.SimpleActivity
The main screen in this app will have two buttons, how can press one of these buttons from ADB Shell?
It looks like the adb shell input command might work for you. You might need to have a rooted device to allow adb simulated touch input to work.
Here's a link to a blog containing a write up on adb input:
https://grymoire.wordpress.com/2014/09/17/remote-input-shell-scripts-for-your-android-device/
You'd normally tap the button (if you know the coordinates):
adb shell input tap <x> <y>
To find coordinates, enable pointer location, then tap the button location on your device:
adb shell settings put system pointer_location 1
No need to root phone.
Tested on Android 10 API 29
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.
Problem description:
Each time wen I connect USB cable between PC and my mobile phone the battery automatically is charged. I want to use ADB protocol but I don't want to charge my battery during ADB connection. Is it possible to to turn off this charging? And ofcourse how can I do this?
Environment:
Mobile phone with Android os 4 and higher
I need only mention that my referential device working on android 5 so there is no /sys/class/power_supply/battery/force_usb_charging file
BEWARE: adb shell dumpsys battery unplug only MOCKS the battery status. I checked with a current indicator on my usb cable and this does not change the amount of flowing current at all so the battery is still charging.
It only changes what applications think about the state, so for example google play would not start updating if you have configured that it can only update when charging...
Changing the value of a file like /sys/devices/battery.XX/power_supply/battery/hv_charger_set to 0 does really work but its a different file for every device. For example, for my yotaphone 2 with a snapdragon 805 there is a file: /sys/devices/qpnp-charger-14/power_supply/battery/charging_enabled
So you could make a script that you can use in tasker(if you have root):
echo $1 > /sys/devices/qpnp-charger-14/power_supply/battery/charging_enabled
if you write that to an executable file /data/setcharging.sh then you could call the script like /data/setcharging.sh 0 to disable or
/data/setcharging.sh 1 to enable.
This works, I checked with my current metering usb cable, but it does not show that it works in the battery status icon. So you could use a combination of this and adb shell dumpsys battery unplug / reset to make it look better, but the problem is that then apps like tasker don't know whether you have ac power or not, so you can not put triggers for that when you've set it to unplugged...
One more thing, I also tested what it does in recovery (twrp) and during boot. And it turns out that during boot and in recovery, the charging just works. So its not like your device will end up dead if you forget to turn on charging again. You can always charge it in recovery mode and then boot up and change the value again (or change it while in recovery if your recovery gives access to adb).
Lastly, there are apps on the play store that are made exactly for this, but I would recommend getting such a current indicating usb-cable and checking if they really do what they say and are not just mocking.
You can make the system think it is not loading th battery using
adb shell dumpsys battery unplug
Refer to this good article :
https://stanfy.com/blog/android-shell-part-1-mocking-battery-status/
Try this for rooted device:
To enable battery Charging:
adb shell dumpsys battery set ac 1
adb shell dumpsys battery set usb 1
adb shell dumpsys battery set wireless 1
To disable battery Charging:
adb shell dumpsys battery set ac 0
adb shell dumpsys battery set usb 0
adb shell dumpsys battery set wireless 0
Probably it can be done via (root privileges):
/sys/devices/battery.XX/power_supply/battery/hv_charger_set
0 - Disable USB Charging
1 - Enable USB Charging
if android os version is more than 6 use unplug and reset to revert back.
adb shell dumpsys battery unplug
adb shell dumpsys battery reset
Copied from perfetto.dev
On rooted phones the power management IC driver allows to disconnect the USB charging while keeping the USB data link active. This feature is SoC-specific, is undocumented and not exposed through any HAL. For instance on a Pixel 2 this can be achieved running, as root: echo 1 > /sys/devices/soc/800f000.qcom,spmi/spmi-0/spmi0-02/800f000.qcom,spmi:qcom,pmi8998#2:qcom,qpnp-smb2/power_supply/battery/input_suspend. Note that in most devices the kernel USB driver holds a wakelock to keep the USB data link active, so the device will never fully suspend even when turning the screen off.
I want to use my phones as a remote camera system that charges via a solar panel however I was wondering whether there is any way to turn the phone on automatically or remotely.
Thats to say, if the phone runs out of battery and turns off, is there anyway to turn it back on automatically or remotely?
If the phone is rooted, here is what you can do.
(Optional) Rename /system/bin/playlpm:
adb shell remount
adb shell mv /system/bin/playlpm /system/bin/playlpm-original
Then create a playlpm file locally and put the following:
#!/system/bin/sh
/system/bin/reboot
And push it to the target:
adb push playlpm /system/bin
Then give it a proper permission:
adb shell chmod 0755 /system/bin/playlpm
adb shell chown root.shell /system/bin/playlpm
Now, whenever phone is connected to a power supply, it is going to (re)boot automatically. That's, if its battery has drained it will boot up when a power will be available from solar panel.
Also see:
Auto Power on Android when the charger is Connected
Programmatically auto-power on the phone
Is there a way to auto-power on the phone
[root] NoMoarPowah!
How to turn on WIFI through adb on a motorola XYboard using android version 4.0
I have already tried the commands
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
adb shell input keyevent 20 & adb shell input keyevent 23
but it just takes to the wifi settings, but the keyevent 20 is not taking to the "ON/OFF" button. In the new 4.0 version of android, we have to do a click on ON/OFF btton next to the WIFI to turn it on. How do I get to click that button using adb
Is there a command that will turn the wifi ON directly like the one for bluetooth, I can use
adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
for turning bluetooth ON.
Please check the keyevent codes for your phone, the keyevents 20 and 23 are for Droid X,
the other droid X keyEvents are listed in this post : ADB Shell Input Events
So on your device the keycode events might be slightly different...