How to Use Service commands for Android Learning

Source: Internet
Author: User

The Android system not only provides some useful commands for us on the host, but also some hidden commands on the device. Generally, it is called by the system. However, due to permission settings, common processes can also use them through the command line.
For example, I mentioned <dumpsys of Android Performance Testing Tool> and <ADBs of Android debugging tool>

In device, there is a service command to view all the current services, and you can also use it to send some information to some activities.
Service Usage:

root@android:/ # 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.

Currently running service:

root@android:/ # service list                                                  Found 61 services:0sip: [android.net.sip.ISipService]1phone: [com.android.internal.telephony.ITelephony]2iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo]3simphonebook: [com.android.internal.telephony.IIccPhoneBook]4isms: [com.android.internal.telephony.ISms]5nfc: [android.nfc.INfcAdapter]6samplingprofiler: []7diskstats: []8appwidget: [com.android.internal.appwidget.IAppWidgetService]9backup: [android.app.backup.IBackupManager]10uimode: [android.app.IUiModeManager]11usb: [android.hardware.usb.IUsbManager]12audio: [android.media.IAudioService]13wallpaper: [android.app.IWallpaperManager]14dropbox: [com.android.internal.os.IDropBoxManagerService]15search: [android.app.ISearchManager]16country_detector: [android.location.ICountryDetector]17location: [android.location.ILocationManager]18devicestoragemonitor: []19notification: [android.app.INotificationManager]20mount: [IMountService]21throttle: [android.net.IThrottleManager]22connectivity: [android.net.IConnectivityManager]......

Use the service phone to call

root@android:/ # service call phone 2 s16 "123"                              Result: Parcel(00000000    '....')

In this case, the user calls the dial directly :), but note that the emergency number does not work here.

Next, let's take a text message.

root@android:/ # service call isms 4 s16 "12345678" s16 "" s16 "hello world!" s16 "" s16 ""

The following describes the principles.
First, you can find the code frameworks/base/telephony/Java/COM/Android/Internal/telephony/itelephony. aidl and isms. aidl,
These two files are used for integration with OEM manufacturers, and I will not post the code here. The above "2 ", "4" indicates the function.
For example, 2 is

 

    /**     * Place a call to the specified number.     * @param number the number to be called.     */    void call(String number);

 

4 is

 

    /**     * Send an SMS.     *     * @param smsc the SMSC to send the message through, or NULL for the     *  default SMSC     * @param text the body of the message to send     * @param sentIntent if not NULL this <code>PendingIntent</code> is     *  broadcast when the message is sucessfully sent, or failed.     *  The result code will be <code>Activity.RESULT_OK<code> for success,     *  or one of these errors:<br>     *  <code>RESULT_ERROR_GENERIC_FAILURE</code><br>     *  <code>RESULT_ERROR_RADIO_OFF</code><br>     *  <code>RESULT_ERROR_NULL_PDU</code><br>     *  For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include     *  the extra "errorCode" containing a radio technology specific value,     *  generally only useful for troubleshooting.<br>     *  The per-application based SMS control checks sentIntent. If sentIntent     *  is NULL the caller will be checked against all unknown applications,     *  which cause smaller number of SMS to be sent in checking period.     * @param deliveryIntent if not NULL this <code>PendingIntent</code> is     *  broadcast when the message is delivered to the recipient.  The     *  raw pdu of the status report is in the extended data ("pdu").     */    void sendText(in String destAddr, in String scAddr, in String text,            in PendingIntent sentIntent, in PendingIntent deliveryIntent);

Therefore, if you want to send text messages and call in the background, you can directly call Java's runtime exec to call the commands provided by the Service. In this way, you can partially bypass some java services in the framework, directly Interacts with the service implemented by the lower-layer C ++/C :)

Http://blog.csdn.net/melody_lu123/article/details/7401744

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.