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

Commit b0582c7a authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Ignore canDisplayOnRemoteDevices=false on secure displays

Fixing the inconsistency between CDD and the implementation

Relevant CDD requirement: [C-13-8]

Bug: 394573488
Test: presubmit
Flag: EXEMPT bugfix
Change-Id: I615cb2554de061fb2e8cd1f758a6687f373f5bb6
parent 1b5e25d3
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -626,7 +626,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     */
    public static final int FLAG_ENABLE_VR_MODE = 0x8000;
    /**
     * Bit in {@link #flags} indicating if the activity can be displayed on a virtual display.
     * Bit in {@link #flags} indicating if the activity can be displayed on an insecure virtual
     * display.
     * Corresponds to {@link android.R.attr#canDisplayOnRemoteDevices}
     * @hide
     */
+5 −9
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
    // and waitAndGetIsMirrorDisplay()
    private int mDisplayId = Display.INVALID_DISPLAY;
    private boolean mIsMirrorDisplay = false;
    private boolean mIsSecureDisplay = false;
    private final CountDownLatch mDisplayIdSetLatch = new CountDownLatch(1);

    // Used for detecting changes in the window flags.
@@ -148,8 +149,6 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
     * Creates a window policy controller that is generic to the different use cases of virtual
     * device.
     *
     * @param windowFlags The window flags that this controller is interested in.
     * @param systemWindowFlags The system window flags that this controller is interested in.
     * @param attributionSource The AttributionSource of the VirtualDevice owner application.
     * @param allowedUsers The set of users that are allowed to stream in this display.
     * @param activityLaunchAllowedByDefault Whether activities are default allowed to be launched
@@ -170,8 +169,6 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
     *   virtual display flag.
     */
    public GenericWindowPolicyController(
            int windowFlags,
            int systemWindowFlags,
            AttributionSource attributionSource,
            @NonNull ArraySet<UserHandle> allowedUsers,
            boolean activityLaunchAllowedByDefault,
@@ -191,7 +188,6 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
        mActivityPolicyPackageExemptions = new ArraySet<>(activityPolicyPackageExemptions);
        mCrossTaskNavigationAllowedByDefault = crossTaskNavigationAllowedByDefault;
        mCrossTaskNavigationExemptions = new ArraySet<>(crossTaskNavigationExemptions);
        setInterestedWindowFlags(windowFlags, systemWindowFlags);
        mActivityListener = activityListener;
        mDisplayCategories = displayCategories;
        mShowTasksInHostDeviceRecents = showTasksInHostDeviceRecents;
@@ -201,9 +197,10 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
    /**
     * Expected to be called once this object is associated with a newly created display.
     */
    void setDisplayId(int displayId, boolean isMirrorDisplay) {
    void setDisplayId(int displayId, boolean isMirrorDisplay, boolean isSecureDisplay) {
        mDisplayId = displayId;
        mIsMirrorDisplay = isMirrorDisplay;
        mIsSecureDisplay = isSecureDisplay;
        mDisplayIdSetLatch.countDown();
    }

@@ -324,9 +321,8 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
                    "Virtual device doesn't support windowing mode " + windowingMode);
            return false;
        }
        if ((activityInfo.flags & FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES) == 0) {
            logActivityLaunchBlocked(
                    "Activity requires android:canDisplayOnRemoteDevices=true");
        if (!mIsSecureDisplay && (activityInfo.flags & FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES) == 0) {
            logActivityLaunchBlocked("Display requires android:canDisplayOnRemoteDevices=true");
            return false;
        }
        final UserHandle activityUser =
+8 −6
Original line number Diff line number Diff line
@@ -1465,8 +1465,6 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
            }

            return new GenericWindowPolicyController(
                    WindowManager.LayoutParams.FLAG_SECURE,
                    WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
                    mAttributionSource,
                    getAllowedUserHandles(),
                    activityLaunchAllowedByDefault,
@@ -1608,12 +1606,16 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
            DisplayWindowPolicyController dwpc) {
        final boolean isMirrorDisplay =
                mDisplayManagerInternal.getDisplayIdToMirror(displayId) != Display.INVALID_DISPLAY;
        final boolean isTrustedDisplay =
                (mDisplayManagerInternal.getDisplayInfo(displayId).flags & Display.FLAG_TRUSTED)
                        == Display.FLAG_TRUSTED;
        final int flags = mDisplayManagerInternal.getDisplayInfo(displayId).flags;
        final boolean isTrustedDisplay = (flags & Display.FLAG_TRUSTED) == Display.FLAG_TRUSTED;
        final boolean isSecureDisplay = (flags & Display.FLAG_SECURE) == Display.FLAG_SECURE;

        GenericWindowPolicyController gwpc = (GenericWindowPolicyController) dwpc;
        gwpc.setDisplayId(displayId, isMirrorDisplay);
        if (!isSecureDisplay) {
            gwpc.setInterestedWindowFlags(WindowManager.LayoutParams.FLAG_SECURE,
                    WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
        }
        gwpc.setDisplayId(displayId, isMirrorDisplay, isSecureDisplay);
        PowerManager.WakeLock wakeLock =
                isTrustedDisplay ? createWakeLockForDisplay(displayId) : null;
        synchronized (mVirtualDeviceLock) {
+3 −1
Original line number Diff line number Diff line
@@ -136,7 +136,9 @@ class DisplayWindowPolicyControllerHelper {
        if (displayType != Display.TYPE_VIRTUAL && displayType != Display.TYPE_WIFI) {
            return true;
        }
        if ((aInfo.flags & FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES) == 0) {

        if ((aInfo.flags & FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES) == 0
                && (mDisplayContent.getDisplay().getFlags() & Display.FLAG_SECURE) == 0) {
            Slog.d(TAG,
                    String.format("Checking activity launch on display %d, activity requires"
                                    + " android:canDisplayOnRemoteDevices=true",
+25 −100

File changed.

Preview size limit exceeded, changes collapsed.

Loading