Android code to boot device without press any power button? - android

Is it possible to boot the device when the battery is already inserted, and then main power is connected, without the help of any power switches?
Is there any ADB command to boot up the device after completely turned off?
Please keep in mind: I am not asking for reboot, I'll ask for boot after switched off.

Is there any Adb command to boot up the device after completely turned
off ??
No.
Perhaps it would help to understand that an app runs. For an app to run it needs a processor/cpu to process the commands. If a processor (cpu) has no power then it can;t process anything. Therefore the app needs power. If there is no power then the app can't run. If it can't run then it can't switch the phone on!!!!!!!
Really quite simple when you think about it.
The closest you will get is to set an alarm to wake up the system if it goes into hibernation/sleep mode

Hold the volume + & volume - and plug the usb cable into your device while its plugged into your PC, the phone should enter fastboot mode. Make sure you have adb and fastboot installed on your PC, open the platform tools folder that is in your PCs C: drive, hold the shift key on your keyboard and right click on an empty spot in the folder and open a command window. Run the following command: fastboot reboot

Related

Is there a way to build and run an Android Studio app on a phone remotely?

I am developing an app for Android that controls a robot using the FTC SDK, and I need to be able to make small changes to motor values in the code and re-install it to test the new code. My problem is that I need to do this a lot of times, and the system of taking the phone out of the mount (which takes a while) and plugging it into my computer to upload, waiting for it to upload, turning off the power to the robot, plugging the phone back in to the robot, and turning the power back on has started slowing our progress down a lot. I was wondering if there was any way I could install the new code on the phone without taking it out of the mount.
Our phone is connected to a usb hub with a webcam and the hardware controller, so I was wondering if attaching a wireless usb transmitter to the hub and my computer would still let the phone show up on the android studio connections manager and let me install it.
So if anyone has done this before, or knows about any way to make this work, thank you for the help!
Yes. First make sure that the robot phone has developer mode and USB debug enabled.
(Do this by going to settings -> software info and click on build number ten times, then go settings -> developer options and enable USB Debug)
Then, go into the robot controller phone and under the three dots at the top right select program and manage. Connect your computer to the shown internet name and password.
Next if you are on Windows plug in the phone and run the following code in command prompt,
pushd "%userprofile%\AppData\Local\Android\sdk\platform-tools"
adb disconnect
adb tcpip 5555
adb connect 192.168.49.1
popd
PAUSE
If you are on Mac plug in the device and run the following code in terminal,
cd ~/Library/Android/sdk/platform-tools
./adb disconnect
./adb tcpip 5555
./adb connect 192.168.49.1:5555
Finally, disconnect the phone, go back to android studio and happy wireless coding.

ADB command to launch screensaver activity

I'm turning crazy finding the way to launch the screensaver activity that can be launched from Settings > Display > Screensaver. I want to simulate from ADB clicking on the option "start now" inside the screensaver options because I need to configure some TV's to quickly launch the screensaver on demand.
I have all of them connected through Intel sticks using Android x86 Nougat stable, I can do adb through wifi without issues and I even installed Simple SSH to access through SSH in case of needed.
The keyevents are working, but there is no keyevent to launch the screensaver, only to simulate the power off button, which causes the wireless connection to go down no matter what is configured in the sleep / battery saving settings.
Is there any chance to fix this?
Thanks!
I have found the following adb command works on devices that I develop on:
adb shell am start -n "com.android.systemui/.Somnambulator"
Credit to https://stackoverflow.com/a/21485967/11385462 for pointing in the right direction. YMMV.

how to run adb command on my phone without giving any current to the phone

I want to measure the current consumption of my device while running different test cases. (Have a tool to measure current consumption).
I have automated the test cases using UIAutomator. But for running the script I have to connect the device via USB or WiFi. In both cases current consumption of the device gets higher.
Is there any method by which I can stop the current coming from USB and run the script?
I have tried:
adb shell dumpsys battery set usb 0
This stops the charging through USB but the current reading is still more, because I think device is still getting the current it only stops the battery charging.
Connect with ADB over wifi. Start a test case that doesn't do anything and measure current increase (consider doing this multiple times). That's your baseline. When you run the real test, however much the current increases above that is due to the test.
My problem is solved. I used:
adb shell
uiautomator runtest projectname.jar -c pkg.cls &
Because of &, the script keeps running even when I disconnect the USB cable

How can I log the activities of my android app on the phone seperated from any PC?

I have created an app which so far works on my phone. But in order to check the long-term functionality I need to record the log file during a day or so, when the phone is not connected to any computer.
How can I do this?
Before you start testing, connect your device to a PC, open ADB shell and enter:
logcat > /sdcard/mylog.txt &
That will dump logcat to file and will run in background, so it's continue to run even when you disconnect device from PC.

Launch Android Emulator with No Data via Command Line

I'm trying to figure out how to launch an emulator with no data connection or airplane mode, either one will work. Im testing my application against data loss, however I need this to be atomized. Therefore I'm trying either to launch the emulator with no data via command line, or write bash script to launch emulator, turn data off, then run Unit Test.
RESOLVED - Per Recommendations
#! /usr/bin/expect
set timeout 10
spawn telnet localhost 5554
expect "OK"
send "gsm data off\n"
send "quit\n"
The quick and dirty way to do it could be to make an app that starts at boot and turns data off, then run the emulator and install the app. This does have potential for inconsistency however.
The other thing you can do to leave just the emulator without a network is to telnet into the emulator and turn data off. To automate it, I made a simple (and crude) example using a batch file and vbscript to feed telnet the commands since my work machine is running Windows.
The batch file:
#echo off
emulator -avd YOURAVDNAMEHERE
timeout /t 10
telnet_turn_data_off.vbs
telnet_turn_data_off.vbs:
set oShell=CreateObject("WScript.Shell")
oShell.Run "telnet localhost 5554", 9
WScript.sleep 500
oShell.Sendkeys "gsm data off{ENTER}"
WScript.sleep 500
oShell.Sendkeys "gsm voice off{ENTER}"
WScript.sleep 500
oShell.Sendkeys "quit{ENTER}"
WScript.sleep 500
oShell.Sendkeys "quit{ENTER}"
WScript.sleep 500
If running on Linux or Mac OS, expect should be able to script telnet (as seen by the edit to the question).
It is also worth noting that on older emulators (eg 2.2), turning data off might not do anything. My above example was tested with a 4.2 emulator and it appeared to cut off data properly.
I typically use physical hardware for testing instead of emulators, but if you can't find an option to enable airplane mode you could simply disconnect your computer from the internet before launching the emulator. No internet for your computer = no internet for your emulator.
Use This Following steps..
Go to Eclipse
Window->show view->other->android->Devices
now select your running emulator and Again
Go to,
Window->show view->other->android->Emulator Control
Now in that..set Data to Unregister from Home
From Device and Emulator
In Device or Emulator Go to,
Setting -> Wireless & networks -> Airplane Mode -> ok

Categories

Resources