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

Commit c17691b3 authored by wilsonshih's avatar wilsonshih Committed by lumark
Browse files

Don't allow showing wallpapers on untrusted virtual displays

Sometimes user's image wallpaper might have sensitive information.
Third party apps can create a public virtual display then copy the
wallpaper from surface.
Add a restriction that wallpaper can only shows on displays that are
owned by system.

Fix: 129160451
Test: atest MultiDisplaySystemDecorationTests
Change-Id: I6dcc355a539b90fb51886c2ac2099c839a05bf0c
parent f8e4e75d
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()")) {