SimSmsInterfaceManagerpublic class SimSmsInterfaceManager extends ISms.Stub SimSmsInterfaceManager to provide an inter-process communication to
access Sms in Sim. |
Fields Summary |
---|
static final String | LOG_TAG | static final boolean | DBG | private GSMPhone | mPhone | private final Object | mLock | private boolean | mSuccess | private List | mSms | private static final int | EVENT_LOAD_DONE | private static final int | EVENT_UPDATE_DONE | android.os.Handler | mHandler |
Constructors Summary |
---|
public SimSmsInterfaceManager(GSMPhone phone)
this.mPhone = phone;
ServiceManager.addService("isms", this);
|
Methods Summary |
---|
private java.util.ArrayList | buildValidRawData(java.util.ArrayList messages)create SmsRawData lists from all sms record byte[]
Use null to indicate "free" record
int count = messages.size();
ArrayList<SmsRawData> ret;
ret = new ArrayList<SmsRawData>(count);
for (int i = 0; i < count; i++) {
byte[] ba = messages.get(i);
if (ba[0] == 0) {
ret.add(null);
} else {
ret.add(new SmsRawData(messages.get(i)));
}
}
return ret;
| public boolean | copyMessageToSimEf(int status, byte[] pdu, byte[] smsc)Copy a raw SMS PDU to the SIM.
if (DBG) log("copyMessageToSimEf: status=" + status + " ==> " +
"pdu=("+ pdu + "), smsm=(" + smsc +")");
enforceReceiveAndSend("Copying message to SIM");
synchronized(mLock) {
mSuccess = false;
Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
mPhone.mCM.writeSmsToSim(status, SimUtils.bytesToHexString(smsc),
SimUtils.bytesToHexString(pdu), response);
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to update by index");
}
}
return mSuccess;
| private void | enforceReceiveAndSend(java.lang.String message)
Context context = mPhone.getContext();
context.enforceCallingPermission(
"android.permission.RECEIVE_SMS", message);
context.enforceCallingPermission(
"android.permission.SEND_SMS", message);
| public java.util.List | getAllMessagesFromSimEf()Retrieves all messages currently stored on SIM.
if (DBG) log("getAllMessagesFromEF");
Context context = mPhone.getContext();
context.enforceCallingPermission(
"android.permission.RECEIVE_SMS",
"Reading messages from SIM");
synchronized(mLock) {
Message response = mHandler.obtainMessage(EVENT_LOAD_DONE);
mPhone.mSIMFileHandler.loadEFLinearFixedAll(SimConstants.EF_SMS,
response);
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to load from the SIM");
}
}
return mSms;
| private void | log(java.lang.String msg)
Log.d(LOG_TAG, "[SmsInterfaceManager] " + msg);
| private byte[] | makeSmsRecordData(int status, byte[] pdu)Generates an EF_SMS record from status and raw PDU.
byte[] data = new byte[SimConstants.SMS_RECORD_LENGTH];
// 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 < SimConstants.SMS_RECORD_LENGTH; j++) {
data[j] = -1;
}
return data;
| public void | sendMultipartText(java.lang.String destinationAddress, java.lang.String scAddress, java.util.List parts, java.util.List sentIntents, java.util.List deliveryIntents)Send a multi-part text based SMS.
Context context = mPhone.getContext();
context.enforceCallingPermission(
"android.permission.SEND_SMS",
"Sending SMS message");
if (DBG) log("sendMultipartText");
mPhone.mSMS.sendMultipartText(destinationAddress, scAddress, (ArrayList<String>) parts,
(ArrayList<PendingIntent>) sentIntents, (ArrayList<PendingIntent>) deliveryIntents);
| public void | sendRawPdu(byte[] smsc, byte[] pdu, android.app.PendingIntent sentIntent, android.app.PendingIntent deliveryIntent)Send a Raw PDU SMS
Context context = mPhone.getContext();
context.enforceCallingPermission(
"android.permission.SEND_SMS",
"Sending SMS message");
if (DBG) log("sendRawPdu: smsc=" + smsc +
" pdu="+ pdu + " sentIntent" + sentIntent +
" deliveryIntent" + deliveryIntent);
mPhone.mSMS.sendRawPdu(smsc, pdu, sentIntent, deliveryIntent);
| public boolean | updateMessageOnSimEf(int index, int status, byte[] pdu)Update the specified message on the SIM.
if (DBG) log("updateMessageOnSimEf: index=" + index +
" status=" + status + " ==> " +
"("+ pdu + ")");
enforceReceiveAndSend("Updating message on SIM");
synchronized(mLock) {
mSuccess = false;
Message response = mHandler.obtainMessage(EVENT_UPDATE_DONE);
if (status == SmsManager.STATUS_ON_SIM_FREE) {
// Special case FREE: call deleteSmsOnSim instead of
// manipulating the SIM record
mPhone.mCM.deleteSmsOnSim(index, response);
} else {
byte[] record = makeSmsRecordData(status, pdu);
mPhone.mSIMFileHandler.updateEFLinearFixed( SimConstants.EF_SMS,
index, record, null, response);
}
try {
mLock.wait();
} catch (InterruptedException e) {
log("interrupted while trying to update by index");
}
}
return mSuccess;
|
|