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:
parent
37b590928f
commit
4a964c508e
|
@ -142,6 +142,19 @@ public class PerformanceManagerService extends SystemService {
|
||||||
CMSettings.Secure.APP_PERFORMANCE_PROFILES_ENABLED, 1) == 1);
|
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
|
* Get the profile saved by the user
|
||||||
*/
|
*/
|
||||||
|
@ -238,8 +251,7 @@ public class PerformanceManagerService extends SystemService {
|
||||||
} else {
|
} else {
|
||||||
profile = getUserProfile();
|
profile = getUserProfile();
|
||||||
// use app specific rules if profile is balanced
|
// use app specific rules if profile is balanced
|
||||||
if (hasAppProfiles() &&
|
if (hasAppProfiles() && getProfileHasAppProfilesInternal(profile)) {
|
||||||
profile == PerformanceManager.PROFILE_BALANCED) {
|
|
||||||
profile = getProfileForActivity(mCurrentActivityName);
|
profile = getProfileForActivity(mCurrentActivityName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,6 +286,11 @@ public class PerformanceManagerService extends SystemService {
|
||||||
public int getNumberOfProfiles() {
|
public int getNumberOfProfiles() {
|
||||||
return mNumProfiles;
|
return mNumProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getProfileHasAppProfiles(int profile) {
|
||||||
|
return getProfileHasAppProfilesInternal(profile);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final class LocalService implements PerformanceManagerInternal {
|
private final class LocalService implements PerformanceManagerInternal {
|
||||||
|
|
|
@ -26,4 +26,6 @@ interface IPerformanceManager {
|
||||||
int getPowerProfile();
|
int getPowerProfile();
|
||||||
|
|
||||||
int getNumberOfProfiles();
|
int getNumberOfProfiles();
|
||||||
|
|
||||||
|
boolean getProfileHasAppProfiles(int profile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,4 +178,23 @@ public class PerformanceManager {
|
||||||
}
|
}
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue