1/*
2** Copyright 2007, The Android Open Source Project
3**
4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at
7**
8**     http://www.apache.org/licenses/LICENSE-2.0
9**
10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and
14** limitations under the License.
15*/
16
17package com.android.internal.telephony;
18
19import android.app.PendingIntent;
20import com.android.internal.telephony.SmsRawData;
21
22/** Interface for applications to access the ICC phone book.
23 *
24 * <p>The following code snippet demonstrates a static method to
25 * retrieve the ISms interface from Android:</p>
26 * <pre>private static ISms getSmsInterface()
27            throws DeadObjectException {
28    IServiceManager sm = ServiceManagerNative.getDefault();
29    ISms ss;
30    ss = ISms.Stub.asInterface(sm.getService("isms"));
31    return ss;
32}
33 * </pre>
34 */
35
36interface ISms {
37    /**
38     * Retrieves all messages currently stored on ICC.
39     *
40     * @return list of SmsRawData of all sms on ICC
41     */
42     List<SmsRawData> getAllMessagesFromIccEf();
43
44    /**
45     * Update the specified message on the ICC.
46     *
47     * @param messageIndex record index of message to update
48     * @param newStatus new message status (STATUS_ON_ICC_READ,
49     *                  STATUS_ON_ICC_UNREAD, STATUS_ON_ICC_SENT,
50     *                  STATUS_ON_ICC_UNSENT, STATUS_ON_ICC_FREE)
51     * @param pdu the raw PDU to store
52     * @return success or not
53     *
54     */
55     boolean updateMessageOnIccEf(int messageIndex, int newStatus,
56            in byte[] pdu);
57
58    /**
59     * Copy a raw SMS PDU to the ICC.
60     *
61     * @param pdu the raw PDU to store
62     * @param status message status (STATUS_ON_ICC_READ, STATUS_ON_ICC_UNREAD,
63     *               STATUS_ON_ICC_SENT, STATUS_ON_ICC_UNSENT)
64     * @return success or not
65     *
66     */
67    boolean copyMessageToIccEf(int status, in byte[] pdu, in byte[] smsc);
68
69    /**
70     * Send a data SMS.
71     *
72     * @param smsc the SMSC to send the message through, or NULL for the
73     *  default SMSC
74     * @param data the body of the message to send
75     * @param sentIntent if not NULL this <code>PendingIntent</code> is
76     *  broadcast when the message is sucessfully sent, or failed.
77     *  The result code will be <code>Activity.RESULT_OK<code> for success,
78     *  or one of these errors:<br>
79     *  <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
80     *  <code>RESULT_ERROR_RADIO_OFF</code><br>
81     *  <code>RESULT_ERROR_NULL_PDU</code><br>
82     *  For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
83     *  the extra "errorCode" containing a radio technology specific value,
84     *  generally only useful for troubleshooting.<br>
85     *  The per-application based SMS control checks sentIntent. If sentIntent
86     *  is NULL the caller will be checked against all unknown applicaitons,
87     *  which cause smaller number of SMS to be sent in checking period.
88     * @param deliveryIntent if not NULL this <code>PendingIntent</code> is
89     *  broadcast when the message is delivered to the recipient.  The
90     *  raw pdu of the status report is in the extended data ("pdu").
91     */
92    void sendData(in String destAddr, in String scAddr, in int destPort,
93            in byte[] data, in PendingIntent sentIntent, in PendingIntent deliveryIntent);
94
95    /**
96     * Send an SMS.
97     *
98     * @param smsc the SMSC to send the message through, or NULL for the
99     *  default SMSC
100     * @param text the body of the message to send
101     * @param sentIntent if not NULL this <code>PendingIntent</code> is
102     *  broadcast when the message is sucessfully sent, or failed.
103     *  The result code will be <code>Activity.RESULT_OK<code> for success,
104     *  or one of these errors:<br>
105     *  <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
106     *  <code>RESULT_ERROR_RADIO_OFF</code><br>
107     *  <code>RESULT_ERROR_NULL_PDU</code><br>
108     *  For <code>RESULT_ERROR_GENERIC_FAILURE</code> the sentIntent may include
109     *  the extra "errorCode" containing a radio technology specific value,
110     *  generally only useful for troubleshooting.<br>
111     *  The per-application based SMS control checks sentIntent. If sentIntent
112     *  is NULL the caller will be checked against all unknown applications,
113     *  which cause smaller number of SMS to be sent in checking period.
114     * @param deliveryIntent if not NULL this <code>PendingIntent</code> is
115     *  broadcast when the message is delivered to the recipient.  The
116     *  raw pdu of the status report is in the extended data ("pdu").
117     */
118    void sendText(in String destAddr, in String scAddr, in String text,
119            in PendingIntent sentIntent, in PendingIntent deliveryIntent);
120
121    /**
122     * Send a multi-part text based SMS.
123     *
124     * @param destinationAddress the address to send the message to
125     * @param scAddress is the service center address or null to use
126     *   the current default SMSC
127     * @param parts an <code>ArrayList</code> of strings that, in order,
128     *   comprise the original message
129     * @param sentIntents if not null, an <code>ArrayList</code> of
130     *   <code>PendingIntent</code>s (one for each message part) that is
131     *   broadcast when the corresponding message part has been sent.
132     *   The result code will be <code>Activity.RESULT_OK<code> for success,
133     *   or one of these errors:
134     *   <code>RESULT_ERROR_GENERIC_FAILURE</code>
135     *   <code>RESULT_ERROR_RADIO_OFF</code>
136     *   <code>RESULT_ERROR_NULL_PDU</code>.
137     * @param deliveryIntents if not null, an <code>ArrayList</code> of
138     *   <code>PendingIntent</code>s (one for each message part) that is
139     *   broadcast when the corresponding message part has been delivered
140     *   to the recipient.  The raw pdu of the status report is in the
141     *   extended data ("pdu").
142     */
143    void sendMultipartText(in String destinationAddress, in String scAddress,
144            in List<String> parts, in List<PendingIntent> sentIntents,
145            in List<PendingIntent> deliveryIntents);
146
147    /**
148     * Enable reception of cell broadcast (SMS-CB) messages with the given
149     * message identifier. Note that if two different clients enable the same
150     * message identifier, they must both disable it for the device to stop
151     * receiving those messages.
152     *
153     * @param messageIdentifier Message identifier as specified in TS 23.041
154     * @return true if successful, false otherwise
155     *
156     * @see #disableCellBroadcast(int)
157     */
158    boolean enableCellBroadcast(int messageIdentifier);
159
160    /**
161     * Disable reception of cell broadcast (SMS-CB) messages with the given
162     * message identifier. Note that if two different clients enable the same
163     * message identifier, they must both disable it for the device to stop
164     * receiving those messages.
165     *
166     * @param messageIdentifier Message identifier as specified in TS 23.041
167     * @return true if successful, false otherwise
168     *
169     * @see #enableCellBroadcast(int)
170     */
171    boolean disableCellBroadcast(int messageIdentifier);
172
173    /**
174     * Enable reception of cell broadcast (SMS-CB) messages with the given
175     * message identifier range. Note that if two different clients enable
176     * a message identifier range, they must both disable it for the device
177     * to stop receiving those messages.
178     *
179     * @param startMessageId first message identifier as specified in TS 23.041
180     * @param endMessageId last message identifier as specified in TS 23.041
181     * @return true if successful, false otherwise
182     *
183     * @see #disableCellBroadcastRange(int, int)
184     */
185    boolean enableCellBroadcastRange(int startMessageId, int endMessageId);
186
187    /**
188     * Disable reception of cell broadcast (SMS-CB) messages with the given
189     * message identifier range. Note that if two different clients enable
190     * a message identifier range, they must both disable it for the device
191     * to stop receiving those messages.
192     *
193     * @param startMessageId first message identifier as specified in TS 23.041
194     * @param endMessageId last message identifier as specified in TS 23.041
195     * @return true if successful, false otherwise
196     *
197     * @see #enableCellBroadcastRange(int, int)
198     */
199    boolean disableCellBroadcastRange(int startMessageId, int endMessageId);
200
201    /**
202     * Returns the premium SMS send permission for the specified package.
203     * Requires system permission.
204     */
205    int getPremiumSmsPermission(String packageName);
206
207    /**
208     * Set the SMS send permission for the specified package.
209     * Requires system permission.
210     */
211    void setPremiumSmsPermission(String packageName, int permission);
212}
213