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

Commit bfff9761 authored by wilsonshih's avatar wilsonshih Committed by android-build-merger
Browse files

Don't allow showing wallpapers on untrusted virtual displays am: c17691b3

am: a1e94b9c

Change-Id: I8fb8223a68042ff69a6fa70386c94d46e65aacef
parents a6ab87fd a1e94b9c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -481,7 +481,7 @@ public abstract class WindowManagerInternal {
    public abstract int getTopFocusedDisplayId();

    /**
     * Checks whether this display should support showing system decorations.
     * Checks if this display is configured and allowed to show system decorations.
     */
    public abstract boolean shouldShowSystemDecorOnDisplay(int displayId);
}
+13 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.TYPE_VIRTUAL;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
@@ -163,6 +164,7 @@ import android.os.PowerManager;
import android.os.PowerManager.ServiceType;
import android.os.PowerManagerInternal;
import android.os.PowerSaveState;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
@@ -6871,10 +6873,21 @@ public class WindowManagerService extends IWindowManager.Stub
                        + "not exist: " + displayId);
                return false;
            }
            final Display display = displayContent.getDisplay();
            if (isUntrustedVirtualDisplay(display)) {
                return false;
            }
            return displayContent.supportsSystemDecorations();
        }
    }

    /**
     * @return {@code true} if the display is non-system created virtual display.
     */
    private static boolean isUntrustedVirtualDisplay(Display display) {
        return display.getType() == TYPE_VIRTUAL && display.getOwnerUid() != Process.SYSTEM_UID;
    }

    @Override
    public void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
        if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "setShouldShowSystemDecors()")) {