mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-02-06 13:13:43 +01:00
catch all exceptions at MarshmallowCamera
This commit is contained in:
parent
6a702ac2d2
commit
10dcb51cae
@ -2,7 +2,6 @@ package com.simplemobiletools.flashlight.helpers
|
|||||||
|
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.hardware.camera2.CameraAccessException
|
|
||||||
import android.hardware.camera2.CameraManager
|
import android.hardware.camera2.CameraManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
@ -18,7 +17,7 @@ internal class MarshmallowCamera constructor(val context: Context) {
|
|||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
cameraId = manager.cameraIdList[0] ?: "0"
|
cameraId = manager.cameraIdList[0] ?: "0"
|
||||||
} catch (ignored: CameraAccessException) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ internal class MarshmallowCamera constructor(val context: Context) {
|
|||||||
fun toggleMarshmallowFlashlight(bus: Bus, enable: Boolean) {
|
fun toggleMarshmallowFlashlight(bus: Bus, enable: Boolean) {
|
||||||
try {
|
try {
|
||||||
manager.setTorchMode(cameraId!!, enable)
|
manager.setTorchMode(cameraId!!, enable)
|
||||||
} catch (e: CameraAccessException) {
|
} catch (e: Exception) {
|
||||||
val mainRunnable = Runnable {
|
val mainRunnable = Runnable {
|
||||||
bus.post(Events.CameraUnavailable())
|
bus.post(Events.CameraUnavailable())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.20'
|
ext.kotlin_version = '1.2.21'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user