博客
关于我
adb命令之service call
阅读量:658 次
发布时间:2019-03-15

本文共 2570 字,大约阅读时间需要 8 分钟。

最近对service call指令参数比较疑惑,特此搜集了一下资料,解释并记录如下:

需要特别说明的是android版本不同,其CODE值可能不同

原文网址:

service 说明如下:

Usage: service [-h|-?]       service list       service check SERVICE       service call SERVICE CODE [i32 INT | s16 STR] ...Options:   i32: Write the integer INT into the send parcel.   s16: Write the UTF-16 string STR into the send parcel.

整个调用如下:

service call 

1.首先需要查询自己需要调用的系统服务:

adb shell service list

查询结果如下:

...64      wifip2p: [android.net.wifi.p2p.IWifiP2pManager]65      netpolicy: [android.net.INetworkPolicyManager]66      netstats: [android.net.INetworkStatsService]67      network_score: [android.net.INetworkScoreService]68      textservices: [com.android.internal.textservice.ITextServicesManager]69      network_management: [android.os.INetworkManagementService]70      clipboard: [android.content.IClipboard]71      statusbar: [com.android.internal.statusbar.IStatusBarService]72      device_policy: [android.app.admin.IDevicePolicyManager]73      deviceidle: [android.os.IDeviceIdleController]74      persistent_data_block: [android.service.persistentdata.IPersistentDataBlockService]75      lock_settings: [com.android.internal.widget.ILockSettings]76      uimode: [android.app.IUiModeManager]77      mount: [IMountService]78      accessibility: [android.view.accessibility.IAccessibilityManager]79      input_method: [com.android.internal.view.IInputMethodManager]...

2.在此使用clipboard服务(方便查看及调用)

clipboard: [android.content.IClipboard]

3.源码查询:

android/content/IClipboard.aidl

 

此处使用android 8.1源码,完整路径为:

https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r51/core/java/android/content/IClipboard.aidl
void setPrimaryClip(in ClipData clip, String callingPackage);    ClipData getPrimaryClip(String pkg);    ClipDescription getPrimaryClipDescription(String callingPackage);    boolean hasPrimaryClip(String callingPackage);    void addPrimaryClipChangedListener(in IOnPrimaryClipChangedListener listener,            String callingPackage);    void removePrimaryClipChangedListener(in IOnPrimaryClipChangedListener listener);    boolean hasClipboardText(String callingPackage);

 

因此,第一个方法的代码即setPrimaryClip将在第一个位置出现,而对于最后一个方法,即hasClipboardText,它将是7,因为它出现在aidl文件的第七位。与其他方法类似。 

所以,如果我想调用第七种方法,我会输入

adb shell service call clipboard 7

可能已经看到我没有放入callingPackage名称,因为它不是必需的。

如果方法需要参数,那么您可以像本示例中那样传递它。

让我们假设一个方法,其代码在剪贴板中为8,看起来像这样 -

getDemo(String arg1, int arg2, boolean arg3)

所以我可以这样调用它

adb shell call clipboard 8 s16 "first_argument" i32 12 i32 1

这里i32代表整数,s16代表字符串。我们甚至可以将布尔值作为整数传递,如示例所示。

在布尔整数中,1代表true,0代表false。

转载地址:http://ypxmz.baihongyu.com/

你可能感兴趣的文章
Mysql8.0注意url变更写法
查看>>
Mysql8.0的特性
查看>>
MySQL8修改密码报错ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
查看>>
MySQL8修改密码的方法
查看>>
Mysql8在Centos上安装后忘记root密码如何重新设置
查看>>
Mysql8在Windows上离线安装时忘记root密码
查看>>
MySQL8找不到my.ini配置文件以及报sql_mode=only_full_group_by解决方案
查看>>
mysql8的安装与卸载
查看>>
MySQL8,体验不一样的安装方式!
查看>>
MySQL: Host '127.0.0.1' is not allowed to connect to this MySQL server
查看>>
Mysql: 对换(替换)两条记录的同一个字段值
查看>>
mysql:Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘解决方法
查看>>
MYSQL:基础——3N范式的表结构设计
查看>>
MYSQL:基础——触发器
查看>>
Mysql:连接报错“closing inbound before receiving peer‘s close_notify”
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 参数--lock-tables浅析
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump 导出数据库中每张表的前n条
查看>>
mysqldump: Got error: 1044: Access denied for user ‘xx’@’xx’ to database ‘xx’ when using LOCK TABLES
查看>>