mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-02-16 20:00:40 +01:00
implementing the actual SOS signalling
This commit is contained in:
parent
c3d00cd536
commit
2cdf4a55a1
@ -19,6 +19,7 @@ class MyCameraImpl(val context: Context) {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var isFlashlightOn = false
|
var isFlashlightOn = false
|
||||||
|
private val SOS = arrayListOf(250L, 250L, 250L, 250L, 250L, 250L, 500L, 250L, 500L, 250L, 500L, 250L, 250L, 250L, 250L, 250L, 250L, 1000L)
|
||||||
|
|
||||||
private var camera: Camera? = null
|
private var camera: Camera? = null
|
||||||
private var params: Camera.Parameters? = null
|
private var params: Camera.Parameters? = null
|
||||||
@ -245,13 +246,16 @@ class MyCameraImpl(val context: Context) {
|
|||||||
isStroboscopeRunning = true
|
isStroboscopeRunning = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sosIndex = 0
|
||||||
if (isNougatPlus()) {
|
if (isNougatPlus()) {
|
||||||
while (!shouldStroboscopeStop) {
|
while (!shouldStroboscopeStop) {
|
||||||
try {
|
try {
|
||||||
marshmallowCamera!!.toggleMarshmallowFlashlight(bus!!, true)
|
marshmallowCamera!!.toggleMarshmallowFlashlight(bus!!, true)
|
||||||
Thread.sleep(stroboFrequency)
|
val onDuration = if (isStroboSOS) SOS[sosIndex++ % SOS.size] else stroboFrequency
|
||||||
|
Thread.sleep(onDuration)
|
||||||
marshmallowCamera!!.toggleMarshmallowFlashlight(bus!!, false)
|
marshmallowCamera!!.toggleMarshmallowFlashlight(bus!!, false)
|
||||||
Thread.sleep(stroboFrequency)
|
val offDuration = if (isStroboSOS) SOS[sosIndex++ % SOS.size] else stroboFrequency
|
||||||
|
Thread.sleep(offDuration)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
shouldStroboscopeStop = true
|
shouldStroboscopeStop = true
|
||||||
}
|
}
|
||||||
@ -277,9 +281,11 @@ class MyCameraImpl(val context: Context) {
|
|||||||
while (!shouldStroboscopeStop) {
|
while (!shouldStroboscopeStop) {
|
||||||
try {
|
try {
|
||||||
camera!!.parameters = torchOn
|
camera!!.parameters = torchOn
|
||||||
Thread.sleep(stroboFrequency)
|
val onDuration = if (isStroboSOS) SOS[sosIndex++ % SOS.size] else stroboFrequency
|
||||||
|
Thread.sleep(onDuration)
|
||||||
camera!!.parameters = torchOff
|
camera!!.parameters = torchOff
|
||||||
Thread.sleep(stroboFrequency)
|
val offDuration = if (isStroboSOS) SOS[sosIndex++ % SOS.size] else stroboFrequency
|
||||||
|
Thread.sleep(offDuration)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user