|
|
@ -24,6 +24,9 @@ public class ExposureMeter extends BaseMeter { |
|
|
|
private static final int STATE_WAITING_PRECAPTURE = 0; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE = 0; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE_END = 1; |
|
|
|
private static final int STATE_WAITING_PRECAPTURE_END = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean mSupportsAreas = false; |
|
|
|
|
|
|
|
private boolean mSupportsTrigger = false; |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("WeakerAccess") |
|
|
|
@SuppressWarnings("WeakerAccess") |
|
|
|
public ExposureMeter(@NonNull List<MeteringRectangle> areas, boolean skipIfPossible) { |
|
|
|
public ExposureMeter(@NonNull List<MeteringRectangle> areas, boolean skipIfPossible) { |
|
|
|
super(areas, skipIfPossible); |
|
|
|
super(areas, skipIfPossible); |
|
|
@ -32,9 +35,9 @@ public class ExposureMeter extends BaseMeter { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected boolean checkIsSupported(@NonNull ActionHolder holder) { |
|
|
|
protected boolean checkIsSupported(@NonNull ActionHolder holder) { |
|
|
|
// In our case, this means checking if we support the AE precapture trigger.
|
|
|
|
// In our case, this means checking if we support the AE precapture trigger.
|
|
|
|
boolean isNotLegacy = readCharacteristic( |
|
|
|
boolean isLegacy = readCharacteristic( |
|
|
|
CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL, -1) |
|
|
|
CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL, -1) |
|
|
|
!= CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY; |
|
|
|
== CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY; |
|
|
|
Integer aeMode = holder.getBuilder(this).get(CaptureRequest.CONTROL_AE_MODE); |
|
|
|
Integer aeMode = holder.getBuilder(this).get(CaptureRequest.CONTROL_AE_MODE); |
|
|
|
boolean isAEOn = aeMode != null && |
|
|
|
boolean isAEOn = aeMode != null && |
|
|
|
(aeMode == CameraCharacteristics.CONTROL_AE_MODE_ON |
|
|
|
(aeMode == CameraCharacteristics.CONTROL_AE_MODE_ON |
|
|
@ -43,8 +46,13 @@ public class ExposureMeter extends BaseMeter { |
|
|
|
|| aeMode == CameraCharacteristics.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE |
|
|
|
|| aeMode == CameraCharacteristics.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE |
|
|
|
|| aeMode == 5 |
|
|
|
|| aeMode == 5 |
|
|
|
/* CameraCharacteristics.CONTROL_AE_MODE_ON_EXTERNAL_FLASH, API 28 */); |
|
|
|
/* CameraCharacteristics.CONTROL_AE_MODE_ON_EXTERNAL_FLASH, API 28 */); |
|
|
|
boolean result = isNotLegacy && isAEOn; |
|
|
|
mSupportsTrigger = !isLegacy; |
|
|
|
LOG.i("checkIsSupported:", result); |
|
|
|
mSupportsAreas = readCharacteristic(CameraCharacteristics.CONTROL_MAX_REGIONS_AE, |
|
|
|
|
|
|
|
0) > 0; |
|
|
|
|
|
|
|
boolean result = isAEOn && (mSupportsTrigger || mSupportsAreas); |
|
|
|
|
|
|
|
LOG.i("checkIsSupported:", result, |
|
|
|
|
|
|
|
"trigger:", mSupportsTrigger, |
|
|
|
|
|
|
|
"areas:", mSupportsAreas); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -66,22 +74,26 @@ public class ExposureMeter extends BaseMeter { |
|
|
|
protected void onStarted(@NonNull ActionHolder holder, @NonNull List<MeteringRectangle> areas) { |
|
|
|
protected void onStarted(@NonNull ActionHolder holder, @NonNull List<MeteringRectangle> areas) { |
|
|
|
LOG.i("onStarted:", "with areas:", areas); |
|
|
|
LOG.i("onStarted:", "with areas:", areas); |
|
|
|
|
|
|
|
|
|
|
|
// Launch the precapture trigger.
|
|
|
|
if (mSupportsAreas && !areas.isEmpty()) { |
|
|
|
holder.getBuilder(this).set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, |
|
|
|
int max = readCharacteristic(CameraCharacteristics.CONTROL_MAX_REGIONS_AE, 0); |
|
|
|
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START); |
|
|
|
max = Math.min(max, areas.size()); |
|
|
|
|
|
|
|
|
|
|
|
// Check the regions.
|
|
|
|
|
|
|
|
int maxRegions = readCharacteristic(CameraCharacteristics.CONTROL_MAX_REGIONS_AE, |
|
|
|
|
|
|
|
0); |
|
|
|
|
|
|
|
if (!areas.isEmpty() && maxRegions > 0) { |
|
|
|
|
|
|
|
int max = Math.min(maxRegions, areas.size()); |
|
|
|
|
|
|
|
holder.getBuilder(this).set(CaptureRequest.CONTROL_AE_REGIONS, |
|
|
|
holder.getBuilder(this).set(CaptureRequest.CONTROL_AE_REGIONS, |
|
|
|
areas.subList(0, max).toArray(new MeteringRectangle[]{})); |
|
|
|
areas.subList(0, max).toArray(new MeteringRectangle[]{})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mSupportsTrigger) { |
|
|
|
|
|
|
|
holder.getBuilder(this).set( |
|
|
|
|
|
|
|
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, |
|
|
|
|
|
|
|
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Apply
|
|
|
|
// Apply
|
|
|
|
holder.applyBuilder(this); |
|
|
|
holder.applyBuilder(this); |
|
|
|
setState(STATE_WAITING_PRECAPTURE); |
|
|
|
if (mSupportsTrigger) { |
|
|
|
|
|
|
|
setState(STATE_WAITING_PRECAPTURE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setState(STATE_WAITING_PRECAPTURE_END); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|