在哪里可以找到有关 Android 的“服务呼叫"的信息?外壳命令? [英] Where to find info on Android's "service call" shell command?

查看:26
本文介绍了在哪里可以找到有关 Android 的“服务呼叫"的信息?外壳命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设备上使用 adb shell 或终端模拟器,输入此项将清除所有通知(需要 su)

服务呼叫通知1

这将发送一条短信(不需要su)

service callisms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText"

在哪里可以了解有关服务调用的更多信息?我找到了这个问题 并感谢答案的细分为一切的意义.但是我在哪里可以找到关于 notification 2 可能试图调用什么方法的信息?

Running service call 不完整并打印了这个用法:

用法:service [-h|-?]服务清单服务检查 SERVICE服务呼叫服务代码 [i32 INT |s16 STR] ...选项:i32:将整数INT写入发送包裹中.s16:将 UTF-16 字符串 STR 写入发送包裹中.

我运行了 service list 并且它为我的设备返回了 78 个服务,包括 ismsnotification 并且对于大多数服务将打印似乎成为一个命名空间(com.android.internal.telephony.ISms 用于 ismsandroid.app.INotificationManager 用于 notification).我如何使用这些信息来了解我可以使用这些服务中的每一个做什么?

解决方案

简而言之

<块引用>

与服务调用命令相关的代码只是函数的参数和命令在该函数出现在该服务的aidl文件中.这是一个语法

服务呼叫<函数出现在 your_service_name.aidl 中的数量><参数的类型,如 i32 或 i64><参数>

详细
我遇到了很多问题需要了解它,因此我将在剪贴板服务的帮助下分享解决方案.
首先您需要了解您感兴趣的服务-
为此,您需要通过键入

来查找特定 android 系统的所有服务

adb shell 服务列表

这是你会得到的 -

<预><代码>...59 以太网:[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 叠加:[android.content.om.IOverlayManager]65 网络策略:[android.net.INetworkPolicyManager]66 网络统计:[android.net.INetworkStatsService]67 network_score: [android.net.INetworkScoreService]68个文本服务:[com.android.internal.textservice.ITextServicesManager]69 network_management: [android.os.INetworkManagementService]70 剪贴板:[android.content.IClipboard]71 状态栏:[com.android.internal.statusbar.IStatusBarService]...

因为我对剪贴板服务感兴趣,所以它的外观是这样的

70 剪贴板:[android.content.IClipboard]

所以从这里我们可以总结出服务名称是clipboard service,包路径是android.content.IClipboard

然后你需要知道IClipboard.aidl所在的完整路径.
要知道您需要在谷歌上搜索 IClipboard.aidl.
您需要在结果中从 android.googlesource.com 网站查找某些内容,例如我的情况-

https://android.googlesource.com/platform/frameworks/base.git/+/android-4.2.2_r1/core/java/android/content/IClipboard.aidl

所以在 +/android-4.2.2_r1 之后就是你的路径所在.让这条路径成为 path_of_clipboard.aidl=

/core/java/android/content/IClipboard.aidl

由于这些服务调用代码依赖于 android 系统,因此您需要知道您的 android 操作系统名称-就我而言,它是 8.1.0
所以我会去下面的网站,在那里谷歌把代码放在那里,然后从页面的左侧选择我的操作系统版本 -

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

然后在添加 path_of_clipboard.aidl 之后,我的完整 url 将如下所示

https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r51/core/java/android/content/IClipboard.aidl

这里的接口会有很多方法.就像我的情况

 void setPrimaryClip(在 ClipData 剪辑中,String callPackage);ClipData getPrimaryClip(String pkg);ClipDescription getPrimaryClipDescription(字符串调用包);boolean hasPrimaryClip(字符串调用包);void addPrimaryClipChangedListener(在 IOnPrimaryClipChangedListener 监听器中,字符串调用包);void removePrimaryClipChangedListener(在 IOnPrimaryClipChangedListener 监听器中);/*** 如果剪贴板包含文本,则返回 true;否则为假.*/boolean hasClipboardText(String callPackage);

因此,第一个方法(即 setPrimaryClip)的代码将是 1,因为它出现在第一个位置,而最后一个方法(即 hasClipboardText)的代码将是 7,因为它出现在 aidl 文件中的第七位.其他方法类似.
所以如果我想调用第七个方法,我会输入

adb shell 服务调用剪贴板 7

您可能已经看到,我没有输入调用包名称,因为它不是必需的.

如果该方法需要参数,那么您可以像本示例中所示那样传递它.
让我们假设一个方法,其剪贴板中的代码为 8,如下所示 -

getDemo(String arg1, int arg2, boolean arg3)

所以我会这样称呼它

adb shell 调用剪贴板 8 s16 "first_argument" i32 12 i32 1

这里 i32 代表 32 位整数,s16 代表字符串.我们甚至可以将布尔值作为整数传递,如示例所示.
在布尔整数中,1 代表真,0 代表假.
来源

提示 保持 logcat 打开(如在 android studio 中)以检查执行该 adb 命令时发生的任何错误.

Using adb shell or a terminal emulator on the device, entering this will clear all notifications (requires su)

service call notification 1

This will send an sms (doesn't require su)

service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText"

Where can I learn more about service call? I've found this question and appreciate the answer's breakdown as to what everything means. But where can I find info on what method notification 2 might be trying to call?

Running service call was incomplete and printed this usage:

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.

I ran service list and it came back with 78 services for my device including isms and notification and for most services will print what seems to be a namespace (com.android.internal.telephony.ISms for isms and android.app.INotificationManager for notification). How can I use this information to find out what I can do with each of these services?

解决方案

In Short

Code related to service call command are just the arguments of the function and order at which the function occur in the aidl file of that service.Here is a syntax

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>

In Detail
I faced a lot of problems to know about it and hence I will share the solution with the help of clipboard service.
First you need to know about the service you are interested in -
For that you need to look for all the service that is there for particular android system by typing

adb shell service list

Here is what you will get -

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

As I am interested in clipboard service, here is how it look

70  clipboard: [android.content.IClipboard]

So from here we can summarise that the service name is clipboard service and the package path is android.content.IClipboard

Then you need to know the complete path where the IClipboard.aidl is.
To know that you need to search on google for IClipboard.aidl.
You need to look for something from android.googlesource.com website in the results, like in my case-

https://android.googlesource.com/platform/frameworks/base.git/+/android-4.2.2_r1/core/java/android/content/IClipboard.aidl

So after +/android-4.2.2_r1 is where your path lies.Let that path be path_of_clipboard.aidl=

/core/java/android/content/IClipboard.aidl

As these service call codes are dependent on the android system, hence you need to know your android os name- In my case it is 8.1.0
So I will go to the following website where google puts there code and select my os version from the left hand side for the page -

https://android.googlesource.com/platform/frameworks/base/

In my case it is android-8.1.0_r50. Here r50 is not important. You can choose any revision. Now I will click on the link and then after that my url will look like this

https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r51

And then after adding path_of_clipboard.aidl, my complete url will look like

https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r51/core/java/android/content/IClipboard.aidl

Here there will be many methods in the interface.Like in my case

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

So the code for the first method i.e. setPrimaryClip will be 1 as it occured at first place and that for the last method i.e hasClipboardText will be 7 as it occured at seventh place in the aidl file. Similarly for the other methods.
So if I want to call the seventh method I will type

adb shell service call clipboard 7 

As you might have seen that I have not put the callingPackage name as it is not required.

If the method need arguments, then you can pass it like as show in this example.
Let us assume a method whose code is 8 in clipboard and that looks like this -

getDemo(String arg1, int arg2, boolean arg3)

So I will call it like this

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

Here i32 stands for 32 bit integer and s16 for the string. We can, even pass boolean value as an integer as shown in the example.
In boolean integer 1 stands for true and 0 for false.
Source

TIP Keep the logcat open(like in android studio) to check for any error that occured while executing that adb command.

这篇关于在哪里可以找到有关 Android 的“服务呼叫"的信息?外壳命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆