-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix image analysis use case to camera hardware under level 3
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
camposer/src/main/java/com/ujizin/camposer/extensions/CameraManagerExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ujizin.camposer.extensions | ||
|
||
import android.hardware.camera2.CameraCharacteristics | ||
import android.hardware.camera2.CameraManager | ||
import com.ujizin.camposer.helper.CameraHelper | ||
|
||
internal fun CameraManager.isImageAnalysisSupported(lensFacing: Int?): Boolean { | ||
val cameraId = cameraIdList.firstOrNull { | ||
getCameraCharacteristics(it).get(CameraCharacteristics.LENS_FACING) == lensFacing | ||
} ?: return false | ||
|
||
val level = getCameraCharacteristics(cameraId) | ||
.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL) ?: 0 | ||
|
||
return level >= CameraHelper.compatHardwareLevel3 | ||
} |
14 changes: 14 additions & 0 deletions
14
camposer/src/main/java/com/ujizin/camposer/helper/CameraHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.ujizin.camposer.helper | ||
|
||
import android.hardware.camera2.CameraCharacteristics | ||
import android.os.Build | ||
|
||
internal object CameraHelper { | ||
|
||
private const val COMPAT_HARDWARE_LEVEL_3 = 3 | ||
|
||
internal val compatHardwareLevel3: Int = when { | ||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3 | ||
else -> COMPAT_HARDWARE_LEVEL_3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters