SmsStorageMonitorpublic final class SmsStorageMonitor extends android.os.Handler Monitors the device and ICC storage, and sends the appropriate events.
This code was formerly part of {@link SMSDispatcher}, and has been moved
into a separate class to support instantiation of multiple SMSDispatchers on
dual-mode devices that require support for both 3GPP and 3GPP2 format messages. |
Fields Summary |
---|
private static final String | TAG | private static final int | EVENT_ICC_FULLSIM/RUIM storage is full | private static final int | EVENT_REPORT_MEMORY_STATUS_DONEMemory status reporting is acknowledged by RIL | private static final int | EVENT_RADIO_ONRadio is ON | private final android.content.Context | mContextContext from phone object passed to constructor. | private PowerManager.WakeLock | mWakeLockWake lock to ensure device stays awake while dispatching the SMS intent. | private boolean | mReportMemoryStatusPending | PhoneBase | mPhoneit is use to put in to extra value for SIM_FULL_ACTION and SMS_REJECTED_ACTION | final CommandsInterface | mCi | boolean | mStorageAvailable | private static final int | WAKE_LOCK_TIMEOUTHold the wake lock for 5 seconds, which should be enough time for
any receiver(s) to grab its own wake lock. | private final android.content.BroadcastReceiver | mResultReceiver |
Constructors Summary |
---|
public SmsStorageMonitor(PhoneBase phone)Creates an SmsStorageMonitor and registers for events.
mPhone = phone;
mContext = phone.getContext();
mCi = phone.mCi;
createWakelock();
mCi.setOnIccSmsFull(this, EVENT_ICC_FULL, null);
mCi.registerForOn(this, EVENT_RADIO_ON, null);
// Register for device storage intents. Use these to notify the RIL
// that storage for SMS is or is not available.
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_DEVICE_STORAGE_FULL);
filter.addAction(Intent.ACTION_DEVICE_STORAGE_NOT_FULL);
mContext.registerReceiver(mResultReceiver, filter);
|
Methods Summary |
---|
private void | createWakelock()
PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SmsStorageMonitor");
mWakeLock.setReferenceCounted(true);
| public void | dispose()
mCi.unSetOnIccSmsFull(this);
mCi.unregisterForOn(this);
mContext.unregisterReceiver(mResultReceiver);
| private void | handleIccFull()Called when SIM_FULL message is received from the RIL. Notifies interested
parties that SIM storage for SMS messages is full.
// broadcast SIM_FULL intent
Intent intent = new Intent(Intents.SIM_FULL_ACTION);
mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
mContext.sendBroadcast(intent, android.Manifest.permission.RECEIVE_SMS);
| public void | handleMessage(android.os.Message msg)Handles events coming from the phone stack. Overridden from handler.
AsyncResult ar;
switch (msg.what) {
case EVENT_ICC_FULL:
handleIccFull();
break;
case EVENT_REPORT_MEMORY_STATUS_DONE:
ar = (AsyncResult) msg.obj;
if (ar.exception != null) {
mReportMemoryStatusPending = true;
Rlog.v(TAG, "Memory status report to modem pending : mStorageAvailable = "
+ mStorageAvailable);
} else {
mReportMemoryStatusPending = false;
}
break;
case EVENT_RADIO_ON:
if (mReportMemoryStatusPending) {
Rlog.v(TAG, "Sending pending memory status report : mStorageAvailable = "
+ mStorageAvailable);
mCi.reportSmsMemoryStatus(mStorageAvailable,
obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
}
break;
}
| public boolean | isStorageAvailable()Returns whether or not there is storage available for an incoming SMS.
return mStorageAvailable;
|
|