Giter Site home page Giter Site logo

play-with-adb's Introduction

paly with adb

intro

this repo is my notes on testing android (I use op6) with adb...

  • capture traffic with tcpdump & wireshark
  • twitter
    • scroll tweets and visit people's profile
    • send a tweet
  • facebook

setup your env

  • get SDK Platform Tools
  • enable developer mode, then
    • enable use debugging / wireless ADB debugging
    • enable pointer locations (touch data) to get the (x, y) coordinates
  • (optional) root your device if you want to run tcpdump directly on your phone

Basic Operations

tap

To click (tap) at (300, 400): adb shell input touchscreen tap 300 400

scroll

adb shell input swipe <start_x> <start_y> <end_x> <end_y> duration_ms>

swipe the screen to scroll, swipe from start to end and use duration to control the speed, the smaller the duration, the faster you scroll.

  • scroll up: adb shell input swipe 250 400 250 800 100 (==swipe down, swipe from (250, 400) to (250, 800) with duration of 100ms)

  • scroll down: adb shell input swipe 250 800 250 400 100 (==swipe up, swipe from (250, 800) to (250, 400) with duration of 100ms)

text input

you can use input command to input text or keyevents: adb shell input [text|keyevent] (some keyevents are for text input, some are for special operations like turning up the volume, see android doc: KeyEvent Code Ref for more details)

but we can only input ascii texts, so adb shell input text "你好" will fail.

to solve this issue, you can use senzhk's ADBKeyBoard.

use ADBKeyBoard to input texts

  1. grab apk from https://github.com/senzhk/ADBKeyBoard/raw/master/ADBKeyboard.apk, use adb install ADBKeyboard.apk to install it.

  2. enable 'ADBKeyBoard' in the settings

  3. adb shell ime list -a to get available input methods, use adb shell ime set com.android.adbkeyboard/.AdbIME to set current input method to adbkeyboard

  4. send Broadcast intent via adb: adb shell am broadcast -a ADB_INPUT_TEXT --es msg '你好嗎? Hello?' or adb shell am broadcast -a ADB_INPUT_B64 --es msg `echo -n '你好嗎? Hello?' | base64`. or if you still have any problem, try something like this:

    send_text() {
      echo "sending text: $1";
      for ((i=0;i<${#1};i+=50));
      do
          adb shell am broadcast -a ADB_INPUT_B64 --es msg "$(echo -n "${1:$i:50}" | base64)" >> /dev/null;
      done;
    }
    send_text "$(fortune)";

some keyevents code

3 -> KEYCODE_HOME
4 -> KEYCODE_BACK
26 -> KEYCODE_POWER
82 -> KEYCODE_MENU

24 -> KEYCODE_VOLUME_UP
25 -> KEYCODE_VOLUME_DOWN
220 -> KEYCODE_BRIGHTNESS_DOWN
221 -> KEYCODE_BRIGHTNESS_UP

66 -> KEYCODE_ENTER
67 -> KEYCODE_DEL

e.g. adb shell input keyevent 24 will turn up the volume

refs

play-with-adb's People

Contributors

sky-bro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sts0mrg0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.