|
@@ -31,6 +31,7 @@ import com.xplora.commonservice.modules.http.FlowableFactory.getFlowable
|
|
|
import com.xplora.commonservice.modules.http.XPHttpServiceExecutor
|
|
|
import com.xplora.commonservice.ui.activity.EmptyActivity
|
|
|
import com.xplora.commonservice.utils.Logger
|
|
|
+import com.xplora.commonservice.utils.ShellUtils
|
|
|
import com.xplora.commonservice.utils.WatchPowerHelper.doShutdown
|
|
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
@@ -52,6 +53,7 @@ class SystemInfoReceiver : BroadcastReceiver() {
|
|
|
Intent.ACTION_BATTERY_CHANGED -> {
|
|
|
var needReport = false
|
|
|
val level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0)
|
|
|
+ val voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0)
|
|
|
var levelFin = level//if (level >= 90) 100 else (level * 100) / 90
|
|
|
/* val enable: Boolean
|
|
|
if (levelFin >= 100) {
|
|
@@ -61,6 +63,18 @@ class SystemInfoReceiver : BroadcastReceiver() {
|
|
|
enable = true
|
|
|
ShellUtils.writeValue(CHARGER_ENABLED_PATH, ENABLED_CHARGER)
|
|
|
}*/
|
|
|
+ val isSmartCharging = Settings.Global.getInt(
|
|
|
+ globalContext.contentResolver,
|
|
|
+ "sk_charging_status",
|
|
|
+ 1
|
|
|
+ ) == 1
|
|
|
+ if (level <= 80) {
|
|
|
+ ShellUtils.writeValue(CHARGER_ENABLED_PATH, ENABLED_CHARGER)
|
|
|
+ }
|
|
|
+ if (isSmartCharging && level >= 90) {
|
|
|
+ ShellUtils.writeValue(CHARGER_ENABLED_PATH, DISABLED_CHARGER)
|
|
|
+
|
|
|
+ }
|
|
|
watchBaseInfo.batteryTemp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0)
|
|
|
val chargeStatus = intent.getIntExtra(
|
|
|
BatteryManager.EXTRA_STATUS,
|
|
@@ -71,7 +85,10 @@ class SystemInfoReceiver : BroadcastReceiver() {
|
|
|
it == BatteryManager.BATTERY_PLUGGED_AC || it == BatteryManager.BATTERY_PLUGGED_USB
|
|
|
}
|
|
|
|
|
|
- Logger.d(TAG, "on battery change level: $levelFin")
|
|
|
+ Logger.d(
|
|
|
+ TAG,
|
|
|
+ "on battery change level: $levelFin -- voltage: $voltage -------------------------------------"
|
|
|
+ )
|
|
|
val disableStatus =
|
|
|
Settings.Global.getInt(globalContext.contentResolver, "disable_status", 0)
|
|
|
|