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

Commit 47a6777b authored by Jordan Liu's avatar Jordan Liu Committed by android-build-merger
Browse files

Merge "Post notifications per subid" am: 73fbc680

am: 2a3924ee

Change-Id: I96e9d5b94a8cceecb56c12804ee84c82620ef6a3
parents 98b33897 2a3924ee
Loading
Loading
Loading
Loading
+24 −12
Original line number Diff line number Diff line
@@ -244,6 +244,7 @@ public class ServiceStateTracker extends Handler {
    private boolean mCurShowPlmn = false;
    private boolean mCurShowSpn = false;
    private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private int mPrevSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;

    private boolean mImsRegistered = false;

@@ -274,6 +275,7 @@ public class ServiceStateTracker extends Handler {
            if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
            // Set the network type, in case the radio does not restore it.
            int subId = mPhone.getSubId();
            ServiceStateTracker.this.mPrevSubId = mPreviousSubId.get();
            if (mPreviousSubId.getAndSet(subId) != subId) {
                if (SubscriptionManager.isValidSubscriptionId(subId)) {
                    Context context = mPhone.getContext();
@@ -1059,7 +1061,9 @@ public class ServiceStateTracker extends Handler {
            case EVENT_SIM_READY:
                // Reset the mPreviousSubId so we treat a SIM power bounce
                // as a first boot.  See b/19194287
                mOnSubscriptionsChangedListener.mPreviousSubId.set(-1);
                mOnSubscriptionsChangedListener.mPreviousSubId.set(
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
                mPrevSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
                mIsSimReady = true;
                pollState();
                // Signal strength polling stops when radio is off
@@ -3450,17 +3454,19 @@ 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.
     * Cancels all notifications posted to NotificationManager for this subId. These notifications
     * for restricted state and rejection cause for cs registration are no longer valid after the
     * SIM has been removed.
     */
    private void cancelAllNotifications() {
        if (DBG) log("setNotification: cancelAllNotifications");
        if (DBG) log("cancelAllNotifications: mPrevSubId=" + mPrevSubId);
        NotificationManager notificationManager = (NotificationManager)
                mPhone.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(PS_NOTIFICATION);
        notificationManager.cancel(CS_NOTIFICATION);
        notificationManager.cancel(CS_REJECT_CAUSE_NOTIFICATION);
        if (SubscriptionManager.isValidSubscriptionId(mPrevSubId)) {
            notificationManager.cancel(Integer.toString(mPrevSubId), PS_NOTIFICATION);
            notificationManager.cancel(Integer.toString(mPrevSubId), CS_NOTIFICATION);
            notificationManager.cancel(Integer.toString(mPrevSubId), CS_REJECT_CAUSE_NOTIFICATION);
        }
    }

    /**
@@ -3473,6 +3479,12 @@ public class ServiceStateTracker extends Handler {
    public void setNotification(int notifyType) {
        if (DBG) log("setNotification: create notification " + notifyType);

        if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
            // notifications are posted per-sub-id, so return if current sub-id is invalid
            loge("cannot setNotification on invalid subid mSubId=" + mSubId);
            return;
        }

        // Needed because sprout RIL sends these when they shouldn't?
        boolean isSetNotification = mPhone.getContext().getResources().getBoolean(
                com.android.internal.R.bool.config_user_notification_of_restrictied_mobile_access);
@@ -3550,7 +3562,7 @@ public class ServiceStateTracker extends Handler {

        if (DBG) {
            log("setNotification, create notification, notifyType: " + notifyType
                    + ", title: " + title + ", details: " + details);
                    + ", title: " + title + ", details: " + details + ", subId: " + mSubId);
        }

        mNotification = new Notification.Builder(context)
@@ -3571,10 +3583,10 @@ public class ServiceStateTracker extends Handler {

        if (notifyType == PS_DISABLED || notifyType == CS_DISABLED) {
            // cancel previous post notification
            notificationManager.cancel(notificationId);
            notificationManager.cancel(Integer.toString(mSubId), notificationId);
        } else {
            // update restricted state notification
            notificationManager.notify(notificationId, mNotification);
            // update restricted state notification for this subId
            notificationManager.notify(Integer.toString(mSubId), notificationId, mNotification);
        }
    }