diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index bd8d5724ac502..315217c52af7b 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -3167,13 +3167,13 @@ - %s draw over other apps + %s displaying over other apps - %s app displaying on top. + %s is displaying over other apps. - Parts of this app may remain visible at all times. If this feature isn\'t working correctly, turn it off. + If you don’t want %s to use this feature, tap to open settings and turn it off. TURN OFF diff --git a/services/core/java/com/android/server/wm/AlertWindowNotification.java b/services/core/java/com/android/server/wm/AlertWindowNotification.java index b7b419bf1b418..efc92cf02dde9 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 @@ package com.android.server.wm; 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.content.pm.PackageManager; 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 @@ class AlertWindowNotification { 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 @@ class AlertWindowNotification { 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 @@ class AlertWindowNotification { .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 @@ class AlertWindowNotification { 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 720a4544259ee..b7a9e663ab0fe 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 @@ public class Session extends IWindowSession.Stub 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 8b859d12be4fc..ce3b8f589cf0d 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -346,9 +346,6 @@ public class WindowManagerService extends IWindowManager.Stub 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) { @@ -364,16 +361,6 @@ public class WindowManagerService extends IWindowManager.Stub } } 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 @@ public class WindowManagerService extends IWindowManager.Stub 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();