Skip to content

Commit

Permalink
ChargingControl: Handle cancel toggle correctly if bypass is not supp…
Browse files Browse the repository at this point in the history
…orted

Change-Id: Ib7e208bba554b76a067d70280785290d5a0ba08d
Signed-off-by: Mohammad Hasan Keramat J <ikeramat@protonmail.com>
  • Loading branch information
hellobbn authored and bheatleyyy committed Sep 28, 2023
1 parent 2856713 commit fa16a38
Showing 1 changed file with 15 additions and 0 deletions.
Expand Up @@ -757,6 +757,21 @@ public boolean isDoneNotification() {
private void handleNotificationIntent(Intent intent) {
if (intent.getAction().equals(ACTION_CHARGING_CONTROL_CANCEL_ONCE)) {
mIsControlCancelledOnce = true;

if (!mIsChargingBypassSupported) {
IntentFilter disconnectFilter = new IntentFilter(
Intent.ACTION_POWER_DISCONNECTED);
// Register a one-time receiver that resets internal state on power
// disconnection
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Power disconnected, reset internal states");
resetInternalState();
mContext.unregisterReceiver(this);
}
}, disconnectFilter);
}
updateChargeControl();
cancelChargingControlNotification();
}
Expand Down

0 comments on commit fa16a38

Please sign in to comment.