Merge changes from topic "b194508189" into sc-dev am: e922ec31aa
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15376189 Change-Id: I9a039d8b92c96043227bb4c81992be4df661e6cf
This commit is contained in:
@@ -446,10 +446,16 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
if (mHandlerThread != null) {
|
||||||
|
mHandlerThread.quitSafely();
|
||||||
|
}
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
mHandlerThread.quitSafely();
|
|
||||||
|
|
||||||
if (mSessionProcessor != null) {
|
if (mSessionProcessor != null) {
|
||||||
try {
|
try {
|
||||||
mSessionProcessor.deInitSession();
|
mSessionProcessor.deInitSession();
|
||||||
|
|||||||
@@ -696,6 +696,16 @@ public class CameraDeviceImpl extends CameraDevice
|
|||||||
mCurrentSession.replaceSessionClose();
|
mCurrentSession.replaceSessionClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCurrentExtensionSession != null) {
|
||||||
|
mCurrentExtensionSession.release();
|
||||||
|
mCurrentExtensionSession = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mCurrentAdvancedExtensionSession != null) {
|
||||||
|
mCurrentAdvancedExtensionSession.release();
|
||||||
|
mCurrentAdvancedExtensionSession = null;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: dont block for this
|
// TODO: dont block for this
|
||||||
boolean configureSuccess = true;
|
boolean configureSuccess = true;
|
||||||
CameraAccessException pendingException = null;
|
CameraAccessException pendingException = null;
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ import android.media.ImageWriter;
|
|||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.IInterface;
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -265,13 +263,6 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new UnsupportedOperationException("Failed casting preview processor!");
|
throw new UnsupportedOperationException("Failed casting preview processor!");
|
||||||
}
|
}
|
||||||
if (mClientRepeatingRequestSurface != null) {
|
|
||||||
mPreviewRequestUpdateProcessor.onOutputSurface(mClientRepeatingRequestSurface,
|
|
||||||
nativeGetSurfaceFormat(mClientRepeatingRequestSurface));
|
|
||||||
mRepeatingRequestImageWriter = ImageWriter.newInstance(
|
|
||||||
mClientRepeatingRequestSurface, PREVIEW_QUEUE_SIZE,
|
|
||||||
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT);
|
|
||||||
}
|
|
||||||
mRepeatingRequestImageReader = ImageReader.newInstance(repeatingSurfaceInfo.mWidth,
|
mRepeatingRequestImageReader = ImageReader.newInstance(repeatingSurfaceInfo.mWidth,
|
||||||
repeatingSurfaceInfo.mHeight,
|
repeatingSurfaceInfo.mHeight,
|
||||||
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT,
|
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT,
|
||||||
@@ -285,11 +276,6 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
mPreviewRequestUpdateProcessor.onImageFormatUpdate(
|
mPreviewRequestUpdateProcessor.onImageFormatUpdate(
|
||||||
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT);
|
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT);
|
||||||
} else {
|
} else {
|
||||||
if (mClientRepeatingRequestSurface != null) {
|
|
||||||
mRepeatingRequestImageWriter = ImageWriter.newInstance(
|
|
||||||
mClientRepeatingRequestSurface, PREVIEW_QUEUE_SIZE,
|
|
||||||
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT);
|
|
||||||
}
|
|
||||||
mRepeatingRequestImageReader = ImageReader.newInstance(repeatingSurfaceInfo.mWidth,
|
mRepeatingRequestImageReader = ImageReader.newInstance(repeatingSurfaceInfo.mWidth,
|
||||||
repeatingSurfaceInfo.mHeight,
|
repeatingSurfaceInfo.mHeight,
|
||||||
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT,
|
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT,
|
||||||
@@ -320,7 +306,6 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
mBurstCaptureImageReader = ImageReader.newInstance(surfaceInfo.mWidth,
|
mBurstCaptureImageReader = ImageReader.newInstance(surfaceInfo.mWidth,
|
||||||
surfaceInfo.mHeight, CameraExtensionCharacteristics.PROCESSING_INPUT_FORMAT,
|
surfaceInfo.mHeight, CameraExtensionCharacteristics.PROCESSING_INPUT_FORMAT,
|
||||||
mImageExtender.getMaxCaptureStage());
|
mImageExtender.getMaxCaptureStage());
|
||||||
mImageProcessor.onOutputSurface(mClientCaptureSurface, surfaceInfo.mFormat);
|
|
||||||
} else {
|
} else {
|
||||||
// The client doesn't intend to trigger multi-frame capture, however the
|
// The client doesn't intend to trigger multi-frame capture, however the
|
||||||
// image extender still needs to get initialized and the camera still capture
|
// image extender still needs to get initialized and the camera still capture
|
||||||
@@ -367,6 +352,29 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void finishPipelineInitialization() throws RemoteException {
|
||||||
|
if (mClientRepeatingRequestSurface != null) {
|
||||||
|
if (mPreviewProcessorType == IPreviewExtenderImpl.PROCESSOR_TYPE_REQUEST_UPDATE_ONLY) {
|
||||||
|
mPreviewRequestUpdateProcessor.onOutputSurface(mClientRepeatingRequestSurface,
|
||||||
|
nativeGetSurfaceFormat(mClientRepeatingRequestSurface));
|
||||||
|
mRepeatingRequestImageWriter = ImageWriter.newInstance(
|
||||||
|
mClientRepeatingRequestSurface,
|
||||||
|
PREVIEW_QUEUE_SIZE,
|
||||||
|
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT);
|
||||||
|
} else if (mPreviewProcessorType == IPreviewExtenderImpl.PROCESSOR_TYPE_NONE) {
|
||||||
|
mRepeatingRequestImageWriter = ImageWriter.newInstance(
|
||||||
|
mClientRepeatingRequestSurface,
|
||||||
|
PREVIEW_QUEUE_SIZE,
|
||||||
|
CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((mImageProcessor != null) && (mClientCaptureSurface != null)) {
|
||||||
|
CameraExtensionUtils.SurfaceInfo surfaceInfo = CameraExtensionUtils.querySurface(
|
||||||
|
mClientCaptureSurface);
|
||||||
|
mImageProcessor.onOutputSurface(mClientCaptureSurface, surfaceInfo.mFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -622,11 +630,18 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
new CameraExtensionUtils.HandlerExecutor(mHandler), requestHandler);
|
new CameraExtensionUtils.HandlerExecutor(mHandler), requestHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
if (mHandlerThread != null) {
|
||||||
|
mHandlerThread.quitSafely();
|
||||||
|
}
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void release() {
|
public void release() {
|
||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
mInternalRepeatingRequestEnabled = false;
|
mInternalRepeatingRequestEnabled = false;
|
||||||
mHandlerThread.quitSafely();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mPreviewExtender.onDeInit();
|
mPreviewExtender.onDeInit();
|
||||||
@@ -750,6 +765,7 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
|
|||||||
synchronized (mInterfaceLock) {
|
synchronized (mInterfaceLock) {
|
||||||
mCaptureSession = session;
|
mCaptureSession = session;
|
||||||
try {
|
try {
|
||||||
|
finishPipelineInitialization();
|
||||||
CameraExtensionCharacteristics.initializeSession(mInitializeHandler);
|
CameraExtensionCharacteristics.initializeSession(mInitializeHandler);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to initialize session! Extension service does"
|
Log.e(TAG, "Failed to initialize session! Extension service does"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.graphics.ImageFormat;
|
import android.graphics.ImageFormat;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.hardware.HardwareBuffer;
|
|
||||||
import android.hardware.camera2.CameraExtensionCharacteristics;
|
import android.hardware.camera2.CameraExtensionCharacteristics;
|
||||||
import android.hardware.camera2.params.OutputConfiguration;
|
import android.hardware.camera2.params.OutputConfiguration;
|
||||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||||
@@ -78,41 +77,20 @@ public final class CameraExtensionUtils {
|
|||||||
SurfaceInfo surfaceInfo = new SurfaceInfo();
|
SurfaceInfo surfaceInfo = new SurfaceInfo();
|
||||||
int nativeFormat = SurfaceUtils.getSurfaceFormat(s);
|
int nativeFormat = SurfaceUtils.getSurfaceFormat(s);
|
||||||
int dataspace = SurfaceUtils.getSurfaceDataspace(s);
|
int dataspace = SurfaceUtils.getSurfaceDataspace(s);
|
||||||
|
Size surfaceSize = SurfaceUtils.getSurfaceSize(s);
|
||||||
|
surfaceInfo.mFormat = nativeFormat;
|
||||||
|
surfaceInfo.mWidth = surfaceSize.getWidth();
|
||||||
|
surfaceInfo.mHeight = surfaceSize.getHeight();
|
||||||
|
surfaceInfo.mUsage = SurfaceUtils.getSurfaceUsage(s);
|
||||||
// Jpeg surfaces cannot be queried for their usage and other parameters
|
// Jpeg surfaces cannot be queried for their usage and other parameters
|
||||||
// in the usual way below. A buffer can only be de-queued after the
|
// in the usual way below. A buffer can only be de-queued after the
|
||||||
// producer overrides the surface dimensions to (width*height) x 1.
|
// producer overrides the surface dimensions to (width*height) x 1.
|
||||||
if ((nativeFormat == StreamConfigurationMap.HAL_PIXEL_FORMAT_BLOB) &&
|
if ((nativeFormat == StreamConfigurationMap.HAL_PIXEL_FORMAT_BLOB) &&
|
||||||
(dataspace == StreamConfigurationMap.HAL_DATASPACE_V0_JFIF)) {
|
(dataspace == StreamConfigurationMap.HAL_DATASPACE_V0_JFIF)) {
|
||||||
surfaceInfo.mFormat = ImageFormat.JPEG;
|
surfaceInfo.mFormat = ImageFormat.JPEG;
|
||||||
Size surfaceSize = SurfaceUtils.getSurfaceSize(s);
|
|
||||||
surfaceInfo.mWidth = surfaceSize.getWidth();
|
|
||||||
surfaceInfo.mHeight = surfaceSize.getHeight();
|
|
||||||
return surfaceInfo;
|
return surfaceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
HardwareBuffer buffer = null;
|
|
||||||
try {
|
|
||||||
writer = ImageWriter.newInstance(s, 1);
|
|
||||||
img = writer.dequeueInputImage();
|
|
||||||
buffer = img.getHardwareBuffer();
|
|
||||||
surfaceInfo.mFormat = buffer.getFormat();
|
|
||||||
surfaceInfo.mWidth = buffer.getWidth();
|
|
||||||
surfaceInfo.mHeight = buffer.getHeight();
|
|
||||||
surfaceInfo.mUsage = buffer.getUsage();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Failed to query surface, returning defaults!");
|
|
||||||
} finally {
|
|
||||||
if (buffer != null) {
|
|
||||||
buffer.close();
|
|
||||||
}
|
|
||||||
if (img != null) {
|
|
||||||
img.close();
|
|
||||||
}
|
|
||||||
if (writer != null) {
|
|
||||||
writer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return surfaceInfo;
|
return surfaceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,20 @@ public class SurfaceUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the surface usage bits.
|
||||||
|
*
|
||||||
|
* @param surface The surface to be queried for usage.
|
||||||
|
* @return the native object id of the surface, 0 if surface is not backed by a native object.
|
||||||
|
*/
|
||||||
|
public static long getSurfaceUsage(Surface surface) {
|
||||||
|
checkNotNull(surface);
|
||||||
|
try {
|
||||||
|
return nativeDetectSurfaceUsageFlags(surface);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get the Surface size.
|
* Get the Surface size.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user