Clean up useless defender dialog code

Test: Unit test passed
Bug: 256523123
Change-Id: If3cbe4072c891f1af6b5aa4fb624e4e486c78ad6
Signed-off-by: Zhenwei Chen <zhenwec@google.com>
This commit is contained in:
Zhenwei Chen
2022-11-22 04:39:03 +08:00
parent f4b81c8207
commit a725bac68c
3 changed files with 0 additions and 83 deletions

View File

@@ -43,7 +43,6 @@ import com.android.settings.fuelgauge.batterytip.tips.HighUsageTip;
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 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
.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());
}

View File

@@ -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);
}
}
}

View File

@@ -244,20 +244,4 @@ public class BatteryTipDialogFragmentTest {
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%"));
}
}