7
7

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.

serviceコマンドの使い方

Posted at

Androidに含まれるserviceコマンドを使うことで、任意のサービスのBinderに対してメッセージを送ることができる。

使い方

service call <SERVICE NAME> <ID> <ARGS>

利用例

例えばパッケージを強制停止させたい場合、SERVICE NAMEには、ActivityManagerを示すactivityを指定する。

IDはトランザクション番号。android.app.IActivityManagerのソースを参照すると(SDK 10)、

int FORCE_STOP_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+78;

とあり、IBinder.FIRST_CALL_TRANSACTIONの値が1であるため、パッケージの強制停止のトランザクション番号は79となる。

ARGSには型と値の組み合わせを指定する。文字列はs16、整数はi32を指定しその後に値を指定する。com.test.pkgを停止させたい場合は最終的に、

service call activity 79 s16 com.test.pkg

を実行するとよい。

7
7
0

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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?