Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bfdbbb4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker Committed by Anis Assi
Browse files

Merge cherrypicks of [16190719, 16510843] into security-aosp-rvc-release.

Change-Id: I90103d50b08b1a012748ec38a03c9206225aef94
parents a84ea51e ec802636
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -5000,6 +5000,10 @@
    <!-- Allows input events to be monitored. Very dangerous!  @hide -->
    <permission android:name="android.permission.MONITOR_INPUT"
                android:protectionLevel="signature" />
    <!-- Allows the use of FLAG_SLIPPERY, which permits touch events to slip from the current
         window to the window where the touch currently is on top of.  @hide -->
    <permission android:name="android.permission.ALLOW_SLIPPERY_TOUCHES"
                android:protectionLevel="signature" />
    <!--  Allows the caller to change the associations between input devices and displays.
        Very dangerous! @hide -->
    <permission android:name="android.permission.ASSOCIATE_INPUT_DEVICE_TO_DISPLAY_BY_PORT"
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@
    <uses-permission android:name="android.permission.SET_ORIENTATION" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.MONITOR_INPUT" />
    <uses-permission android:name="android.permission.ALLOW_SLIPPERY_TOUCHES" />

    <!-- DreamManager -->
    <uses-permission android:name="android.permission.READ_DREAM_STATE" />
+23 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
import static android.view.WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
@@ -1564,6 +1565,7 @@ public class WindowManagerService extends IWindowManager.Stub

            final DisplayPolicy displayPolicy = displayContent.getDisplayPolicy();
            displayPolicy.adjustWindowParamsLw(win, win.mAttrs, callingPid, callingUid);
            attrs.flags = sanitizeFlagSlippery(attrs.flags, win.getName(), callingUid, callingPid);

            res = displayPolicy.validateAddingWindowLw(attrs, callingPid, callingUid);
            if (res != WindowManagerGlobal.ADD_OKAY) {
@@ -2148,6 +2150,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (attrs != null) {
                displayPolicy.adjustWindowParamsLw(win, attrs, pid, uid);
                win.mToken.adjustWindowParams(win, attrs);
                attrs.flags = sanitizeFlagSlippery(attrs.flags, win.getName(), uid, pid);
                // if they don't have the permission, mask out the status bar bits
                if (seq == win.mSeq) {
                    int systemUiVisibility = attrs.systemUiVisibility
@@ -8047,6 +8050,23 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    /**
     * You need ALLOW_SLIPPERY_TOUCHES permission to be able to set FLAG_SLIPPERY.
     */
    private int sanitizeFlagSlippery(int flags, String windowName, int callingUid, int callingPid) {
        if ((flags & FLAG_SLIPPERY) == 0) {
            return flags;
        }
        final int permissionResult = mContext.checkPermission(
                    android.Manifest.permission.ALLOW_SLIPPERY_TOUCHES, callingPid, callingUid);
        if (permissionResult != PackageManager.PERMISSION_GRANTED) {
            Slog.w(TAG, "Removing FLAG_SLIPPERY from '" + windowName
                    + "' because it doesn't have ALLOW_SLIPPERY_TOUCHES permission");
            return flags & ~FLAG_SLIPPERY;
        }
        return flags;
    }

    /**
     * Assigns an InputChannel to a SurfaceControl and configures it to receive
     * touch input according to it's on-screen geometry.
@@ -8084,8 +8104,9 @@ public class WindowManagerService extends IWindowManager.Stub
        h.token = channelToken;
        h.name = name;

        final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE
                | LayoutParams.FLAG_SLIPPERY);
        flags = sanitizeFlagSlippery(flags, name, callingUid, callingPid);

        final int sanitizedFlags = flags & (LayoutParams.FLAG_NOT_TOUCHABLE | FLAG_SLIPPERY);
        h.layoutParamsFlags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | sanitizedFlags;
        h.layoutParamsType = type;
        h.dispatchingTimeoutNanos = DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;