aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java21
-rw-r--r--src/java/cyanogenmod/power/IPerformanceManager.aidl2
-rw-r--r--src/java/cyanogenmod/power/PerformanceManager.java19
3 files changed, 40 insertions, 2 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java
index 92a2322..85dc7c6 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java
@@ -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 {
diff --git a/src/java/cyanogenmod/power/IPerformanceManager.aidl b/src/java/cyanogenmod/power/IPerformanceManager.aidl
index 106854f..bf44ac9 100644
--- a/src/java/cyanogenmod/power/IPerformanceManager.aidl
+++ b/src/java/cyanogenmod/power/IPerformanceManager.aidl
@@ -26,4 +26,6 @@ interface IPerformanceManager {
int getPowerProfile();
int getNumberOfProfiles();
+
+ boolean getProfileHasAppProfiles(int profile);
}
diff --git a/src/java/cyanogenmod/power/PerformanceManager.java b/src/java/cyanogenmod/power/PerformanceManager.java
index f91bc98..e8e41b4 100644
--- a/src/java/cyanogenmod/power/PerformanceManager.java
+++ b/src/java/cyanogenmod/power/PerformanceManager.java
@@ -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;
+ }
}