Loading core/res/res/values/strings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -2429,6 +2429,20 @@ <!-- See SMS_DIALOG. This is a button choice to disallow sending the SMSes.. --> <string name="sms_control_no">Cancel</string> <!-- SIM swap and device reboot Dialog --> <skip /> <!-- See SIM_REMOVED_DIALOG. This is the title of that dialog. --> <string name="sim_removed_title">SIM card removed</string> <!-- See SIM_REMOVED_DIALOG. This is the message of that dialog. --> <string name="sim_removed_message">The mobile network will be unavailable until you replace the SIM card.</string> <!-- See SIM_REMOVED_DIALOG. This is the button of that dialog. --> <string name="sim_done_button">Done</string> <!-- See SIM_ADDED_DIALOG. This is the title of that dialog. --> <string name="sim_added_title">SIM card added</string> <!-- See SIM_ADDED_DIALOG. This is the message of that dialog. --> <string name="sim_added_message">You must restart your device to access the mobile network.</string> <!-- See SIM_ADDED_DIALOG. This is the button of that dialog. --> <string name="sim_restart_button">Restart</string> <!-- Date/Time picker dialogs strings --> <!-- The title of the time picker dialog. [CHAR LIMIT=NONE] --> Loading telephony/java/com/android/internal/telephony/IccCard.java +85 −3 Original line number Diff line number Diff line Loading @@ -18,13 +18,20 @@ package com.android.internal.telephony; import static android.Manifest.permission.READ_PHONE_STATE; import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.Power; import android.os.PowerManager; import android.os.Registrant; import android.os.RegistrantList; import android.util.Log; import android.view.WindowManager; import com.android.internal.telephony.PhoneBase; import com.android.internal.telephony.CommandsInterface.RadioState; Loading @@ -32,6 +39,8 @@ import com.android.internal.telephony.gsm.SIMRecords; import android.os.SystemProperties; import com.android.internal.R; /** * {@hide} */ Loading Loading @@ -88,6 +97,12 @@ public abstract class IccCard { private static final int EVENT_QUERY_FACILITY_FDN_DONE = 10; private static final int EVENT_CHANGE_FACILITY_FDN_DONE = 11; private static final int EVENT_ICC_STATUS_CHANGED = 12; private static final int EVENT_CARD_REMOVED = 13; private static final int EVENT_CARD_ADDED = 14; static final boolean LTE_AVAILABLE_ON_CDMA = SystemProperties.getBoolean(TelephonyProperties.PROPERTY_NETWORK_LTE_ON_CDMA, false); /* UNKNOWN is a transient state, for example, after uesr inputs ICC pin under Loading @@ -106,6 +121,11 @@ public abstract class IccCard { public boolean isPinLocked() { return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED)); } public boolean iccCardExist() { return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED) || (this == NETWORK_LOCKED) || (this == READY)); } } public State getState() { Loading Loading @@ -400,6 +420,8 @@ public abstract class IccCard { boolean transitionedIntoPinLocked; boolean transitionedIntoAbsent; boolean transitionedIntoNetworkLocked; boolean isIccCardRemoved; boolean isIccCardAdded; State oldState, newState; Loading @@ -416,6 +438,10 @@ public abstract class IccCard { transitionedIntoAbsent = (oldState != State.ABSENT && newState == State.ABSENT); transitionedIntoNetworkLocked = (oldState != State.NETWORK_LOCKED && newState == State.NETWORK_LOCKED); isIccCardRemoved = (oldState != null && oldState.iccCardExist() && newState == State.ABSENT); isIccCardAdded = (oldState == State.ABSENT && newState != null && newState.iccCardExist()); if (transitionedIntoPinLocked) { if (mDbg) log("Notify SIM pin or puk locked."); Loading @@ -434,6 +460,14 @@ public abstract class IccCard { INTENT_VALUE_LOCKED_NETWORK); } if (isIccCardRemoved) { mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_REMOVED, null)); } else if (isIccCardAdded) { mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_ADDED, null)); } /* * TODO: We need to try to remove this, maybe if the RIL sends up a RIL_UNSOL_SIM_REFRESH? */ Loading @@ -443,6 +477,48 @@ public abstract class IccCard { ((SIMRecords)mPhone.mIccRecords).onSimReady(); } } } private void onIccSwap(boolean isAdded) { // TODO: Here we assume the device can't handle SIM hot-swap // and has to reboot. We may want to add a property, // e.g. REBOOT_ON_SIM_SWAP, to indicate if modem support // hot-swap. DialogInterface.OnClickListener listener = null; // TODO: SimRecords is not reset while SIM ABSENT (only reset while // Radio_off_or_not_available). Have to reset in both both // added or removed situation. listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { if (mDbg) log("Reboot due to SIM swap"); PowerManager pm = (PowerManager) mPhone.getContext() .getSystemService(Context.POWER_SERVICE); pm.reboot("SIM is added."); } } }; Resources r = Resources.getSystem(); String title = (isAdded) ? r.getString(R.string.sim_added_title) : r.getString(R.string.sim_removed_title); String message = (isAdded) ? r.getString(R.string.sim_added_message) : r.getString(R.string.sim_removed_message); String buttonTxt = r.getString(R.string.sim_restart_button); AlertDialog dialog = new AlertDialog.Builder(mPhone.getContext()) .setTitle(title) .setMessage(message) .setPositiveButton(buttonTxt, listener) .create(); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.show(); } /** Loading Loading @@ -609,6 +685,12 @@ public abstract class IccCard { Log.d(mLogTag, "Received Event EVENT_ICC_STATUS_CHANGED"); mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE)); break; case EVENT_CARD_REMOVED: onIccSwap(false); break; case EVENT_CARD_ADDED: onIccSwap(true); break; default: Log.e(mLogTag, "[IccCard] Unknown Event " + msg.what); } Loading telephony/java/com/android/internal/telephony/gsm/SimCard.java +6 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public final class SimCard extends IccCard { if(mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) { mPhone.mCM.registerForNVReady(mHandler, EVENT_ICC_READY, null); mPhone.mCM.registerForIccStatusChanged(mHandler, EVENT_ICC_LOCKED_OR_ABSENT, null); } } Loading @@ -60,6 +61,11 @@ public final class SimCard extends IccCard { mPhone.mCM.unregisterForSIMLockedOrAbsent(mHandler); mPhone.mCM.unregisterForOffOrNotAvailable(mHandler); mPhone.mCM.unregisterForSIMReady(mHandler); if(mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) { mPhone.mCM.unregisterForNVReady(mHandler); mPhone.mCM.unregisterForIccStatusChanged(mHandler); } } @Override Loading Loading
core/res/res/values/strings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -2429,6 +2429,20 @@ <!-- See SMS_DIALOG. This is a button choice to disallow sending the SMSes.. --> <string name="sms_control_no">Cancel</string> <!-- SIM swap and device reboot Dialog --> <skip /> <!-- See SIM_REMOVED_DIALOG. This is the title of that dialog. --> <string name="sim_removed_title">SIM card removed</string> <!-- See SIM_REMOVED_DIALOG. This is the message of that dialog. --> <string name="sim_removed_message">The mobile network will be unavailable until you replace the SIM card.</string> <!-- See SIM_REMOVED_DIALOG. This is the button of that dialog. --> <string name="sim_done_button">Done</string> <!-- See SIM_ADDED_DIALOG. This is the title of that dialog. --> <string name="sim_added_title">SIM card added</string> <!-- See SIM_ADDED_DIALOG. This is the message of that dialog. --> <string name="sim_added_message">You must restart your device to access the mobile network.</string> <!-- See SIM_ADDED_DIALOG. This is the button of that dialog. --> <string name="sim_restart_button">Restart</string> <!-- Date/Time picker dialogs strings --> <!-- The title of the time picker dialog. [CHAR LIMIT=NONE] --> Loading
telephony/java/com/android/internal/telephony/IccCard.java +85 −3 Original line number Diff line number Diff line Loading @@ -18,13 +18,20 @@ package com.android.internal.telephony; import static android.Manifest.permission.READ_PHONE_STATE; import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; import android.os.Power; import android.os.PowerManager; import android.os.Registrant; import android.os.RegistrantList; import android.util.Log; import android.view.WindowManager; import com.android.internal.telephony.PhoneBase; import com.android.internal.telephony.CommandsInterface.RadioState; Loading @@ -32,6 +39,8 @@ import com.android.internal.telephony.gsm.SIMRecords; import android.os.SystemProperties; import com.android.internal.R; /** * {@hide} */ Loading Loading @@ -88,6 +97,12 @@ public abstract class IccCard { private static final int EVENT_QUERY_FACILITY_FDN_DONE = 10; private static final int EVENT_CHANGE_FACILITY_FDN_DONE = 11; private static final int EVENT_ICC_STATUS_CHANGED = 12; private static final int EVENT_CARD_REMOVED = 13; private static final int EVENT_CARD_ADDED = 14; static final boolean LTE_AVAILABLE_ON_CDMA = SystemProperties.getBoolean(TelephonyProperties.PROPERTY_NETWORK_LTE_ON_CDMA, false); /* UNKNOWN is a transient state, for example, after uesr inputs ICC pin under Loading @@ -106,6 +121,11 @@ public abstract class IccCard { public boolean isPinLocked() { return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED)); } public boolean iccCardExist() { return ((this == PIN_REQUIRED) || (this == PUK_REQUIRED) || (this == NETWORK_LOCKED) || (this == READY)); } } public State getState() { Loading Loading @@ -400,6 +420,8 @@ public abstract class IccCard { boolean transitionedIntoPinLocked; boolean transitionedIntoAbsent; boolean transitionedIntoNetworkLocked; boolean isIccCardRemoved; boolean isIccCardAdded; State oldState, newState; Loading @@ -416,6 +438,10 @@ public abstract class IccCard { transitionedIntoAbsent = (oldState != State.ABSENT && newState == State.ABSENT); transitionedIntoNetworkLocked = (oldState != State.NETWORK_LOCKED && newState == State.NETWORK_LOCKED); isIccCardRemoved = (oldState != null && oldState.iccCardExist() && newState == State.ABSENT); isIccCardAdded = (oldState == State.ABSENT && newState != null && newState.iccCardExist()); if (transitionedIntoPinLocked) { if (mDbg) log("Notify SIM pin or puk locked."); Loading @@ -434,6 +460,14 @@ public abstract class IccCard { INTENT_VALUE_LOCKED_NETWORK); } if (isIccCardRemoved) { mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_REMOVED, null)); } else if (isIccCardAdded) { mHandler.sendMessage(mHandler.obtainMessage(EVENT_CARD_ADDED, null)); } /* * TODO: We need to try to remove this, maybe if the RIL sends up a RIL_UNSOL_SIM_REFRESH? */ Loading @@ -443,6 +477,48 @@ public abstract class IccCard { ((SIMRecords)mPhone.mIccRecords).onSimReady(); } } } private void onIccSwap(boolean isAdded) { // TODO: Here we assume the device can't handle SIM hot-swap // and has to reboot. We may want to add a property, // e.g. REBOOT_ON_SIM_SWAP, to indicate if modem support // hot-swap. DialogInterface.OnClickListener listener = null; // TODO: SimRecords is not reset while SIM ABSENT (only reset while // Radio_off_or_not_available). Have to reset in both both // added or removed situation. listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { if (mDbg) log("Reboot due to SIM swap"); PowerManager pm = (PowerManager) mPhone.getContext() .getSystemService(Context.POWER_SERVICE); pm.reboot("SIM is added."); } } }; Resources r = Resources.getSystem(); String title = (isAdded) ? r.getString(R.string.sim_added_title) : r.getString(R.string.sim_removed_title); String message = (isAdded) ? r.getString(R.string.sim_added_message) : r.getString(R.string.sim_removed_message); String buttonTxt = r.getString(R.string.sim_restart_button); AlertDialog dialog = new AlertDialog.Builder(mPhone.getContext()) .setTitle(title) .setMessage(message) .setPositiveButton(buttonTxt, listener) .create(); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); dialog.show(); } /** Loading Loading @@ -609,6 +685,12 @@ public abstract class IccCard { Log.d(mLogTag, "Received Event EVENT_ICC_STATUS_CHANGED"); mPhone.mCM.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE)); break; case EVENT_CARD_REMOVED: onIccSwap(false); break; case EVENT_CARD_ADDED: onIccSwap(true); break; default: Log.e(mLogTag, "[IccCard] Unknown Event " + msg.what); } Loading
telephony/java/com/android/internal/telephony/gsm/SimCard.java +6 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public final class SimCard extends IccCard { if(mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) { mPhone.mCM.registerForNVReady(mHandler, EVENT_ICC_READY, null); mPhone.mCM.registerForIccStatusChanged(mHandler, EVENT_ICC_LOCKED_OR_ABSENT, null); } } Loading @@ -60,6 +61,11 @@ public final class SimCard extends IccCard { mPhone.mCM.unregisterForSIMLockedOrAbsent(mHandler); mPhone.mCM.unregisterForOffOrNotAvailable(mHandler); mPhone.mCM.unregisterForSIMReady(mHandler); if(mPhone.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) { mPhone.mCM.unregisterForNVReady(mHandler); mPhone.mCM.unregisterForIccStatusChanged(mHandler); } } @Override Loading