aboutsummaryrefslogtreecommitdiffstats
path: root/cm
diff options
context:
space:
mode:
authorScott Mertz <scott@cyngn.com>2016-05-12 15:26:49 -0700
committerScott Mertz <scott@cyngn.com>2016-05-12 15:29:27 -0700
commit61137013376ee0bd5ddcd07343f05ca044876485 (patch)
treeff010b087c2d56635af0fe75b7b5ec5dfed6ab13 /cm
parent256a7350cef055c58a95c902abdb25c2557097c9 (diff)
downloadvendor_cmsdk-61137013376ee0bd5ddcd07343f05ca044876485.zip
vendor_cmsdk-61137013376ee0bd5ddcd07343f05ca044876485.tar.gz
vendor_cmsdk-61137013376ee0bd5ddcd07343f05ca044876485.tar.bz2
PerformanceManagerService: drop requests if system is not yet ready
There is a race condition between when onBootPhase(PHASE_SYSTEM_SERVICES_READY) is handled and when clients request profiles, cpu boost, or launch boost. Drop these requests in this condition. OPO-702 Change-Id: I0860f824473767a4a4776e9febc7fb786b81f457
Diffstat (limited to 'cm')
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java16
1 files changed, 16 insertions, 0 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 9c6a44a..ba10e5e 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/PerformanceManagerService.java
@@ -180,6 +180,10 @@ public class PerformanceManagerService extends SystemService {
"setPowerProfileInternal(profile=%d, fromUser=%b)",
profile, fromUser));
}
+ if (mPm == null) {
+ Slog.e(TAG, "System is not ready, dropping profile request");
+ return false;
+ }
if (profile < 0 || profile > mNumProfiles) {
Slog.e(TAG, "Invalid profile: " + profile);
return false;
@@ -248,6 +252,12 @@ public class PerformanceManagerService extends SystemService {
}
private void cpuBoostInternal(int duration) {
+ synchronized (PerformanceManagerService.this) {
+ if (mPm == null) {
+ Slog.e(TAG, "System is not ready, dropping cpu boost request");
+ return;
+ }
+ }
if (duration > 0 && duration <= MAX_CPU_BOOST_TIME) {
// Don't send boosts if we're in another power profile
if (mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE ||
@@ -325,6 +335,12 @@ public class PerformanceManagerService extends SystemService {
@Override
public void launchBoost(int pid, String packageName) {
+ synchronized (PerformanceManagerService.this) {
+ if (mPm == null) {
+ Slog.e(TAG, "System is not ready, dropping launch boost request");
+ return;
+ }
+ }
// Don't send boosts if we're in another power profile
if (mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE ||
mCurrentProfile == PerformanceManager.PROFILE_HIGH_PERFORMANCE) {