Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b42074b6 authored by Pajace Chen's avatar Pajace Chen Committed by Android (Google) Code Review
Browse files

Merge "Delete DockDefenderTip and Detector" into main

parents b35f828b 98a522c4
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -5612,18 +5612,6 @@
    <string name="battery_tip_limited_temporarily_title">Charging optimized to protect your battery</string>
    <!-- Summary for the battery limited temporarily tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_limited_temporarily_summary">To help extend your battery\'s lifespan, charging is optimized</string>
    <!-- Title for the battery dock defender future bypass tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dock_defender_future_bypass_title">Charging optimized to protect your battery</string>
    <!-- Summary for the battery dock defender future bypass tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dock_defender_future_bypass_summary">To help extend your battery\'s lifespan, charging is optimized while docked</string>
    <!-- Title for the battery dock defender active tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dock_defender_active_title">Charging optimized to protect your battery</string>
    <!-- Summary for the battery dock defender active tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dock_defender_active_summary">To help extend your battery\'s lifespan, charging is optimized while docked</string>
    <!-- Title for the battery dock defender temporarily bypassed tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dock_defender_temporarily_bypassed_title">Charging to full</string>
    <!-- Summary for the battery dock defender temporarily bypassed tip [CHAR LIMIT=NONE] -->
    <string name="battery_tip_dock_defender_temporarily_bypassed_summary">To protect your battery, charging will be optimized the next time your tablet is docked</string>
    <!-- Content description for the battery limited temporarily tip secondary button [CHAR LIMIT=NONE] -->
    <string name="battery_tip_limited_temporarily_sec_button_content_description">Learn more about charging is paused</string>
    <!-- Text of battery limited temporarily tip resume charge button. [CHAR LIMIT=NONE] -->
+1 −1
Original line number Diff line number Diff line
@@ -35,5 +35,5 @@ public interface BatterySettingsFeatureProvider {
    boolean isBatteryInfoEnabled(Context context);

    /** A way to add more battery tip detectors. */
    void addBatteryTipDetector(Context context, List<BatteryTip> tips);
    void addBatteryTipDetector(Context context, List<BatteryTip> tips, BatteryInfo batteryInfo);
}
+2 −1
Original line number Diff line number Diff line
@@ -41,5 +41,6 @@ public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatur
    }

    @Override
    public void addBatteryTipDetector(Context context, List<BatteryTip> tips) {}
    public void addBatteryTipDetector(
            Context context, List<BatteryTip> tips, BatteryInfo batteryInfo) {}
}
+1 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import androidx.annotation.VisibleForTesting;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.detectors.BatteryDefenderDetector;
import com.android.settings.fuelgauge.batterytip.detectors.DockDefenderDetector;
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
import com.android.settings.fuelgauge.batterytip.detectors.IncompatibleChargerDetector;
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
@@ -66,11 +65,10 @@ public class BatteryTipLoader extends AsyncLoaderCompat<List<BatteryTip>> {
        tips.add(new LowBatteryDetector(context, policy, batteryInfo, isPowerSaveMode).detect());
        tips.add(new HighUsageDetector(context, policy, mBatteryUsageStats, batteryInfo).detect());
        tips.add(new BatteryDefenderDetector(batteryInfo, context).detect());
        tips.add(new DockDefenderDetector(batteryInfo, context).detect());
        tips.add(new IncompatibleChargerDetector(context).detect());
        FeatureFactory.getFeatureFactory()
                .getBatterySettingsFeatureProvider()
                .addBatteryTipDetector(context, tips);
                .addBatteryTipDetector(context, tips, batteryInfo);
        Collections.sort(tips);
        return tips;
    }
+0 −45
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings.fuelgauge.batterytip.detectors;

import android.content.Context;

import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.BatteryUtils;
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
import com.android.settings.fuelgauge.batterytip.tips.DockDefenderTip;

/** Detect whether the dock defender mode is enabled. */
public class DockDefenderDetector implements BatteryTipDetector {
    private final BatteryInfo mBatteryInfo;
    private final Context mContext;

    public DockDefenderDetector(BatteryInfo batteryInfo, Context context) {
        mBatteryInfo = batteryInfo;
        mContext = context;
    }

    @Override
    public BatteryTip detect() {
        int mode = BatteryUtils.getCurrentDockDefenderMode(mContext, mBatteryInfo);
        return new DockDefenderTip(
                mode != BatteryUtils.DockDefenderMode.DISABLED
                        ? BatteryTip.StateType.NEW
                        : BatteryTip.StateType.INVISIBLE,
                mode);
    }
}
Loading