获取设备属性的 Android ADB 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21099301/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android ADB commands to get the device properties
提问by Venkatesh
I am trying to get the device properties from ADB commands. I can how ever get those values by running sample android application. How ever I wish to get using adb shell command itself to make my life easier. Here is the way I will get through sample application but I want corresponding adb commands for
我正在尝试从 ADB 命令获取设备属性。我如何通过运行示例 android 应用程序来获取这些值。我多么希望使用 adb shell 命令本身来让我的生活更轻松。这是我将通过示例应用程序的方式,但我想要相应的 adb 命令
- device manufacturer
- device hardware
- device model
- Os version(integer value)
- Kernel version
- 设备制造商
- 设备硬件
- 设备型号
- 操作系统版本(整数值)
- 内核版本
* Please note my device is not rooted and I have no idea of rooting the device to get these values :-) *
*请注意我的设备没有root,我不知道root设备来获取这些值:-)*
## Code snippet
import android.os.Build;
manufacturer = Build.MANUFACTURER;
hardware = Build.HARDWARE;
model = Build.MODEL;
oSVersion = Build.VERSION.SDK_INT;
kernelVersion = System.getProperty("os.version");
However I can able to get the os version. But then I want SDK version in integer. I want 18 in place of 4.2.2
但是我可以获得 os 版本。但后来我想要整数的 SDK 版本。我想要 18 代替 4.2.2
C:\>adb shell getprop ro.build.version.release
4.2.2
回答by dmarin
adb shell getprop ro.build.version.sdk
If you want to see the whole list of parameters just type:
如果您想查看整个参数列表,只需键入:
adb shell getprop
回答by 0x8BADF00D
From Linux Terminal:
从 Linux 终端:
adb shell getprop | grep "model\|version.sdk\|manufacturer\|hardware\|platform\|revision\|serialno\|product.name\|brand"
From Windows PowerShell:
从 Windows PowerShell:
adb shell
getprop | grep -e 'model' -e 'version.sdk' -e 'manufacturer' -e 'hardware' -e 'platform' -e 'revision' -e 'serialno' -e 'product.name' -e 'brand'
Sample output for Samsung:
三星的示例输出:
[gsm.version.baseband]: [G900VVRU2BOE1]
[gsm.version.ril-impl]: [Samsung RIL v3.0]
[net.knoxscep.version]: [2.0.1]
[net.knoxsso.version]: [2.1.1]
[net.knoxvpn.version]: [2.2.0]
[persist.service.bdroid.version]: [4.1]
[ro.board.platform]: [msm8974]
[ro.boot.hardware]: [qcom]
[ro.boot.serialno]: [xxxxxx]
[ro.build.version.all_codenames]: [REL]
[ro.build.version.codename]: [REL]
[ro.build.version.incremental]: [G900VVRU2BOE1]
[ro.build.version.release]: [5.0]
[ro.build.version.sdk]: [21]
[ro.build.version.sdl]: [2101]
[ro.com.google.gmsversion]: [5.0_r2]
[ro.config.timaversion]: [3.0]
[ro.hardware]: [qcom]
[ro.opengles.version]: [196108]
[ro.product.brand]: [Verizon]
[ro.product.manufacturer]: [samsung]
[ro.product.model]: [SM-G900V]
[ro.product.name]: [kltevzw]
[ro.revision]: [14]
[ro.serialno]: [e5ce97c7]
回答by avivamg
You should use adb shell getprop
command and grep
specific info about your current device, For additional information you can read documentation:
Android Debug Bridge documentation
您应该使用有关当前设备的adb shell getprop
命令和grep
特定信息,有关其他信息,您可以阅读文档:
Android Debug Bridge 文档
I added some examples below:
我在下面添加了一些示例:
- language -
adb shell getprop | grep language
- 语 -
adb shell getprop | grep language
[persist.sys.language]: [en]
[ro.product.locale.language]: [en]
[persist.sys.language]: [en]
[ro.product.locale.language]: [en]
- boot complete ( device ready after reset) -
adb shell getprop | grep boot_completed
- 启动完成(重置后设备准备就绪)-
adb shell getprop | grep boot_completed
[sys.boot_completed]: 1
[sys.boot_completed]: 1
- device model -
adb shell getprop | grep model
- 设备型号 -
adb shell getprop | grep model
[ro.product.model]: [Nexus 4]
[ro.product.model]:[Nexus 4]
- sdk version -
adb shell getprop | grep sdk
- sdk 版本 -
adb shell getprop | grep sdk
[ro.build.version.sdk]: [22]
[ro.build.version.sdk]:[22]
- time zone -
adb shell getprop | grep timezone
- 时区 -
adb shell getprop | grep timezone
[persist.sys.timezone]: [Asia/China]
[persist.sys.timezone]:[亚洲/中国]
- serial number -
adb shell getprop | grep serialno
- 序列号 -
adb shell getprop | grep serialno
[ro.boot.serialno]: [1234567]
[ro.boot.serialno]:[1234567]
回答by P Satish Patro
For Power-Shell
对于 Power-Shell
./adb shell getprop | Select-String -Pattern '(model)|(version.sdk)|(manufacturer)|(platform)|(serialno)|(product.name)|(brand)'
For linux(burrowing asnwer from @0x8BADF00D)
对于 linux(从@0x8BADF00D 挖掘答案)
adb shell getprop | grep "model\|version.sdk\|manufacturer\|hardware\|platform\|revision\|serialno\|product.name\|brand"
For single string find in power shell
对于在 power shell 中查找的单个字符串
./adb shell getprop | Select-String -Pattern 'model'
or
或者
./adb shell getprop | Select-String -Pattern '(model)'
For multiple
对于多个
./adb shell getprop | Select-String -Pattern '(a|b|c|d)'