1 /* 2 * Copyright (C) 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 android.telephony.gsm; 18 19 import android.app.PendingIntent; 20 21 import java.util.ArrayList; 22 23 24 /** 25 * Manages SMS operations such as sending data, text, and pdu SMS messages. 26 * Get this object by calling the static method SmsManager.getDefault(). 27 * @deprecated Replaced by android.telephony.SmsManager that supports both GSM and CDMA. 28 */ 29 @Deprecated public final class SmsManager { 30 private static SmsManager sInstance; 31 private android.telephony.SmsManager mSmsMgrProxy; 32 33 /** Get the default instance of the SmsManager 34 * 35 * @return the default instance of the SmsManager 36 * @deprecated Use android.telephony.SmsManager. 37 */ 38 @Deprecated 39 public static final SmsManager getDefault() { 40 if (sInstance == null) { 41 sInstance = new SmsManager(); 42 } 43 return sInstance; 44 } 45 46 @Deprecated 47 private SmsManager() { 48 mSmsMgrProxy = android.telephony.SmsManager.getDefault(); 49 } 50 51 /** 52 * Send a text based SMS. 53 * 54 * @param destinationAddress the address to send the message to 55 * @param scAddress is the service center address or null to use 56 * the current default SMSC 57 * @param text the body of the message to send 58 * @param sentIntent if not NULL this <code>PendingIntent</code> is 59 * broadcast when the message is successfully sent, or failed. 60 * The result code will be <code>Activity.RESULT_OK<code> for success, 61 * or one of these errors: 62 * <code>RESULT_ERROR_GENERIC_FAILURE</code> 63 * <code>RESULT_ERROR_RADIO_OFF</code> 64 * <code>RESULT_ERROR_NULL_PDU</code>. 65 * The per-application based SMS control checks sentIntent. If sentIntent 66 * is NULL the caller will be checked against all unknown applications, 67 * which cause smaller number of SMS to be sent in checking period. 68 * @param deliveryIntent if not NULL this <code>PendingIntent</code> is 69 * broadcast when the message is delivered to the recipient. The 70 * raw pdu of the status report is in the extended data ("pdu"). 71 * 72 * @throws IllegalArgumentException if destinationAddress or text are empty 73 * @deprecated Use android.telephony.SmsManager. 74 */ 75 @Deprecated 76 public final void sendTextMessage( 77 String destinationAddress, String scAddress, String text, 78 PendingIntent sentIntent, PendingIntent deliveryIntent) { 79 mSmsMgrProxy.sendTextMessage(destinationAddress, scAddress, text, 80 sentIntent, deliveryIntent); 81 } 82 83 /** 84 * Divide a text message into several messages, none bigger than 85 * the maximum SMS message size. 86 * 87 * @param text the original message. Must not be null. 88 * @return an <code>ArrayList</code> of strings that, in order, 89 * comprise the original message 90 * @deprecated Use android.telephony.SmsManager. 91 */ 92 @Deprecated 93 public final ArrayList<String> divideMessage(String text) { 94 return mSmsMgrProxy.divideMessage(text); 95 } 96 97 /** 98 * Send a multi-part text based SMS. The callee should have already 99 * divided the message into correctly sized parts by calling 100 * <code>divideMessage</code>. 101 * 102 * @param destinationAddress the address to send the message to 103 * @param scAddress is the service center address or null to use 104 * the current default SMSC 105 * @param parts an <code>ArrayList</code> of strings that, in order, 106 * comprise the original message 107 * @param sentIntents if not null, an <code>ArrayList</code> of 108 * <code>PendingIntent</code>s (one for each message part) that is 109 * broadcast when the corresponding message part has been sent. 110 * The result code will be <code>Activity.RESULT_OK<code> for success, 111 * or one of these errors: 112 * <code>RESULT_ERROR_GENERIC_FAILURE</code> 113 * <code>RESULT_ERROR_RADIO_OFF</code> 114 * <code>RESULT_ERROR_NULL_PDU</code>. 115 * The per-application based SMS control checks sentIntent. If sentIntent 116 * is NULL the caller will be checked against all unknown applicaitons, 117 * which cause smaller number of SMS to be sent in checking period. 118 * @param deliveryIntents if not null, an <code>ArrayList</code> of 119 * <code>PendingIntent</code>s (one for each message part) that is 120 * broadcast when the corresponding message part has been delivered 121 * to the recipient. The raw pdu of the status report is in the 122 * extended data ("pdu"). 123 * 124 * @throws IllegalArgumentException if destinationAddress or data are empty 125 * @deprecated Use android.telephony.SmsManager. 126 */ 127 @Deprecated 128 public final void sendMultipartTextMessage( 129 String destinationAddress, String scAddress, ArrayList<String> parts, 130 ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) { 131 mSmsMgrProxy.sendMultipartTextMessage(destinationAddress, scAddress, parts, 132 sentIntents, deliveryIntents); 133 } 134 135 /** 136 * Send a data based SMS to a specific application port. 137 * 138 * @param destinationAddress the address to send the message to 139 * @param scAddress is the service center address or null to use 140 * the current default SMSC 141 * @param destinationPort the port to deliver the message to 142 * @param data the body of the message to send 143 * @param sentIntent if not NULL this <code>PendingIntent</code> is 144 * broadcast when the message is sucessfully sent, or failed. 145 * The result code will be <code>Activity.RESULT_OK<code> for success, 146 * or one of these errors: 147 * <code>RESULT_ERROR_GENERIC_FAILURE</code> 148 * <code>RESULT_ERROR_RADIO_OFF</code> 149 * <code>RESULT_ERROR_NULL_PDU</code>. 150 * The per-application based SMS control checks sentIntent. If sentIntent 151 * is NULL the caller will be checked against all unknown applicaitons, 152 * which cause smaller number of SMS to be sent in checking period. 153 * @param deliveryIntent if not NULL this <code>PendingIntent</code> is 154 * broadcast when the message is delivered to the recipient. The 155 * raw pdu of the status report is in the extended data ("pdu"). 156 * 157 * @throws IllegalArgumentException if destinationAddress or data are empty 158 * @deprecated Use android.telephony.SmsManager. 159 */ 160 @Deprecated 161 public final void sendDataMessage( 162 String destinationAddress, String scAddress, short destinationPort, 163 byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent) { 164 mSmsMgrProxy.sendDataMessage(destinationAddress, scAddress, destinationPort, 165 data, sentIntent, deliveryIntent); 166 } 167 168 /** 169 * Copy a raw SMS PDU to the SIM. 170 * 171 * @param smsc the SMSC for this message, or NULL for the default SMSC 172 * @param pdu the raw PDU to store 173 * @param status message status (STATUS_ON_SIM_READ, STATUS_ON_SIM_UNREAD, 174 * STATUS_ON_SIM_SENT, STATUS_ON_SIM_UNSENT) 175 * @return true for success 176 * @deprecated Use android.telephony.SmsManager. 177 * {@hide} 178 */ 179 @Deprecated 180 public final boolean copyMessageToSim(byte[] smsc, byte[] pdu, int status) { 181 return mSmsMgrProxy.copyMessageToIcc(smsc, pdu, status); 182 } 183 184 /** 185 * Delete the specified message from the SIM. 186 * 187 * @param messageIndex is the record index of the message on SIM 188 * @return true for success 189 * @deprecated Use android.telephony.SmsManager. 190 * {@hide} 191 */ 192 @Deprecated 193 public final boolean deleteMessageFromSim(int messageIndex) { 194 return mSmsMgrProxy.deleteMessageFromIcc(messageIndex); 195 } 196 197 /** 198 * Update the specified message on the SIM. 199 * 200 * @param messageIndex record index of message to update 201 * @param newStatus new message status (STATUS_ON_SIM_READ, 202 * STATUS_ON_SIM_UNREAD, STATUS_ON_SIM_SENT, 203 * STATUS_ON_SIM_UNSENT, STATUS_ON_SIM_FREE) 204 * @param pdu the raw PDU to store 205 * @return true for success 206 * @deprecated Use android.telephony.SmsManager. 207 * {@hide} 208 */ 209 @Deprecated 210 public final boolean updateMessageOnSim(int messageIndex, int newStatus, byte[] pdu) { 211 return mSmsMgrProxy.updateMessageOnIcc(messageIndex, newStatus, pdu); 212 } 213 214 /** 215 * Retrieves all messages currently stored on SIM. 216 * @return <code>ArrayList</code> of <code>SmsMessage</code> objects 217 * @deprecated Use android.telephony.SmsManager. 218 * {@hide} 219 */ 220 @Deprecated 221 public final ArrayList<android.telephony.SmsMessage> getAllMessagesFromSim() { 222 return android.telephony.SmsManager.getAllMessagesFromIcc(); 223 } 224 225 /** Free space (TS 51.011 10.5.3). 226 * @deprecated Use android.telephony.SmsManager. */ 227 @Deprecated static public final int STATUS_ON_SIM_FREE = 0; 228 229 /** Received and read (TS 51.011 10.5.3). 230 * @deprecated Use android.telephony.SmsManager. */ 231 @Deprecated static public final int STATUS_ON_SIM_READ = 1; 232 233 /** Received and unread (TS 51.011 10.5.3). 234 * @deprecated Use android.telephony.SmsManager. */ 235 @Deprecated static public final int STATUS_ON_SIM_UNREAD = 3; 236 237 /** Stored and sent (TS 51.011 10.5.3). 238 * @deprecated Use android.telephony.SmsManager. */ 239 @Deprecated static public final int STATUS_ON_SIM_SENT = 5; 240 241 /** Stored and unsent (TS 51.011 10.5.3). 242 * @deprecated Use android.telephony.SmsManager. */ 243 @Deprecated static public final int STATUS_ON_SIM_UNSENT = 7; 244 245 /** Generic failure cause 246 * @deprecated Use android.telephony.SmsManager. */ 247 @Deprecated static public final int RESULT_ERROR_GENERIC_FAILURE = 1; 248 249 /** Failed because radio was explicitly turned off 250 * @deprecated Use android.telephony.SmsManager. */ 251 @Deprecated static public final int RESULT_ERROR_RADIO_OFF = 2; 252 253 /** Failed because no pdu provided 254 * @deprecated Use android.telephony.SmsManager. */ 255 @Deprecated static public final int RESULT_ERROR_NULL_PDU = 3; 256 257 /** Failed because service is currently unavailable 258 * @deprecated Use android.telephony.SmsManager. */ 259 @Deprecated static public final int RESULT_ERROR_NO_SERVICE = 4; 260 261 } 262