39
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

ADB Shell メモ

Androidをadbコマンドから操作するための自分用のメモです。

  • /system のリマウント
mount -o rw,remount /system
  • セキュリティロックの解除
sqlite3 /data/system/locksettings.db "UPDATE locksettings SET value = '1' WHERE name = 'lockscreen.disabled'"
sqlite3 /data/system/locksettings.db "UPDATE locksettings SET value = '0' WHERE name = 'lockscreen.password_type'"
sqlite3 /data/system/locksettings.db "UPDATE locksettings SET value = '0' WHERE name = 'lockscreen.password_type_alternate'"
echo "" > /data/system/password.key
  • Tetheringの設定ページを開く (その他)
am start -n 'com.android.settings/com.android.settings.TetherSettings'
  • Location設定のページを開く (その他)
am start -a android.settings.LOCATION_SOURCE_SETTINGS
  • スクリーンのTurn off
SCREEN_STATUS=`dumpsys power | grep mScreenOn`
if [[ $SCREEN_STATUS == *mScreenOn=true* ]]; then
  echo "Turn off the screen"
  # Turn off the screen
  input keyevent 26
fi

# input keyevent 26 #turn on the screen
  • apkに含まれるActivityの一覧を取得
android-sdk/build-tools/<version>/aapt dump xmltree <apk-file> AndroidManifest.xml
  • タイムゾーンの設定
setprop persist.sys.timezone "America/Los_Angeles"
  • 音量とディスプレイのタイムアウト
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '7' WHERE name = 'volume_music'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '0' WHERE name = 'volume_ring'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '7' WHERE name = 'volume_system'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '7' WHERE name = 'volume_voice'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '0' WHERE name = 'volume_alarm'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '0' WHERE name = 'volume_notification'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '0' WHERE name = 'volume_bluetooth_sco'"
sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE system SET value = '-1' WHERE name = 'screen_off_timeout'"
  • Home画面に戻る
am start com.android.launcher/com.android/launcher2  #デバイスによって異なるので、要調整
  • SystemUIを殺す
# ProcID = 79 # for HONEYCOMB AND OLDER
ProcID = 42 # for ICS AND NEWER
service call activity <ProcID> s16 com.android.systemui
  • SystemUIを復活
am startservice -n com.android.systemui/.SystemUIService
  • スクリーンキャプチャ
screencap -p /sdcard/capture.png
  • 画面のタッチ
input touchscreen tap <x> <y>
  • 画面をスワイプ
input touchscreen swipe <x1> <y1> <x2> <y2>
  • BluetoothのON/OFF
am start -a android.bluetooth.adapter.action.REQUEST_ENABLE
  • Wifiの設定画面を開く
am start -n com.android.settings/.wifi.WifiSettings
  • Wifiの取得
am start -n com.android.settings/.wifi.WifiInfo
  • Wifiのステータス
am start -n com.android.settings/.wifi.WifiStatusTest
  • 言語設定を開く
am start -n com.android.settings/.LanguageSettings
  • 開発者オプションを開く
am start -n com.android.settings/.DevelopmentSettings
  • 日付設定を開く
am start -n com.android.settings/.DateTimeSettingsSetupWizard
input text "Hello"
input keyevent 62  #space
input text "World"
input keyevent 66  #enter
~$ adb shell id
uid=2000(shell) gid=2000(shell)

~$ adb root
restarting adbd as root

~$ adb shell id
uid=0(root) gid=0(root)

~$ adb shell 'setprop service.adb.root 0; setprop ctl.restart adbd'

~$ adb shell id
uid=2000(shell) gid=2000(shell)
adb shell killall b2g
  • adbの認証キー (SSHプライベートキー)
adb shell cat /data/misc/adb/adb_keys
  • タイムゾーンの変更
~$ adb root
restarting adbd as root

~$ adb shell "setprop persist.sys.timezone \"America/Chicago\""
  • プログラムのサービスをスタート
~$ adb shell "am startservice com.some.package.name/.YourServiceSubClassName"
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
39
Help us understand the problem. What are the problem?