@@ -109,6 +109,12 @@ public abstract class SMSDispatcher extends Handler {
109109 /** Stop the sending */
110110 static final protected int EVENT_STOP_SENDING = 10 ;
111111
112+ /** Memory status reporting is acknowledged by RIL */
113+ static final protected int EVENT_REPORT_MEMORY_STATUS_DONE = 11 ;
114+
115+ /** Radio is ON */
116+ static final protected int EVENT_RADIO_ON = 12 ;
117+
112118 protected Phone mPhone ;
113119 protected Context mContext ;
114120 protected ContentResolver mResolver ;
@@ -152,6 +158,7 @@ public abstract class SMSDispatcher extends Handler {
152158 private SmsMessageBase .SubmitPduBase mSubmitPduBase ;
153159
154160 protected boolean mStorageAvailable = true ;
161+ protected boolean mReportMemoryStatusPending = false ;
155162
156163 protected static int getNextConcatenatedRef () {
157164 sConcatenatedRef += 1 ;
@@ -235,6 +242,7 @@ protected SMSDispatcher(PhoneBase phone) {
235242 mCm .setOnNewSMS (this , EVENT_NEW_SMS , null );
236243 mCm .setOnSmsStatus (this , EVENT_NEW_SMS_STATUS_REPORT , null );
237244 mCm .setOnIccSmsFull (this , EVENT_ICC_FULL , null );
245+ mCm .registerForOn (this , EVENT_RADIO_ON , null );
238246
239247 // Don't always start message ref at 0.
240248 sConcatenatedRef = new Random ().nextInt (256 );
@@ -253,6 +261,7 @@ public void dispose() {
253261 mCm .unSetOnNewSMS (this );
254262 mCm .unSetOnSmsStatus (this );
255263 mCm .unSetOnIccSmsFull (this );
264+ mCm .unregisterForOn (this );
256265 }
257266
258267 protected void finalize () {
@@ -370,6 +379,26 @@ public void handleMessage(Message msg) {
370379 removeMessages (EVENT_ALERT_TIMEOUT , msg .obj );
371380 }
372381 break ;
382+
383+ case EVENT_REPORT_MEMORY_STATUS_DONE :
384+ ar = (AsyncResult )msg .obj ;
385+ if (ar .exception != null ) {
386+ mReportMemoryStatusPending = true ;
387+ Log .v (TAG , "Memory status report to modem pending : mStorageAvailable = "
388+ + mStorageAvailable );
389+ } else {
390+ mReportMemoryStatusPending = false ;
391+ }
392+ break ;
393+
394+ case EVENT_RADIO_ON :
395+ if (mReportMemoryStatusPending ) {
396+ Log .v (TAG , "Sending pending memory status report : mStorageAvailable = "
397+ + mStorageAvailable );
398+ mCm .reportSmsMemoryStatus (mStorageAvailable ,
399+ obtainMessage (EVENT_REPORT_MEMORY_STATUS_DONE ));
400+ }
401+ break ;
373402 }
374403 }
375404
@@ -940,10 +969,10 @@ public void onClick(DialogInterface dialog, int which) {
940969 public void onReceive (Context context , Intent intent ) {
941970 if (intent .getAction ().equals (Intent .ACTION_DEVICE_STORAGE_LOW )) {
942971 mStorageAvailable = false ;
943- mCm .reportSmsMemoryStatus (false , null );
972+ mCm .reportSmsMemoryStatus (false , obtainMessage ( EVENT_REPORT_MEMORY_STATUS_DONE ) );
944973 } else if (intent .getAction ().equals (Intent .ACTION_DEVICE_STORAGE_OK )) {
945974 mStorageAvailable = true ;
946- mCm .reportSmsMemoryStatus (true , null );
975+ mCm .reportSmsMemoryStatus (true , obtainMessage ( EVENT_REPORT_MEMORY_STATUS_DONE ) );
947976 } else {
948977 // Assume the intent is one of the SMS receive intents that
949978 // was sent as an ordered broadcast. Check result and ACK.
0 commit comments