Skip to content

Commit

Permalink
Merge pull request #435 from this-Aditya/exception
Browse files Browse the repository at this point in the history
Updated exception-handling for unregisterReceiver
  • Loading branch information
yatharthranjan authored May 9, 2024
2 parents f7e4092 + 9aed432 commit 4256245
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright 2017 The Hyve
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -134,7 +134,7 @@ class GoogleSleepManager(context: GoogleSleepService) : AbstractSourceManager<Go
try {
service.unregisterReceiver(sleepBroadcastReceiver)
logger.info("Unregistered from sleep receiver ")
} catch (ex: IllegalStateException) {
} catch (ex: IllegalArgumentException) {
logger.error("Exception when unregistering from sleep receiver", ex)
}
}
Expand Down Expand Up @@ -170,4 +170,4 @@ class GoogleSleepManager(context: GoogleSleepService) : AbstractSourceManager<Go
else -> SleepClassificationStatus.UNKNOWN
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class PhoneBluetoothManager(service: PhoneBluetoothService) : AbstractSourceMana
bluetoothBroadcastReceiver?.let {
try {
service.unregisterReceiver(it)
} catch (ex: IllegalStateException) {
} catch (ex: IllegalArgumentException) {
logger.warn("Bluetooth receiver already unregistered in broadcast")
}
bluetoothBroadcastReceiver = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class BatteryLevelReceiver(
override fun unregister() {
try {
context.unregisterReceiver(receiver)
} catch (ex: IllegalStateException) {
} catch (ex: IllegalArgumentException) {
logger.warn(
"Cannot unregister BatteryLevelReceiver. It probably was incompletely registered: {}",
ex.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class OfflineProcessor(
alarmManager.cancel(pendingIntent)
try {
context.unregisterReceiver(receiver)
} catch (ex: IllegalStateException) {
} catch (ex: IllegalArgumentException) {
logger.warn(
"Cannot unregister OfflineProcessor {}, it was most likely not completely started: {}",
config.requestName,
Expand Down

0 comments on commit 4256245

Please sign in to comment.