diff options
author | LuK1337 <priv.luk@gmail.com> | 2016-05-07 18:45:45 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-05-23 09:00:29 -0700 |
commit | 805983d24c9d2aeb3f00f99273584fc530e0b932 (patch) | |
tree | ae66a6c1b5513a8576a55ab2add9caa4ff0c1271 /packages | |
parent | 070cd3b58ab3244516da3ed68078e96d49a4f2e0 (diff) | |
download | frameworks_base-805983d24c9d2aeb3f00f99273584fc530e0b932.zip frameworks_base-805983d24c9d2aeb3f00f99273584fc530e0b932.tar.gz frameworks_base-805983d24c9d2aeb3f00f99273584fc530e0b932.tar.bz2 |
SystemUI: Filter out unsupported values off perf profile tile
Change-Id: I4409d1e9e7310530b47ac7d48db8c4796f0ae49e
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/PerfProfileTile.java | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/PerfProfileTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/PerfProfileTile.java index a93c39a..4863683 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/PerfProfileTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/PerfProfileTile.java @@ -48,6 +48,7 @@ public class PerfProfileTile extends QSTile<PerfProfileTile.ProfileState> { private final String[] mDescriptionEntries; private final String[] mAnnouncementEntries; private final int[] mPerfProfileValues; + private final int mNumPerfProfiles; private final Icon mIcon; private final PowerManager mPm; @@ -61,16 +62,36 @@ public class PerfProfileTile extends QSTile<PerfProfileTile.ProfileState> { mObserver = new PerformanceProfileObserver(mHandler); mPm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mPerformanceManager = PerformanceManager.getInstance(mContext); + mNumPerfProfiles = mPerformanceManager.getNumberOfProfiles(); - Resources res = mContext.getResources(); - - mPerfProfileValues = res.getIntArray(org.cyanogenmod.platform.internal.R.array.perf_profile_values); - - mEntries = res.getStringArray(org.cyanogenmod.platform.internal.R.array.perf_profile_entries); - mDescriptionEntries = res.getStringArray(R.array.perf_profile_description); - mAnnouncementEntries = res.getStringArray(R.array.perf_profile_announcement); + mPerfProfileValues = new int[mNumPerfProfiles]; + mEntries = new String[mNumPerfProfiles]; + mDescriptionEntries = new String[mNumPerfProfiles]; + mAnnouncementEntries = new String[mNumPerfProfiles]; mIcon = ResourceIcon.get(R.drawable.ic_qs_perf_profile); + + // Filter out unsupported profiles + Resources res = mContext.getResources(); + final int[] perfProfileValues = res.getIntArray( + org.cyanogenmod.platform.internal.R.array.perf_profile_values); + final String[] entries = res.getStringArray( + org.cyanogenmod.platform.internal.R.array.perf_profile_entries); + final String[] descriptionEntries = res.getStringArray( + R.array.perf_profile_description); + final String[] announcementEntries = res.getStringArray( + R.array.perf_profile_announcement); + int i = 0; + + for (int j = 0; j < perfProfileValues.length; j++) { + if (perfProfileValues[j] < mNumPerfProfiles) { + mPerfProfileValues[i] = perfProfileValues[j]; + mEntries[i] = entries[j]; + mDescriptionEntries[i] = descriptionEntries[j]; + mAnnouncementEntries[i] = announcementEntries[j]; + i++; + } + } } @Override |