Merge "Camera: Try to recover from failing stopRepeating requests" into sc-v2-dev am: d0d3b02874
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16244846 Change-Id: I7d5078d67e684f33cc0b100c36e6d1aac1493ed8
This commit is contained in:
@@ -110,6 +110,11 @@ public class CameraDeviceImpl extends CameraDevice
|
|||||||
private int mRepeatingRequestId = REQUEST_ID_NONE;
|
private int mRepeatingRequestId = REQUEST_ID_NONE;
|
||||||
// Latest repeating request list's types
|
// Latest repeating request list's types
|
||||||
private int[] mRepeatingRequestTypes;
|
private int[] mRepeatingRequestTypes;
|
||||||
|
|
||||||
|
// Cache failed requests to process later in case of a repeating error callback
|
||||||
|
private int mFailedRepeatingRequestId = REQUEST_ID_NONE;
|
||||||
|
private int[] mFailedRepeatingRequestTypes;
|
||||||
|
|
||||||
// Map stream IDs to input/output configurations
|
// Map stream IDs to input/output configurations
|
||||||
private SimpleEntry<Integer, InputConfiguration> mConfiguredInput =
|
private SimpleEntry<Integer, InputConfiguration> mConfiguredInput =
|
||||||
new SimpleEntry<>(REQUEST_ID_NONE, null);
|
new SimpleEntry<>(REQUEST_ID_NONE, null);
|
||||||
@@ -1326,16 +1331,25 @@ public class CameraDeviceImpl extends CameraDevice
|
|||||||
|
|
||||||
int requestId = mRepeatingRequestId;
|
int requestId = mRepeatingRequestId;
|
||||||
mRepeatingRequestId = REQUEST_ID_NONE;
|
mRepeatingRequestId = REQUEST_ID_NONE;
|
||||||
|
mFailedRepeatingRequestId = REQUEST_ID_NONE;
|
||||||
int[] requestTypes = mRepeatingRequestTypes;
|
int[] requestTypes = mRepeatingRequestTypes;
|
||||||
mRepeatingRequestTypes = null;
|
mRepeatingRequestTypes = null;
|
||||||
|
mFailedRepeatingRequestTypes = null;
|
||||||
|
|
||||||
long lastFrameNumber;
|
long lastFrameNumber;
|
||||||
try {
|
try {
|
||||||
lastFrameNumber = mRemoteDevice.cancelRequest(requestId);
|
lastFrameNumber = mRemoteDevice.cancelRequest(requestId);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.v(TAG, "Repeating request was already stopped for request " + requestId);
|
Log.v(TAG, "Repeating request was already stopped for request " +
|
||||||
|
requestId);
|
||||||
}
|
}
|
||||||
|
// Cache request id and request types in case of a race with
|
||||||
|
// "onRepeatingRequestError" which may no yet be scheduled on another thread
|
||||||
|
// or blocked by us.
|
||||||
|
mFailedRepeatingRequestId = requestId;
|
||||||
|
mFailedRepeatingRequestTypes = requestTypes;
|
||||||
|
|
||||||
// Repeating request was already stopped. Nothing more to do.
|
// Repeating request was already stopped. Nothing more to do.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1965,7 +1979,17 @@ public class CameraDeviceImpl extends CameraDevice
|
|||||||
synchronized(mInterfaceLock) {
|
synchronized(mInterfaceLock) {
|
||||||
// Camera is already closed or no repeating request is present.
|
// Camera is already closed or no repeating request is present.
|
||||||
if (mRemoteDevice == null || mRepeatingRequestId == REQUEST_ID_NONE) {
|
if (mRemoteDevice == null || mRepeatingRequestId == REQUEST_ID_NONE) {
|
||||||
return; // Camera already closed
|
if ((mFailedRepeatingRequestId == repeatingRequestId) &&
|
||||||
|
(mFailedRepeatingRequestTypes != null) && (mRemoteDevice != null)) {
|
||||||
|
Log.v(TAG, "Resuming stop of failed repeating request with id: " +
|
||||||
|
mFailedRepeatingRequestId);
|
||||||
|
|
||||||
|
checkEarlyTriggerSequenceCompleteLocked(mFailedRepeatingRequestId,
|
||||||
|
lastFrameNumber, mFailedRepeatingRequestTypes);
|
||||||
|
mFailedRepeatingRequestId = REQUEST_ID_NONE;
|
||||||
|
mFailedRepeatingRequestTypes = null;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect device callback to the offline session in case we are in the middle
|
// Redirect device callback to the offline session in case we are in the middle
|
||||||
|
|||||||
Reference in New Issue
Block a user