From 897750a79b13abc91d501df9d089d9fe35c5afde Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Tue, 30 Apr 2019 17:15:03 +0100 Subject: [PATCH] Bump several device admin notifications to high priority The following device admin related events now generate interruptive notifications: 1. Admin-triggered remote bug report collections (requires user action) 2. Remote work profile wipe - post wipe notification 3. The enabling of Network logging 4. Admin remotely installs/removes an APK 5. Work profile needs unlocking after boot Test: manual Change-Id: If5a51123c05b15e544a31ac7ec6b42ec831a1ccc Fix: 130623009 Fix: 120770584 Fix: 118810015 --- .../notification/SystemNotificationChannels.java | 15 +++++++++++++-- core/res/res/values/strings.xml | 13 ++++--------- core/res/res/values/symbols.xml | 4 +--- .../server/locksettings/LockSettingsService.java | 4 ++-- .../server/devicepolicy/RemoteBugreportUtils.java | 3 +-- .../java/com/android/server/SystemServer.java | 1 + 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/core/java/com/android/internal/notification/SystemNotificationChannels.java b/core/java/com/android/internal/notification/SystemNotificationChannels.java index accfc875956ca..a35e42e4e1402 100644 --- a/core/java/com/android/internal/notification/SystemNotificationChannels.java +++ b/core/java/com/android/internal/notification/SystemNotificationChannels.java @@ -43,7 +43,12 @@ public class SystemNotificationChannels { public static String NETWORK_ALERTS = "NETWORK_ALERTS"; public static String NETWORK_AVAILABLE = "NETWORK_AVAILABLE"; public static String VPN = "VPN"; - public static String DEVICE_ADMIN = "DEVICE_ADMIN"; + /** + * @deprecated Legacy device admin channel with low importance which is no longer used, + * Use the high importance {@link #DEVICE_ADMIN} channel instead. + */ + @Deprecated public static String DEVICE_ADMIN_DEPRECATED = "DEVICE_ADMIN"; + public static String DEVICE_ADMIN = "DEVICE_ADMIN_ALERTS"; public static String ALERTS = "ALERTS"; public static String RETAIL_MODE = "RETAIL_MODE"; public static String USB = "USB"; @@ -128,7 +133,7 @@ public class SystemNotificationChannels { final NotificationChannel deviceAdmin = new NotificationChannel( DEVICE_ADMIN, context.getString(R.string.notification_channel_device_admin), - NotificationManager.IMPORTANCE_LOW); + NotificationManager.IMPORTANCE_HIGH); channelsList.add(deviceAdmin); final NotificationChannel alertsChannel = new NotificationChannel( @@ -180,6 +185,12 @@ public class SystemNotificationChannels { nm.createNotificationChannels(channelsList); } + /** Remove notification channels which are no longer used */ + public static void removeDeprecated(Context context) { + final NotificationManager nm = context.getSystemService(NotificationManager.class); + nm.deleteNotificationChannel(DEVICE_ADMIN_DEPRECATED); + } + public static void createAccountChannelForPackage(String pkg, int uid, Context context) { final INotificationManager iNotificationManager = NotificationManager.getService(); try { diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index dd0a6e605f608..e44a10f498528 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -633,8 +633,8 @@ VPN status - - Device administration + + Alerts from your IT admin Alerts @@ -5035,13 +5035,8 @@ Open SMS app to view - - Some functionality may be limited - - Tap to unlock - - User data locked - + + Some functionality may be limited Work profile locked diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 18a019a3e1445..28217751df6f3 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3024,9 +3024,7 @@ - - - + diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java index 1b705bb7c4be9..59e83a289df9e 100644 --- a/services/core/java/com/android/server/locksettings/LockSettingsService.java +++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java @@ -500,7 +500,7 @@ public class LockSettingsService extends ILockSettings.Stub { private void showEncryptionNotificationForProfile(UserHandle user) { Resources r = mContext.getResources(); CharSequence title = r.getText( - com.android.internal.R.string.user_encrypted_title); + com.android.internal.R.string.profile_encrypted_title); CharSequence message = r.getText( com.android.internal.R.string.profile_encrypted_message); CharSequence detail = r.getText( @@ -528,7 +528,7 @@ public class LockSettingsService extends ILockSettings.Stub { if (!StorageManager.isFileEncryptedNativeOrEmulated()) return; Notification notification = - new Notification.Builder(mContext, SystemNotificationChannels.SECURITY) + new Notification.Builder(mContext, SystemNotificationChannels.DEVICE_ADMIN) .setSmallIcon(com.android.internal.R.drawable.ic_user_secure) .setWhen(0) .setOngoing(true) diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java b/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java index 344077cce06e1..0838fbc536c1e 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/RemoteBugreportUtils.java @@ -20,7 +20,6 @@ import android.annotation.IntDef; import android.app.Notification; import android.app.PendingIntent; import android.app.admin.DevicePolicyManager; -import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.UserHandle; @@ -65,7 +64,7 @@ class RemoteBugreportUtils { dialogIntent, 0, null, UserHandle.CURRENT); Notification.Builder builder = - new Notification.Builder(context, SystemNotificationChannels.DEVELOPER) + new Notification.Builder(context, SystemNotificationChannels.DEVICE_ADMIN) .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) .setOngoing(true) .setLocalOnly(true) diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 4ac8342e6e607..428ecf097ab2e 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -1407,6 +1407,7 @@ public final class SystemServer { traceBeginAndSlog("StartNotificationManager"); mSystemServiceManager.startService(NotificationManagerService.class); + SystemNotificationChannels.removeDeprecated(context); SystemNotificationChannels.createAll(context); notification = INotificationManager.Stub.asInterface( ServiceManager.getService(Context.NOTIFICATION_SERVICE));