diff options
7 files changed, 133 insertions, 48 deletions
diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml index cbac1dc4cf0f..ac1d4424da0f 100644 --- a/packages/SystemUI/res/values/ids.xml +++ b/packages/SystemUI/res/values/ids.xml @@ -40,11 +40,7 @@ <item type="id" name="scrim_target"/> <item type="id" name="scrim_alpha_start"/> <item type="id" name="scrim_alpha_end"/> - <item type="id" name="notification_power"/> - <item type="id" name="notification_screenshot"/> - <item type="id" name="notification_hidden"/> <item type="id" name="notification_volumeui"/> - <item type="id" name="notification_temperature"/> <item type="id" name="transformation_start_x_tag"/> <item type="id" name="transformation_start_y_tag"/> <item type="id" name="transformation_start_scale_x_tag"/> diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java index 4cb40d51ff90..a8ed7a1fe5e7 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java @@ -37,6 +37,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.util.Slog; +import com.android.internal.messages.SystemMessageProto.SystemMessage; import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.statusbar.phone.PhoneStatusBar; @@ -49,8 +50,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { private static final String TAG = PowerUI.TAG + ".Notification"; private static final boolean DEBUG = PowerUI.DEBUG; - private static final String TAG_NOTIFICATION_BATTERY = "low_battery"; - private static final String TAG_NOTIFICATION_TEMPERATURE = "high_temp"; + private static final String TAG_BATTERY = "low_battery"; + private static final String TAG_TEMPERATURE = "high_temp"; private static final int SHOWING_NOTHING = 0; private static final int SHOWING_WARNING = 1; @@ -134,7 +135,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { showWarningNotification(); mShowing = SHOWING_WARNING; } else { - mNoMan.cancelAsUser(TAG_NOTIFICATION_BATTERY, R.id.notification_power, UserHandle.ALL); + mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL); + mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL); mShowing = SHOWING_NOTHING; } } @@ -153,7 +155,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { com.android.internal.R.color.system_notification_accent_color)); SystemUI.overrideNotificationAppName(mContext, nb); final Notification n = nb.build(); - mNoMan.notifyAsUser(TAG_NOTIFICATION_BATTERY, R.id.notification_power, n, UserHandle.ALL); + mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, UserHandle.ALL); + mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, n, UserHandle.ALL); } private void showWarningNotification() { @@ -183,8 +186,9 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { mPlaySound = false; } SystemUI.overrideNotificationAppName(mContext, nb); - mNoMan.notifyAsUser( - TAG_NOTIFICATION_BATTERY, R.id.notification_power, nb.build(), UserHandle.ALL); + final Notification n = nb.build(); + mNoMan.cancelAsUser(TAG_BATTERY, SystemMessage.NOTE_BAD_CHARGER, UserHandle.ALL); + mNoMan.notifyAsUser(TAG_BATTERY, SystemMessage.NOTE_POWER_LOW, n, UserHandle.ALL); } private PendingIntent pendingBroadcast(String action) { @@ -211,8 +215,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { return; } mTempWarning = false; - mNoMan.cancelAsUser( - TAG_NOTIFICATION_TEMPERATURE, R.id.notification_temperature, UserHandle.ALL); + mNoMan.cancelAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, + UserHandle.ALL); } @Override @@ -235,8 +239,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { com.android.internal.R.color.battery_saver_mode_color)); SystemUI.overrideNotificationAppName(mContext, nb); final Notification n = nb.build(); - mNoMan.notifyAsUser( - TAG_NOTIFICATION_TEMPERATURE, R.id.notification_temperature, n, UserHandle.ALL); + mNoMan.notifyAsUser(TAG_TEMPERATURE, SystemMessage.NOTE_HIGH_TEMP, n, UserHandle.ALL); } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index d7894772454d..e7960bdd52dd 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -59,6 +59,7 @@ import android.view.WindowManager; import android.view.animation.Interpolator; import android.widget.ImageView; +import com.android.internal.messages.SystemMessageProto.SystemMessage; import com.android.systemui.R; import com.android.systemui.SystemUI; @@ -201,7 +202,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> { mNotificationBuilder.setFlag(Notification.FLAG_NO_CLEAR, true); SystemUI.overrideNotificationAppName(context, mNotificationBuilder); - mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build()); + mNotificationManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT, + mNotificationBuilder.build()); /** * NOTE: The following code prepares the notification builder for updating the notification @@ -347,7 +349,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> { .setPublicVersion(mPublicNotificationBuilder.build()) .setFlag(Notification.FLAG_NO_CLEAR, false); - mNotificationManager.notify(R.id.notification_screenshot, mNotificationBuilder.build()); + mNotificationManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT, + mNotificationBuilder.build()); } mParams.finisher.run(); mParams.clearContext(); @@ -363,7 +366,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> { mParams.clearContext(); // Cancel the posted notification - mNotificationManager.cancel(R.id.notification_screenshot); + mNotificationManager.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT); } } @@ -865,7 +868,7 @@ class GlobalScreenshot { Notification n = new Notification.BigTextStyle(b) .bigText(errorMsg) .build(); - nManager.notify(R.id.notification_screenshot, n); + nManager.notify(SystemMessage.NOTE_GLOBAL_SCREENSHOT, n); } /** @@ -877,7 +880,7 @@ class GlobalScreenshot { // Clear the notification final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - nm.cancel(R.id.notification_screenshot); + nm.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT); } } @@ -895,7 +898,7 @@ class GlobalScreenshot { final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final Uri uri = Uri.parse(intent.getStringExtra(SCREENSHOT_URI_ID)); - nm.cancel(R.id.notification_screenshot); + nm.cancel(SystemMessage.NOTE_GLOBAL_SCREENSHOT); // And delete the image from the media store new DeleteImageInBackgroundTask(context).execute(uri); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 4866fca05916..8e60df9a956a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -88,6 +88,7 @@ import android.widget.Toast; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsProto.MetricsEvent; +import com.android.internal.messages.SystemMessageProto.SystemMessage; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.StatusBarIcon; import com.android.internal.widget.LockPatternUtils; @@ -547,7 +548,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(R.id.notification_hidden); + noMan.cancel(SystemMessage.NOTE_HIDDEN_NOTIFICATIONS); Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0); @@ -878,7 +879,7 @@ public abstract class BaseStatusBar extends SystemUI implements NotificationManager noMan = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); - noMan.notify(R.id.notification_hidden, note.build()); + noMan.notify(SystemMessage.NOTE_HIDDEN_NOTIFICATIONS, note.build()); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index 27ba003c6ef1..85888a3b2082 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -47,6 +47,7 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import com.android.internal.logging.MetricsProto.MetricsEvent; +import com.android.internal.messages.SystemMessageProto.SystemMessage; import com.android.internal.util.UserIcons; import com.android.settingslib.RestrictedLockUtils; import com.android.systemui.GuestResumeSessionReceiver; @@ -79,8 +80,6 @@ public class UserSwitcherController { private static final String ACTION_LOGOUT_USER = "com.android.systemui.LOGOUT_USER"; private static final int PAUSE_REFRESH_USERS_TIMEOUT_MS = 3000; - private static final int ID_REMOVE_GUEST = 1010; - private static final int ID_LOGOUT_USER = 1011; private static final String TAG_REMOVE_GUEST = "remove_guest"; private static final String TAG_LOGOUT_USER = "logout_user"; @@ -553,8 +552,8 @@ public class UserSwitcherController { mContext.getString(R.string.user_logout_notification_action), logoutPI); SystemUI.overrideNotificationAppName(mContext, builder); - NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER, ID_LOGOUT_USER, - builder.build(), new UserHandle(userId)); + NotificationManager.from(mContext).notifyAsUser(TAG_LOGOUT_USER, + SystemMessage.NOTE_LOGOUT_USER, builder.build(), new UserHandle(userId)); } }; @@ -576,8 +575,8 @@ public class UserSwitcherController { mContext.getString(R.string.guest_notification_remove_action), removeGuestPI); SystemUI.overrideNotificationAppName(mContext, builder); - NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, ID_REMOVE_GUEST, - builder.build(), new UserHandle(guestUserId)); + NotificationManager.from(mContext).notifyAsUser(TAG_REMOVE_GUEST, + SystemMessage.NOTE_REMOVE_GUEST, builder.build(), new UserHandle(guestUserId)); } private final Runnable mUnpauseRefreshUsers = new Runnable() { diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java index 97d5e1078312..25e9bb0cce3d 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java @@ -41,6 +41,7 @@ import android.util.Log; import android.util.SparseArray; import com.android.internal.R; +import com.android.internal.messages.SystemMessageProto.SystemMessage; import com.android.systemui.SystemUI; import java.util.List; @@ -48,11 +49,6 @@ import java.util.List; public class StorageNotification extends SystemUI { private static final String TAG = "StorageNotification"; - private static final int PUBLIC_ID = 0x53505542; // SPUB - private static final int PRIVATE_ID = 0x53505256; // SPRV - private static final int DISK_ID = 0x5344534b; // SDSK - private static final int MOVE_ID = 0x534d4f56; // SMOV - private static final String ACTION_SNOOZE_VOLUME = "com.android.systemui.action.SNOOZE_VOLUME"; private static final String ACTION_FINISH_WIZARD = "com.android.systemui.action.FINISH_WIZARD"; @@ -91,7 +87,8 @@ public class StorageNotification extends SystemUI { @Override public void onVolumeForgotten(String fsUuid) { // Stop annoying the user - mNotificationManager.cancelAsUser(fsUuid, PRIVATE_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE, + UserHandle.ALL); } @Override @@ -119,7 +116,8 @@ public class StorageNotification extends SystemUI { public void onReceive(Context context, Intent intent) { // When finishing the adoption wizard, clean up any notifications // for moving primary storage - mNotificationManager.cancelAsUser(null, MOVE_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(null, SystemMessage.NOTE_STORAGE_MOVE, + UserHandle.ALL); } }; @@ -190,7 +188,8 @@ public class StorageNotification extends SystemUI { final VolumeInfo info = mStorageManager.findVolumeByUuid(fsUuid); if ((info != null && info.isMountedWritable()) || rec.isSnoozed()) { // Yay, private volume is here, or user snoozed - mNotificationManager.cancelAsUser(fsUuid, PRIVATE_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE, + UserHandle.ALL); } else { // Boo, annoy the user to reinsert the private volume @@ -211,8 +210,8 @@ public class StorageNotification extends SystemUI { .setDeleteIntent(buildSnoozeIntent(fsUuid)); SystemUI.overrideNotificationAppName(mContext, builder); - mNotificationManager.notifyAsUser(fsUuid, PRIVATE_ID, builder - .build(), UserHandle.ALL); + mNotificationManager.notifyAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE, + builder.build(), UserHandle.ALL); } } } @@ -237,12 +236,13 @@ public class StorageNotification extends SystemUI { .setCategory(Notification.CATEGORY_ERROR); SystemUI.overrideNotificationAppName(mContext, builder); - mNotificationManager.notifyAsUser(disk.getId(), DISK_ID, builder.build(), - UserHandle.ALL); + mNotificationManager.notifyAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK, + builder.build(), UserHandle.ALL); } else { // Yay, we have volumes! - mNotificationManager.cancelAsUser(disk.getId(), DISK_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK, + UserHandle.ALL); } } @@ -252,7 +252,8 @@ public class StorageNotification extends SystemUI { * @param disk The disk that went away. */ private void onDiskDestroyedInternal(@NonNull DiskInfo disk) { - mNotificationManager.cancelAsUser(disk.getId(), DISK_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK, + UserHandle.ALL); } private void onVolumeStateChangedInternal(VolumeInfo vol) { @@ -308,9 +309,11 @@ public class StorageNotification extends SystemUI { } if (notif != null) { - mNotificationManager.notifyAsUser(vol.getId(), PUBLIC_ID, notif, UserHandle.ALL); + mNotificationManager.notifyAsUser(vol.getId(), SystemMessage.NOTE_STORAGE_PUBLIC, + notif, UserHandle.ALL); } else { - mNotificationManager.cancelAsUser(vol.getId(), PUBLIC_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(vol.getId(), SystemMessage.NOTE_STORAGE_PUBLIC, + UserHandle.ALL); } } @@ -488,7 +491,7 @@ public class StorageNotification extends SystemUI { .setOngoing(true); SystemUI.overrideNotificationAppName(mContext, builder); - mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, + mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE, builder.build(), UserHandle.ALL); } @@ -496,7 +499,8 @@ public class StorageNotification extends SystemUI { if (move.packageName != null) { // We currently ignore finished app moves; just clear the last // published progress - mNotificationManager.cancelAsUser(move.packageName, MOVE_ID, UserHandle.ALL); + mNotificationManager.cancelAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE, + UserHandle.ALL); return; } @@ -537,8 +541,8 @@ public class StorageNotification extends SystemUI { .setAutoCancel(true); SystemUI.overrideNotificationAppName(mContext, builder); - mNotificationManager.notifyAsUser(move.packageName, MOVE_ID, builder.build(), - UserHandle.ALL); + mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE, + builder.build(), UserHandle.ALL); } private int getSmallIcon(DiskInfo disk, int state) { diff --git a/proto/src/system_messages.proto b/proto/src/system_messages.proto new file mode 100644 index 000000000000..5b917761a6f6 --- /dev/null +++ b/proto/src/system_messages.proto @@ -0,0 +1,79 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +option java_package = "com.android.internal.messages"; +option java_outer_classname = "SystemMessageProto"; + +package com_android_notifications; + +// Descriptors for system messages: notifications, dialogs, toasts, etc. +message SystemMessage { + + // System message IDs + // These are non-consecutive in order to preserve some existing, ad hoc IDs. + enum ID { + // Unknown + NOTE_UNKNOWN = 0; + + // Notify the user that a screenshot was captured. + // Package: com.android.systemui + NOTE_GLOBAL_SCREENSHOT = 1; + + // Warn the user about an invalid charger. + // Package: com.android.systemui + NOTE_BAD_CHARGER = 2; + + // Warn the user about low battery. + // Package: com.android.systemui + NOTE_POWER_LOW = 3; + + // Warn the user that the device has gotten warm. + // Package: com.android.systemui + NOTE_HIGH_TEMP = 4; + + // Warn the user that some notifications are hidden. + // Package: com.android.systemui + NOTE_HIDDEN_NOTIFICATIONS = 5; + + // Notify the user of a problem with a plugin (dev devices only). + // Package: com.android.systemui + NOTE_PLUGIN = 6; + + // Confirm that the user wants to remove the guest account. + // Package: com.android.systemui + NOTE_REMOVE_GUEST = 1010; + + // Confirm that the user wants to log out of the device. + // Package: com.android.systemui + NOTE_LOGOUT_USER = 1011; + + // Notify the user about public volume state changes.. + // Package: com.android.systemui + NOTE_STORAGE_PUBLIC = 0x53505542; + + // Notify the user about private volume state changes. + // Package: com.android.systemui + NOTE_STORAGE_PRIVATE = 0x53505256; + + // Notify the user about an unsupported storage device.. + // Package: com.android.systemui + NOTE_STORAGE_DISK = 0x5344534b; + + // Notify the user that data or apps are being moved to external storage. + // Package: com.android.systemui + NOTE_STORAGE_MOVE = 0x534d4f56; + } +} |