31
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ADB Shell メモ

Last updated at Posted at 2015-09-03

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"
31
41
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?