Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 390628aa authored by Jordan Liu's avatar Jordan Liu
Browse files

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
parent d142983a
Loading
Loading
Loading
Loading
+29 −9
Original line number Diff line number Diff line
@@ -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) {
@@ -3845,6 +3858,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 {