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 17 package com.android.internal.telephony; 18 19 import android.app.PendingIntent; 20 import 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 36 interface ISms { 37 /** 38 * Retrieves all messages currently stored on ICC. 39 * 40 * @return list of SmsRawData of all sms on ICC 41 */ getAllMessagesFromIccEf(String callingPkg)42 List<SmsRawData> getAllMessagesFromIccEf(String callingPkg); 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 */ updateMessageOnIccEf(String callingPkg, int messageIndex, int newStatus, in byte[] pdu)55 boolean updateMessageOnIccEf(String callingPkg, 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 */ copyMessageToIccEf(String callingPkg, int status, in byte[] pdu, in byte[] smsc)67 boolean copyMessageToIccEf(String callingPkg, 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 */ sendData(String callingPkg, in String destAddr, in String scAddr, in int destPort, in byte[] data, in PendingIntent sentIntent, in PendingIntent deliveryIntent)92 void sendData(String callingPkg, 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 */ sendText(String callingPkg, in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent, in PendingIntent deliveryIntent)118 void sendText(String callingPkg, 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 */ sendMultipartText(String callingPkg, in String destinationAddress, in String scAddress, in List<String> parts, in List<PendingIntent> sentIntents, in List<PendingIntent> deliveryIntents)143 void sendMultipartText(String callingPkg, 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 (3GPP) or 154 * C.R1001-G (3GPP2) 155 * @return true if successful, false otherwise 156 * 157 * @see #disableCellBroadcast(int) 158 */ enableCellBroadcast(int messageIdentifier)159 boolean enableCellBroadcast(int messageIdentifier); 160 161 /** 162 * Disable reception of cell broadcast (SMS-CB) messages with the given 163 * message identifier. Note that if two different clients enable the same 164 * message identifier, they must both disable it for the device to stop 165 * receiving those messages. 166 * 167 * @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP) or 168 * C.R1001-G (3GPP2) 169 * @return true if successful, false otherwise 170 * 171 * @see #enableCellBroadcast(int) 172 */ disableCellBroadcast(int messageIdentifier)173 boolean disableCellBroadcast(int messageIdentifier); 174 175 /* 176 * Enable reception of cell broadcast (SMS-CB) messages with the given 177 * message identifier range. Note that if two different clients enable 178 * a message identifier range, they must both disable it for the device 179 * to stop receiving those messages. 180 * 181 * @param startMessageId first message identifier as specified in TS 23.041 (3GPP) or 182 * C.R1001-G (3GPP2) 183 * @param endMessageId last message identifier as specified in TS 23.041 (3GPP) or 184 * C.R1001-G (3GPP2) 185 * @return true if successful, false otherwise 186 * 187 * @see #disableCellBroadcastRange(int, int) 188 */ enableCellBroadcastRange(int startMessageId, int endMessageId)189 boolean enableCellBroadcastRange(int startMessageId, int endMessageId); 190 191 /** 192 * Disable reception of cell broadcast (SMS-CB) messages with the given 193 * message identifier range. Note that if two different clients enable 194 * a message identifier range, they must both disable it for the device 195 * to stop receiving those messages. 196 * 197 * @param startMessageId first message identifier as specified in TS 23.041 (3GPP) or 198 * C.R1001-G (3GPP2) 199 * @param endMessageId last message identifier as specified in TS 23.041 (3GPP) or 200 * C.R1001-G (3GPP2) 201 * @return true if successful, false otherwise 202 * 203 * @see #enableCellBroadcastRange(int, int) 204 */ disableCellBroadcastRange(int startMessageId, int endMessageId)205 boolean disableCellBroadcastRange(int startMessageId, int endMessageId); 206 207 /** 208 * Returns the premium SMS send permission for the specified package. 209 * Requires system permission. 210 */ getPremiumSmsPermission(String packageName)211 int getPremiumSmsPermission(String packageName); 212 213 /** 214 * Set the SMS send permission for the specified package. 215 * Requires system permission. 216 */ setPremiumSmsPermission(String packageName, int permission)217 void setPremiumSmsPermission(String packageName, int permission); 218 } 219