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

Commit afd03aad authored by Thomas Stuart's avatar Thomas Stuart
Browse files

make silence emergency nofitication broadcast protected

A user reported the Emergency Calling Wifi Notification kept
popping up and the Do Not Ask Again button was not working.

Upon inspection, the ActivityManager was blocking the broadcast
action because the broadcast was not protected.  Also, the
notification should be dismissed when clicked.

Flag: com.android.internal.telephony.flags.stop_spamming_emergency_notification
Bug: 368690328
Test: manual
Change-Id: I57c606947cac5927c16e4d4af3d18a310b51ed46
parent 8a5b42bd
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -75,7 +75,8 @@ public class CarrierServiceStateTracker extends Handler {


    @VisibleForTesting
    public static final String ACTION_NEVER_ASK_AGAIN = "SilenceNoWifiEmrgCallingNotification";
    public static final String ACTION_NEVER_ASK_AGAIN =
            "com.android.internal.telephony.action.SILENCE_WIFI_CALLING_NOTIFICATION";
    public final NotificationActionReceiver mActionReceiver = new NotificationActionReceiver();

    @VisibleForTesting
@@ -733,6 +734,7 @@ public class CarrierServiceStateTracker extends Handler {
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(ACTION_NEVER_ASK_AGAIN)) {
                Rlog.i(LOG_TAG, "NotificationActionReceiver: ACTION_NEVER_ASK_AGAIN");
                dismissEmergencyCallingNotification();
                // insert a key to silence future notifications
                SharedPreferences.Editor editor =
                        PreferenceManager.getDefaultSharedPreferences(context).edit();
@@ -743,5 +745,22 @@ public class CarrierServiceStateTracker extends Handler {
                context.unregisterReceiver(mActionReceiver);
            }
        }

        /**
         * Dismiss the notification when the "Do Not Ask Again" button is clicked
         */
        private void dismissEmergencyCallingNotification() {
            if (!mFeatureFlags.stopSpammingEmergencyNotification()) {
                return;
            }
            try {
                NotificationType t = mNotificationTypeMap.get(NOTIFICATION_EMERGENCY_NETWORK);
                if (t != null) {
                    cancelNotification(t);
                }
            } catch (Exception e) {
                Rlog.e(LOG_TAG, "dismissEmergencyCallingNotification", e);
            }
        }
    }
}