Merge "camera: Fix exception handling from ImageReader#detach" into tm-d1-dev am: 00d8fb5022 am: f7be5a5d08
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19139699 Change-Id: Ib920a44f3fee261e5511978ed0a2107dd0c5b43a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1737,6 +1737,20 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// This is possible in case the client disconnects from the output surface
|
// This is possible in case the client disconnects from the output surface
|
||||||
// abruptly.
|
// abruptly.
|
||||||
|
Log.w(TAG, "Output surface likely abandoned, dropping buffer!");
|
||||||
|
img.close();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// NOTE: This is intended to catch RuntimeException from ImageReader.detachImage
|
||||||
|
// ImageReader.detachImage is not supposed to throw RuntimeExceptions but the
|
||||||
|
// bug went unchecked for a few years and now its behavior cannot be changed
|
||||||
|
// without breaking backwards compatibility.
|
||||||
|
|
||||||
|
if (!e.getClass().equals(RuntimeException.class)) {
|
||||||
|
// re-throw any exceptions that aren't base RuntimeException since they are
|
||||||
|
// coming from elsewhere, and we shouldn't silently drop those.
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
Log.w(TAG, "Output surface likely abandoned, dropping buffer!");
|
Log.w(TAG, "Output surface likely abandoned, dropping buffer!");
|
||||||
img.close();
|
img.close();
|
||||||
}
|
}
|
||||||
@@ -1773,9 +1787,23 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
reader.detachImage(img);
|
reader.detachImage(img);
|
||||||
} catch (Exception e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.e(TAG,
|
Log.e(TAG, "Failed to detach image!");
|
||||||
"Failed to detach image!");
|
img.close();
|
||||||
|
return;
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// NOTE: This is intended to catch RuntimeException from ImageReader.detachImage
|
||||||
|
// ImageReader.detachImage is not supposed to throw RuntimeExceptions but the
|
||||||
|
// bug went unchecked for a few years and now its behavior cannot be changed
|
||||||
|
// without breaking backwards compatibility.
|
||||||
|
|
||||||
|
if (!e.getClass().equals(RuntimeException.class)) {
|
||||||
|
// re-throw any exceptions that aren't base RuntimeException since they are
|
||||||
|
// coming from elsewhere, and we shouldn't silently drop those.
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.e(TAG, "Failed to detach image!");
|
||||||
img.close();
|
img.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user