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

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

问题描述

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

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

service call notification 1

这将发送短信(不需要 su

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

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

在哪里可以了解有关服务电话的更多信息?我发现了这个问题,并希望将答案细分为一切意味着什么但是我在哪里可以找到有关 notification 2 可能试图调用的方法的信息?

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.

我运行了服务列表为我的设备提供了78种服务,包括 isms notification ,并且对于大多数服务而言,它会打印出一个似乎是名称空间的内容( code> com.android.internal.telephony.ISms for isms android.app.INotificationManager 用于通知 )。我如何使用这些信息来找出我可以使用这些服务中的每一项?

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?

推荐答案

总之


与服务调用命令相关的代码只是函数的参数和
的顺序(该函数在其中发生)

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>


详细信息

我需要了解很多问题,因此,我将在剪贴板服务的帮助下分享解决方案。

首先,您需要了解您感兴趣的服务-

为此,您需要通过键入以下内容来查找特定Android系统中存在的所有服务

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

这是您将得到的-

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

因此,从这里我们可以总结出服务名称是剪贴板服务,包路径是android.content.IClipboard

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

然后,您需要知道IClipboard.aidl的完整路径。

要知道您需要在Google上搜索IClipboard.aidl。

您需要从android.googlesource中查找内容。 com网站上的结果,例如我的情况-

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

所以在+ / android-4.2.2_r1之后是您的路径所在,让该路径为path_of_clipboard.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

l代码取决于android系统,因此您需要知道您的android操作系统名称-
以我为例,它是8.1.0

所以我将转到google放在以下网站代码,然后从页面的左侧选择我的操作系统版本-

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/

对于我来说,它是android- 8.1.0_r50。在此,r50不重要。您可以选择任何版本。现在,我将单击链接,然后,我的网址将如下所示:

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

然后添加path_of_clipboard.aidl ,我的完整网址应为

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

因此第一个方法(即setPrimaryClip)的代码将是1,因为它首先出现最后一个方法,即hasClipboardText将为7,因为它出现在aidl文件中的第七位。其他方法类似。


因此,如果我想调用第七种方法,我将输入

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 

正如您可能已经看到的那样,我并没有放置callingPackage名称,因为它不是必需的

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

如果该方法需要参数,则可以像本示例中所示那样传递它。
让我们假设一个方法的代码在剪贴板中为8,并且看起来像这样-

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)

所以我会这样称呼

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

此处i32代表32位整数和s16为字符串。我们甚至可以将布尔值作为整数传递,如示例中所示。

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

来源

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

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

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

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

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