health: Update charging control if next alarm is changed
Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/8744 Change-Id: I390f7c2110add51f776f56d9de1ab690721e2e21
This commit is contained in:
@@ -44,6 +44,7 @@ public class ChargingControlController extends LineageHealthFeature {
|
||||
private final ContentResolver mContentResolver;
|
||||
private ChargingControlNotification mChargingNotification;
|
||||
private LineageHealthBatteryBroadcastReceiver mBattReceiver;
|
||||
private BroadcastReceiver mAlarmBroadcastReceiver;
|
||||
|
||||
// Defaults
|
||||
private boolean mDefaultEnabled = false;
|
||||
@@ -439,6 +440,26 @@ public class ChargingControlController extends LineageHealthFeature {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == MODE_AUTO) {
|
||||
if (mAlarmBroadcastReceiver == null) {
|
||||
IntentFilter alarmChangedFilter = new IntentFilter(
|
||||
android.app.AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
||||
mAlarmBroadcastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i(TAG, "Alarm changed, update charge times");
|
||||
updateChargeControl();
|
||||
}
|
||||
};
|
||||
mContext.registerReceiver(mAlarmBroadcastReceiver, alarmChangedFilter);
|
||||
}
|
||||
} else {
|
||||
if (mAlarmBroadcastReceiver != null) {
|
||||
mContext.unregisterReceiver(mAlarmBroadcastReceiver);
|
||||
mAlarmBroadcastReceiver = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user