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
This commit is contained in:
Scott Mertz 2016-05-12 15:26:49 -07:00
parent 256a7350ce
commit 6113701337
1 changed files with 16 additions and 0 deletions

View File

@ -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) {