From 35c0f0508cdcc1423603b4d40ba481c96fab87ce Mon Sep 17 00:00:00 2001 From: Pavel Grafov Date: Thu, 30 Apr 2020 15:01:49 +0100 Subject: [PATCH] Add button to personal apps suspension notification Before this CL the whole notification used to be clickable, with this CL it is not clickable but contains a button with "Turn on work profile" text to match the mocks and to make it more clear to the user. Also, added text style so that the text is warpped if it can't fit into one line. Test: manual with TestDPC Bug: 149075510 Change-Id: Iabe7387df99a6b719a7ce1f310c38f2916e7e4c7 --- core/res/res/values/symbols.xml | 1 + .../server/devicepolicy/DevicePolicyManagerService.java | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 4bc16bba03556..01cfe29b54fbe 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1200,6 +1200,7 @@ + diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 4a56b20ebc0f4..27e0aaf6cde0d 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -16124,6 +16124,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { final PendingIntent pendingIntent = mInjector.pendingIntentGetBroadcast(mContext, 0 /* requestCode */, intent, PendingIntent.FLAG_UPDATE_CURRENT); + final String buttonText = + mContext.getString(R.string.personal_apps_suspended_turn_profile_on); + final Notification.Action turnProfileOnButton = + new Notification.Action.Builder(null /* icon */, buttonText, pendingIntent).build(); + final String text = mContext.getString( notificationState == PROFILE_OFF_DEADLINE_WARNING ? R.string.personal_apps_suspension_tomorrow_text @@ -16134,11 +16139,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { new Notification.Builder(mContext, SystemNotificationChannels.DEVICE_ADMIN) .setSmallIcon(android.R.drawable.stat_sys_warning) .setOngoing(ongoing) + .setAutoCancel(false) .setContentTitle(mContext.getString( R.string.personal_apps_suspension_title)) .setContentText(text) + .setStyle(new Notification.BigTextStyle().bigText(text)) .setColor(mContext.getColor(R.color.system_notification_accent_color)) - .setContentIntent(pendingIntent) + .addAction(turnProfileOnButton) .build(); mInjector.getNotificationManager().notify( SystemMessage.NOTE_PERSONAL_APPS_SUSPENDED, notification);