Merge "Camera: Pass targetSdkVersion to camera service APIs" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
59239bf794
@@ -2511,9 +2511,9 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
|
|||||||
* <p>Not all output formats may be supported in a configuration with
|
* <p>Not all output formats may be supported in a configuration with
|
||||||
* an input stream of a particular format. For more details, see
|
* an input stream of a particular format. For more details, see
|
||||||
* android.scaler.availableInputOutputFormatsMap.</p>
|
* android.scaler.availableInputOutputFormatsMap.</p>
|
||||||
* <p>The following table describes the minimum required output stream
|
* <p>For applications targeting SDK version older than 31, the following table
|
||||||
* configurations based on the hardware level
|
* describes the minimum required output stream configurations based on the hardware level
|
||||||
* ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel}), prior to Android 12:</p>
|
* ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel}):</p>
|
||||||
* <table>
|
* <table>
|
||||||
* <thead>
|
* <thead>
|
||||||
* <tr>
|
* <tr>
|
||||||
@@ -2574,10 +2574,13 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
|
|||||||
* </tr>
|
* </tr>
|
||||||
* </tbody>
|
* </tbody>
|
||||||
* </table>
|
* </table>
|
||||||
* <p>Starting from Android 12, the camera device may not support JPEG sizes smaller than the
|
* <p>For applications targeting SDK version 31 or newer, if the mobile device declares to be
|
||||||
* minimum of 1080p and the camera sensor active array size. The requirements for
|
* {@link android.os.Build.VERSION_CDOES.MEDIA_PERFORMANCE_CLASS media performance class} S,
|
||||||
* IMPLEMENTATION_DEFINED and YUV_420_888 stay the same. This new minimum required output
|
* the primary camera devices (first rear/front camera in the camera ID list) will not
|
||||||
* stream configurations are illustrated by the table below:</p>
|
* support JPEG sizes smaller than 1080p. If the application configures a JPEG stream
|
||||||
|
* smaller than 1080p, the camera device will round up the JPEG image size to at least
|
||||||
|
* 1080p. The requirements for IMPLEMENTATION_DEFINED and YUV_420_888 stay the same.
|
||||||
|
* This new minimum required output stream configurations are illustrated by the table below:</p>
|
||||||
* <table>
|
* <table>
|
||||||
* <thead>
|
* <thead>
|
||||||
* <tr>
|
* <tr>
|
||||||
@@ -2644,6 +2647,10 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
|
|||||||
* </tr>
|
* </tr>
|
||||||
* </tbody>
|
* </tbody>
|
||||||
* </table>
|
* </table>
|
||||||
|
* <p>For applications targeting SDK version 31 or newer, if the mobile device doesn't declare
|
||||||
|
* to be media performance class S, or if the camera device isn't a primary rear/front
|
||||||
|
* camera, the minimum required output stream configurations are the same as for applications
|
||||||
|
* targeting SDK version older than 31.</p>
|
||||||
* <p>Refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} for additional
|
* <p>Refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} for additional
|
||||||
* mandatory stream configurations on a per-capability basis.</p>
|
* mandatory stream configurations on a per-capability basis.</p>
|
||||||
* <p>Exception on 176x144 (QCIF) resolution: camera devices usually have a fixed capability for
|
* <p>Exception on 176x144 (QCIF) resolution: camera devices usually have a fixed capability for
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ public final class CameraManager {
|
|||||||
@NonNull Map<String, SessionConfiguration> cameraIdAndSessionConfig)
|
@NonNull Map<String, SessionConfiguration> cameraIdAndSessionConfig)
|
||||||
throws CameraAccessException {
|
throws CameraAccessException {
|
||||||
return CameraManagerGlobal.get().isConcurrentSessionConfigurationSupported(
|
return CameraManagerGlobal.get().isConcurrentSessionConfigurationSupported(
|
||||||
cameraIdAndSessionConfig);
|
cameraIdAndSessionConfig, mContext.getApplicationInfo().targetSdkVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -413,7 +413,8 @@ public final class CameraManager {
|
|||||||
try {
|
try {
|
||||||
for (String physicalCameraId : physicalCameraIds) {
|
for (String physicalCameraId : physicalCameraIds) {
|
||||||
CameraMetadataNative physicalCameraInfo =
|
CameraMetadataNative physicalCameraInfo =
|
||||||
cameraService.getCameraCharacteristics(physicalCameraId);
|
cameraService.getCameraCharacteristics(physicalCameraId,
|
||||||
|
mContext.getApplicationInfo().targetSdkVersion);
|
||||||
StreamConfiguration[] configs = physicalCameraInfo.get(
|
StreamConfiguration[] configs = physicalCameraInfo.get(
|
||||||
CameraCharacteristics.
|
CameraCharacteristics.
|
||||||
SCALER_PHYSICAL_CAMERA_MULTI_RESOLUTION_STREAM_CONFIGURATIONS);
|
SCALER_PHYSICAL_CAMERA_MULTI_RESOLUTION_STREAM_CONFIGURATIONS);
|
||||||
@@ -472,7 +473,8 @@ public final class CameraManager {
|
|||||||
try {
|
try {
|
||||||
Size displaySize = getDisplaySize();
|
Size displaySize = getDisplaySize();
|
||||||
|
|
||||||
CameraMetadataNative info = cameraService.getCameraCharacteristics(cameraId);
|
CameraMetadataNative info = cameraService.getCameraCharacteristics(cameraId,
|
||||||
|
mContext.getApplicationInfo().targetSdkVersion);
|
||||||
try {
|
try {
|
||||||
info.setCameraId(Integer.parseInt(cameraId));
|
info.setCameraId(Integer.parseInt(cameraId));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@@ -590,7 +592,7 @@ public final class CameraManager {
|
|||||||
}
|
}
|
||||||
cameraUser = cameraService.connectDevice(callbacks, cameraId,
|
cameraUser = cameraService.connectDevice(callbacks, cameraId,
|
||||||
mContext.getOpPackageName(), mContext.getAttributionTag(), uid,
|
mContext.getOpPackageName(), mContext.getAttributionTag(), uid,
|
||||||
oomScoreOffset);
|
oomScoreOffset, mContext.getApplicationInfo().targetSdkVersion);
|
||||||
} catch (ServiceSpecificException e) {
|
} catch (ServiceSpecificException e) {
|
||||||
if (e.errorCode == ICameraService.ERROR_DEPRECATED_HAL) {
|
if (e.errorCode == ICameraService.ERROR_DEPRECATED_HAL) {
|
||||||
throw new AssertionError("Should've gone down the shim path");
|
throw new AssertionError("Should've gone down the shim path");
|
||||||
@@ -1613,8 +1615,8 @@ public final class CameraManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConcurrentSessionConfigurationSupported(
|
public boolean isConcurrentSessionConfigurationSupported(
|
||||||
@NonNull Map<String, SessionConfiguration> cameraIdsAndSessionConfigurations)
|
@NonNull Map<String, SessionConfiguration> cameraIdsAndSessionConfigurations,
|
||||||
throws CameraAccessException {
|
int targetSdkVersion) throws CameraAccessException {
|
||||||
|
|
||||||
if (cameraIdsAndSessionConfigurations == null) {
|
if (cameraIdsAndSessionConfigurations == null) {
|
||||||
throw new IllegalArgumentException("cameraIdsAndSessionConfigurations was null");
|
throw new IllegalArgumentException("cameraIdsAndSessionConfigurations was null");
|
||||||
@@ -1650,7 +1652,7 @@ public final class CameraManager {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return mCameraService.isConcurrentSessionConfigurationSupported(
|
return mCameraService.isConcurrentSessionConfigurationSupported(
|
||||||
cameraIdsAndConfigs);
|
cameraIdsAndConfigs, targetSdkVersion);
|
||||||
} catch (ServiceSpecificException e) {
|
} catch (ServiceSpecificException e) {
|
||||||
throwAsPublicException(e);
|
throwAsPublicException(e);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
@@ -566,8 +566,9 @@ static jint android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz,
|
|||||||
env->ReleaseStringChars(clientPackageName,
|
env->ReleaseStringChars(clientPackageName,
|
||||||
reinterpret_cast<const jchar*>(rawClientName));
|
reinterpret_cast<const jchar*>(rawClientName));
|
||||||
|
|
||||||
sp<Camera> camera =
|
int targetSdkVersion = android_get_application_target_sdk_version();
|
||||||
Camera::connect(cameraId, clientName, Camera::USE_CALLING_UID, Camera::USE_CALLING_PID);
|
sp<Camera> camera = Camera::connect(cameraId, clientName, Camera::USE_CALLING_UID,
|
||||||
|
Camera::USE_CALLING_PID, targetSdkVersion);
|
||||||
if (camera == NULL) {
|
if (camera == NULL) {
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,8 @@ public class CameraBinderTest extends AndroidTestCase {
|
|||||||
ICamera cameraUser = mUtils.getCameraService()
|
ICamera cameraUser = mUtils.getCameraService()
|
||||||
.connect(dummyCallbacks, cameraId, clientPackageName,
|
.connect(dummyCallbacks, cameraId, clientPackageName,
|
||||||
ICameraService.USE_CALLING_UID,
|
ICameraService.USE_CALLING_UID,
|
||||||
ICameraService.USE_CALLING_PID);
|
ICameraService.USE_CALLING_PID,
|
||||||
|
getContext().getApplicationInfo().targetSdkVersion);
|
||||||
assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
|
assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
|
||||||
|
|
||||||
Log.v(TAG, String.format("Camera %s connected", cameraId));
|
Log.v(TAG, String.format("Camera %s connected", cameraId));
|
||||||
@@ -262,7 +263,8 @@ public class CameraBinderTest extends AndroidTestCase {
|
|||||||
mUtils.getCameraService().connectDevice(
|
mUtils.getCameraService().connectDevice(
|
||||||
dummyCallbacks, String.valueOf(cameraId),
|
dummyCallbacks, String.valueOf(cameraId),
|
||||||
clientPackageName, clientAttributionTag,
|
clientPackageName, clientAttributionTag,
|
||||||
ICameraService.USE_CALLING_UID, 0 /*oomScoreOffset*/);
|
ICameraService.USE_CALLING_UID, 0 /*oomScoreOffset*/,
|
||||||
|
getContext().getApplicationInfo().targetSdkVersion);
|
||||||
assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
|
assertNotNull(String.format("Camera %s was null", cameraId), cameraUser);
|
||||||
|
|
||||||
Log.v(TAG, String.format("Camera %s connected", cameraId));
|
Log.v(TAG, String.format("Camera %s connected", cameraId));
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ public class CameraDeviceBinderTest extends AndroidTestCase {
|
|||||||
|
|
||||||
mCameraUser = mUtils.getCameraService().connectDevice(mMockCb, mCameraId,
|
mCameraUser = mUtils.getCameraService().connectDevice(mMockCb, mCameraId,
|
||||||
clientPackageName, clientAttributionTag, ICameraService.USE_CALLING_UID,
|
clientPackageName, clientAttributionTag, ICameraService.USE_CALLING_UID,
|
||||||
/*oomScoreOffset*/0);
|
/*oomScoreOffset*/0, getContext().getApplicationInfo().targetSdkVersion);
|
||||||
assertNotNull(String.format("Camera %s was null", mCameraId), mCameraUser);
|
assertNotNull(String.format("Camera %s was null", mCameraId), mCameraUser);
|
||||||
mHandlerThread = new HandlerThread(TAG);
|
mHandlerThread = new HandlerThread(TAG);
|
||||||
mHandlerThread.start();
|
mHandlerThread.start();
|
||||||
@@ -416,7 +416,8 @@ public class CameraDeviceBinderTest extends AndroidTestCase {
|
|||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testCameraCharacteristics() throws RemoteException {
|
public void testCameraCharacteristics() throws RemoteException {
|
||||||
CameraMetadataNative info = mUtils.getCameraService().getCameraCharacteristics(mCameraId);
|
CameraMetadataNative info = mUtils.getCameraService().getCameraCharacteristics(mCameraId,
|
||||||
|
getContext().getApplicationInfo().targetSdkVersion);
|
||||||
|
|
||||||
assertFalse(info.isEmpty());
|
assertFalse(info.isEmpty());
|
||||||
assertNotNull(info.get(CameraCharacteristics.SCALER_AVAILABLE_FORMATS));
|
assertNotNull(info.get(CameraCharacteristics.SCALER_AVAILABLE_FORMATS));
|
||||||
|
|||||||
Reference in New Issue
Block a user