Loading core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3447,6 +3447,7 @@ package android.companion.virtual { } public static interface VirtualDeviceManager.ActivityListener { method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public default void onActivityLaunchBlocked(int, @NonNull android.content.ComponentName, int); method public void onDisplayEmpty(int); method @Deprecated public void onTopActivityChanged(int, @NonNull android.content.ComponentName); method public default void onTopActivityChanged(int, @NonNull android.content.ComponentName, int); core/java/android/companion/virtual/IVirtualDeviceActivityListener.aidl +10 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ oneway interface IVirtualDeviceActivityListener { * @param topActivity The component name of the top activity. * @param userId The user ID associated with the top activity. */ void onTopActivityChanged(int displayId, in ComponentName topActivity, in int userId); void onTopActivityChanged(int displayId, in ComponentName topActivity, int userId); /** * Called when the display becomes empty (e.g. if the user hits back on the last Loading @@ -41,4 +41,13 @@ oneway interface IVirtualDeviceActivityListener { * @param displayId The display ID that became empty. */ void onDisplayEmpty(int displayId); /** * Called when an activity launch was blocked due to a policy violation. * * @param displayId The display ID on which the activity tried to launch. * @param componentName The component name of the blocked activity. * @param userId The user ID associated with the blocked activity. */ void onActivityLaunchBlocked(int displayId, in ComponentName componentName, int userId); } core/java/android/companion/virtual/VirtualDeviceInternal.java +22 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,22 @@ public class VirtualDeviceInternal { Binder.restoreCallingIdentity(token); } } @Override public void onActivityLaunchBlocked(int displayId, ComponentName componentName, @UserIdInt int userId) { final long token = Binder.clearCallingIdentity(); try { synchronized (mActivityListenersLock) { for (int i = 0; i < mActivityListeners.size(); i++) { mActivityListeners.valueAt(i) .onActivityLaunchBlocked(displayId, componentName, userId); } } } finally { Binder.restoreCallingIdentity(token); } } }; private final IVirtualDeviceSoundEffectListener mSoundEffectListener = new IVirtualDeviceSoundEffectListener.Stub() { Loading Loading @@ -525,6 +541,12 @@ public class VirtualDeviceInternal { public void onDisplayEmpty(int displayId) { mExecutor.execute(() -> mActivityListener.onDisplayEmpty(displayId)); } public void onActivityLaunchBlocked(int displayId, ComponentName componentName, @UserIdInt int userId) { mExecutor.execute(() -> mActivityListener.onActivityLaunchBlocked(displayId, componentName, userId)); } } /** Loading core/java/android/companion/virtual/VirtualDeviceManager.java +15 −1 Original line number Diff line number Diff line Loading @@ -1126,7 +1126,7 @@ public final class VirtualDeviceManager { } /** * Listener for activity changes in this virtual device. * Listener for activity changes and other activity events on a virtual device. * * @hide */ Loading Loading @@ -1167,6 +1167,20 @@ public final class VirtualDeviceManager { * @param displayId The display ID that became empty. */ void onDisplayEmpty(int displayId); /** * Called when an activity launch was blocked due to a policy violation. * * @param displayId The display ID on which the activity tried to launch. * @param componentName The component name of the blocked activity. * @param userId The user ID associated with the blocked activity. * * @see VirtualDeviceParams#POLICY_TYPE_ACTIVITY * @see VirtualDevice#addActivityPolicyExemption(ComponentName) */ @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API) default void onActivityLaunchBlocked(int displayId, @NonNull ComponentName componentName, @UserIdInt int userId) {} } /** Loading core/java/android/companion/virtual/flags/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,13 @@ flag { is_fixed_read_only: true } flag { namespace: "virtual_devices" name: "activity_control_api" description: "Enable APIs for fine grained activity policy, fallback and callbacks" bug: "333443509" } flag { namespace: "virtual_devices" name: "camera_device_awareness" Loading Loading
core/api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3447,6 +3447,7 @@ package android.companion.virtual { } public static interface VirtualDeviceManager.ActivityListener { method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public default void onActivityLaunchBlocked(int, @NonNull android.content.ComponentName, int); method public void onDisplayEmpty(int); method @Deprecated public void onTopActivityChanged(int, @NonNull android.content.ComponentName); method public default void onTopActivityChanged(int, @NonNull android.content.ComponentName, int);
core/java/android/companion/virtual/IVirtualDeviceActivityListener.aidl +10 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ oneway interface IVirtualDeviceActivityListener { * @param topActivity The component name of the top activity. * @param userId The user ID associated with the top activity. */ void onTopActivityChanged(int displayId, in ComponentName topActivity, in int userId); void onTopActivityChanged(int displayId, in ComponentName topActivity, int userId); /** * Called when the display becomes empty (e.g. if the user hits back on the last Loading @@ -41,4 +41,13 @@ oneway interface IVirtualDeviceActivityListener { * @param displayId The display ID that became empty. */ void onDisplayEmpty(int displayId); /** * Called when an activity launch was blocked due to a policy violation. * * @param displayId The display ID on which the activity tried to launch. * @param componentName The component name of the blocked activity. * @param userId The user ID associated with the blocked activity. */ void onActivityLaunchBlocked(int displayId, in ComponentName componentName, int userId); }
core/java/android/companion/virtual/VirtualDeviceInternal.java +22 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,22 @@ public class VirtualDeviceInternal { Binder.restoreCallingIdentity(token); } } @Override public void onActivityLaunchBlocked(int displayId, ComponentName componentName, @UserIdInt int userId) { final long token = Binder.clearCallingIdentity(); try { synchronized (mActivityListenersLock) { for (int i = 0; i < mActivityListeners.size(); i++) { mActivityListeners.valueAt(i) .onActivityLaunchBlocked(displayId, componentName, userId); } } } finally { Binder.restoreCallingIdentity(token); } } }; private final IVirtualDeviceSoundEffectListener mSoundEffectListener = new IVirtualDeviceSoundEffectListener.Stub() { Loading Loading @@ -525,6 +541,12 @@ public class VirtualDeviceInternal { public void onDisplayEmpty(int displayId) { mExecutor.execute(() -> mActivityListener.onDisplayEmpty(displayId)); } public void onActivityLaunchBlocked(int displayId, ComponentName componentName, @UserIdInt int userId) { mExecutor.execute(() -> mActivityListener.onActivityLaunchBlocked(displayId, componentName, userId)); } } /** Loading
core/java/android/companion/virtual/VirtualDeviceManager.java +15 −1 Original line number Diff line number Diff line Loading @@ -1126,7 +1126,7 @@ public final class VirtualDeviceManager { } /** * Listener for activity changes in this virtual device. * Listener for activity changes and other activity events on a virtual device. * * @hide */ Loading Loading @@ -1167,6 +1167,20 @@ public final class VirtualDeviceManager { * @param displayId The display ID that became empty. */ void onDisplayEmpty(int displayId); /** * Called when an activity launch was blocked due to a policy violation. * * @param displayId The display ID on which the activity tried to launch. * @param componentName The component name of the blocked activity. * @param userId The user ID associated with the blocked activity. * * @see VirtualDeviceParams#POLICY_TYPE_ACTIVITY * @see VirtualDevice#addActivityPolicyExemption(ComponentName) */ @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API) default void onActivityLaunchBlocked(int displayId, @NonNull ComponentName componentName, @UserIdInt int userId) {} } /** Loading
core/java/android/companion/virtual/flags/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,13 @@ flag { is_fixed_read_only: true } flag { namespace: "virtual_devices" name: "activity_control_api" description: "Enable APIs for fine grained activity policy, fallback and callbacks" bug: "333443509" } flag { namespace: "virtual_devices" name: "camera_device_awareness" Loading