perf: Add PerformanceManager.getProfileHasAppProfiles API

Add an API to query PerformanceManager if a perf profile supports
app-profiles.

Change-Id: I51d958343624ab085de0352ac182cb05308e0da4
This commit is contained in:
Khalid Zubair 2015-11-24 09:57:46 -08:00 committed by Scott Mertz
parent 37b590928f
commit 4a964c508e
3 changed files with 40 additions and 2 deletions

View File

@ -142,6 +142,19 @@ public class PerformanceManagerService extends SystemService {
CMSettings.Secure.APP_PERFORMANCE_PROFILES_ENABLED, 1) == 1);
}
private boolean getProfileHasAppProfilesInternal(int profile) {
if (profile < 0 || profile > mNumProfiles) {
Slog.e(TAG, "Invalid profile: " + profile);
return false;
}
if (profile == PerformanceManager.PROFILE_BALANCED) {
return mPatterns != null;
}
return false;
}
/**
* Get the profile saved by the user
*/
@ -238,8 +251,7 @@ public class PerformanceManagerService extends SystemService {
} else {
profile = getUserProfile();
// use app specific rules if profile is balanced
if (hasAppProfiles() &&
profile == PerformanceManager.PROFILE_BALANCED) {
if (hasAppProfiles() && getProfileHasAppProfilesInternal(profile)) {
profile = getProfileForActivity(mCurrentActivityName);
}
}
@ -274,6 +286,11 @@ public class PerformanceManagerService extends SystemService {
public int getNumberOfProfiles() {
return mNumProfiles;
}
@Override
public boolean getProfileHasAppProfiles(int profile) {
return getProfileHasAppProfilesInternal(profile);
}
};
private final class LocalService implements PerformanceManagerInternal {

View File

@ -26,4 +26,6 @@ interface IPerformanceManager {
int getPowerProfile();
int getNumberOfProfiles();
boolean getProfileHasAppProfiles(int profile);
}

View File

@ -178,4 +178,23 @@ public class PerformanceManager {
}
return ret;
}
/**
* Check if profile has app-specific profiles
*
* Returns true if profile has app-specific profiles.
*/
public boolean getProfileHasAppProfiles(int profile) {
boolean ret = false;
if (mNumberOfProfiles > 0) {
try {
if (checkService()) {
ret = sService.getProfileHasAppProfiles(profile);
}
} catch (RemoteException e) {
// nothing
}
}
return ret;
}
}