Loading core/java/android/companion/virtual/IVirtualDeviceManager.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,11 @@ interface IVirtualDeviceManager { */ int getDevicePolicy(int deviceId, int policyType); /** * Returns the device policy for the given display ID and policy type. */ int getDevicePolicyForDisplayId(int displayId, int policyType); /** * Returns device-specific session id for playback, or AUDIO_SESSION_ID_GENERATE * if there's none. Loading core/java/android/companion/virtual/VirtualDeviceManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -377,6 +377,31 @@ public final class VirtualDeviceManager { } } /** * Returns the device policy for the display with the given ID and the given policy type. * * <p>In case the display does not exist or is not owned by a virtual device, * {@link VirtualDeviceParams#DEVICE_POLICY_DEFAULT} is returned. * * @hide */ public @VirtualDeviceParams.DevicePolicy int getDevicePolicyForDisplayId( int displayId, @VirtualDeviceParams.PolicyType int policyType) { if (displayId == Context.DEVICE_ID_DEFAULT) { // Avoid unnecessary binder call, for default display, policy will be always default. return VirtualDeviceParams.DEVICE_POLICY_DEFAULT; } if (mService == null) { Log.w(TAG, "Failed to retrieve device policy; no virtual device manager service."); return VirtualDeviceParams.DEVICE_POLICY_DEFAULT; } try { return mService.getDevicePolicyForDisplayId(displayId, policyType); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the ID of the device which owns the display with the given ID. * Loading services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java +6 −0 Original line number Diff line number Diff line Loading @@ -239,6 +239,12 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController } } boolean isActivityLaunchAllowedByDefault() { synchronized (mGenericWindowPolicyControllerLock) { return mActivityLaunchAllowedByDefault; } } void setActivityLaunchDefaultAllowed(boolean activityLaunchDefaultAllowed) { synchronized (mGenericWindowPolicyControllerLock) { if (mActivityLaunchAllowedByDefault != activityLaunchDefaultAllowed) { Loading services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -605,6 +605,25 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub } } public @VirtualDeviceParams.DevicePolicy int getDevicePolicyForDisplayId( int displayId, @VirtualDeviceParams.PolicyType int policyType) { synchronized (mVirtualDeviceLock) { switch (policyType) { case POLICY_TYPE_RECENTS: return mVirtualDisplays.get(displayId).getWindowPolicyController() .canShowTasksInHostDeviceRecents() ? DEVICE_POLICY_DEFAULT : DEVICE_POLICY_CUSTOM; case POLICY_TYPE_ACTIVITY: return mVirtualDisplays.get(displayId).getWindowPolicyController() .isActivityLaunchAllowedByDefault() ? DEVICE_POLICY_DEFAULT : DEVICE_POLICY_CUSTOM; default: // fallback to device-level policy return mDevicePolicies.get(policyType, DEVICE_POLICY_DEFAULT); } } } /** Returns device-specific audio session id for playback. */ public int getAudioPlaybackSessionId() { return mParams.getAudioPlaybackSessionId(); Loading services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -567,6 +567,23 @@ public class VirtualDeviceManagerService extends SystemService { return virtualDevice.getDevicePolicy(policyType); } @Override // Binder call @VirtualDeviceParams.DevicePolicy public int getDevicePolicyForDisplayId(int displayId, @VirtualDeviceParams.PolicyType int policyType) { final int deviceId = getDeviceIdForDisplayId(displayId); if (deviceId == Context.DEVICE_ID_DEFAULT) { return DEVICE_POLICY_DEFAULT; } VirtualDeviceImpl virtualDevice = getVirtualDeviceForId(deviceId); // Do not return DEVICE_POLICY_INVALID here, because the display may exist but not // owned by any virtual device, just like the default display. if (virtualDevice == null) { return DEVICE_POLICY_DEFAULT; } return virtualDevice.getDevicePolicyForDisplayId(displayId, policyType); } @Override // Binder call public int getDeviceIdForDisplayId(int displayId) { if (displayId == Display.INVALID_DISPLAY || displayId == Display.DEFAULT_DISPLAY) { Loading Loading
core/java/android/companion/virtual/IVirtualDeviceManager.aidl +5 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,11 @@ interface IVirtualDeviceManager { */ int getDevicePolicy(int deviceId, int policyType); /** * Returns the device policy for the given display ID and policy type. */ int getDevicePolicyForDisplayId(int displayId, int policyType); /** * Returns device-specific session id for playback, or AUDIO_SESSION_ID_GENERATE * if there's none. Loading
core/java/android/companion/virtual/VirtualDeviceManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -377,6 +377,31 @@ public final class VirtualDeviceManager { } } /** * Returns the device policy for the display with the given ID and the given policy type. * * <p>In case the display does not exist or is not owned by a virtual device, * {@link VirtualDeviceParams#DEVICE_POLICY_DEFAULT} is returned. * * @hide */ public @VirtualDeviceParams.DevicePolicy int getDevicePolicyForDisplayId( int displayId, @VirtualDeviceParams.PolicyType int policyType) { if (displayId == Context.DEVICE_ID_DEFAULT) { // Avoid unnecessary binder call, for default display, policy will be always default. return VirtualDeviceParams.DEVICE_POLICY_DEFAULT; } if (mService == null) { Log.w(TAG, "Failed to retrieve device policy; no virtual device manager service."); return VirtualDeviceParams.DEVICE_POLICY_DEFAULT; } try { return mService.getDevicePolicyForDisplayId(displayId, policyType); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the ID of the device which owns the display with the given ID. * Loading
services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java +6 −0 Original line number Diff line number Diff line Loading @@ -239,6 +239,12 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController } } boolean isActivityLaunchAllowedByDefault() { synchronized (mGenericWindowPolicyControllerLock) { return mActivityLaunchAllowedByDefault; } } void setActivityLaunchDefaultAllowed(boolean activityLaunchDefaultAllowed) { synchronized (mGenericWindowPolicyControllerLock) { if (mActivityLaunchAllowedByDefault != activityLaunchDefaultAllowed) { Loading
services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -605,6 +605,25 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub } } public @VirtualDeviceParams.DevicePolicy int getDevicePolicyForDisplayId( int displayId, @VirtualDeviceParams.PolicyType int policyType) { synchronized (mVirtualDeviceLock) { switch (policyType) { case POLICY_TYPE_RECENTS: return mVirtualDisplays.get(displayId).getWindowPolicyController() .canShowTasksInHostDeviceRecents() ? DEVICE_POLICY_DEFAULT : DEVICE_POLICY_CUSTOM; case POLICY_TYPE_ACTIVITY: return mVirtualDisplays.get(displayId).getWindowPolicyController() .isActivityLaunchAllowedByDefault() ? DEVICE_POLICY_DEFAULT : DEVICE_POLICY_CUSTOM; default: // fallback to device-level policy return mDevicePolicies.get(policyType, DEVICE_POLICY_DEFAULT); } } } /** Returns device-specific audio session id for playback. */ public int getAudioPlaybackSessionId() { return mParams.getAudioPlaybackSessionId(); Loading
services/companion/java/com/android/server/companion/virtual/VirtualDeviceManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -567,6 +567,23 @@ public class VirtualDeviceManagerService extends SystemService { return virtualDevice.getDevicePolicy(policyType); } @Override // Binder call @VirtualDeviceParams.DevicePolicy public int getDevicePolicyForDisplayId(int displayId, @VirtualDeviceParams.PolicyType int policyType) { final int deviceId = getDeviceIdForDisplayId(displayId); if (deviceId == Context.DEVICE_ID_DEFAULT) { return DEVICE_POLICY_DEFAULT; } VirtualDeviceImpl virtualDevice = getVirtualDeviceForId(deviceId); // Do not return DEVICE_POLICY_INVALID here, because the display may exist but not // owned by any virtual device, just like the default display. if (virtualDevice == null) { return DEVICE_POLICY_DEFAULT; } return virtualDevice.getDevicePolicyForDisplayId(displayId, policyType); } @Override // Binder call public int getDeviceIdForDisplayId(int displayId) { if (displayId == Display.INVALID_DISPLAY || displayId == Display.DEFAULT_DISPLAY) { Loading