欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SIM卡满处理流程分析

程序员文章站 2024-02-13 20:46:46
...

SIM卡满处理流程分析

//框架层分析
// SMSDispatcher.java
   /** SIM/RUIM storage is full */
static final protected int EVENT_ICC_FULL = 6;

  @Override
    public void handleMessage(Message msg) {

。。。。。。
case EVENT_ICC_FULL:  //SIM卡满处理分支
     handleIccFull();
     break;

}

 /**
 * Called when SIM_FULL message is received from the RIL.  Notifies intereste
* parties that SIM storage for SMS messages is full.
*/
private void handleIccFull(){  //SIM卡满消息最初是发自RIL层
// broadcast SIM_FULL intent
Intent intent = new Intent(Intents.SIM_FULL_ACTION);
 mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
 mContext.sendBroadcast(intent, "android.permission.RECEIVE_SMS");
}

//应用层分析:
//AndroidManifest.xml
   <receiver android:name=".transaction.SimFullReceiver">
            <intent-filter>
                <action android:name="android.provider.Telephony.SIM_FULL" />
            </intent-filter>
        </receiver>

// SimFullReceiver.java
/**
 * Receive Intent.SIM_FULL_ACTION.  Handle notification that SIM is full.
 */
public class SimFullReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Settings.Secure.getInt(context.getContentResolver(),
            Settings.Secure.DEVICE_PROVISIONED, 0) == 1 &&
            Telephony.Sms.Intents.SIM_FULL_ACTION.equals(intent.getAction())) {

            NotificationManager nm = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);

            Intent viewSimIntent = new Intent(context, ManageSimMessages.class);
            viewSimIntent.setAction(Intent.ACTION_VIEW);
            viewSimIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            PendingIntent pendingIntent = PendingIntent.getActivity(
                    context, 0, viewSimIntent, 0);

            Notification notification = new Notification();
            notification.icon = R.drawable.stat_sys_no_sim;
            notification.tickerText = context.getString(R.string.sim_full_title);
            notification.defaults = Notification.DEFAULT_ALL;

            notification.setLatestEventInfo(
                    context, context.getString(R.string.sim_full_title),
                    context.getString(R.string.sim_full_body),
                    pendingIntent);
            nm.notify(ManageSimMessages.SIM_FULL_NOTIFICATION_ID, notification);
       }
}


//ManageSimMessages.java
//ManageSimMessages管理SIM卡上的短信息。