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

Commit d8775100 authored by Chris Wren's avatar Chris Wren
Browse files

Standardize notification IDs in the sysui package.

Use the resource system to assign IDs for notifications,
so that we know there will be no collisions.

Bug: 10671709
Change-Id: I403e89f6ec953f6e2e63520b86e2cd464ebce6b3
parent dbf22ccd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -37,5 +37,8 @@
    <item type="id" name="doze_saved_filter_tag"/>
    <item type="id" name="qs_icon_tag"/>
    <item type="id" name="scrim"/>
    <item type="id" name="notification_power"/>
    <item type="id" name="notification_screenshot"/>
    <item type="id" name="notification_hidden"/>
</resources>
+4 −5
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
    private static final boolean DEBUG = PowerUI.DEBUG;

    private static final String TAG_NOTIFICATION = "low_battery";
    private static final int ID_NOTIFICATION = 100;

    private static final int SHOWING_NOTHING = 0;
    private static final int SHOWING_WARNING = 1;
@@ -145,7 +144,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
            showSaverNotification();
            mShowing = SHOWING_SAVER;
        } else {
            mNoMan.cancelAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, UserHandle.ALL);
            mNoMan.cancelAsUser(TAG_NOTIFICATION, R.id.notification_power, UserHandle.ALL);
            mShowing = SHOWING_NOTHING;
        }
    }
@@ -166,7 +165,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        if (n.headsUpContentView != null) {
            n.headsUpContentView.setViewVisibility(com.android.internal.R.id.right_icon, View.GONE);
        }
        mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, n, UserHandle.ALL);
        mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
    }

    private void showWarningNotification() {
@@ -204,7 +203,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        if (n.headsUpContentView != null) {
            n.headsUpContentView.setViewVisibility(com.android.internal.R.id.right_icon, View.GONE);
        }
        mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, n, UserHandle.ALL);
        mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, n, UserHandle.ALL);
    }

    private void showSaverNotification() {
@@ -221,7 +220,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        if (hasSaverSettings()) {
            nb.setContentIntent(pendingActivity(mOpenSaverSettings));
        }
        mNoMan.notifyAsUser(TAG_NOTIFICATION, ID_NOTIFICATION, nb.build(), UserHandle.ALL);
        mNoMan.notifyAsUser(TAG_NOTIFICATION, R.id.notification_power, nb.build(), UserHandle.ALL);
    }

    private void addStopSaverAction(Notification.Builder nb) {
+2 −3
Original line number Diff line number Diff line
@@ -341,7 +341,6 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
class GlobalScreenshot {
    private static final String TAG = "GlobalScreenshot";

    private static final int SCREENSHOT_NOTIFICATION_ID = 789;
    private static final int SCREENSHOT_FLASH_TO_PEAK_DURATION = 130;
    private static final int SCREENSHOT_DROP_IN_DURATION = 430;
    private static final int SCREENSHOT_DROP_OUT_DELAY = 500;
@@ -464,7 +463,7 @@ class GlobalScreenshot {
            mSaveInBgTask.cancel(false);
        }
        mSaveInBgTask = new SaveImageInBackgroundTask(mContext, data, mNotificationManager,
                SCREENSHOT_NOTIFICATION_ID).execute(data);
                R.id.notification_screenshot).execute(data);
    }

    /**
@@ -731,6 +730,6 @@ class GlobalScreenshot {
            new Notification.BigTextStyle(b)
                .bigText(r.getString(R.string.screenshot_failed_text))
                .build();
        nManager.notify(SCREENSHOT_NOTIFICATION_ID, n);
        nManager.notify(R.id.notification_screenshot, n);
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -140,7 +140,6 @@ public abstract class BaseStatusBar extends SystemUI implements
    public static final int EXPANDED_LEAVE_ALONE = -10000;
    public static final int EXPANDED_FULL_OPEN = -10001;

    private static final int HIDDEN_NOTIFICATION_ID = 10000;
    private static final String BANNER_ACTION_CANCEL =
            "com.android.systemui.statusbar.banner_action_cancel";
    private static final String BANNER_ACTION_SETUP =
@@ -387,7 +386,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            } else if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) {
                NotificationManager noMan = (NotificationManager)
                        mContext.getSystemService(Context.NOTIFICATION_SERVICE);
                noMan.cancel(HIDDEN_NOTIFICATION_ID);
                noMan.cancel(R.id.notification_hidden);

                Settings.Secure.putInt(mContext.getContentResolver(),
                        Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
@@ -658,7 +657,7 @@ public abstract class BaseStatusBar extends SystemUI implements

            NotificationManager noMan =
                    (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
            noMan.notify(HIDDEN_NOTIFICATION_ID, note.build());
            noMan.notify(R.id.notification_hidden, note.build());
        }
    }