Handle invalid deviceId in device-aware system services
When virtual camera, sensors, etc are being accessed from a foreground service using an explicit device context (by calling Context#createDeviceContext with a virtual device id), there are situations where the camera, sensors, etc APIs fallback to the ones corresponding to the default device if the virtual device gets destroyed. As a result, a FGS expecting virtual camera, sensors, etc might end up using default device camera, sensors, etc unintentionally when the virtual device goes away. We introduce DEVICE_POLICY_INVALID in VDM and make VDM#getDevicePolicy return DEVICE_POLICY_INVALID for invalid deviceIds, so that system services calling this method can detect this use case and handle the same in a manner they see fit. Test: atest CtsVirtualDevicesSensorTestCases Test: atest CtsVirtualDevicesCameraTestCases Test: atest CtsVirtualDevicesTestCases Bug: 394613051 Flag: android.companion.virtualdevice.flags.handle_invalid_device_id Change-Id: I7cac7e1dcb3396d8daabd72052b7f30e15261514
Loading
Please register or sign in to comment