Android: How can I get device hardware information with adb command? - android

I would like to know how to retrieve specific hardware information, for example, from the camera, using an adb command. I would like to know if its possible to retrieve hardware ID or Physical device object name for example, to store these values.

Sdk:
adb shell getprop ro.build.version.sdk
Complete list:
adb shell getprop
Through the package manager:
adb shell pm list features
To retrieve detailed information about the camera
adb shell dumpsys media.camera

adb shell getprop
replace x with the prop. you want

Related

adb command to set voice assistant

I'm working on a voice assistant, and every time the app is deployed on the phone, I need to change again the default assistant to my app. Just a few clicks, but 100 times a day, that's some time gone !!
Something similar exists for setting the default launcher
adb shell cmd package set-home-activity "the.package/.TheLauncherActivity"
So I tried
adb shell cmd package set-assistant "the.package/.TheLauncherActivity"
adb shell cmd package set-voice-assistant "the.package/.TheLauncherActivity"
adb shell cmd package set-assist "the.package/.TheLauncherActivity"
adb shell cmd package set-voice-assist "the.package/.TheLauncherActivity"
It's weird because the assistant itself is more a service than an activity, but anyways, all I got is:
Unknown command: set-voice-assist (and the others)
So I guess I'm not even close.
I'm not sure if you were looking for something like this:
$ adb shell cmd role remove-role-holder --user 10 android.app.role.ASSISTANT com.google.android.carassistant
$ adb shell cmd role add-role-holder --user 10 android.app.role.ASSISTANT CUSTOM.PACKAGE.NAME
Good information about Role managing can be found here:
http://aospxref.com/android-12.0.0_r3/xref/packages/modules/Permission/PermissionController/src/com/android/permissioncontroller/role/Role.md
and list of the roles: http://aospxref.com/android-12.0.0_r3/xref/packages/modules/Permission/framework-s/api/current.txt#8
If your device contains custom build of AOSP and you have the platform key you are able write own app which will change role holders with method RoleManager.addRoleHolderAsUser.

Get chip name of the android device using adb?

Is there an easy way to get the chip name like the MediaTek SoCs (ARMv5 MT1000 ..) of an Android device using adb shell?
I'm trying to run "adb shell cat system/build.prop" but I don't found the chip or SoC name.
Any Help for that!
To get CPU info of a device via adb try,
adb shell cat /proc/cpuinfo
You will get your soc model number from this you can search it on the Qualcomm product list to find SOC name
adb shell cat /proc/cpuinfo | grep hardware
In some cases you will directly get your product name
At least on Samsung S8, I get the SoC name (exynos8895) by running
adb shell getprop ro.hardware ro.hardware.chipname
Also, I get samsungexynos8895 from
adb shell getprop ro.hardware

"setprop ro.product.model" not working

I am using below command to set property, but getting an error. Please help.
Adb shell setprop ro.product.model "Ino5"
setprop: failed to set property 'ro.product.model' to "Ino5"
If you don't have root access, you can't change the value of the props. This applies to (AFAIK) all the props available. If you don't have root, you can't change the value.
However, if you have root, make sure you call su first:
adb shell su
adb shell setprop [prop] [value]
EDIT
Since it still doesn't work, my theory is that it's dependent on the shell instance. So instead, do this:
adb shell
su
setprop [prop] [val]
Doing adb shell creates a local instance where as adb shell [command] executes a single command. The next commands are then done within the ADB shell without the need to call adb shell first.

Get Android OS version of device connected via ADB [duplicate]

This question already has answers here:
Android ADB commands to get the device properties
(4 answers)
Closed 7 years ago.
Can one use adb or adb shell commands to get attached emulator/device OS info, i.e. API version?
To get Android version you can use:
adb shell getprop ro.build.version.release
to get API level:
adb shell getprop ro.build.version.sdk
You can see all available properties with this command:
adb shell getprop
I know , you already got the correct solution , & here is my solution only for additional information.
You will get every details by cat ing the /system/build.prop file like
adb shell cat /system/build.prop
Here is collection of adb commands
For all properties:
adb shell getprop

Change Device language via ADB

I want to change language via ADB.
I try:
adb shell setprop persist.sys.language fr;setprop persist.sys.country CA;stop;sleep 5;start
but I get errors:
setprop: command not found
stop: missing job name
Try `stop --help' for more information.
start: missing job name
Try `start --help' for more information.
what is wrong?
I want to do this on physical device
Your errors have nothing to do with adb. You just lack understanding of how your local shell processes your command. What you are doing is running these commands locally (on your PC):
adb shell setprop persist.sys.language fr
setprop persist.sys.country CA
stop
sleep 5
start
and the error messages you see are from local shell (i.e. there is no setprop executable on your system and start and stop commands have non-optional parameters.
the correct command would be
adb shell "setprop persist.sys.language fr; setprop persist.sys.country CA; setprop ctl.restart zygote"
or in more recent Android versions:
adb shell "setprop persist.sys.locale fr-CA; setprop ctl.restart zygote"
You can change the locale/language for testing purposes without rooting the device, also on newer (4.2+) devices. You have to create an application that changes the device locale. Or, you can use a helper app, e.g. ADB Change Language.
Next, on 4.2+ devices, you have to use grant the app CHANGE_CONFIGURATION permission via adb, adb shell pm grant <package_name> android.permission.CHANGE_CONFIGURATION.
Finally, you can use adb commands (launch activity) to switch locale.
There is few solutions.It works for me.
1.
adb shell am start -a android.settings.LOCALE_SETTINGS
(You could see the language menu, then choose language by appium)
2.
download adbchangelanguage on google store
adb shell pm grant net.sanapeli.adbchangelanguage android.permission.CHANGE_CONFIGURATION
adb shell am start -n net.sanapeli.adbchangelanguage/.AdbChangeLanguage -e language zh -e country TW
https://gist.github.com/douglasselph/b9998e69998759c6cceec1df1aa96ac5
3.
using appium then set desired capabilities (language and locale)
http://appium.io/docs/en/writing-running-appium/caps/
Run through the following steps:
Create emulator with google APIs Intel x86
Root the emulator, by running the command:
adb root
Run the following shell command through adb:
adb -e shell "su root; setprop persist.sys.locale pt-PT; stop; sleep 2; start”
then, exit the shell which restarts the emulator.
Locales we need for screenshots:
de_DE
en_EN
fr_FR
ko_KO
pt_PT
es_ES
ja_JA
This is all over the place, to put it simply
setprop will only work on an AVD or a rooted physical device
The alternative is to use the settings in the Launcher.
Rooted device or AVD this works:
<android-sdk path>/platform-tools/adb shell
root#generic:/ # getprop persist.sys.language
getprop persist.sys.language
en
root#generic:/ # setprop persist.sys.language fr
setprop persist.sys.language fr
root#generic:/ # setprop persist.sys.country CA
setprop persist.sys.country CA
root#generic:/ # stop
stop
root#generic:/ # start
start
root#generic:/ # sleep 5
sleep 5
root#generic:/ # getprop |grep lang
getprop |grep lang
[persist.sys.language]: [fr]
root#generic:/ # getprop |grep country
getprop |grep country
[persist.sys.country]: [CA]
root#generic:/ #
Try this
adb shell "su -c 'setprop persist.sys.language fr; setprop persist.sys.country CA; stop; sleep 5; start'
You need a rooted device.
To set the language to US English, run the following command in the terminal:
adb shell "setprop persist.sys.locale en-US; setprop ctl.restart zygote"
To change to other languages, refer this list of languages:
https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/localization#locale-codes
On Emulator:
When changed language manually, it stopped working and had to do wipe data of Emulator in AVD manager to make it work again.
And the script used:
adb shell "su 0 setprop persist.sys.locale ja";adb shell "su 0 setprop ctl.restart zygote"
May add ;sleep 20 in the end if some commands in script below this command depend on device to be ready.
According to official documents:
To change the locale in the emulator by using the adb shell.
Pick the locale you want to test and determine its BCP-47 language tag, for example, Canadian French would be fr-CA.
Launch an emulator.
From a command-line shell on the host computer, run the following command:
adb shell
or if you have a device attached, specify that you want the emulator by adding the -e option:
adb -e shell
At the adb shell prompt (#), run this command:
setprop persist.sys.locale [BCP-47 language tag];stop;sleep 5;start
Replace bracketed sections with the appropriate codes from Step 1.
For instance, to test in Canadian French:
setprop persist.sys.locale fr-CA;stop;sleep 5;start
This causes the emulator to restart. (It looks like a full reboot, but it isn't.) Once the Home screen appears again, re-launch your app, and the app launches with the new locale.
In case this helps someone: I changed my phone's language to something buggy called en-XA (it was called English one in the UI I believe?) by mistake, and I couldn't even unlock the screen, but I had to fix my language settings somehow. I had no root access, but I had a custom recovery (TWRP) flashed fortunately.
The solution for me was to edit the /data/system/users/0/settings_system.xml file, this line in particular:
<setting id="24885" name="system_locales" value="en-XA,pl-PL" package="android" defaultValue="en-XA,pl-PL" defaultSysSet="true" preserve_in_restore="true" />
I changed the en-XA to en-US, rebooted, and the phone works again!
You can edit the file using your recovery's built-in file editor or use /adb pull /data/system/users/0/settings_system.xml to download and edit the file locally, then adb push settings_system.xml /data/system/users/0/settings_system.xml to update it on the device.
BTW I also changed the en-XA to en-US in the /data/property/persistent_properties file before and it didn't work alone, but perhaps both are needed.
Everything tested on a clean Android 11 device.
For Android M or newer, you need use:
setprop ro.product.locale xx-XX
setprop persist.sys.locale xx-XX
xx is language, XX is country
The solution to do it without rooting.
You can use something like this the below function.
The function goes into settings and exercises the UI to change the locale settings.
https://github.com/dtmilano/AndroidViewClient/blob/480ab93dbd01296a68c1ce7109ceb8275d1ed8a7/src/com/dtmilano/android/viewclient.py#L1302
The tricky part is to get to the right language when you are in a different language. You would think the language always maintain the same index in the list, but unfortunately not. So you have to have a solution like this.
Con: You my have to tweak it a little for handling different phones, the settings may have a different order.
The solution for API 28+ is
adb shell am broadcast -a com.android.intent.action.SET_LOCALE --es com.android.intent.extra.LOCALE "en_US" com.android.customlocale2
You cant do that with the adb on your device. Your adb outside the device, I mean on your computer connected with usb, can change it with passing a permission before changing the language.
On your device directly, you need a rooted device.

Categories

Resources