Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…MP-kotlin into android_14_foreground_service_type
  • Loading branch information
anjumg03 committed Aug 28, 2024
2 parents d4f0c8f + 43ecf32 commit e0dc8c7
Showing 1 changed file with 53 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,39 @@ class WiFi : Service() {

if (frequency != null) {
if (frequency!! >= LampConstants.FREQUENCY_WIFI) {
alarmManager?.cancel(wifiScan)
alarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(),
frequency!! * 1000,
wifiScan
)
wifiScan?.let {
alarmManager?.cancel(it)
alarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(),
frequency!! * 1000,
it
)
}

}else{
alarmManager?.cancel(wifiScan)
wifiScan?.let {
alarmManager?.cancel(it)
alarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(),
(LampConstants.FREQUENCY_WIFI * 1000).toLong(),
it
)
}

}
} else {
wifiScan?.let {
alarmManager?.cancel(it)
alarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(),
(LampConstants.FREQUENCY_WIFI * 1000).toLong(),
wifiScan
it
)
}
} else {
alarmManager?.cancel(wifiScan)
alarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(),
(LampConstants.FREQUENCY_WIFI * 1000).toLong(),
wifiScan
)


}

Expand All @@ -118,31 +127,38 @@ class WiFi : Service() {
val startTime = System.currentTimeMillis()
if (frequency != null) {
if (frequency!! >= LampConstants.FREQUENCY_WIFI) {
bluetoothAlarmManager?.cancel(bluetoothScan)
bluetoothAlarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
startTime,
frequency!! * 1000,
bluetoothScan
)
bluetoothScan?.let { bluetoothScan->
bluetoothAlarmManager?.cancel(bluetoothScan)
bluetoothAlarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
startTime,
frequency!! * 1000,
bluetoothScan
)
}

}else {
bluetoothAlarmManager?.cancel(bluetoothScan)
bluetoothScan?.let { bluetoothScan->
bluetoothAlarmManager?.cancel(bluetoothScan)
bluetoothAlarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
startTime,
(LampConstants.FREQUENCY_WIFI * 1000).toLong(),
bluetoothScan
)
}
}

} else {
bluetoothScan?.let {
bluetoothAlarmManager?.cancel(it)
bluetoothAlarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
startTime,
(LampConstants.FREQUENCY_WIFI * 1000).toLong(),
bluetoothScan
it
)
}

} else {
bluetoothAlarmManager?.cancel(bluetoothScan)
bluetoothAlarmManager?.setRepeating(
AlarmManager.RTC_WAKEUP,
startTime,
(LampConstants.FREQUENCY_WIFI * 1000).toLong(),
bluetoothScan
)
}


Expand All @@ -152,8 +168,8 @@ class WiFi : Service() {
super.onDestroy()
unregisterReceiver(wifiMonitor)
unregisterReceiver(bluetoothMonitor)
if (wifiScan != null) alarmManager!!.cancel(wifiScan)
if (bluetoothScan != null) bluetoothAlarmManager!!.cancel(bluetoothScan)
if (wifiScan != null) alarmManager!!.cancel(wifiScan!!)
if (bluetoothScan != null) bluetoothAlarmManager!!.cancel(bluetoothScan!!)
if (Lamp.DEBUG) Log.d(TAG, "WiFi service terminated...")
}

Expand Down

0 comments on commit e0dc8c7

Please sign in to comment.