aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Liu <jminjie@google.com>2017-09-27 11:50:24 -0700
committerJordan Liu <jminjie@google.com>2017-10-04 14:52:04 -0700
commit390628aa550a2edb01716a48e4e36f4a9b1aa927 (patch)
tree1fceb846553abfa08e36f71ab443132ce1efac87
parentd142983a7254329ab4f535ebffe9f4beea9971fe (diff)
downloadtelephony-390628aa550a2edb01716a48e4e36f4a9b1aa927.tar.gz
Don't cancel CS reject cause notifications
Notification should stay until the user dismisses it. Since the error that causes this notification is a permanent error (until power cycle or SIM swap), we shouldn't cancel it when we enter a new service state or the SIM is removed. Test: manual Change-Id: I25735ca2c13a655a604d76880a805d9cf63ad1f6 Fixes: 64194949
-rw-r--r--src/java/com/android/internal/telephony/ServiceStateTracker.java38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
index e9d6759944..45fea43399 100644
--- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -210,6 +210,7 @@ public class ServiceStateTracker extends Handler {
protected static final int EVENT_ALL_DATA_DISCONNECTED = 49;
protected static final int EVENT_PHONE_TYPE_SWITCHED = 50;
protected static final int EVENT_RADIO_POWER_FROM_CARRIER = 51;
+ protected static final int EVENT_SIM_NOT_INSERTED = 52;
protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone";
@@ -354,6 +355,14 @@ public class ServiceStateTracker extends Handler {
}
// update voicemail count and notify message waiting changed
mPhone.updateVoiceMail();
+
+ // cancel notifications if we see SIM_NOT_INSERTED (This happens on bootup before
+ // the SIM is first detected and then subsequently on SIM removals)
+ if (mSubscriptionController.getSlotIndex(subId)
+ == SubscriptionManager.SIM_NOT_INSERTED) {
+ // this is handled on the main thread to mitigate racing with setNotification().
+ sendMessage(obtainMessage(EVENT_SIM_NOT_INSERTED));
+ }
}
}
};
@@ -446,7 +455,6 @@ public class ServiceStateTracker extends Handler {
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
@@ -1297,6 +1305,11 @@ public class ServiceStateTracker extends Handler {
}
break;
+ case EVENT_SIM_NOT_INSERTED:
+ if (DBG) log("EVENT_SIM_NOT_INSERTED, cancelling notifications.");
+ cancelAllNotifications();
+ break;
+
case EVENT_ALL_DATA_DISCONNECTED:
int dds = SubscriptionManager.getDefaultDataSubscriptionId();
ProxyController.getInstance().unregisterForAllDataDisconnected(dds, this);
@@ -2820,7 +2833,7 @@ public class ServiceStateTracker extends Handler {
}
if (hasRejectCauseChanged) {
- setNotification(mRejectCode == 0 ? CS_REJECT_CAUSE_DISABLED : CS_REJECT_CAUSE_ENABLED);
+ setNotification(CS_REJECT_CAUSE_ENABLED);
}
if (hasChanged) {
@@ -3846,6 +3859,17 @@ public class ServiceStateTracker extends Handler {
}
/**
+ * Cancels all notifications posted to NotificationManager. These notifications for restricted
+ * state and rejection cause for cs registration are no longer valid after the SIM has been
+ * removed.
+ */
+ private void cancelAllNotifications() {
+ NotificationManager notificationManager = (NotificationManager)
+ mPhone.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancelAll();
+ }
+
+ /**
* Post a notification to NotificationManager for restricted state and
* rejection cause for cs registration
*
@@ -3920,17 +3944,14 @@ public class ServiceStateTracker extends Handler {
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;
+ loge("setNotification: mRejectCode=" + mRejectCode + " is not handled.");
+ return;
} 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) {
@@ -3954,8 +3975,7 @@ public class ServiceStateTracker extends Handler {
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
- if (notifyType == PS_DISABLED || notifyType == CS_DISABLED
- || notifyType == CS_REJECT_CAUSE_DISABLED) {
+ if (notifyType == PS_DISABLED || notifyType == CS_DISABLED) {
// cancel previous post notification
notificationManager.cancel(notificationId);
} else {