FileDocCategorySizeDatePackage
SmsStorageMonitor.javaAPI DocAndroid 5.1 API6267Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony

SmsStorageMonitor

public 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_FULL
SIM/RUIM storage is full
private static final int
EVENT_REPORT_MEMORY_STATUS_DONE
Memory status reporting is acknowledged by RIL
private static final int
EVENT_RADIO_ON
Radio is ON
private final android.content.Context
mContext
Context from phone object passed to constructor.
private PowerManager.WakeLock
mWakeLock
Wake lock to ensure device stays awake while dispatching the SMS intent.
private boolean
mReportMemoryStatusPending
PhoneBase
mPhone
it 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_TIMEOUT
Hold 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.

param
phone the Phone to use


                      
       
        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 voidcreateWakelock()

        PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SmsStorageMonitor");
        mWakeLock.setReferenceCounted(true);
    
public voiddispose()

        mCi.unSetOnIccSmsFull(this);
        mCi.unregisterForOn(this);
        mContext.unregisterReceiver(mResultReceiver);
    
private voidhandleIccFull()
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 voidhandleMessage(android.os.Message msg)
Handles events coming from the phone stack. Overridden from handler.

param
msg the message to handle

        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 booleanisStorageAvailable()
Returns whether or not there is storage available for an incoming SMS.

        return mStorageAvailable;