Merge "Drop down late RARE prediction into RESTRICTED." into rvc-dev am: 09c3427e5d
Change-Id: I36703abdf4f96424e877daca2bf44d491a73c372
This commit is contained in:
@@ -1364,6 +1364,19 @@ public class AppStandbyController implements AppStandbyInternal {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, " Keeping at WORKING_SET due to min timeout");
|
||||
}
|
||||
} else if (newBucket == STANDBY_BUCKET_RARE
|
||||
&& getBucketForLocked(packageName, userId, elapsedRealtime)
|
||||
== STANDBY_BUCKET_RESTRICTED) {
|
||||
// Prediction doesn't think the app will be used anytime soon and
|
||||
// it's been long enough that it could just time out into restricted,
|
||||
// so time it out there instead. Using TIMEOUT will allow prediction
|
||||
// to raise the bucket when it needs to.
|
||||
newBucket = STANDBY_BUCKET_RESTRICTED;
|
||||
reason = REASON_MAIN_TIMEOUT;
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG,
|
||||
"Prediction to RARE overridden by timeout into RESTRICTED");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -818,6 +818,69 @@ public class AppStandbyControllerTests {
|
||||
assertBucket(STANDBY_BUCKET_RESTRICTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an app is "timed out" into the RESTRICTED bucket if prediction tries to put it into
|
||||
* a low bucket after the RESTRICTED timeout.
|
||||
*/
|
||||
@Test
|
||||
public void testRestrictedTimeoutOverridesRestoredLowBucketPrediction() {
|
||||
reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1);
|
||||
assertBucket(STANDBY_BUCKET_ACTIVE);
|
||||
|
||||
// Predict to RARE Not long enough to time out into RESTRICTED.
|
||||
mInjector.mElapsedRealtime += RARE_THRESHOLD;
|
||||
mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RARE,
|
||||
REASON_MAIN_PREDICTED);
|
||||
assertBucket(STANDBY_BUCKET_RARE);
|
||||
|
||||
// Add a short timeout event
|
||||
mInjector.mElapsedRealtime += 1000;
|
||||
reportEvent(mController, SYSTEM_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1);
|
||||
assertBucket(STANDBY_BUCKET_ACTIVE);
|
||||
mInjector.mElapsedRealtime += 1000;
|
||||
mController.checkIdleStates(USER_ID);
|
||||
assertBucket(STANDBY_BUCKET_ACTIVE);
|
||||
|
||||
// Long enough that it could have timed out into RESTRICTED. Instead of reverting to
|
||||
// predicted RARE, should go into RESTRICTED
|
||||
mInjector.mElapsedRealtime += RESTRICTED_THRESHOLD * 4;
|
||||
mController.checkIdleStates(USER_ID);
|
||||
assertBucket(STANDBY_BUCKET_RESTRICTED);
|
||||
|
||||
// Ensure that prediction can still raise it out despite this override.
|
||||
mInjector.mElapsedRealtime += 1;
|
||||
mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_ACTIVE,
|
||||
REASON_MAIN_PREDICTED);
|
||||
assertBucket(STANDBY_BUCKET_ACTIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an app is "timed out" into the RESTRICTED bucket if prediction tries to put it into
|
||||
* a low bucket after the RESTRICTED timeout.
|
||||
*/
|
||||
@Test
|
||||
public void testRestrictedTimeoutOverridesPredictionLowBucket() {
|
||||
reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1);
|
||||
|
||||
// Not long enough to time out into RESTRICTED.
|
||||
mInjector.mElapsedRealtime += RARE_THRESHOLD;
|
||||
mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RARE,
|
||||
REASON_MAIN_PREDICTED);
|
||||
assertBucket(STANDBY_BUCKET_RARE);
|
||||
|
||||
mInjector.mElapsedRealtime += 1;
|
||||
reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1);
|
||||
|
||||
// Long enough that it could have timed out into RESTRICTED.
|
||||
mInjector.mElapsedRealtime += RESTRICTED_THRESHOLD * 4;
|
||||
mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_ACTIVE,
|
||||
REASON_MAIN_PREDICTED);
|
||||
assertBucket(STANDBY_BUCKET_ACTIVE);
|
||||
mController.setAppStandbyBucket(PACKAGE_1, USER_ID, STANDBY_BUCKET_RARE,
|
||||
REASON_MAIN_PREDICTED);
|
||||
assertBucket(STANDBY_BUCKET_RESTRICTED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPredictionRaiseFromRestrictedTimeout_highBucket() {
|
||||
reportEvent(mController, USER_INTERACTION, mInjector.mElapsedRealtime, PACKAGE_1);
|
||||
|
||||
Reference in New Issue
Block a user