summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/am/AppRestrictionController.java16
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java5
2 files changed, 16 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/am/AppRestrictionController.java b/services/core/java/com/android/server/am/AppRestrictionController.java
index c15deac701eb..a9e8aa1914b4 100644
--- a/services/core/java/com/android/server/am/AppRestrictionController.java
+++ b/services/core/java/com/android/server/am/AppRestrictionController.java
@@ -1413,11 +1413,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);
+ }
}
}
@@ -2822,6 +2824,10 @@ public final class AppRestrictionController {
@CurrentTimeMillisLong long currentTimeMillis() {
return System.currentTimeMillis();
}
+
+ boolean isTest() {
+ return false;
+ }
}
private void registerForSystemBroadcasts() {
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java
index b512ac51e2fb..77cf54363c62 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/BackgroundRestrictionTest.java
@@ -3056,6 +3056,11 @@ public final class BackgroundRestrictionTest {
long currentTimeMillis() {
return mCurrentTimeMillis;
}
+
+ @Override
+ boolean isTest() {
+ return true;
+ }
}
private class TestBaseTrackerInjector<T extends BaseAppStatePolicy>