Camera Compat: Track cameraId, and the app and task that had it opened.

This allows the camera policies to restore task and app config if a
 different task takes over camera. The existing solution can override
 mCameraTask when a new task takes over camera: due to a deliberate
 difference in open and close delays, onCameraOpened for task2 will
 likely come before onCameraClosed for task1 when cameras are
 switched quickly. In this case, task2 will override task1 in
 mCameraTask, and task1 will not be restored onCameraClosed.

This change also allows Policies to receive a single onCameraOpened and
onCameraClosed per task, even when refreshing the activity or switching
cameras, thus abstracting away cameraId, and open/close signals that
are irrelevant for camera compat policies, like switching cameras,
resizing, or finishing camera compat mode setup.

Flag: com.android.window.flags.enable_camera_compat_track_task_and_app_bugfix
Test: atest WmTests:CameraCompatFreeformPolicyTests
Fixes: 380840084
Change-Id: I6422a86672c2c619901baea82c8e87443e4da7fc
5 files changed