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:
parent
256a7350ce
commit
6113701337
|
@ -180,6 +180,10 @@ public class PerformanceManagerService extends SystemService {
|
||||||
"setPowerProfileInternal(profile=%d, fromUser=%b)",
|
"setPowerProfileInternal(profile=%d, fromUser=%b)",
|
||||||
profile, fromUser));
|
profile, fromUser));
|
||||||
}
|
}
|
||||||
|
if (mPm == null) {
|
||||||
|
Slog.e(TAG, "System is not ready, dropping profile request");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (profile < 0 || profile > mNumProfiles) {
|
if (profile < 0 || profile > mNumProfiles) {
|
||||||
Slog.e(TAG, "Invalid profile: " + profile);
|
Slog.e(TAG, "Invalid profile: " + profile);
|
||||||
return false;
|
return false;
|
||||||
|
@ -248,6 +252,12 @@ public class PerformanceManagerService extends SystemService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cpuBoostInternal(int duration) {
|
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) {
|
if (duration > 0 && duration <= MAX_CPU_BOOST_TIME) {
|
||||||
// Don't send boosts if we're in another power profile
|
// Don't send boosts if we're in another power profile
|
||||||
if (mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE ||
|
if (mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE ||
|
||||||
|
@ -325,6 +335,12 @@ public class PerformanceManagerService extends SystemService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launchBoost(int pid, String packageName) {
|
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
|
// Don't send boosts if we're in another power profile
|
||||||
if (mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE ||
|
if (mCurrentProfile == PerformanceManager.PROFILE_POWER_SAVE ||
|
||||||
mCurrentProfile == PerformanceManager.PROFILE_HIGH_PERFORMANCE) {
|
mCurrentProfile == PerformanceManager.PROFILE_HIGH_PERFORMANCE) {
|
||||||
|
|
Loading…
Reference in New Issue