Merge "Camera: Handling implicit session close" into udc-qpr-dev am: 2bbf00d84a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23773074 Change-Id: Ie617bc62d72f8f278c867ac870993da997d415d6 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -526,7 +526,11 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
if (mInitialized) {
|
if (mInitialized) {
|
||||||
try {
|
try {
|
||||||
mCaptureSession.stopRepeating();
|
try {
|
||||||
|
mCaptureSession.stopRepeating();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// OK: already be closed, nothing else to do
|
||||||
|
}
|
||||||
mSessionProcessor.stopRepeating();
|
mSessionProcessor.stopRepeating();
|
||||||
mSessionProcessor.onCaptureSessionEnd();
|
mSessionProcessor.onCaptureSessionEnd();
|
||||||
mSessionClosed = true;
|
mSessionClosed = true;
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
private int mPreviewProcessorType = IPreviewExtenderImpl.PROCESSOR_TYPE_NONE;
|
private int mPreviewProcessorType = IPreviewExtenderImpl.PROCESSOR_TYPE_NONE;
|
||||||
|
|
||||||
private boolean mInitialized;
|
private boolean mInitialized;
|
||||||
|
private boolean mSessionClosed;
|
||||||
// Enable/Disable internal preview/(repeating request). Extensions expect
|
// Enable/Disable internal preview/(repeating request). Extensions expect
|
||||||
// that preview/(repeating request) is enabled and active at any point in time.
|
// that preview/(repeating request) is enabled and active at any point in time.
|
||||||
// In case the client doesn't explicitly enable repeating requests, the framework
|
// In case the client doesn't explicitly enable repeating requests, the framework
|
||||||
@@ -278,6 +279,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
mHandlerThread.start();
|
mHandlerThread.start();
|
||||||
mHandler = new Handler(mHandlerThread.getLooper());
|
mHandler = new Handler(mHandlerThread.getLooper());
|
||||||
mInitialized = false;
|
mInitialized = false;
|
||||||
|
mSessionClosed = false;
|
||||||
mInitializeHandler = new InitializeSessionHandler();
|
mInitializeHandler = new InitializeSessionHandler();
|
||||||
mSessionId = sessionId;
|
mSessionId = sessionId;
|
||||||
mSupportedRequestKeys = requestKeys;
|
mSupportedRequestKeys = requestKeys;
|
||||||
@@ -775,7 +777,12 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
if (mInitialized) {
|
if (mInitialized) {
|
||||||
mInternalRepeatingRequestEnabled = false;
|
mInternalRepeatingRequestEnabled = false;
|
||||||
mCaptureSession.stopRepeating();
|
try {
|
||||||
|
mCaptureSession.stopRepeating();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
// OK: already be closed, nothing else to do
|
||||||
|
mSessionClosed = true;
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<CaptureStageImpl> captureStageList = new ArrayList<>();
|
ArrayList<CaptureStageImpl> captureStageList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
@@ -793,13 +800,14 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
Log.e(TAG, "Failed to disable extension! Extension service does not "
|
Log.e(TAG, "Failed to disable extension! Extension service does not "
|
||||||
+ "respond!");
|
+ "respond!");
|
||||||
}
|
}
|
||||||
if (!captureStageList.isEmpty()) {
|
if (!captureStageList.isEmpty() && !mSessionClosed) {
|
||||||
CaptureRequest disableRequest = createRequest(mCameraDevice, captureStageList,
|
CaptureRequest disableRequest = createRequest(mCameraDevice, captureStageList,
|
||||||
mCameraRepeatingSurface, CameraDevice.TEMPLATE_PREVIEW);
|
mCameraRepeatingSurface, CameraDevice.TEMPLATE_PREVIEW);
|
||||||
mCaptureSession.capture(disableRequest,
|
mCaptureSession.capture(disableRequest,
|
||||||
new CloseRequestHandler(mRepeatingRequestImageCallback), mHandler);
|
new CloseRequestHandler(mRepeatingRequestImageCallback), mHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSessionClosed = true;
|
||||||
mStatsAggregator.commit(/*isFinal*/true); // Commit stats before closing session
|
mStatsAggregator.commit(/*isFinal*/true); // Commit stats before closing session
|
||||||
mCaptureSession.close();
|
mCaptureSession.close();
|
||||||
}
|
}
|
||||||
@@ -854,6 +862,11 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
mHandlerThread.quit();
|
mHandlerThread.quit();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!mSessionClosed) {
|
||||||
|
// return value is omitted. nothing can do after session is closed.
|
||||||
|
mPreviewExtender.onDisableSession();
|
||||||
|
mImageExtender.onDisableSession();
|
||||||
|
}
|
||||||
mPreviewExtender.onDeInit();
|
mPreviewExtender.onDeInit();
|
||||||
mImageExtender.onDeInit();
|
mImageExtender.onDeInit();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user