Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Fix service auto start
Browse files Browse the repository at this point in the history
  • Loading branch information
nazmulidris committed Jun 14, 2020
1 parent f644cb3 commit 49d98da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.r3bl.stayawake"
minSdkVersion 25
targetSdkVersion 28
versionCode 14
versionName "2.2"
versionCode 15
versionName "2.3"
}
buildTypes {
release {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/r3bl/stayawake/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class MainActivity : AppCompatActivity() {
MyTileService.fireIntentWithStartService(this)
d(TAG, "MainActivity.handleAutoStartOfService: Initiate auto start")
}
else d(TAG, "MainActivity.handleAutoStartOfService: Do nothing, auto start disabled")
else d(TAG, "MainActivity.handleAutoStartOfService: Do not auto start")
}

private fun setupCheckbox() = mySettingsHolder.value.autoStartEnabled.let { autoStartEnabled ->
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/java/com/r3bl/stayawake/MyTileService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MyTileService : TileService() {
commandStart()
d(TAG, "MyTileService.handleAutoStartOfService: Initiate auto start")
}
else d(TAG, "MyTileService.handleAutoStartOfService: Do nothing, auto start disabled")
else d(TAG, "MyTileService.handleAutoStartOfService: Do not auto start")
}

override fun onDestroy() {
Expand Down Expand Up @@ -431,9 +431,7 @@ class MyTileService : TileService() {
val intentFilter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
val batteryStatus = context.applicationContext.registerReceiver(null, intentFilter)
val status = batteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
return status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL ||
status == BatteryManager.BATTERY_PLUGGED_AC ||
return status == BatteryManager.BATTERY_PLUGGED_AC ||
status == BatteryManager.BATTERY_PLUGGED_WIRELESS ||
status == BatteryManager.BATTERY_PLUGGED_USB
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PowerConnectionReceiver(private val myContext: Context) : BroadcastReceive
d(TAG, message)
}
else {
val message = "onReceive: PowerConnectionReceiver ACTION_POWER_CONNECTED ... Do nothing, auto start disabled"
val message = "onReceive: PowerConnectionReceiver ACTION_POWER_CONNECTED ... Do not auto start"
// showToast(myContext, message)
d(TAG, message)
}
Expand All @@ -83,7 +83,7 @@ class PowerConnectionReceiver(private val myContext: Context) : BroadcastReceive
d(TAG, message)
}
else {
val message = "onReceive: PowerConnectionReceiver ACTION_POWER_DISCONNECTED ... Do nothing, auto start disabled"
val message = "onReceive: PowerConnectionReceiver ACTION_POWER_DISCONNECTED ... Do not auto start"
// showToast(myContext, message)
d(TAG, message)
}
Expand Down

0 comments on commit 49d98da

Please sign in to comment.