Merge "Updated alert window notification to new UX spec."
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 6a14ee7..d1d406d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3167,13 +3167,13 @@
<skip />
<!-- Name of notification channel the system post notification to inform the use about apps
that are drawing ui on-top of other apps (alert-windows) [CHAR LIMIT=NONE] -->
- <string name="alert_windows_notification_channel_name"><xliff:g id="name" example="Google Maps">%s</xliff:g> draw over other apps</string>
+ <string name="alert_windows_notification_channel_name"><xliff:g id="name" example="Google Maps">%s</xliff:g> displaying over other apps</string>
<!-- Notification title when an application is displaying ui on-top of other apps
[CHAR LIMIT=30] -->
- <string name="alert_windows_notification_title"><xliff:g id="name" example="Google Maps">%s</xliff:g> app displaying on top.</string>
+ <string name="alert_windows_notification_title"><xliff:g id="name" example="Google Maps">%s</xliff:g> is displaying over other apps.</string>
<!-- Notification body when an application is displaying ui on-top of other apps
[CHAR LIMIT=NONE] -->
- <string name="alert_windows_notification_message">Parts of this app may remain visible at all times. If this feature isn\'t working correctly, turn it off.</string>
+ <string name="alert_windows_notification_message">If you don’t want <xliff:g id="name" example="Google Maps">%s</xliff:g> to use this feature, tap to open settings and turn it off.</string>
<!-- Notification action to turn-off app displaying on-top of other apps. [CHAR LIMIT=20] -->
<string name="alert_windows_notification_turn_off_action">TURN OFF</string>
diff --git a/services/core/java/com/android/server/wm/AlertWindowNotification.java b/services/core/java/com/android/server/wm/AlertWindowNotification.java
index b7b419b..efc92cf 100644
--- a/services/core/java/com/android/server/wm/AlertWindowNotification.java
+++ b/services/core/java/com/android/server/wm/AlertWindowNotification.java
@@ -19,9 +19,9 @@
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
import static android.content.Context.NOTIFICATION_SERVICE;
-import static android.content.Intent.EXTRA_PACKAGE_NAME;
-import static android.content.Intent.EXTRA_UID;
-import static com.android.server.wm.WindowManagerService.ACTION_REVOKE_SYSTEM_ALERT_WINDOW_PERMISSION;
+import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -35,6 +35,7 @@
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import com.android.internal.R;
import com.android.server.policy.IconUtilities;
@@ -49,14 +50,12 @@
private String mNotificationTag;
private final NotificationManager mNotificationManager;
private final String mPackageName;
- private final int mUid;
private boolean mCancelled;
private IconUtilities mIconUtilities;
- AlertWindowNotification(WindowManagerService service, String packageName, int uid) {
+ AlertWindowNotification(WindowManagerService service, String packageName) {
mService = service;
mPackageName = packageName;
- mUid = uid;
mNotificationManager =
(NotificationManager) mService.mContext.getSystemService(NOTIFICATION_SERVICE);
mNotificationTag = CHANNEL_PREFIX + mPackageName;
@@ -96,7 +95,8 @@
createNotificationChannelIfNeeded(context, appName);
- final String message = context.getString(R.string.alert_windows_notification_message);
+ final String message = context.getString(R.string.alert_windows_notification_message,
+ appName);
final Notification.Builder builder = new Notification.Builder(context, mNotificationTag)
.setOngoing(true)
.setContentTitle(
@@ -106,7 +106,7 @@
.setColor(context.getColor(R.color.system_notification_accent_color))
.setStyle(new Notification.BigTextStyle().bigText(message))
.setLocalOnly(true)
- .addAction(getTurnOffAction(context, mPackageName, mUid));
+ .setContentIntent(getContentIntent(context, mPackageName));
if (aInfo != null) {
final Drawable drawable = pm.getApplicationIcon(aInfo);
@@ -119,17 +119,12 @@
mNotificationManager.notify(mNotificationTag, NOTIFICATION_ID, builder.build());
}
- private Notification.Action getTurnOffAction(Context context, String packageName, int uid) {
- final Intent intent = new Intent(ACTION_REVOKE_SYSTEM_ALERT_WINDOW_PERMISSION);
- intent.putExtra(EXTRA_PACKAGE_NAME, packageName);
- intent.putExtra(EXTRA_UID, uid);
+ private PendingIntent getContentIntent(Context context, String packageName) {
+ final Intent intent = new Intent(ACTION_MANAGE_OVERLAY_PERMISSION,
+ Uri.fromParts("package", packageName, null));
+ intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
// Calls into activity manager...
- final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, mRequestCode,
- intent, FLAG_CANCEL_CURRENT);
- return new Notification.Action.Builder(R.drawable.alert_window_layer,
- context.getString(R.string.alert_windows_notification_turn_off_action),
- pendingIntent).build();
-
+ return PendingIntent.getActivity(context, mRequestCode, intent, FLAG_CANCEL_CURRENT);
}
private void createNotificationChannelIfNeeded(Context context, String appName) {
diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java
index 720a454..b7a9e66 100644
--- a/services/core/java/com/android/server/wm/Session.java
+++ b/services/core/java/com/android/server/wm/Session.java
@@ -601,8 +601,7 @@
if (mAlertWindowSurfaces.isEmpty()) {
cancelAlertWindowNotification();
} else if (mAlertWindowNotification == null){
- mAlertWindowNotification = new AlertWindowNotification(
- mService, mPackageName, mUid);
+ mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName);
}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index bd83980..c0cc923 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -351,9 +351,6 @@
final private KeyguardDisableHandler mKeyguardDisableHandler;
- static final String ACTION_REVOKE_SYSTEM_ALERT_WINDOW_PERMISSION =
- "com.android.server.wm.ACTION_REVOKE_SYSTEM_ALERT_WINDOW_PERMISSION";
-
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -369,16 +366,6 @@
}
}
break;
- case ACTION_REVOKE_SYSTEM_ALERT_WINDOW_PERMISSION:
- final String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
- final int uid = intent.getIntExtra(EXTRA_UID, -1);
- if (packageName != null && uid != -1) {
- synchronized (mWindowMap) {
- // Revoke permission.
- mAppOps.setMode(OP_SYSTEM_ALERT_WINDOW, uid, packageName, MODE_IGNORED);
- }
- }
- break;
}
}
};
@@ -1070,7 +1057,6 @@
filter.addAction(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
// Listen to user removal broadcasts so that we can remove the user-specific data.
filter.addAction(Intent.ACTION_USER_REMOVED);
- filter.addAction(ACTION_REVOKE_SYSTEM_ALERT_WINDOW_PERMISSION);
mContext.registerReceiver(mBroadcastReceiver, filter);
mSettingsObserver = new SettingsObserver();