Java Code Examples for android.hardware.camera2.CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY

The following examples show how to use android.hardware.camera2.CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraXUtil.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@RequiresApi(21)
public static int getLowestSupportedHardwareLevel(@NonNull Context context) {
  @SuppressLint("RestrictedApi") CameraManager cameraManager = CameraManagerCompat.from(context).unwrap();

  try {
    int supported = maxHardwareLevel();

    for (String cameraId : cameraManager.getCameraIdList()) {
      CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);
      Integer               hwLevel         = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);

      if (hwLevel == null || hwLevel == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
        return CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
      }

      supported = smallerHardwareLevel(supported, hwLevel);
    }

    return supported;
  } catch (CameraAccessException e) {
    Log.w(TAG, "Failed to enumerate cameras", e);

    return CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
  }
}
 
Example 2
Source File: VideoCaptureCamera2.java    From 365browser with Apache License 2.0 6 votes vote down vote up
static int getCaptureApiType(int id) {
    final CameraCharacteristics cameraCharacteristics = getCameraCharacteristics(id);
    if (cameraCharacteristics == null) {
        return VideoCaptureApi.UNKNOWN;
    }

    final int supportedHWLevel =
            cameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
    switch (supportedHWLevel) {
        case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY:
            return VideoCaptureApi.ANDROID_API2_LEGACY;
        case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL:
            return VideoCaptureApi.ANDROID_API2_FULL;
        case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED:
            return VideoCaptureApi.ANDROID_API2_LIMITED;
        default:
            return VideoCaptureApi.ANDROID_API2_LEGACY;
    }
}
 
Example 3
Source File: CameraXUtil.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@RequiresApi(21)
private static int smallerHardwareLevel(int levelA, int levelB) {

  int[] hardwareInfoOrdering = getHardwareInfoOrdering();
  for (int hwInfo : hardwareInfoOrdering) {
    if (levelA == hwInfo || levelB == hwInfo) return hwInfo;
  }

  return CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
}
 
Example 4
Source File: CameraXUtil.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
@RequiresApi(21)
public static boolean isMixedModeSupported(@NonNull Context context) {
  return getLowestSupportedHardwareLevel(context) != CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
}
 
Example 5
Source File: VideoCaptureCamera2.java    From 365browser with Apache License 2.0 4 votes vote down vote up
static boolean isLegacyDevice(int id) {
    final CameraCharacteristics cameraCharacteristics = getCameraCharacteristics(id);
    return cameraCharacteristics != null
            && cameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)
            == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
}