Merge "Fix only one battery stat showing sometimes." into nyc-dev

This commit is contained in:
Jason Monk
2016-04-21 14:21:40 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 3 deletions

View File

@@ -399,6 +399,10 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
} }
} }
protected int getCachedCount() {
return mPreferenceCache.size();
}
private void highlightPreference(String key) { private void highlightPreference(String key) {
final int position = canUseListViewForHighLighting(key); final int position = canUseListViewForHighLighting(key);
if (position >= 0) { if (position >= 0) {

View File

@@ -368,7 +368,8 @@ public class PowerUsageSummary extends PowerUsageBase {
} }
addedSome = true; addedSome = true;
mAppListGroup.addPreference(pref); mAppListGroup.addPreference(pref);
if (mAppListGroup.getPreferenceCount() > (MAX_ITEMS_TO_LIST + 1)) { if (mAppListGroup.getPreferenceCount() - getCachedCount()
> (MAX_ITEMS_TO_LIST + 1)) {
break; break;
} }
} }
@@ -391,8 +392,10 @@ public class PowerUsageSummary extends PowerUsageBase {
stats.add(new BatterySipper(type, null, use)); stats.add(new BatterySipper(type, null, use));
use += 5; use += 5;
} }
stats.add(new BatterySipper(DrainType.APP, for (int i = 0; i < 100; i++) {
new FakeUid(Process.FIRST_APPLICATION_UID), use)); stats.add(new BatterySipper(DrainType.APP,
new FakeUid(Process.FIRST_APPLICATION_UID + i), use));
}
stats.add(new BatterySipper(DrainType.APP, stats.add(new BatterySipper(DrainType.APP,
new FakeUid(0), use)); new FakeUid(0), use));