Clean up useless defender dialog code

Test: Unit test passed
Bug: 260687359
Merged-In: If3cbe4072c891f1af6b5aa4fb624e4e486c78ad6
Change-Id: If3cbe4072c891f1af6b5aa4fb624e4e486c78ad6
Signed-off-by: Zhenwei Chen <zhenwec@google.com>
(cherry picked from commit a725bac68c9d1846cef096e4c5958b161787cd9c)
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index d4c00a4..5fd3905 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
@@ -43,7 +43,6 @@
 import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
 import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
 
-import java.text.NumberFormat;
 import java.util.List;
 
 /**
@@ -142,29 +141,6 @@
                         .setPositiveButton(R.string.battery_tip_unrestrict_app_dialog_ok, this)
                         .setNegativeButton(R.string.battery_tip_unrestrict_app_dialog_cancel, null)
                         .create();
-            case BatteryTip.TipType.BATTERY_DEFENDER:
-                mMetricsFeatureProvider.action(context,
-                        SettingsEnums.ACTION_TIP_BATTERY_DEFENDER, mMetricsKey);
-                final double chargeLimitLevel = 0.8f;
-                final String percentage =
-                        NumberFormat.getPercentInstance().format(chargeLimitLevel);
-                final String message = context.getString(
-                        R.string.battery_tip_limited_temporarily_dialog_msg, percentage);
-                final boolean isPluggedIn = isPluggedIn();
-                final AlertDialog.Builder dialogBuilder =
-                        new AlertDialog.Builder(context)
-                                .setTitle(R.string.battery_tip_limited_temporarily_title)
-                                .setMessage(message);
-                if (isPluggedIn) {
-                    dialogBuilder
-                            .setPositiveButton(
-                                    R.string.battery_tip_limited_temporarily_dialog_resume_charge,
-                                    this)
-                            .setNegativeButton(R.string.okay, null);
-                } else {
-                    dialogBuilder.setPositiveButton(R.string.okay, null);
-                }
-                return dialogBuilder.create();
             default:
                 throw new IllegalArgumentException("unknown type " + mBatteryTip.getType());
         }
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/BatteryDefenderAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/BatteryDefenderAction.java
deleted file mode 100644
index 824b6be..0000000
--- a/src/com/android/settings/fuelgauge/batterytip/actions/BatteryDefenderAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 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.actions;
-
-import android.content.Intent;
-
-import com.android.settings.SettingsActivity;
-import com.android.settings.overlay.FeatureFactory;
-
-/**
- * Action to open the Support Center article
- */
-public class BatteryDefenderAction extends BatteryTipAction {
-    private SettingsActivity mSettingsActivity;
-
-    public BatteryDefenderAction(SettingsActivity settingsActivity) {
-        super(settingsActivity.getApplicationContext());
-        mSettingsActivity = settingsActivity;
-    }
-
-    @Override
-    public void handlePositiveAction(int metricsKey) {
-        final Intent intent = FeatureFactory.getFactory(mContext)
-                .getPowerUsageFeatureProvider(mContext).getResumeChargeIntent();
-        if (intent != null) {
-            mContext.sendBroadcast(intent);
-        }
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index db1159e..c5d66a6 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -244,20 +244,4 @@
         assertThat(shadowDialog.getMessage()).isEqualTo(
                 mContext.getText(R.string.battery_tip_dialog_summary_message));
     }
-
-    @Test
-    public void testOnCreateDialog_defenderTip_fireDialog() {
-        mDialogFragment = BatteryTipDialogFragment.newInstance(mDefenderTip, METRICS_KEY);
-
-        FragmentController.setupFragment(mDialogFragment, FragmentActivity.class,
-                0 /* containerViewId */, null /* bundle */);
-
-        final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
-        ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
-
-        assertThat(shadowDialog.getTitle()).isEqualTo(
-                mContext.getString(R.string.battery_tip_limited_temporarily_title));
-        assertThat(shadowDialog.getMessage()).isEqualTo(
-                mContext.getString(R.string.battery_tip_limited_temporarily_dialog_msg, "80%"));
-    }
 }