diff options
author | jsh <jsh@google.com> | 2009-06-05 16:09:38 -0700 |
---|---|---|
committer | jsh <jsh@google.com> | 2009-06-08 16:05:00 -0700 |
commit | 52f2825c29293a85984f188f5dd5e230d589b29d (patch) | |
tree | 9400124e113411a7e3f3867609922b06573d106f /telephony | |
parent | 996b1c8d681268961a9e6518b9a5cbe98ccf0111 (diff) | |
download | frameworks_base-52f2825c29293a85984f188f5dd5e230d589b29d.zip frameworks_base-52f2825c29293a85984f188f5dd5e230d589b29d.tar.gz frameworks_base-52f2825c29293a85984f188f5dd5e230d589b29d.tar.bz2 |
Report device storage status (for SMS) to RIL.
Indicate SMS memory available/not available based on DEVICE_STORAGE_OK/FULL
intents, and immediately NAK with MEMORY_FULL if we've received a
DEVICE_STORAGE_FULL notification.
This may end up being a short term solution, as the messaging app is
getting re-worked in Eclair, which may change the way we want to handle
memory full reporting (ie, more app involvement).
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/com/android/internal/telephony/SMSDispatcher.java | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/telephony/java/com/android/internal/telephony/SMSDispatcher.java b/telephony/java/com/android/internal/telephony/SMSDispatcher.java index 12808ce..ca03f47 100644 --- a/telephony/java/com/android/internal/telephony/SMSDispatcher.java +++ b/telephony/java/com/android/internal/telephony/SMSDispatcher.java @@ -26,6 +26,7 @@ import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.DialogInterface; +import android.content.IntentFilter; import android.content.res.Resources; import android.database.Cursor; import android.database.SQLException; @@ -142,6 +143,7 @@ public abstract class SMSDispatcher extends Handler { private static SmsMessage mSmsMessage; private static SmsMessageBase mSmsMessageBase; private SmsMessageBase.SubmitPduBase mSubmitPduBase; + private boolean mStorageAvailable = true; protected static int getNextConcatenatedRef() { sConcatenatedRef += 1; @@ -229,6 +231,15 @@ public abstract class SMSDispatcher extends Handler { // Don't always start message ref at 0. sConcatenatedRef = new Random().nextInt(256); + + // Register for device storage intents. Use these to notify the RIL + // that storage for SMS is or is not available. + // TODO: Revisit this for a later release. Storage reporting should + // rely more on application indication. + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); + filter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); + mContext.registerReceiver(mResultReceiver, filter); } public void dispose() { @@ -277,7 +288,11 @@ public abstract class SMSDispatcher extends Handler { sms = (SmsMessage) ar.result; try { - dispatchMessage(sms.mWrappedSmsMessage); + if (mStorageAvailable) { + dispatchMessage(sms.mWrappedSmsMessage); + } else { + acknowledgeLastIncomingSms(false, Intents.RESULT_SMS_OUT_OF_MEMORY, null); + } } catch (RuntimeException ex) { acknowledgeLastIncomingSms(false, Intents.RESULT_SMS_GENERIC_ERROR, null); } @@ -795,12 +810,23 @@ public abstract class SMSDispatcher extends Handler { private BroadcastReceiver mResultReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - int rc = getResultCode(); - boolean success = (rc == Activity.RESULT_OK) || (rc == Intents.RESULT_SMS_HANDLED); - - // For a multi-part message, this only ACKs the last part. - // Previous parts were ACK'd as they were received. - acknowledgeLastIncomingSms(success, rc, null); + if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_LOW)) { + mStorageAvailable = false; + mCm.reportSmsMemoryStatus(false, null); + } else if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_OK)) { + mStorageAvailable = true; + mCm.reportSmsMemoryStatus(true, null); + } else { + // Assume the intent is one of the SMS receive intents that + // was sent as an ordered broadcast. Check result and ACK. + int rc = getResultCode(); + boolean success = (rc == Activity.RESULT_OK) + || (rc == Intents.RESULT_SMS_HANDLED); + + // For a multi-part message, this only ACKs the last part. + // Previous parts were ACK'd as they were received. + acknowledgeLastIncomingSms(success, rc, null); + } } }; |