Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +74 −4 Original line number Diff line number Diff line Loading @@ -400,6 +400,14 @@ public class ServiceStateTracker extends Handler { private int mNewMaxDataCalls = 1; private int mReasonDataDenied = -1; private int mNewReasonDataDenied = -1; /** * The code of the rejection cause that is sent by network when the CS * registration is rejected. It should be shown to the user as a notification. */ private int mRejectCode; private int mNewRejectCode; /** * GSM roaming status solely based on TS 27.007 7.2 CREG. Only used by * handlePollStateResult to store CREG roaming result. Loading Loading @@ -433,9 +441,13 @@ public class ServiceStateTracker extends Handler { public static final int CS_DISABLED = 1004; // Access Control enables all voice/sms service public static final int CS_NORMAL_ENABLED = 1005; // Access Control blocks normal voice/sms service public static final int CS_EMERGENCY_ENABLED = 1006; // Access Control blocks emergency call service public static final int CS_REJECT_CAUSE_ENABLED = 2001; // Notify MM rejection cause public static final int CS_REJECT_CAUSE_DISABLED = 2002; // Cancel MM rejection cause /** Notification id. */ public static final int PS_NOTIFICATION = 888; // Id to update and cancel PS restricted public static final int CS_NOTIFICATION = 999; // Id to update and cancel CS restricted public static final int CS_REJECT_CAUSE_NOTIFICATION = 111; // Id to update and cancel MM // rejection cause private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading Loading @@ -1753,6 +1765,7 @@ public class ServiceStateTracker extends Handler { if (mPhone.isPhoneTypeGsm()) { mGsmRoaming = regCodeIsRoaming(registrationState); mNewRejectCode = reasonForDenial; boolean isVoiceCapable = mPhone.getContext().getResources() .getBoolean(com.android.internal.R.bool.config_voice_capable); Loading Loading @@ -2614,6 +2627,8 @@ public class ServiceStateTracker extends Handler { boolean hasDataRoamingOff = mSS.getDataRoaming() && !mNewSS.getDataRoaming(); boolean hasRejectCauseChanged = mRejectCode != mNewRejectCode; boolean has4gHandoff = false; boolean hasMultiApnSupport = false; boolean hasLostMultiApnSupport = false; Loading Loading @@ -2696,6 +2711,7 @@ public class ServiceStateTracker extends Handler { } mReasonDataDenied = mNewReasonDataDenied; mMaxDataCalls = mNewMaxDataCalls; mRejectCode = mNewRejectCode; } // swap mSS and mNewSS to put new state in mSS Loading Loading @@ -2740,6 +2756,10 @@ public class ServiceStateTracker extends Handler { mNetworkDetachedRegistrants.notifyRegistrants(); } if (hasRejectCauseChanged) { setNotification(mRejectCode == 0 ? CS_REJECT_CAUSE_DISABLED : CS_REJECT_CAUSE_ENABLED); } if (hasChanged) { updateSpnDisplay(); Loading Loading @@ -3735,7 +3755,8 @@ public class ServiceStateTracker extends Handler { } /** * Post a notification to NotificationManager for restricted state * Post a notification to NotificationManager for restricted state and * rejection cause for cs registration * * @param notifyType is one state of PS/CS_*_ENABLE/DISABLE */ Loading @@ -3757,6 +3778,7 @@ public class ServiceStateTracker extends Handler { CharSequence details = ""; CharSequence title = context.getText(com.android.internal.R.string.RestrictedOnData); int notificationId = CS_NOTIFICATION; int icon = com.android.internal.R.drawable.stat_sys_warning; switch (notifyType) { case PS_ENABLED: Loading @@ -3782,13 +3804,32 @@ public class ServiceStateTracker extends Handler { case CS_DISABLED: // do nothing and cancel the notification later break; case CS_REJECT_CAUSE_ENABLED: notificationId = CS_REJECT_CAUSE_NOTIFICATION; int resId = selectResourceForRejectCode(mRejectCode); if (0 == resId) { // cancel notification because current reject code is not handled. notifyType = CS_REJECT_CAUSE_DISABLED; } else { icon = com.android.internal.R.drawable.stat_notify_mmcc_indication_icn; title = Resources.getSystem().getString(resId); details = null; } break; case CS_REJECT_CAUSE_DISABLED: notificationId = CS_REJECT_CAUSE_NOTIFICATION; break; } if (DBG) { log("setNotification, create notification, notifyType: " + notifyType + ", title: " + title + ", details: " + details); } if (DBG) log("setNotification: put notification " + title + " / " +details); mNotification = new Notification.Builder(context) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setSmallIcon(com.android.internal.R.drawable.stat_sys_warning) .setSmallIcon(icon) .setTicker(title) .setColor(context.getResources().getColor( com.android.internal.R.color.system_notification_accent_color)) Loading @@ -3799,7 +3840,8 @@ public class ServiceStateTracker extends Handler { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (notifyType == PS_DISABLED || notifyType == CS_DISABLED) { if (notifyType == PS_DISABLED || notifyType == CS_DISABLED || notifyType == CS_REJECT_CAUSE_DISABLED) { // cancel previous post notification notificationManager.cancel(notificationId); } else { Loading @@ -3808,6 +3850,34 @@ public class ServiceStateTracker extends Handler { } } /** * Selects the resource ID, which depends on rejection cause that is sent by the network when CS * registration is rejected. * * @param rejCode should be compatible with TS 24.008. */ private int selectResourceForRejectCode(int rejCode) { int rejResourceId = 0; switch (rejCode) { case 1:// Authentication reject rejResourceId = com.android.internal.R.string.mmcc_authentication_reject; break; case 2:// IMSI unknown in HLR rejResourceId = com.android.internal.R.string.mmcc_imsi_unknown_in_hlr; break; case 3:// Illegal MS rejResourceId = com.android.internal.R.string.mmcc_illegal_ms; break; case 6:// Illegal ME rejResourceId = com.android.internal.R.string.mmcc_illegal_me; break; default: // The other codes are not defined or not required by operators till now. break; } return rejResourceId; } private UiccCardApplication getUiccCardApplication() { if (mPhone.isPhoneTypeGsm()) { return mUiccController.getUiccCardApplication(mPhone.getPhoneId(), Loading Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +74 −4 Original line number Diff line number Diff line Loading @@ -400,6 +400,14 @@ public class ServiceStateTracker extends Handler { private int mNewMaxDataCalls = 1; private int mReasonDataDenied = -1; private int mNewReasonDataDenied = -1; /** * The code of the rejection cause that is sent by network when the CS * registration is rejected. It should be shown to the user as a notification. */ private int mRejectCode; private int mNewRejectCode; /** * GSM roaming status solely based on TS 27.007 7.2 CREG. Only used by * handlePollStateResult to store CREG roaming result. Loading Loading @@ -433,9 +441,13 @@ public class ServiceStateTracker extends Handler { public static final int CS_DISABLED = 1004; // Access Control enables all voice/sms service public static final int CS_NORMAL_ENABLED = 1005; // Access Control blocks normal voice/sms service public static final int CS_EMERGENCY_ENABLED = 1006; // Access Control blocks emergency call service public static final int CS_REJECT_CAUSE_ENABLED = 2001; // Notify MM rejection cause public static final int CS_REJECT_CAUSE_DISABLED = 2002; // Cancel MM rejection cause /** Notification id. */ public static final int PS_NOTIFICATION = 888; // Id to update and cancel PS restricted public static final int CS_NOTIFICATION = 999; // Id to update and cancel CS restricted public static final int CS_REJECT_CAUSE_NOTIFICATION = 111; // Id to update and cancel MM // rejection cause private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Loading Loading @@ -1753,6 +1765,7 @@ public class ServiceStateTracker extends Handler { if (mPhone.isPhoneTypeGsm()) { mGsmRoaming = regCodeIsRoaming(registrationState); mNewRejectCode = reasonForDenial; boolean isVoiceCapable = mPhone.getContext().getResources() .getBoolean(com.android.internal.R.bool.config_voice_capable); Loading Loading @@ -2614,6 +2627,8 @@ public class ServiceStateTracker extends Handler { boolean hasDataRoamingOff = mSS.getDataRoaming() && !mNewSS.getDataRoaming(); boolean hasRejectCauseChanged = mRejectCode != mNewRejectCode; boolean has4gHandoff = false; boolean hasMultiApnSupport = false; boolean hasLostMultiApnSupport = false; Loading Loading @@ -2696,6 +2711,7 @@ public class ServiceStateTracker extends Handler { } mReasonDataDenied = mNewReasonDataDenied; mMaxDataCalls = mNewMaxDataCalls; mRejectCode = mNewRejectCode; } // swap mSS and mNewSS to put new state in mSS Loading Loading @@ -2740,6 +2756,10 @@ public class ServiceStateTracker extends Handler { mNetworkDetachedRegistrants.notifyRegistrants(); } if (hasRejectCauseChanged) { setNotification(mRejectCode == 0 ? CS_REJECT_CAUSE_DISABLED : CS_REJECT_CAUSE_ENABLED); } if (hasChanged) { updateSpnDisplay(); Loading Loading @@ -3735,7 +3755,8 @@ public class ServiceStateTracker extends Handler { } /** * Post a notification to NotificationManager for restricted state * Post a notification to NotificationManager for restricted state and * rejection cause for cs registration * * @param notifyType is one state of PS/CS_*_ENABLE/DISABLE */ Loading @@ -3757,6 +3778,7 @@ public class ServiceStateTracker extends Handler { CharSequence details = ""; CharSequence title = context.getText(com.android.internal.R.string.RestrictedOnData); int notificationId = CS_NOTIFICATION; int icon = com.android.internal.R.drawable.stat_sys_warning; switch (notifyType) { case PS_ENABLED: Loading @@ -3782,13 +3804,32 @@ public class ServiceStateTracker extends Handler { case CS_DISABLED: // do nothing and cancel the notification later break; case CS_REJECT_CAUSE_ENABLED: notificationId = CS_REJECT_CAUSE_NOTIFICATION; int resId = selectResourceForRejectCode(mRejectCode); if (0 == resId) { // cancel notification because current reject code is not handled. notifyType = CS_REJECT_CAUSE_DISABLED; } else { icon = com.android.internal.R.drawable.stat_notify_mmcc_indication_icn; title = Resources.getSystem().getString(resId); details = null; } break; case CS_REJECT_CAUSE_DISABLED: notificationId = CS_REJECT_CAUSE_NOTIFICATION; break; } if (DBG) { log("setNotification, create notification, notifyType: " + notifyType + ", title: " + title + ", details: " + details); } if (DBG) log("setNotification: put notification " + title + " / " +details); mNotification = new Notification.Builder(context) .setWhen(System.currentTimeMillis()) .setAutoCancel(true) .setSmallIcon(com.android.internal.R.drawable.stat_sys_warning) .setSmallIcon(icon) .setTicker(title) .setColor(context.getResources().getColor( com.android.internal.R.color.system_notification_accent_color)) Loading @@ -3799,7 +3840,8 @@ public class ServiceStateTracker extends Handler { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (notifyType == PS_DISABLED || notifyType == CS_DISABLED) { if (notifyType == PS_DISABLED || notifyType == CS_DISABLED || notifyType == CS_REJECT_CAUSE_DISABLED) { // cancel previous post notification notificationManager.cancel(notificationId); } else { Loading @@ -3808,6 +3850,34 @@ public class ServiceStateTracker extends Handler { } } /** * Selects the resource ID, which depends on rejection cause that is sent by the network when CS * registration is rejected. * * @param rejCode should be compatible with TS 24.008. */ private int selectResourceForRejectCode(int rejCode) { int rejResourceId = 0; switch (rejCode) { case 1:// Authentication reject rejResourceId = com.android.internal.R.string.mmcc_authentication_reject; break; case 2:// IMSI unknown in HLR rejResourceId = com.android.internal.R.string.mmcc_imsi_unknown_in_hlr; break; case 3:// Illegal MS rejResourceId = com.android.internal.R.string.mmcc_illegal_ms; break; case 6:// Illegal ME rejResourceId = com.android.internal.R.string.mmcc_illegal_me; break; default: // The other codes are not defined or not required by operators till now. break; } return rejResourceId; } private UiccCardApplication getUiccCardApplication() { if (mPhone.isPhoneTypeGsm()) { return mUiccController.getUiccCardApplication(mPhone.getPhoneId(), Loading