Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2008 The Android Open Source Project
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package com.android.internal.telephony;
 
 
 
 import java.util.List;
 
 import static android.telephony.SmsManager.STATUS_ON_ICC_FREE;

IccSmsInterfaceManager to provide an inter-process communication to access Sms in Icc.
 
 public abstract class IccSmsInterfaceManager extends ISms.Stub {
     protected PhoneBase mPhone;
     protected Context mContext;
     protected SMSDispatcher mDispatcher;
 
     protected IccSmsInterfaceManager(PhoneBase phone){
          = phone;
          = phone.getContext();
     }
 
     protected void enforceReceiveAndSend(String message) {
                 "android.permission.RECEIVE_SMS"message);
                 "android.permission.SEND_SMS"message);
     }

    
Send a data based SMS to a specific application port.

Parameters:
destAddr the address to send the message to
scAddr is the service center address or null to use the current default SMSC
destPort the port to deliver the message to
data the body of the message to send
sentIntent if not NULL this PendingIntent is broadcast when the message is successfully sent, or failed. The result code will be Activity.RESULT_OK for success, or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
For RESULT_ERROR_GENERIC_FAILURE the sentIntent may include the extra "errorCode" containing a radio technology specific value, generally only useful for troubleshooting.
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.
deliveryIntent if not NULL this PendingIntent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
 
     public void sendData(String destAddrString scAddrint destPort,
             byte[] dataPendingIntent sentIntentPendingIntent deliveryIntent) {
                 "android.permission.SEND_SMS",
                 "Sending SMS message");
         if (Log.isLoggable("SMS".)) {
             log("sendData: destAddr=" + destAddr + " scAddr=" + scAddr + " destPort=" +
                 destPort + " data='"+ HexDump.toHexString(data)  + "' sentIntent=" +
                 sentIntent + " deliveryIntent=" + deliveryIntent);
         }
         .sendData(destAddrscAddrdestPortdatasentIntentdeliveryIntent);
     }

    
Send a text based SMS.

Parameters:
destAddr the address to send the message to
scAddr is the service center address or null to use the current default SMSC
text the body of the message to send
sentIntent if not NULL this PendingIntent is broadcast when the message is successfully sent, or failed. The result code will be Activity.RESULT_OK for success, or one of these errors:
RESULT_ERROR_GENERIC_FAILURE
RESULT_ERROR_RADIO_OFF
RESULT_ERROR_NULL_PDU
For RESULT_ERROR_GENERIC_FAILURE the sentIntent may include the extra "errorCode" containing a radio technology specific value, generally only useful for troubleshooting.
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.
deliveryIntent if not NULL this PendingIntent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
    public void sendText(String destAddrString scAddr,
            String textPendingIntent sentIntentPendingIntent deliveryIntent) {
                "android.permission.SEND_SMS",
                "Sending SMS message");
        if (Log.isLoggable("SMS".)) {
            log("sendText: destAddr=" + destAddr + " scAddr=" + scAddr +
                " text='"text + "' sentIntent=" +
                sentIntent + " deliveryIntent=" + deliveryIntent);
        }
        .sendText(destAddrscAddrtextsentIntentdeliveryIntent);
    }

    
Send a multi-part text based SMS.

Parameters:
destAddr the address to send the message to
scAddr is the service center address or null to use the current default SMSC
parts an ArrayList of strings that, in order, comprise the original message
sentIntents if not null, an ArrayList of PendingIntents (one for each message part) that is broadcast when the corresponding message part has been sent. The result code will be Activity.RESULT_OK for success, or one of these errors: RESULT_ERROR_GENERIC_FAILURE RESULT_ERROR_RADIO_OFF RESULT_ERROR_NULL_PDU. 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.
deliveryIntents if not null, an ArrayList of PendingIntents (one for each message part) that is broadcast when the corresponding message part has been delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").
    public void sendMultipartText(String destAddrString scAddrList<Stringparts,
            List<PendingIntentsentIntentsList<PendingIntentdeliveryIntents) {
                "android.permission.SEND_SMS",
                "Sending SMS message");
        if (Log.isLoggable("SMS".)) {
            int i = 0;
            for (String part : parts) {
                log("sendMultipartText: destAddr=" + destAddr + ", srAddr=" + scAddr +
                        ", part[" + (i++) + "]=" + part);
            }
        }
        .sendMultipartText(destAddrscAddr, (ArrayList<String>) parts,
                (ArrayList<PendingIntent>) sentIntents, (ArrayList<PendingIntent>) deliveryIntents);
    }

    
create SmsRawData lists from all sms record byte[] Use null to indicate "free" record

Parameters:
messages List of message records from EF_SMS.
Returns:
SmsRawData list of all in-used records
    protected ArrayList<SmsRawDatabuildValidRawData(ArrayList<byte[]> messages) {
        int count = messages.size();
        ArrayList<SmsRawDataret;
        ret = new ArrayList<SmsRawData>(count);
        for (int i = 0; i < counti++) {
            byte[] ba = messages.get(i);
            if (ba[0] == ) {
                ret.add(null);
            } else {
                ret.add(new SmsRawData(messages.get(i)));
            }
        }
        return ret;
    }

    
Generates an EF_SMS record from status and raw PDU.

Parameters:
status Message status. See TS 51.011 10.5.3.
pdu Raw message PDU.
Returns:
byte array for the record.
    protected byte[] makeSmsRecordData(int statusbyte[] pdu) {
        byte[] data = new byte[.];
        // Status bits for this record.  See TS 51.011 10.5.3
        data[0] = (byte)(status & 7);
        System.arraycopy(pdu, 0, data, 1, pdu.length);
        // Pad out with 0xFF's.
        for (int j = pdu.length+1; j < .j++) {
            data[j] = -1;
        }
        return data;
    }
    protected abstract void log(String msg);
New to GrepCode? Check out our FAQ X