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 the <dumpsys of Android performance testing tools> http://www.bkjia.com/kf/201203/125340.html AND THE <adbs of Android debugging tools> http://www.bkjia.com/kf/201203/125341.html
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
[Plain]
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
[Plain]
Root @ android:/# service list
Found 61 services:
0 sip: [android.net. sip. ISipService]
1 phone: [com. android. internal. telephony. ITelephony]
2 iphonesubinfo: [com. android. internal. telephony. IPhoneSubInfo]
3 simphonebook: [com. android. internal. telephony. IIccPhoneBook]
4 isms: [com. android. internal. telephony. ISms]
5 nfc: [android. nfc. INfcAdapter]
6 samplingprofiler: []
7 diskstats: []
8 appwidget: [com. android. internal. appwidget. IAppWidgetService]
9 backup: [android. app. backup. IBackupManager]
10 uimode: [android. app. IUiModeManager]
11 usb: [android. hardware. usb. IUsbManager]
12 audio: [android. media. IAudioService]
13 wallpaper: [android. app. IWallpaperManager]
14 dropbox: [com. android. internal. OS. IDropBoxManagerService]
15 search: [android. app. ISearchManager]
16 country_detector: [android. location. ICountryDetector]
17 location: [android. location. ILocationManager]
18 devicestoragemonitor: []
19 notification: [android. app. INotificationManager]
20 mount: [IMountService]
21 throttle: [android.net. IThrottleManager]
22 connectivity: [android.net. IConnectivityManager]
......
Use the service phone to call
[Plain]
Root @ android:/# service call phone <span style = "color: # FF0000;"> 2 </span> 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.
[Plain]
Root @ android:/# service call isms <span style = "color: # FF0000;"> 4 </span> 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
[Plain]
/**
* Place a call to the specified number.
* @ Param number the number to be called.
*/
Void call (String number );
4 is
[Plain]
/**
* Send an SMS.
*
* @ Param smsc the SMSC to send the message through, or NULL for
* 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.
* 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 :)
From Melody_lu123