Remve menu item in battery settings
Bug: 72568422 Test: robotest still pass Change-Id: Idd9463cc31bffb2f5751b630bee85789493357dc
This commit is contained in:
@@ -93,13 +93,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
private static final int MENU_STATS_TYPE = Menu.FIRST;
|
||||
@VisibleForTesting
|
||||
static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
|
||||
@VisibleForTesting
|
||||
static final int MENU_TOGGLE_APPS = Menu.FIRST + 4;
|
||||
private static final int MENU_HELP = Menu.FIRST + 5;
|
||||
public static final int DEBUG_INFO_LOADER = 3;
|
||||
|
||||
@VisibleForTesting
|
||||
boolean mShowAllApps = false;
|
||||
@VisibleForTesting
|
||||
PowerGaugePreference mScreenUsagePref;
|
||||
@VisibleForTesting
|
||||
@@ -221,7 +217,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
mAnomalySparseArray = new SparseArray<>();
|
||||
|
||||
restartBatteryInfoLoader();
|
||||
restoreSavedInstance(icicle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,12 +224,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
return MetricsEvent.FUELGAUGE_POWER_USAGE_SUMMARY_V2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(KEY_SHOW_ALL_APPS, mShowAllApps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
if (KEY_BATTERY_HEADER.equals(preference.getKey())) {
|
||||
@@ -284,11 +273,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
|
||||
menu.add(Menu.NONE, MENU_HIGH_POWER_APPS, Menu.NONE, R.string.high_power_apps);
|
||||
|
||||
if (mPowerFeatureProvider.isPowerAccountingToggleEnabled()) {
|
||||
menu.add(Menu.NONE, MENU_TOGGLE_APPS, Menu.NONE,
|
||||
mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
|
||||
}
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@@ -322,25 +306,11 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
metricsFeatureProvider.action(context,
|
||||
MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
|
||||
return true;
|
||||
case MENU_TOGGLE_APPS:
|
||||
mShowAllApps = !mShowAllApps;
|
||||
item.setTitle(mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
|
||||
metricsFeatureProvider.action(context,
|
||||
MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, mShowAllApps);
|
||||
restartBatteryStatsLoader(false /* clearHeader */);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void restoreSavedInstance(Bundle savedInstance) {
|
||||
if (savedInstance != null) {
|
||||
mShowAllApps = savedInstance.getBoolean(KEY_SHOW_ALL_APPS, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void performBatteryHeaderClick() {
|
||||
if (mPowerFeatureProvider.isAdvancedUiEnabled()) {
|
||||
Utils.startWithFragment(getContext(), PowerUsageAdvanced.class.getName(), null,
|
||||
@@ -375,8 +345,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
|
||||
|
||||
final CharSequence timeSequence = Utils.formatRelativeTime(context, lastFullChargeTime,
|
||||
false);
|
||||
mBatteryAppListPreferenceController.refreshAppListGroup(mStatsHelper, mShowAllApps,
|
||||
timeSequence);
|
||||
mBatteryAppListPreferenceController.refreshAppListGroup(mStatsHelper,
|
||||
false /* showAllApps */, timeSequence);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_HIGH_POWER_APPS;
|
||||
import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_TOGGLE_APPS;
|
||||
import static com.android.settings.fuelgauge.PowerUsageSummaryLegacy.MENU_HIGH_POWER_APPS;
|
||||
import static com.android.settings.fuelgauge.PowerUsageSummaryLegacy.MENU_TOGGLE_APPS;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
|
@@ -16,7 +16,6 @@
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_HIGH_POWER_APPS;
|
||||
import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_TOGGLE_APPS;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -170,7 +169,6 @@ public class PowerUsageSummaryTest {
|
||||
doReturn(mock(LoaderManager.class)).when(mFragment).getLoaderManager();
|
||||
|
||||
when(mFragment.getActivity()).thenReturn(mSettingsActivity);
|
||||
when(mToggleAppsMenu.getItemId()).thenReturn(MENU_TOGGLE_APPS);
|
||||
when(mHighPowerMenu.getItemId()).thenReturn(MENU_HIGH_POWER_APPS);
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.getAdditionalBatteryInfoIntent())
|
||||
.thenReturn(sAdditionalBatteryInfoIntent);
|
||||
@@ -214,39 +212,6 @@ public class PowerUsageSummaryTest {
|
||||
MetricsProto.MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionsMenu_menuAppToggle_metricEventInvoked() {
|
||||
mFragment.onOptionsItemSelected(mToggleAppsMenu);
|
||||
mFragment.mShowAllApps = false;
|
||||
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(mContext,
|
||||
MetricsProto.MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionsMenu_toggleAppsEnabled() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isPowerAccountingToggleEnabled())
|
||||
.thenReturn(true);
|
||||
mFragment.mShowAllApps = false;
|
||||
|
||||
mFragment.onCreateOptionsMenu(mMenu, mMenuInflater);
|
||||
|
||||
verify(mMenu).add(Menu.NONE, MENU_TOGGLE_APPS, Menu.NONE, R.string.show_all_apps);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionsMenu_clickToggleAppsMenu_dataChanged() {
|
||||
testToggleAllApps(true);
|
||||
testToggleAllApps(false);
|
||||
}
|
||||
|
||||
private void testToggleAllApps(final boolean isShowApps) {
|
||||
mFragment.mShowAllApps = isShowApps;
|
||||
|
||||
mFragment.onOptionsItemSelected(mToggleAppsMenu);
|
||||
assertThat(mFragment.mShowAllApps).isEqualTo(!isShowApps);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateLastFullChargePreference_showCorrectSummary() {
|
||||
doReturn(mRealContext).when(mFragment).getContext();
|
||||
@@ -323,18 +288,6 @@ public class PowerUsageSummaryTest {
|
||||
assertThat(summary1.getText().toString().contains(OLD_EST_SUFFIX));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveInstanceState_showAllAppsRestored() {
|
||||
Bundle bundle = new Bundle();
|
||||
mFragment.mShowAllApps = true;
|
||||
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
|
||||
|
||||
mFragment.onSaveInstanceState(bundle);
|
||||
mFragment.restoreSavedInstance(bundle);
|
||||
|
||||
assertThat(mFragment.mShowAllApps).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDebugMode() {
|
||||
doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isEstimateDebugEnabled();
|
||||
|
Reference in New Issue
Block a user