美文网首页
ADB 命令

ADB 命令

作者: zsg555666 | 来源:发表于2018-11-30 12:23 被阅读0次

    1、查看MAC地址:adb shell cat /sys/class/net/wlan0/address
    2、CPU信息:adb shell cat /proc/cpuinfo
    3、查看wifi密码:adb shell cat /data/misc/wifi/*.conf
    4、通过wifi连接adb: adb connect 172.27.96.5:5555

    5、恢复出厂设置:adb shell am broadcast -a android.intent.action.MASTER_CLEAR
    需要先adb root
    android 8.0版本后改为:adb shell am broadcast -a android.intent.action.FACTORY_RESET android

    adb源码分析: https://blog.csdn.net/viewsky11/article/details/53889143

    6、关机: adb shell reboot -p

    7、端口转发:adb forward tcp:1150 tcp:1160


    image.png

    8、adb授权过程:

    • 执行adb shell后,adb.exe会将当前PC的公钥(或者公钥的hash值之类的fingerprint)发送给android设备,公钥保存在~/.android/目录中的adbkey与adbkey.pub
    • 如果android已经保存了PC的公钥,则能成功匹配,进行认证,建立adb连接
    • 如果android没有保存PC的公钥,则弹出提示框提示是否允许这台机器进行adb连接,当点击了允许授权之后,android就会保存这台PC的adbkey.pub公钥,目录为/data/misc/adb/adb_keys

    9、通过包名查看apk文件的位置:adb shell pm path com.zsg.launcher
    输出:package:/system/app/Launcher.apk

    10、状态栏、导航栏控制

    • 全隐藏:adb shell settings put global policy_control immersive.full=*
    • 隐藏状态栏:adb shell settings put global policy_control immersive.status=*
    • 隐藏导航栏:adb shell settings put global policy_control immersive.navigation=*
    • 单独控制app不隐藏,设置com.zsg.test不隐藏,其他程序隐藏:
      adb shell settings put global policy_control immersive.full=apps,-com.zsg.test
    • 恢复正常模式:adb shell settings put global policy_control null

    11、获取当前设备支持的features。Get Android System Available Features

    adb shell pm list features:
    
    feature:android.hardware.nfc
    feature:android.hardware.nfc.any
    feature:android.hardware.nfc.hce
    feature:android.hardware.nfc.hcef
    feature:android.hardware.bluetooth_le
    feature:android.hardware.camera
    feature:android.hardware.camera.any
    feature:android.hardware.camera.front
    feature:android.hardware.faketouch
    feature:android.hardware.location
    feature:android.hardware.location.network
    feature:android.hardware.microphone
    feature:android.hardware.sensor.light
    feature:android.hardware.sensor.proximity
    feature:android.hardware.sensor.stepcounter
    feature:android.hardware.sensor.stepdetector
    feature:android.hardware.touchscreen
    feature:android.hardware.usb.accessory
    feature:android.hardware.usb.host
    feature:android.hardware.wifi
    feature:android.hardware.wifi.direct
    feature:android.software.activities_on_secondary_displays
    feature:android.software.adoptable_storage
    feature:android.software.app_widgets
    feature:android.software.autofill
    feature:android.software.backup
    feature:android.software.cts
    feature:android.software.device_id_attestation
    feature:android.software.webview
    
    //使用系统接口获取:
    FeatureInfo[] features = getPackageManager().getSystemAvailableFeatures();
    
    boolean b = getPackageManager().hasSystemFeature(featureName)
    boolean hasCamera = pm.hsaSystemFeature(PackageManager.FEATURE_CAMERA); //是否支持相机
    boolean b = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
    

    相关文章

      网友评论

          本文标题:ADB 命令

          本文链接:https://www.haomeiwen.com/subject/tszccqtx.html