Android shell 命令總結,androidshell

來源:互聯網
上載者:User

Android shell 命令總結,androidshell
pm

Package Manage

 

pm list packages [FILTER] 查看已安裝的應用程式套件

  -f   顯示關聯的apk檔案

  -s  只在系統應用中搜尋Filter

  -3  只在第三方應用中搜尋Filter

  -d  只在disabled package搜尋Filter

  -e  只在enabled package搜尋Filter

  -i  顯示installer

  -u  uninstalled package

  --user USERID  

 

pm list instrumentation [TARGET-PACKAGE] 顯示所有測試包

  -f  顯示關聯的apk檔案

 

pm list features

pm list permission-groups

pm list permissions [GROUP]

  -g  按組組織

  -f  顯示所有資訊

  -s  顯示簡述

  -d  只顯示危險許可權

  -u  只顯示使用者可見的

pm list users

 

pm uninstall <package>

  -k  保留資料和緩衝

pm clear <package>  清除資料

  --user USERID

pm path <package>  查看某個應用的apk包路徑

pm dump <package>  顯示與包相關的系統狀態資訊

 

pm install PATH

  -l  FORWARD_LOCK

  -r  重新安裝,保留資料

  -t  運行安裝測試apk

  -i  指定安裝包名

  -s  SDCard

  -f  內部儲存空間

  -d  允許版本降級

 

pm get-install-location  返回當前預設安裝位置

  傳回值:

    0  auto

    1  內部儲存

    2  外部儲存

pm set-install-location 0|1|2 修改預設安裝位置,

pm enable|disable|disable-user|disable-until-used|block|unblock  [--user USERID] PACKAGE_OR_COMPONENT

pm grant|revoke  PACKAGE PERMISSION  應用增減許可權(必須在應用中已聲明)

pm create-user USER_NAME

pm remove-user USER_ID

pm get-max-users

pm set-permission-enforced PERMISSION [true|false]

pm trim-caches DESIRED_FREE_SPACE

 

 

am

Activity Manage

通用選項

--user <USER_ID> | current | all  以特定使用者運行

 

am start [options] <INTENT> 啟動Activity

  options:

    -D  偵錯模式

    -W  等待啟動結束

    --start-profilter <FILE> 啟動分析器,結果輸出到檔案

    -P <FILE> 啟動分析器,輸出結果到檔案,應用空閑時停止分析

    -R <COUNT> 反覆啟動Count次,每次重複前,結束最上層Activity

    -S 啟動後強制停止

    --opengl-trace 啟動OpenGL函數記錄

    --user <USER_ID> | current  指定以哪個使用者運行,預設為目前使用者

 

am startservice <INTENT>  啟動服務

am stopservice <INTENT>  停止服務

am force-stop <PACKAGE>   強行停止與包相關的所有東西

am kill <PACKAGE>  殺掉與包相關的進程

am kill-all  殺掉所有後台進程

am broadcast <INTENT>

am instrument [options] <COMPONENT>

  options:

    -r  以原始形式輸出測試結果。該選項通常是在效能測試時與-e perf true一起使用

    -p <FILE> 輸出分析資料到檔案

    -w <TEST_PACKAGE/RUNNER_CLASS> 等到instrumentation結束時才返回

    --no-window-animation

    --user <USER_ID> | current

    -e <testrunner_flag> <value>[,<value>…]

  InstrumentationTestRunner可用flag

package

<full_java_package>

執行某個java包裡的測試

class

<full_class_name>
<full_class_name>#methos_name

執行某個測試類別

func

true

執行所有InstrumentationTestCase

unit

true

執行非InstrumentationTestCase和非PerformanceTestCase的測試類別

size

small|medium|large

運行@SmallTest,@MediumTest,@LargeTest標註的測試

android.test.annotation包裡定義了@LargeTest,@MediumTest,@SmallTest,@Smoke,和@Suppress

perf

true

執行PerformanceTestCase
與-r配合,輸出原始格式輸出

debug

true

偵錯模式執行測試

log

true

 

 

<INTENT> specifications include these flags and arguments:
  [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]    android.intent.action.VIEW content://contacts/people/1  image/png
  [-c <CATEGORY> [-c <CATEGORY>] ...]  android.intent.category.APP_CONTACTS
  [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
  [--esn <EXTRA_KEY> ...]
  [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
  [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
  [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]
  [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]
  [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]
  [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
  [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]
  [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]
  [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]
  [-n <COMPONENT>] [-f <FLAGS>]
  [--grant-read-uri-permission] [--grant-write-uri-permission]
  [--debug-log-resolution] [--exclude-stopped-packages]
  [--include-stopped-packages]
  [--activity-brought-to-front] [--activity-clear-top]
  [--activity-clear-when-task-reset] [--activity-exclude-from-recents]
  [--activity-launched-from-history] [--activity-multiple-task]
  [--activity-no-animation] [--activity-no-history]
  [--activity-no-user-action] [--activity-previous-is-top]
  [--activity-reorder-to-front] [--activity-reset-task-if-needed]
  [--activity-single-top] [--activity-clear-task]
  [--activity-task-on-home]
  [--receiver-registered-only] [--receiver-replace-pending]
  [--selector]
  [<URI> | <PACKAGE> | <COMPONENT>]

 

 

dumpsys 

查詢系統服務,擷取系統運行時狀態資訊

原理:調用ServiceManager服務的listServices來查詢系統註冊的所有服務,並且通過checkService介面來擷取服務的Binder遠程代理對象,使用每個服務的dump函數來列印該服務的相關資訊。

原始碼:  https://android.googlesource.com/platform/frameworks/native/+/master/cmds/dumpsys/dumpsys.cpp

 

dumpsys  不帶任何參數時,列出所有服務,並依次顯示所有服務狀態資訊

dumpsys | grep FILTER

service list  顯示系統服務列表 

dumpsys SERVICE [SERVICE_OPTIONS] 顯示指定服務的狀態資訊

dumpsys SERVICE -h  某些服務可以查看能接受的參數

  例如:

    dumpsys battery

    dumpsys wifi

    dumpsys cpuinfo

    dumpsys meminfo

    dumpsys meminfo com.xracoon.wifisetter

    dumpsys window w(indows) | grep mCurrentFocus

    dumpsys window d(disply) | grep Display

調試測試

dumpstate

dmesg

 

monkey [options] count

screenrecord [options] <file>  android4.4+

screencap -p <file>

 

 

input

input [<source>] <command> [<arg>...]

  source:

    trackball, joystick, touchnavigation, mouse, keyboard, gamepad, touchpad, dpad, stylus, touchscreen

  command和   /預設source:

    text <string>  /touchscreen

    keyevent [--longpress] <key code number or name> ...  /keyboard

    tap <x> <y>    /touchscreen

    swipe <x1> <y1> <x2> <y2>  [duration_ms]  /touchscreen

    press  /trackball

    roll <dx> <dy>  /trackball

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.