Skip to content

Commit fed84f2

Browse files
vishniakouInVictusXV
authored andcommitted
Only allow trusted overlays to specify FLAG_SLIPPERY
For all other requests, drop this flag. Test: atest FlagSlipperyTest Bug: 157929241 Change-Id: Ia30f1c38d5ddb351c90b748ea76448a76a9dde7b Merged-In: Ia30f1c38d5ddb351c90b748ea76448a76a9dde7b (cherry picked from commit 07e7aaf) Merged-In:Ia30f1c38d5ddb351c90b748ea76448a76a9dde7b
1 parent dc7e204 commit fed84f2

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

services/core/java/com/android/server/wm/DisplayPolicy.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
6666
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
6767
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
68+
import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
6869
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
6970
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
7071
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
@@ -873,6 +874,20 @@ private boolean hasStatusBarServicePermission(int pid, int uid) {
873874
== PackageManager.PERMISSION_GRANTED;
874875
}
875876

877+
/**
878+
* Only trusted overlays are allowed to use FLAG_SLIPPERY.
879+
*/
880+
static int sanitizeFlagSlippery(int flags, int privateFlags, String name) {
881+
if ((flags & FLAG_SLIPPERY) == 0) {
882+
return flags;
883+
}
884+
if ((privateFlags & PRIVATE_FLAG_TRUSTED_OVERLAY) != 0) {
885+
return flags;
886+
}
887+
Slog.w(TAG, "Removing FLAG_SLIPPERY for non-trusted overlay " + name);
888+
return flags & ~FLAG_SLIPPERY;
889+
}
890+
876891
/**
877892
* Sanitize the layout parameters coming from a client. Allows the policy
878893
* to do things like ensure that windows of a specific type can't take
@@ -956,6 +971,7 @@ public void adjustWindowParamsLw(WindowState win, WindowManager.LayoutParams att
956971
}
957972
break;
958973
}
974+
attrs.flags = sanitizeFlagSlippery(attrs.flags, attrs.privateFlags, win.getName());
959975

960976
// Check if alternate bars positions were updated.
961977
if (mStatusBarAlt == win) {

services/core/java/com/android/server/wm/WindowManagerService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
5757
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
5858
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
59+
import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
5960
import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL;
6061
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
6162
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
@@ -8087,8 +8088,9 @@ private void updateInputChannel(IBinder channelToken, int callingUid, int callin
80878088
h.token = channelToken;
80888089
h.name = name;
80898090

8090-
final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE
8091-
| LayoutParams.FLAG_SLIPPERY);
8091+
flags = DisplayPolicy.sanitizeFlagSlippery(flags, privateFlags, name);
8092+
8093+
final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE | FLAG_SLIPPERY);
80928094
h.layoutParamsFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | sanitizedFlags;
80938095
h.layoutParamsType = type;
80948096
h.dispatchingTimeoutNanos = DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;

0 commit comments

Comments
 (0)