Cor*_*urn 21 shell service android adb
adb shell在设备上使用或终端仿真器,输入此将清除所有通知(要求su)
service call notification 1
Run Code Online (Sandbox Code Playgroud)
这将发送短信(不需要su)
service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText"
Run Code Online (Sandbox Code Playgroud)
我在哪里可以了解更多信息service call?我发现了这个问题,并理解答案是关于一切意味着什么.但是我在哪里可以找到notification 2可能试图调用的方法的信息?
运行service call不完整并打印此用法:
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.
Run Code Online (Sandbox Code Playgroud)
我跑了service list,它为我的设备提供了78个服务,包括isms和,notification并且对于大多数服务将打印似乎是命名空间(com.android.internal.telephony.ISmsfor isms和android.app.INotificationManagerfor notification).我如何使用这些信息来了解我可以对这些服务做些什么?
Ale*_* P. 11
这是我关于从ADB shell调用Android服务的帖子.它包含一个小的bash脚本,我用它自动为我的特定设备下载适当版本的服务源代码,然后解析它以找出所有方法的事务代码.
小智 7
我在这里的第一个答案,所以我希望对你有用.
为了解释这个小谜题让我使用android 4.3.1.在您的情况下,此链接可能是必不可少的 向下滚动java代码到第669行.等待你的TRANSACTION块与com.android.internal.telephony.ISms服务严格相关,可能是你的答案,你可以做更多.
在您的情况下,您正在调用TRANSACTION_sendText.解释在第673行,您可以找到
static final int TRANSACTION_sendText = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
Run Code Online (Sandbox Code Playgroud)
代码的最后部分由数字"4"组成.每个TRANSACTION号码+ 1 =正确的号码.这就是为什么service call isms 5要负责sendText而不是负责sendMultipartText.
同样的规则适用于所有服务.
我相信你现在可以找到如何检查TRANSACTIONs的通知服务.好开心.
简而言之
与服务调用命令相关的代码只是该函数的参数和该函数在该服务的辅助文件中出现的顺序。这里是一种语法
Run Code Online (Sandbox Code Playgroud)service call <your_service_name> <number at which the function appears in your_service_name.aidl> <type of the argument like i32 or i64> <argument>
详细地说,
我面临许多有关此问题的知识,因此,我将在剪贴板服务的帮助下共享该解决方案。
首先,您需要了解您感兴趣的服务-
为此,您需要通过键入以下内容来查找特定的android系统存在的所有服务
adb shell service list
Run Code Online (Sandbox Code Playgroud)
这是您将得到的-
.
.
.
59 ethernet: [android.net.IEthernetManager]
60 wifip2p: [android.net.wifi.p2p.IWifiP2pManager]
61 rttmanager: [android.net.wifi.IRttManager]
62 wifiscanner: [android.net.wifi.IWifiScanner]
63 wifi: [android.net.wifi.IWifiManager]
64 overlay: [android.content.om.IOverlayManager]
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]
.
.
.
Run Code Online (Sandbox Code Playgroud)
因为我对剪贴板服务感兴趣,所以它是这样的
70 clipboard: [android.content.IClipboard]
Run Code Online (Sandbox Code Playgroud)
所以从这里我们可以总结出服务名称是剪贴板服务,包路径是android.content.IClipboard
然后,您需要知道IClipboard.aidl所在的完整路径。
要知道您需要在Google上搜索IClipboard.aidl。
您需要在结果中从android.googlesource.com网站中查找某些内容,例如在我的情况下,
https://android.googlesource.com/platform/frameworks/base.git/+/android-4.2.2_r1/core/java/android/content/IClipboard.aidl
Run Code Online (Sandbox Code Playgroud)
所以在+ / android-4.2.2_r1之后是您的路径所在,让该路径为path_of_clipboard.aidl =
/core/java/android/content/IClipboard.aidl
Run Code Online (Sandbox Code Playgroud)
由于这些服务呼叫代码取决于android系统,因此您需要知道您的android操作系统名称-在我的情况下为8.1.0,
所以我将转到以下网站,其中google将代码放在该网站上,然后从页面的左侧-
https://android.googlesource.com/platform/frameworks/base/
就我而言,它是android-8.1.0_r50。在此,r50不重要。您可以选择任何修订。现在,我将单击链接,然后,我的网址将如下所示
https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r51
Run Code Online (Sandbox Code Playgroud)
然后在添加path_of_clipboard.aidl之后,我的完整网址将如下所示
https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r51/core/java/android/content/IClipboard.aidl
Run Code Online (Sandbox Code Playgroud)
界面中会有很多方法,就我而言
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);
/**
* Returns true if the clipboard contains text; false otherwise.
*/
boolean hasClipboardText(String callingPackage);
Run Code Online (Sandbox Code Playgroud)
因此,第一个方法(即setPrimaryClip)的代码将在第一个位置出现,因此它的代码将为1,而最后一个方法(即hasClipboardText)的代码将在第7个文件中位于第七位的代码出现。其他方法类似。
因此,如果我想调用第七种方法,我将输入
adb shell service call clipboard 7
Run Code Online (Sandbox Code Playgroud)
正如您可能已经看到的那样,我并没有放置callingPackage名称,因为它不是必需的。
如果该方法需要参数,则可以像本示例中所示那样传递它。
让我们假设一个在剪贴板中代码为8的方法看起来像这样-
getDemo(String arg1, int arg2, boolean arg3)
Run Code Online (Sandbox Code Playgroud)
所以我会这样称呼它
adb shell call clipboard 8 s16 "first_argument" i32 12 i32 1
Run Code Online (Sandbox Code Playgroud)
i32代表32位整数,s16代表字符串。如示例所示,我们甚至可以将布尔值作为整数传递。
在布尔整数中,1代表true,0代表false。
资源
提示保持logcat打开(例如在android studio中)以检查执行该adb命令时发生的任何错误。
| 归档时间: |
|
| 查看次数: |
21524 次 |
| 最近记录: |