Creating an AVD profile via ADB - android

Is there any way to get or see all the device's
properties in Android Debug Bridege Shell?
adb-shell shows and retrieves only the device's, which is connected, current prosesses of the current session as I see.
I just wonder that there is an adb-shell script command to see that device's all technical product informations.
I am planning to create an Android Virtual Device profile, but I don't have any technical information about the device. But if I can get those informations from adb, then I will be able to create that profile to build and to run android applications.

To see all connected devices, you can type adb devices
To get the serial number, you can type adb serialno
Also, adb status-window opens a window with constant monitoring of the device
More crazy:
adb shell pm list features shows a list of features the device has
adb shell pm list users shows a list of users the device has (needs root)
You can't really get things like screen resolution etc through ADB unfortunately.

Related

Inside my Android app (java), I want to retrieve IP address while connecting my Android with usb connection to another device

I am pretty sure it's possible as I successfully got same from termux Android app where I installed nmap and ran following commands:
Run ifconfig first and get the device IP (xxx.xxx.xxx.x)
Run nmap -sn xxx.xxx.xxx.x/24
Note: the device was not rooted and it even works in airplane mode.
Testing device: Android version 11, Samsung Galaxy m30s
I tried official Android docs for usb overview (usb manager, usbdevicce, etc.) and even running command line inside my app but wasn't successful (however I was able to do ssh once I know the ip address through command line).
You can get the IP address of the device.
Process p = Runtime.getRuntime().exec("/system/bin/ip address");
This will give you lots of information including loopback,ip4,ip6, broadcast, etc
You can use additional switches to further modify it according to your requirement.
to get all the available switches
open terminal/command prompt
Connect your Android Device
Type - ADB devices
You should be able to see your device.
Then type ADB shell and press enter
then type /system/bin/ip --help
this will show all the switches for this IP utility.
You can sent a request to a httpbin server, and obtain the answer from the resonse.
e.g.
Request URL
https://httpbin.org/ip
Response body
{
"origin": "104.132.33.92"
}

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

Command to clear the previous dumpsys info

Question is straight forward and simple. Is it possible to get the dumpsys information after certain point or certain user action. Not from the scratch.
There is no such thing.
Logs belong to the logcat facility. dumpsys is mostly for reporting the current state and some more advanced things. It is true that few of the Android service developers included some limited logging excerpts into their dumpsys output but virtually none of them implemented a way to clear those logs.
I realise this is a bit late but...
As per the documentation:
Connect your mobile device to your computer.
Open a terminal and type the following commands to reset the adb server:
adb kill-server
adb devices
This will list any connected devices (If you don't see any devices listed, make sure your phone is connected, and USB Debugging is turned on, and then kill and restart adb again).
Next you will need to reset battery data gathering. The device is always collecting batterystats and other debugging information in the background. Resetting erases old battery collection data. If you do not reset, the output will be huge.
In terminal use command:
adb shell dumpsys batterystats --reset
Disconnect your device from your computer so that you are only drawing current from the device's battery.
Play with your app and perform actions for which you would like data; for example, disconnect from WiFi and send data to the cloud.
Reconnect your phone and make sure it is recognized:
adb devices
Dump all battery data (This can take a while):
adb shell dumpsys batterystats > [path/]batterystats.txt
The batterystats.txt file is created in the directory you specify using the optional path argument. If you leave out [path/], the file is created in your home directory.
You can find the home directory in Android Studio by going to:
Tools > SDK Manager > Android SDK Location.
Navigate to that filepath then open the subdirectory 'platform-tools' and look for batterystats.txt.

adb device list is empty for one particular device

I have two identical devices(not mobile phone) in which I am trying to update an apk file.
Device 1, I connect to my laptop using USB cable. I get a prompt to open the internal storage system of the device which is basically a SD card.
Now I run the adb devices command and I get the list of devices attached as "0123456789ABCDEF device"
Then I disconnect the device 1 and connect device 2(Also reconnect the USB cable, adb kill-server and start it again). I get the same prompt to open the internal storage system. Then I run the adb devices and it the list is empty.
In both cases, I can see my devices correctly under the portable devices. I can not enable the USB debugging mode in the devices as the devices always brings an application after power up. So I can not reach settings screen.
Any help is appreciated. If you any questions to support, i would be able to answer.
I think this question is because the vid of device2 is differnet from device1. You need to add the vid of device2 in adb_usb.ini file in C:/Users/your_pc_name/.android directory. You can get the vid from Computer-Device Management.

Remove Google Glass apk without having root access?

I was testing out the Glass quickstart and chose COMPASS to "re-upload" as a test (tutorial: https://developers.google.com/glass/develop/gdk/quick-start#for_android_beginners)
Now that it worked, I'm stuck with 2x "Compass - sample" and can't call either one by voice commands.
Compass isn't important to me but I am in the process of making an apps for the medical field and I would like to be able to remove it.
Is it possible to remove an .apk from Glass without rooting the device? I have Glass in debug mode and I'm capable of uploading apk's.
Thanks for the help!
You can remove it via the standard way over ADB:
adb shell pm uninstall com.example.MyApp
(where com.example.MyApp is the package name defined in the manifest).
If you have more than one device connected the command will fail - you can direct it to the only attached emulator via the -e flag, the only attached USB device via the -d flag, or a specific device via its serial number and the -s flag (serial numbers as listed in adb devices).

Categories

Resources