Merge "Don't load app restriction from saved files in test" into tm-dev am: a496007df5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17547136

Change-Id: I6b5905483d9beeb29be1313f36162efe510cd076
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jing Ji
2022-04-02 04:59:40 +00:00
committed by Automerger Merge Worker
2 changed files with 16 additions and 5 deletions

View File

@@ -1439,11 +1439,13 @@ public final class AppRestrictionController {
refreshAppRestrictionLevelForUser(userId, REASON_MAIN_FORCED_BY_USER,
REASON_SUB_FORCED_USER_FLAG_INTERACTION);
}
// Load the previously saved levels and update the current levels if needed.
mRestrictionSettings.scheduleLoadFromXml();
// Also save the current levels right away.
for (int userId : allUsers) {
mRestrictionSettings.schedulePersistToXml(userId);
if (!mInjector.isTest()) {
// Load the previously saved levels and update the current levels if needed.
mRestrictionSettings.scheduleLoadFromXml();
// Also save the current levels right away.
for (int userId : allUsers) {
mRestrictionSettings.schedulePersistToXml(userId);
}
}
}
@@ -2995,6 +2997,10 @@ public final class AppRestrictionController {
@CurrentTimeMillisLong long currentTimeMillis() {
return System.currentTimeMillis();
}
boolean isTest() {
return false;
}
}
private void registerForSystemBroadcasts() {

View File

@@ -3056,6 +3056,11 @@ public final class BackgroundRestrictionTest {
long currentTimeMillis() {
return mCurrentTimeMillis;
}
@Override
boolean isTest() {
return true;
}
}
private class TestBaseTrackerInjector<T extends BaseAppStatePolicy>