Make time remaining estimate debug mode more reliable.

Previously, the long click handler was unregistered on first use and
never re-registered. This meant that, e.g., on plugging and unplugging
the phone, debug mode stopped working. This change moves long click
activation into restartBatteryInfoLoader().

Bug: 63133793
Test: make RunSettingsRoboTests
Change-Id: I4c25a1f05ab3718bf06faf455cf670b5460a7306
This commit is contained in:
Alex Kulesza
2017-06-29 12:27:19 -04:00
parent 4b351b4ca1
commit 120e7a71c6
2 changed files with 31 additions and 7 deletions

View File

@@ -231,13 +231,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
initFeatureProvider();
mBatteryLayoutPref = (LayoutPreference) findPreference(KEY_BATTERY_HEADER);
View header = mBatteryLayoutPref.findViewById(R.id.summary1);
// Unfortunately setting a long click listener on a means it will no longer pass the regular
// click event to the parent, so we have to register a regular click listener as well.
if (mPowerFeatureProvider.isEstimateDebugEnabled()) {
header.setOnLongClickListener(this);
header.setOnClickListener(this);
}
mAppListGroup = (PreferenceGroup) findPreference(KEY_APP_LIST);
mScreenUsagePref = (PowerGaugePreference) findPreference(KEY_SCREEN_USAGE);
mLastFullChargePref = (PowerGaugePreference) findPreference(
@@ -772,6 +766,14 @@ public class PowerUsageSummary extends PowerUsageBase implements
void restartBatteryInfoLoader() {
getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
mBatteryInfoLoaderCallbacks);
if (mPowerFeatureProvider.isEstimateDebugEnabled()) {
// Unfortunately setting a long click listener on a view means it will no
// longer pass the regular click event to the parent, so we have to register
// a regular click listener as well.
View header = mBatteryLayoutPref.findViewById(R.id.summary1);
header.setOnLongClickListener(this);
header.setOnClickListener(this);
}
}
private static List<BatterySipper> getFakeStats() {