mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-05 02:39:30 +02:00
Add battery limit feature
This commit is contained in:
parent
3d4fa21183
commit
f0cd6b92c0
35 changed files with 1481 additions and 58 deletions
|
@ -36,6 +36,7 @@ import io.timelimit.android.integration.platform.ProtectionLevel
|
|||
import io.timelimit.android.integration.platform.android.AccessibilityService
|
||||
import io.timelimit.android.integration.platform.android.AndroidIntegrationApps
|
||||
import io.timelimit.android.livedata.*
|
||||
import io.timelimit.android.logic.extension.isCategoryAllowed
|
||||
import io.timelimit.android.sync.actions.UpdateDeviceStatusAction
|
||||
import io.timelimit.android.sync.actions.apply.ApplyActionUtil
|
||||
import io.timelimit.android.ui.IsAppInForeground
|
||||
|
@ -261,6 +262,7 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
|
||||
// get the current status
|
||||
val isScreenOn = appLogic.platformIntegration.isScreenOn()
|
||||
val batteryStatus = appLogic.platformIntegration.getBatteryStatus()
|
||||
|
||||
appLogic.defaultUserLogic.reportScreenOn(isScreenOn)
|
||||
|
||||
|
@ -335,6 +337,10 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
|||
if (category == null) {
|
||||
usedTimeUpdateHelper?.commit(appLogic)
|
||||
|
||||
openLockscreen(foregroundAppPackageName, foregroundAppActivityName)
|
||||
} else if ((!batteryStatus.isCategoryAllowed(category)) || (!batteryStatus.isCategoryAllowed(parentCategory))) {
|
||||
usedTimeUpdateHelper?.commit(appLogic)
|
||||
|
||||
openLockscreen(foregroundAppPackageName, foregroundAppActivityName)
|
||||
} else if (category.temporarilyBlocked or (parentCategory?.temporarilyBlocked == true)) {
|
||||
usedTimeUpdateHelper?.commit(appLogic)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue