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

Commit 67253ffd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[1/3] VDM Activity control APIs" into main

parents bb4ade05 c04c0e1c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+10 −1
Original line number Diff line number Diff line
@@ -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
@@ -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);
}
+22 −0
Original line number Diff line number Diff line
@@ -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() {
@@ -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));
        }
    }

    /**
+15 −1
Original line number Diff line number Diff line
@@ -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
     */
@@ -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) {}
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -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