summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/src/AutoOnFeature.kt6
-rw-r--r--service/src/AutoOnFeatureTest.kt10
2 files changed, 15 insertions, 1 deletions
diff --git a/service/src/AutoOnFeature.kt b/service/src/AutoOnFeature.kt
index 03fcabeeef..0f53bee7ad 100644
--- a/service/src/AutoOnFeature.kt
+++ b/service/src/AutoOnFeature.kt
@@ -109,6 +109,10 @@ public fun notifyBluetoothOn(context: Context) {
} else {
Log.i(TAG, "Feature was set to its default value ${defaultFeatureValue}")
}
+ } else {
+ // When Bluetooth turned on state, any saved time will be obsolete.
+ // This happen only when the phone reboot while Bluetooth is ON
+ Timer.resetStorage(context.contentResolver)
}
}
@@ -204,7 +208,7 @@ private constructor(
return date?.let { LocalDateTime.parse(it) }
}
- private fun resetStorage(resolver: ContentResolver) {
+ fun resetStorage(resolver: ContentResolver) {
Settings.Secure.putString(resolver, STORAGE_KEY, null)
}
diff --git a/service/src/AutoOnFeatureTest.kt b/service/src/AutoOnFeatureTest.kt
index 3b282e9faa..b511f70bb2 100644
--- a/service/src/AutoOnFeatureTest.kt
+++ b/service/src/AutoOnFeatureTest.kt
@@ -210,6 +210,16 @@ class AutoOnFeatureTest {
}
@Test
+ fun notifyBluetoothOn_whenStorage_resetStorage() {
+ Settings.Secure.putString(resolver, Timer.STORAGE_KEY, timerTarget.toString())
+ shadowOf(looper).idle()
+
+ notifyBluetoothOn(context)
+
+ expectNoStorageTime()
+ }
+
+ @Test
fun apiIsUserEnable_whenItWasNeverUsed_throwException() {
restoreSettings()