summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Wren <cwren@android.com> 2017-03-27 15:01:44 -0400
committer Chris Wren <cwren@android.com> 2017-03-31 11:44:05 -0400
commit282cfefea0fbbd299839e353e6d30affdcd4a55c (patch)
treeef3c5e95aa4f517f0fb9a9bf7f60aaad4dc7b456
parent474662da390937a95ed2e3b3acdae00c92be47d8 (diff)
standardize system notification IDs
All the trivial cases, plus some fixes to try to mitigate collisions with the complex ones. Complex services to follow in another CL, Bug: 32584866 Test: make framework services Change-Id: Ie9663600171d8ede11676e9d66f009dbb06def03
-rw-r--r--proto/src/system_messages.proto119
-rw-r--r--services/core/java/com/android/server/InputMethodManagerService.java5
-rw-r--r--services/core/java/com/android/server/LockSettingsService.java8
-rw-r--r--services/core/java/com/android/server/UiModeManagerService.java5
-rw-r--r--services/core/java/com/android/server/accounts/AccountManagerService.java4
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java7
-rw-r--r--services/core/java/com/android/server/am/PreBootBroadcaster.java7
-rw-r--r--services/core/java/com/android/server/connectivity/Tethering.java26
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java4
-rw-r--r--services/core/java/com/android/server/content/SyncManager.java10
-rw-r--r--services/core/java/com/android/server/input/InputManagerService.java5
-rw-r--r--services/core/java/com/android/server/net/LockdownVpnTracker.java6
-rw-r--r--services/core/java/com/android/server/pm/PackageInstallerService.java9
-rw-r--r--services/core/java/com/android/server/storage/DeviceStorageMonitorService.java7
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java3
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java12
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java3
-rw-r--r--services/retaildemo/java/com/android/server/retaildemo/RetailDemoModeService.java6
-rw-r--r--services/usb/java/com/android/server/usb/MtpNotificationManager.java7
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java38
20 files changed, 231 insertions, 60 deletions
diff --git a/proto/src/system_messages.proto b/proto/src/system_messages.proto
index 74f5cf5b41c6..97099df0829a 100644
--- a/proto/src/system_messages.proto
+++ b/proto/src/system_messages.proto
@@ -24,6 +24,9 @@ message SystemMessage {
// System message IDs
// These are non-consecutive in order to preserve some existing, ad hoc IDs.
+ // It is OK to use skipped IDs.
+ // Prefer to add new IDs consecutively from zero, search for ADD_NEW_IDS_ABOVE_THIS_LINE.
+ // Most of these IDs only became meaningful with the O release.
enum ID {
// Unknown
NOTE_UNKNOWN = 0;
@@ -56,6 +59,112 @@ message SystemMessage {
// Package: com.android.systemui
NOTE_INSTANT_APPS = 7;
+ // Notify the user that they should select an input method
+ // Package: android
+ NOTE_SELECT_INPUT_METHOD = 8;
+
+ // Notify the user about limited functionality before decryption
+ // Package: android
+ NOTE_FBE_ENCRYPTED_NOTIFICATION = 9;
+
+ // Give the user a way out of car mode
+ // Package: android
+ NOTE_CAR_MODE_DISABLE = 10;
+
+ // Notification to tell the user that a heavy-weight application is running.
+ // Package: android
+ NOTE_HEAVY_WEIGHT_NOTIFICATION = 11;
+
+ // Notification to tell the user that a process has exceeded its memory limit.
+ // Package: android
+ NOTE_DUMP_HEAP_NOTIFICATION = 12;
+
+ // Notification that is shown when finishing a system upgrade
+ // Package: android
+ NOTE_SYSTEM_UPGRADING = 13;
+
+ // Notify the user that tethering is active.
+ // Package: android
+ NOTE_TETHER_GENERAL = 14;
+ NOTE_TETHER_USB = 15;
+ NOTE_TETHER_BLUETOOTH = 16;
+
+ // Notify the user that always-on VPN has disconnected.
+ // Package: android
+ NOTE_VPN_DISCONNECTED = 17;
+
+ // Notify the user about a sync error.
+ // Package: android
+ NOTE_SYNC_ERROR = 18;
+
+ // Ask the user to select a keyboard language and layout
+ // Package: android
+ NOTE_SELECT_KEYBOARD_LAYOUT = 19;
+
+ // Update the user about the status of the VPN
+ // Package: android
+ NOTE_VPN_STATUS = 20;
+
+ // Package manager either installed or deleted a package
+ // Package: android
+ NOTE_PACKAGE_STATE = 21;
+
+ // Tell the user that storage space is low
+ // Package: android
+ NOTE_LOW_STORAGE = 23;
+
+ // Confirm that the user wants to reset out of retail demo mode
+ // Package: android
+ NOTE_RETAIL_RESET = 24;
+
+ // Entice the use to tap to share files
+ // Package: android
+ NOTE_USB_MTP_TAP = 25;
+
+ // Display the Android Debug Protocol status
+ // Package: android
+ NOTE_ADB_ACTIVE = 26;
+
+ // Inform that USB is configured for Media Transfer Protocol
+ // Package: android
+ NOTE_USB_MTP = 27;
+
+ // Inform that USB is configured for Picture Transfer Protocol
+ // Package: android
+ NOTE_USB_PTP = 28;
+
+ // Inform that USB is configured as a Musical Instrument Digital Interface
+ // Package: android
+ NOTE_USB_MIDI = 29;
+
+ // Inform that USB is configured in host mode
+ // Package: android
+ NOTE_USB_ACCESSORY = 30;
+
+ // Inform the user that the device is supplying power to another device.
+ // Package: android
+ NOTE_USB_SUPPLYING = 31;
+
+ // Inform the user that the device is consuming power from another device.
+ // Package: android
+ NOTE_USB_CHARGING = 32;
+
+ // Inform the user that a certificate authority is managing SSL
+ // Package: android
+ NOTE_SSL_CERT_INFO = 33;
+
+ // ADD_NEW_IDS_ABOVE_THIS_LINE
+ // Legacy IDs with arbitrary values appear below
+ // Legacy IDs existed as stable non-conflicting constants prior to the O release
+
+ // Notify the user that their work profile has been deleted
+ // Package: android
+ NOTE_PROFILE_WIPED = 1001;
+
+ // Warn the user that their org can monitor the network
+ // Package: android
+ NOTE_NETWORK_LOGGING = 1002;
+
// Confirm that the user wants to remove the guest account.
// Package: com.android.systemui
NOTE_REMOVE_GUEST = 1010;
@@ -64,9 +173,13 @@ message SystemMessage {
// Package: com.android.systemui
NOTE_LOGOUT_USER = 1011;
+ // Communicate to the user about remote bugreports.
+ // Package: android
+ NOTE_REMOTE_BUGREPORT = 678432343;
+
// Notify the user about public volume state changes..
// Package: com.android.systemui
- NOTE_STORAGE_PUBLIC = 0x53505542;
+ NOTE_STORAGE_PUBLIC = 0x53505542; // 1397773634
// Notify the user about private volume state changes.
// Package: com.android.systemui
@@ -79,5 +192,9 @@ message SystemMessage {
// Notify the user that data or apps are being moved to external storage.
// Package: com.android.systemui
NOTE_STORAGE_MOVE = 0x534d4f56;
+
+ // Account Manager allocates IDs sequentially, starting here.
+ // Package: android
+ ACCOUNT_MANAGER_BASE = 0x70000000;
}
}
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 69e481fc9e1c..c5f9599ac816 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -28,6 +28,7 @@ import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController;
import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem;
import com.android.internal.inputmethod.InputMethodUtils;
import com.android.internal.inputmethod.InputMethodUtils.InputMethodSettings;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.HandlerCaller;
import com.android.internal.os.SomeArgs;
@@ -2192,7 +2193,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Slog.d(TAG, "--- show notification: label = " + summary);
}
mNotificationManager.notifyAsUser(null,
- com.android.internal.R.string.select_input_method,
+ SystemMessage.NOTE_SELECT_INPUT_METHOD,
mImeSwitcherNotification.build(), UserHandle.ALL);
mNotificationShown = true;
}
@@ -2204,7 +2205,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
Slog.d(TAG, "--- hide notification");
}
mNotificationManager.cancelAsUser(null,
- com.android.internal.R.string.select_input_method, UserHandle.ALL);
+ SystemMessage.NOTE_SELECT_INPUT_METHOD, UserHandle.ALL);
mNotificationShown = false;
}
}
diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java
index c0d11071cc89..6f3ff10e306c 100644
--- a/services/core/java/com/android/server/LockSettingsService.java
+++ b/services/core/java/com/android/server/LockSettingsService.java
@@ -76,6 +76,7 @@ import android.util.Log;
import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.ICheckCredentialProgressCallback;
@@ -127,7 +128,6 @@ import javax.crypto.spec.GCMParameterSpec;
public class LockSettingsService extends ILockSettings.Stub {
private static final String TAG = "LockSettingsService";
private static final String PERMISSION = ACCESS_KEYGUARD_SECURE_STORAGE;
- private static final int FBE_ENCRYPTED_NOTIFICATION = 0;
private static final boolean DEBUG = false;
private static final int PROFILE_KEY_IV_SIZE = 12;
@@ -461,12 +461,14 @@ public class LockSettingsService extends ILockSettings.Stub {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setContentIntent(intent)
.build();
- mNotificationManager.notifyAsUser(null, FBE_ENCRYPTED_NOTIFICATION, notification, user);
+ mNotificationManager.notifyAsUser(null, SystemMessage.NOTE_FBE_ENCRYPTED_NOTIFICATION,
+ notification, user);
}
private void hideEncryptionNotification(UserHandle userHandle) {
if (DEBUG) Slog.v(TAG, "hide encryption notification, user: " + userHandle.getIdentifier());
- mNotificationManager.cancelAsUser(null, FBE_ENCRYPTED_NOTIFICATION, userHandle);
+ mNotificationManager.cancelAsUser(null, SystemMessage.NOTE_FBE_ENCRYPTED_NOTIFICATION,
+ userHandle);
}
public void onCleanupUser(int userId) {
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java
index e4f468732686..227e2a2ac3e4 100644
--- a/services/core/java/com/android/server/UiModeManagerService.java
+++ b/services/core/java/com/android/server/UiModeManagerService.java
@@ -58,6 +58,7 @@ import java.util.Collections;
import com.android.internal.R;
import com.android.internal.app.DisableCarModeActivity;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.server.power.ShutdownThread;
import com.android.server.twilight.TwilightListener;
@@ -710,10 +711,10 @@ final class UiModeManagerService extends SystemService {
PendingIntent.getActivityAsUser(context, 0, carModeOffIntent, 0,
null, UserHandle.CURRENT));
mNotificationManager.notifyAsUser(null,
- R.string.car_mode_disable_notification_title, n.build(), UserHandle.ALL);
+ SystemMessage.NOTE_CAR_MODE_DISABLE, n.build(), UserHandle.ALL);
} else {
mNotificationManager.cancelAsUser(null,
- R.string.car_mode_disable_notification_title, UserHandle.ALL);
+ SystemMessage.NOTE_CAR_MODE_DISABLE, UserHandle.ALL);
}
}
}
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index 625e4a5d9b20..847574b8df0d 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -89,6 +89,7 @@ import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.content.PackageMonitor;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.IndentingPrintWriter;
@@ -189,7 +190,8 @@ public class AccountManagerService
}
private final LinkedHashMap<String, Session> mSessions = new LinkedHashMap<String, Session>();
- private final AtomicInteger mNotificationIds = new AtomicInteger(1);
+ private final AtomicInteger mNotificationIds =
+ new AtomicInteger(SystemMessage.ACCOUNT_MANAGER_BASE);
static class UserAccounts {
private final int userId;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index b4da152a18ae..a5484ff2c23d 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -339,6 +339,7 @@ import com.android.internal.app.SystemUserHomeActivity;
import com.android.internal.app.procstats.ProcessStats;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.os.BackgroundThread;
import com.android.internal.os.BatteryStatsImpl;
import com.android.internal.os.IResultReceiver;
@@ -2121,7 +2122,7 @@ public class ActivityManagerService extends IActivityManager.Stub
try {
int[] outId = new int[1];
inm.enqueueNotificationWithTag("android", "android", null,
- R.string.heavy_weight_notification,
+ SystemMessage.NOTE_HEAVY_WEIGHT_NOTIFICATION,
notification, outId, root.userId);
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
@@ -2139,7 +2140,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
try {
inm.cancelNotificationWithTag("android", null,
- R.string.heavy_weight_notification, msg.arg1);
+ SystemMessage.NOTE_HEAVY_WEIGHT_NOTIFICATION, msg.arg1);
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
"Error canceling notification for service", e);
@@ -2376,7 +2377,7 @@ public class ActivityManagerService extends IActivityManager.Stub
try {
int[] outId = new int[1];
inm.enqueueNotificationWithTag("android", "android", null,
- R.string.dump_heap_notification,
+ SystemMessage.NOTE_DUMP_HEAP_NOTIFICATION,
notification, outId, userId);
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
diff --git a/services/core/java/com/android/server/am/PreBootBroadcaster.java b/services/core/java/com/android/server/am/PreBootBroadcaster.java
index e0d3abd03988..3ea114758498 100644
--- a/services/core/java/com/android/server/am/PreBootBroadcaster.java
+++ b/services/core/java/com/android/server/am/PreBootBroadcaster.java
@@ -35,6 +35,7 @@ import android.os.UserHandle;
import android.util.Slog;
import com.android.internal.R;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.ProgressReporter;
import com.android.server.UiThread;
@@ -159,11 +160,13 @@ public abstract class PreBootBroadcaster extends IIntentReceiver.Stub {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setProgress(max, index, false)
.build();
- notifManager.notifyAsUser(TAG, 0, notif, UserHandle.of(mUserId));
+ notifManager.notifyAsUser(TAG, SystemMessage.NOTE_SYSTEM_UPGRADING, notif,
+ UserHandle.of(mUserId));
break;
case MSG_HIDE:
- notifManager.cancelAsUser(TAG, 0, UserHandle.of(mUserId));
+ notifManager.cancelAsUser(TAG, SystemMessage.NOTE_SYSTEM_UPGRADING,
+ UserHandle.of(mUserId));
break;
}
}
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index be770a36c3de..07ab0671c926 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -66,6 +66,7 @@ import android.util.Log;
import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
@@ -618,30 +619,43 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
if (usbTethered) {
if (wifiTethered || bluetoothTethered) {
- showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_general);
+ showTetheredNotification(SystemMessage.NOTE_TETHER_GENERAL);
} else {
- showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_usb);
+ showTetheredNotification(SystemMessage.NOTE_TETHER_USB);
}
} else if (wifiTethered) {
if (bluetoothTethered) {
- showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_general);
+ showTetheredNotification(SystemMessage.NOTE_TETHER_GENERAL);
} else {
/* We now have a status bar icon for WifiTethering, so drop the notification */
clearTetheredNotification();
}
} else if (bluetoothTethered) {
- showTetheredNotification(com.android.internal.R.drawable.stat_sys_tether_bluetooth);
+ showTetheredNotification(SystemMessage.NOTE_TETHER_BLUETOOTH);
} else {
clearTetheredNotification();
}
}
- private void showTetheredNotification(int icon) {
+ private void showTetheredNotification(int id) {
NotificationManager notificationManager =
(NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager == null) {
return;
}
+ int icon = 0;
+ switch(id) {
+ case SystemMessage.NOTE_TETHER_USB:
+ icon = com.android.internal.R.drawable.stat_sys_tether_usb;
+ break;
+ case SystemMessage.NOTE_TETHER_BLUETOOTH:
+ icon = com.android.internal.R.drawable.stat_sys_tether_bluetooth;
+ break;
+ case SystemMessage.NOTE_TETHER_GENERAL:
+ default:
+ icon = com.android.internal.R.drawable.stat_sys_tether_general;
+ break;
+ }
if (mLastNotificationId != 0) {
if (mLastNotificationId == icon) {
@@ -678,7 +692,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
.setContentTitle(title)
.setContentText(message)
.setContentIntent(pi);
- mLastNotificationId = icon;
+ mLastNotificationId = id;
notificationManager.notifyAsUser(null, mLastNotificationId,
mTetheredNotificationBuilder.build(), UserHandle.ALL);
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 9fc2fc7bb31e..2eb555754732 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -81,6 +81,7 @@ import android.util.Log;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnInfo;
@@ -1304,7 +1305,8 @@ public class Vpn {
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setOngoing(true)
.setColor(mContext.getColor(R.color.system_notification_accent_color));
- notificationManager.notifyAsUser(TAG, 0, builder.build(), user);
+ notificationManager.notifyAsUser(TAG, SystemMessage.NOTE_VPN_DISCONNECTED,
+ builder.build(), user);
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 1a27a39bd1bf..150453854450 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -81,6 +81,7 @@ import android.util.Log;
import android.util.Pair;
import android.util.Slog;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.ArrayUtils;
import com.android.server.LocalServices;
@@ -3169,8 +3170,9 @@ public class SyncManager {
info.provider, syncResult.stats.numDeletes,
info.userId);
} else {
- mNotificationMgr.cancelAsUser(null,
- info.account.hashCode() ^ info.provider.hashCode(),
+ mNotificationMgr.cancelAsUser(
+ Integer.toString(info.account.hashCode() ^ info.provider.hashCode()),
+ SystemMessage.NOTE_SYNC_ERROR,
new UserHandle(info.userId));
}
if (syncResult != null && syncResult.fullSyncRequested) {
@@ -3270,7 +3272,9 @@ public class SyncManager {
.setContentIntent(pendingIntent)
.build();
notification.flags |= Notification.FLAG_ONGOING_EVENT;
- mNotificationMgr.notifyAsUser(null, account.hashCode() ^ authority.hashCode(),
+ mNotificationMgr.notifyAsUser(
+ Integer.toString(account.hashCode() ^ authority.hashCode()),
+ SystemMessage.NOTE_SYNC_ERROR,
notification, user);
}
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 297d5bd1afc9..65a46042f9b8 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -23,6 +23,7 @@ import android.os.ShellCallback;
import android.util.Log;
import android.view.Display;
import com.android.internal.inputmethod.InputMethodSubtypeHandle;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.SomeArgs;
import com.android.internal.R;
@@ -986,7 +987,7 @@ public class InputManagerService extends IInputManager.Stub
com.android.internal.R.color.system_notification_accent_color))
.build();
mNotificationManager.notifyAsUser(null,
- R.string.select_keyboard_layout_notification_title,
+ SystemMessage.NOTE_SELECT_KEYBOARD_LAYOUT,
notification, UserHandle.ALL);
mKeyboardLayoutNotificationShown = true;
}
@@ -997,7 +998,7 @@ public class InputManagerService extends IInputManager.Stub
if (mKeyboardLayoutNotificationShown) {
mKeyboardLayoutNotificationShown = false;
mNotificationManager.cancelAsUser(null,
- R.string.select_keyboard_layout_notification_title,
+ SystemMessage.NOTE_SELECT_KEYBOARD_LAYOUT,
UserHandle.ALL);
}
}
diff --git a/services/core/java/com/android/server/net/LockdownVpnTracker.java b/services/core/java/com/android/server/net/LockdownVpnTracker.java
index a5e7d7c7b945..5eb12770c726 100644
--- a/services/core/java/com/android/server/net/LockdownVpnTracker.java
+++ b/services/core/java/com/android/server/net/LockdownVpnTracker.java
@@ -45,6 +45,7 @@ import android.text.TextUtils;
import android.util.Slog;
import com.android.internal.R;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile;
import com.android.internal.notification.SystemNotificationChannels;
@@ -344,10 +345,11 @@ public class LockdownVpnTracker {
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color));
- NotificationManager.from(mContext).notify(TAG, 0, builder.build());
+ NotificationManager.from(mContext).notify(null, SystemMessage.NOTE_VPN_STATUS,
+ builder.build());
}
private void hideNotification() {
- NotificationManager.from(mContext).cancel(TAG, 0);
+ NotificationManager.from(mContext).cancel(null, SystemMessage.NOTE_VPN_STATUS);
}
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index a317ca52abb5..132ea2b91a47 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -88,6 +88,7 @@ import libcore.io.IoUtils;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.content.PackageHelper;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.ImageUtils;
@@ -995,7 +996,9 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
if (PackageManager.DELETE_SUCCEEDED == returnCode && mNotification != null) {
NotificationManager notificationManager = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(basePackageName, 0, mNotification);
+ notificationManager.notify(basePackageName,
+ SystemMessage.NOTE_PACKAGE_STATE,
+ mNotification);
}
final Intent fillIn = new Intent();
fillIn.putExtra(PackageInstaller.EXTRA_PACKAGE_NAME, mPackageName);
@@ -1054,7 +1057,9 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
if (notification != null) {
NotificationManager notificationManager = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(basePackageName, 0, notification);
+ notificationManager.notify(basePackageName,
+ SystemMessage.NOTE_PACKAGE_STATE,
+ notification);
}
}
final Intent fillIn = new Intent();
diff --git a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
index ba160bac650c..a847a3c43dfb 100644
--- a/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
+++ b/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
@@ -17,6 +17,8 @@
package com.android.server.storage;
import android.app.NotificationChannel;
+
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.server.EventLogTags;
import com.android.server.SystemService;
@@ -93,7 +95,6 @@ public class DeviceStorageMonitorService extends SystemService {
static final int DEVICE_MEMORY_WHAT = 1;
static final int FORCE_MEMORY_WHAT = 2;
private static final int MONITOR_INTERVAL = 1; //in minutes
- private static final int LOW_MEMORY_NOTIFICATION_ID = 1;
private static final int DEFAULT_FREE_STORAGE_LOG_INTERVAL_IN_MINUTES = 12*60; //in minutes
private static final long DEFAULT_DISK_FREE_CHANGE_REPORTING_THRESHOLD = 2 * 1024 * 1024; // 2MB
@@ -669,7 +670,7 @@ public class DeviceStorageMonitorService extends SystemService {
.setChannel(TV_NOTIFICATION_CHANNEL_ID))
.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
- notificationMgr.notifyAsUser(null, LOW_MEMORY_NOTIFICATION_ID, notification,
+ notificationMgr.notifyAsUser(null, SystemMessage.NOTE_LOW_STORAGE, notification,
UserHandle.ALL);
Intent broadcast = new Intent(mStorageLowIntent);
if (seq != 0) {
@@ -688,7 +689,7 @@ public class DeviceStorageMonitorService extends SystemService {
(NotificationManager)context.getSystemService(
Context.NOTIFICATION_SERVICE);
//cancel notification since memory has been freed
- mNotificationMgr.cancelAsUser(null, LOW_MEMORY_NOTIFICATION_ID, UserHandle.ALL);
+ mNotificationMgr.cancelAsUser(null, SystemMessage.NOTE_LOW_STORAGE, UserHandle.ALL);
context.removeStickyBroadcastAsUser(mStorageLowIntent, UserHandle.ALL);
Intent broadcast = new Intent(mStorageOkIntent);
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java b/services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java
index a2bc19586995..4a456f720db3 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/CertificateMonitor.java
@@ -39,6 +39,7 @@ import android.security.KeyChain;
import android.security.KeyChain.KeyChainConnection;
import android.util.Log;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.R;
@@ -52,7 +53,7 @@ import java.util.Set;
public class CertificateMonitor {
protected static final String LOG_TAG = DevicePolicyManagerService.LOG_TAG;
- protected static final int MONITORING_CERT_NOTIFICATION_ID = R.plurals.ssl_ca_cert_warning;
+ protected static final int MONITORING_CERT_NOTIFICATION_ID = SystemMessage.NOTE_SSL_CERT_INFO;
private final DevicePolicyManagerService mService;
private final DevicePolicyManagerService.Injector mInjector;
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index ab86966334c3..db7c99ea4480 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -165,6 +165,7 @@ import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.BackgroundThread;
import com.android.internal.statusbar.IStatusBarService;
@@ -261,9 +262,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
private static final String ACTION_EXPIRED_PASSWORD_NOTIFICATION
= "com.android.server.ACTION_EXPIRED_PASSWORD_NOTIFICATION";
- private static final int PROFILE_WIPED_NOTIFICATION_ID = 1001;
- private static final int NETWORK_LOGGING_NOTIFICATION_ID = 1002;
-
private static final String ATTR_PERMISSION_PROVIDER = "permission-provider";
private static final String ATTR_SETUP_COMPLETE = "setup-complete";
private static final String ATTR_PROVISIONING_STATE = "provisioning-state";
@@ -5301,11 +5299,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
.setColor(mContext.getColor(R.color.system_notification_accent_color))
.setStyle(new Notification.BigTextStyle().bigText(contentText))
.build();
- mInjector.getNotificationManager().notify(PROFILE_WIPED_NOTIFICATION_ID, notification);
+ mInjector.getNotificationManager().notify(SystemMessage.NOTE_PROFILE_WIPED, notification);
}
private void clearWipeProfileNotification() {
- mInjector.getNotificationManager().cancel(PROFILE_WIPED_NOTIFICATION_ID);
+ mInjector.getNotificationManager().cancel(SystemMessage.NOTE_PROFILE_WIPED);
}
@Override
@@ -10624,7 +10622,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
+ " service not being available yet.");
}
mNetworkLogger = null;
- mInjector.getNotificationManager().cancel(NETWORK_LOGGING_NOTIFICATION_ID);
+ mInjector.getNotificationManager().cancel(SystemMessage.NOTE_NETWORK_LOGGING);
}
} finally {
mInjector.binderRestoreCallingIdentity(callingIdentity);
@@ -10751,7 +10749,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
.setStyle(new Notification.BigTextStyle()
.bigText(mContext.getString(R.string.network_logging_notification_text)))
.build();
- mInjector.getNotificationManager().notify(NETWORK_LOGGING_NOTIFICATION_ID, notification);
+ mInjector.getNotificationManager().notify(SystemMessage.NOTE_NETWORK_LOGGING, notification);
saveSettingsLocked(mOwners.getDeviceOwnerUserId());
}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java b/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java
index 969c89eb4029..344077cce06e 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java
@@ -28,6 +28,7 @@ import android.provider.Settings;
import android.text.format.DateUtils;
import com.android.internal.R;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import java.lang.annotation.Retention;
@@ -38,7 +39,7 @@ import java.lang.annotation.RetentionPolicy;
*/
class RemoteBugreportUtils {
- static final int NOTIFICATION_ID = 678432343;
+ static final int NOTIFICATION_ID = SystemMessage.NOTE_REMOTE_BUGREPORT;
@Retention(RetentionPolicy.SOURCE)
@IntDef({
diff --git a/services/retaildemo/java/com/android/server/retaildemo/RetailDemoModeService.java b/services/retaildemo/java/com/android/server/retaildemo/RetailDemoModeService.java
index 43c38a6422a4..d9a937aa5a40 100644
--- a/services/retaildemo/java/com/android/server/retaildemo/RetailDemoModeService.java
+++ b/services/retaildemo/java/com/android/server/retaildemo/RetailDemoModeService.java
@@ -61,6 +61,8 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.KeyValueListParser;
import android.util.Slog;
+
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.BackgroundThread;
import com.android.internal.R;
@@ -621,8 +623,8 @@ public class RetailDemoModeService extends SystemService {
if (!mIsCarrierDemoMode) {
// Show reset notification (except in carrier demo mode).
- mInjector.getNotificationManager().notifyAsUser(TAG,
- 1, mInjector.createResetNotification(), UserHandle.of(userId));
+ mInjector.getNotificationManager().notifyAsUser(TAG, SystemMessage.NOTE_RETAIL_RESET,
+ mInjector.createResetNotification(), UserHandle.of(userId));
synchronized (mActivityLock) {
mUserUntouched = true;
diff --git a/services/usb/java/com/android/server/usb/MtpNotificationManager.java b/services/usb/java/com/android/server/usb/MtpNotificationManager.java
index db7b3853d06e..462ee19124ff 100644
--- a/services/usb/java/com/android/server/usb/MtpNotificationManager.java
+++ b/services/usb/java/com/android/server/usb/MtpNotificationManager.java
@@ -31,6 +31,7 @@ import android.hardware.usb.UsbInterface;
import android.hardware.usb.UsbManager;
import android.os.UserHandle;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
/**
@@ -101,11 +102,13 @@ class MtpNotificationManager {
notification.flags |= Notification.FLAG_LOCAL_ONLY;
mContext.getSystemService(NotificationManager.class).notify(
- TAG, device.getDeviceId(), notification);
+ Integer.toString(device.getDeviceId()), SystemMessage.NOTE_USB_MTP_TAP,
+ notification);
}
void hideNotification(int deviceId) {
- mContext.getSystemService(NotificationManager.class).cancel(TAG, deviceId);
+ mContext.getSystemService(NotificationManager.class).cancel(
+ Integer.toString(deviceId), SystemMessage.NOTE_USB_MTP_TAP);
}
private class Receiver extends BroadcastReceiver {
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index d69f933d1fe9..32530561ba43 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -51,6 +51,7 @@ import android.util.Pair;
import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.IndentingPrintWriter;
@@ -60,8 +61,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Scanner;
@@ -946,35 +945,46 @@ public class UsbDeviceManager {
return;
}
int id = 0;
+ int titleRes = 0;
Resources r = mContext.getResources();
if (mConnected) {
if (!mUsbDataUnlocked) {
if (mSourcePower) {
- id = com.android.internal.R.string.usb_supplying_notification_title;
+ titleRes = com.android.internal.R.string.usb_supplying_notification_title;
+ id = SystemMessage.NOTE_USB_SUPPLYING;
} else {
- id = com.android.internal.R.string.usb_charging_notification_title;
+ titleRes = com.android.internal.R.string.usb_charging_notification_title;
+ id = SystemMessage.NOTE_USB_CHARGING;
}
} else if (UsbManager.containsFunction(mCurrentFunctions,
UsbManager.USB_FUNCTION_MTP)) {
- id = com.android.internal.R.string.usb_mtp_notification_title;
+ titleRes = com.android.internal.R.string.usb_mtp_notification_title;
+ id = SystemMessage.NOTE_USB_MTP;
} else if (UsbManager.containsFunction(mCurrentFunctions,
UsbManager.USB_FUNCTION_PTP)) {
- id = com.android.internal.R.string.usb_ptp_notification_title;
+ titleRes = com.android.internal.R.string.usb_ptp_notification_title;
+ id = SystemMessage.NOTE_USB_PTP;
} else if (UsbManager.containsFunction(mCurrentFunctions,
UsbManager.USB_FUNCTION_MIDI)) {
- id = com.android.internal.R.string.usb_midi_notification_title;
+ titleRes = com.android.internal.R.string.usb_midi_notification_title;
+ id = SystemMessage.NOTE_USB_MIDI;
} else if (UsbManager.containsFunction(mCurrentFunctions,
UsbManager.USB_FUNCTION_ACCESSORY)) {
- id = com.android.internal.R.string.usb_accessory_notification_title;
+ titleRes = com.android.internal.R.string.usb_accessory_notification_title;
+ id = SystemMessage.NOTE_USB_ACCESSORY;
} else if (mSourcePower) {
- id = com.android.internal.R.string.usb_supplying_notification_title;
+ titleRes = com.android.internal.R.string.usb_supplying_notification_title;
+ id = SystemMessage.NOTE_USB_SUPPLYING;
} else {
- id = com.android.internal.R.string.usb_charging_notification_title;
+ titleRes = com.android.internal.R.string.usb_charging_notification_title;
+ id = SystemMessage.NOTE_USB_CHARGING;
}
} else if (mSourcePower) {
- id = com.android.internal.R.string.usb_supplying_notification_title;
+ titleRes = com.android.internal.R.string.usb_supplying_notification_title;
+ id = SystemMessage.NOTE_USB_SUPPLYING;
} else if (mHostConnected && mSinkPower && mUsbCharging) {
- id = com.android.internal.R.string.usb_charging_notification_title;
+ titleRes = com.android.internal.R.string.usb_charging_notification_title;
+ id = SystemMessage.NOTE_USB_CHARGING;
}
if (id != mUsbNotificationId) {
// clear notification if title needs changing
@@ -986,7 +996,7 @@ public class UsbDeviceManager {
if (id != 0) {
CharSequence message = r.getText(
com.android.internal.R.string.usb_notification_message);
- CharSequence title = r.getText(id);
+ CharSequence title = r.getText(titleRes);
Intent intent = Intent.makeRestartActivityTask(
new ComponentName("com.android.settings",
@@ -1018,7 +1028,7 @@ public class UsbDeviceManager {
private void updateAdbNotification() {
if (mNotificationManager == null) return;
- final int id = com.android.internal.R.string.adb_active_notification_title;
+ final int id = SystemMessage.NOTE_ADB_ACTIVE;
if (mAdbEnabled && mConnected) {
if ("0".equals(SystemProperties.get("persist.adb.notify"))) return;