Loading core/java/android/content/pm/ActivityInfo.java +2 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java +5 −9 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 Loading @@ -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, Loading @@ -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; Loading @@ -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(); } Loading Loading @@ -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 = Loading services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java +8 −6 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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) { Loading services/core/java/com/android/server/wm/DisplayWindowPolicyControllerHelper.java +3 −1 Original line number Diff line number Diff line Loading @@ -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", Loading services/tests/servicestests/src/com/android/server/companion/virtual/GenericWindowPolicyControllerTest.java +25 −100 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/content/pm/ActivityInfo.java +2 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading
services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java +5 −9 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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 Loading @@ -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, Loading @@ -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; Loading @@ -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(); } Loading Loading @@ -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 = Loading
services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java +8 −6 Original line number Diff line number Diff line Loading @@ -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, Loading Loading @@ -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) { Loading
services/core/java/com/android/server/wm/DisplayWindowPolicyControllerHelper.java +3 −1 Original line number Diff line number Diff line Loading @@ -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", Loading
services/tests/servicestests/src/com/android/server/companion/virtual/GenericWindowPolicyControllerTest.java +25 −100 File changed.Preview size limit exceeded, changes collapsed. Show changes