If I have Android phone connected via USB, how do I know the commands I can send via USB to get Information like
core temperature of the device,
version of android,
power consumption details, etc.
Can I then use ADB logs, command to interact with Android mobile. Please may i know the process apart from commands if I have to send commands via ADB.
To get information from an android device, you can always use the following tools.
Use utilities like dumpsys or getprop.
Query from /sys/ or /proc/.
Eventually all utilities, fetch information from /proc or /sys, so you can directly investigate into these.
You could use dumpsys tools to get information:
Core temperature of the device
I'm not sure, what exactly do you mean by core temperature of the device.
Temperature of Device: Note
$ adb shell cat /sys/class/thermal/thermal_zone0/temp
37
Temperature of Battery:
$ adb shell cat /sys/class/power_supply/battery/device/power_supply/battery/temp
285
or
$ adb shell dumpsys battery
Current Battery Service state:
AC powered: false
USB powered: true
Wireless powered: false
status: 2
health: 2
present: true
level: 15
scale: 100
voltage: 3768
current now: -357254
temperature: 285 # <---- Temparature.
technology: Li-ion
Version of android
$ getprop ro.build.version.release
4.4.4 #<--- Android Kitkat 4.4.4
I'm not completely sure how you can get exact information:
You could start with,
$ adb shell dumpsys power
POWER MANAGER (dumpsys power)
Power Manager State:
....
Note: Results on a Linux System.
$ acpi -t # <--- apci power utility/tool.
Thermal 0: ok, 29.8 degrees C
Thermal 1: ok, 27.8 degrees C
$ cat /sys/class/thermal/thermal_zone0/temp
27800
I want this to be executed every 50 ms ?
You could write a script with above commands, that queries every 50ms.
Set-up ADB on Windows ?
A quick Google search should help you out.
Set Up Android ADB On Windows
To make proper use of Dumpsys,
See What's the Android ADB shell "dumpsys" tool and what are its benefits?
http://android-test-tw.blogspot.in/2012/10/dumpsys-information-android-open-source.html
Getprop : Android ADB commands to get the device properties
I hope this should give you a good start.
You will get the Android device properties using getprop command.
Please go through this blog .Here I am listing some of the major ADB commands. Feel free to ask doubts regarding these commands.
Related
I am trying to install third party apk to Samsung android smart tv...
1) I've turn on Developer mode in Apps and put my computer ip address there.
2) I'm runing this commands in terminal (mac os, the latest version of sdk-tools)
adb kill-server && adb start-server && adb connect 192.168.1.237:26101 && adb devices
Getting this:
* daemon not running; starting now at tcp:5037
* daemon started successfully
connected to 192.168.1.237:26101
List of devices attached
192.168.1.237:26101 device
3) And run:
adb install ./my.apk**
And got this:
Performing Push Install
adb: error: connect failed: closed
- waiting for device -
p.s. almost every command failed with error: closed
(i've tried adb shell, adb logcat, and so on...)
What next step to try ? Is port 26101 correct? (I've also tried port 5555, but get Connection refused
Sorry but I haven't seen any Samsung Smart TV running Android. Samsung has their own operating system (Tizen) but, as far I know you can't install apk apps, also you cannot install apps using adb (in Tizen is named SDB), instead of SDB you need to use the Tizen SDK + Tizen Studio to pair your PC, sign your app (.wgt extension) and install it using the SDB
When opening the Device file explorer window in Android Studio Preview 3, I don't see the device's files (There is a message "Nothing to show").
I searched this topic a lot but couldn't find anything that is relevant to this issue.
I'm using my test device:
Android Galaxy S5 running Android OS 6 (API 23) - Rooted
The specific build of Android Studio I'm using is:
Android Studio 3.0 Beta 6
Build #AI-171.4333198, built on September 13, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Any idea's how to solve this issue?
After struggling with this for a day, the answer for me was associated with disabling SuperUser permissions for the ADB shell on my Android Device.
If you have rooted your device and are using an app like SuperSU, try disabling the SU permission for ADB shell in the apps view list.
First disconnect your Android device from the computer running Android Studio
On your Android device open SuperSU and select the apps tab.
Click on ADB shell and select Access:'deny'
Reconnect your device to your dev computer using a USB cable
In Android Studio open the "Device File Explorer".
You should now see a list of files on the device, including files in /data/data/ and its subfolders
You would think that having SU permissions would be a good thing: but in this case, no.
Disable ADB shell's SU permissions in SuperSU
AS file explorer will execute su 0 sh -c 'ls -l /' to list the files. For unknown reason, SuperSu remove the single quotes and the actual command are su 0 sh -c ls -l /. In such case, the -l will not work. AS file explorer may have some problem to parse the output. So there is nothing to show.
You can check the log of AS to get such behavior. Open the log from: help -> show log in explorer
I want to know bugs of my android app so i tried to use logcat to see its log and followed these steps:-
You need to use adb server.
1. Connect your android with your laptop/pc
2. Go to developer options and turn on the stay awake and USB debugging options. (Your phone)
3. In your terminal, type "sudo adb kill-server" and then "sudo adb start-server".
4. Type "adb devices" (this should give list of devices connected)
List of devices attached
you_device_name device
5. "cd" to your folder where you have made your build.
6. Type "buildozer android debug deploy run logcat > logcat.txt"
this saves the logs (for the entire process) in a file logcat.txtx in the same folder and also deploys you app on the phone.
Go through it and find your error.
7. keep your phone awake.(do not lock it).
But when i run the 6th step, a time comes it says:-
error: device 'adb' not found
- waiting for device -
i have searched many times on the internet and when finally i am posting here to get solution
I actually initially misread the bulldozer error. It is complaining that a device adb doesn't exist. Which is strange. It should have picked up the device serial instead.
You could theoretically force adb commands to go to your device by executing
export ANDROID_SERIAL= <your device's serial number>
you could now repeat the steps and check if this works.
Also just for completeness just check if there exists an adb binary in the system partitin of your device.
Also make sure you haven't missed out any bulldozer init steps
Using: selenium webdriver, rubygems, appium, android and ios devices
The app I am testing has a button which becomes enabled only when connected to a specific wireless network. I'd like to create a script which will check if the button is active or not
vKioskStatus = element.enabled?
puts(vKioskStatus)
If it is not active, then I'd like to change wifi networks. Is that possible to automate changing networks on a mobile device?
UPDATE
I'm receiving the following error when trying to use getNetworkConnection. Is there a require I need to add?
<main>': undefined method `getNetworkConnection' for #<Selenium::WebDriver::Driver:0x..fe1a5511e browser=:firefox> (NoMethodError)
Here's my code:
require 'rubygems'
require 'selenium-webdriver'
require 'uri'
require 'appium_lib'
require_relative 'AndroidLib'
cButton = Buttons.new
driver = Selenium::WebDriver.for(:remote, :url => "http://127.0.0.1:4723/wd/hub") # Works for Android
sleep(5)
bob = driver.getNetworkConnection()
puts bob
you can toggle the wifi connection in Android (not possible in iOS) using the below appium commands,
To enable flight mode :
# Python
def enableFlightMode(self,context):
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
driver.implicitly_wait(10)
if driver.network_connection == 1:
self.report_pass("The network connection is disabled in the mobile and flight mode is active.")
else:
self.report_fail("The flight mode is not active yet!")
And to disable flight mode:
def enableFlightMode(self,context):
driver.mobile.set_network_connection(driver.mobile.AIRPLANE_MODE)
driver.implicitly_wait(10)
if driver.network_connection == 1:
self.report_pass("The network connection is disabled in the mobile and flight mode is active.")
else:
self.report_fail("The flight mode is not active yet!")
You can achieve this by accessing all available wifi networks using Shell Script. It means you need to write logic of firing ADB/Shell commands through your code.Connecting to wifi using adb shell
On your button click you can fire command to connect to desired wifi network.
Yes, it is possible to change the network using Appium. Look here
I am using below adb commands to turn on & off WiFi/data.And it is working fine.
Turn on wifi - adb shell am start -n io.appium.settings/.Settings -e wifi on
Turn off WiFi - adb shell am start -n io.appium.settings/.Settings -e wifi off
Turn on mobile data - adb shell am start -n io.appium.settings/.Settings -e data on
Turn off mobile data - adb shell am start -n io.appium.settings/.Settings -e data off
You can get/change network connection settings through AndroidDriver. However, it works only for Android version less than 5.
AppiumDriver<WebElement> driver = new AndroidDriver<WebElement>(new URL("..."), caps);
NetworkConnectionSetting networkConnection = new NetworkConnectionSetting(false, true, false); // airplane mode, wiif, data
networkConnection.setData(true); // enable mobile data
networkConnection.setWifi(false); // close wifi
((AndroidDriver<WebElement>)driver).setNetworkConnection(networkConnection);
networkConnection = ((AndroidDriver<WebElement>)driver).getNetworkConnection();
This ADB command will certainly switch off your wifi :
adb shell am broadcast -a io.appium.settings.wifi --es setstatus disable
To turn it on use :
adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable
OR
Try this code -
self.driver.open_notifications()
self.driver.find_element_by_xpath('//android.widget.Switch[#content-desc="Airplane mode"]').click()
self.driver.back()
Give me a thumps up if it works for you
I'm confuse with adb shell device login, I'm not able to go in root mode (# mode). I can only access $ mode from adb shell on any non rooted devices such as, Samsung galaxy Note, Galaxy 2 and Samsung galaxy Apollo (2.1), and as well not able to use "su -" command to be super user, and therefore restricted to directories such as /data/data/com.myapp.exmple.
But with root device can get root access with adb shell, and access them so my basic doubt is with non rooted devices can we get the root access with adb shell?
If not, I'm using Andrew Hoog's book "Synergy Android Forensics" which demonstrates adb shell can give you access to root (#mode) on non rooted devices, as well there are few examples on internet and forum which states so. take this video for example.
http://www.youtube.com/watch?v=tVJ7T2oC_Zs
Which is basically demonstrating how to unlock the security pattern lock with adb shell, which gets the root access (# mode) on non rooted device.
And if yes, what is the mistake I'm making? I install the latest JDK, then Android sdk in C:, then from c:android-sdk/platform-tools/ directory tried to access the adb shell.
I am running Cyanogenmod with Android 4.1.2 so this probably does not apply to stock roms. When I enter
adb root
the console returns
root access is disabled by system setting - enable in settings -> development options
in that menu you can disable root access, grant it for apps only, adb only and apps and adb. Select apps and adb and everything should work as expected.
AFAIK adb root or su- wont work on non-rooted android mobiles.
You can Google on how to root your specific model, but beware that you may loose company warranty if you force root your phone.
There is a command for getting root access on Android:
adb root
I don't know if it works on any version of Android. The above command restarts the adb as root.
Tap your device version build number (at the bottom of the info page) 7 times for android 4.2. This will enable the developer's menu.