Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d469d2c8 authored by Jing Ji's avatar Jing Ji
Browse files

Don't load app restriction from saved files in test

As it interfers with testing.

Bug: 203105544
Test: atest FrameworksMockingServicesTests:BackgroundRestrictionTest
Change-Id: I6004f924c6e76fce1a9a20d2c26ddb9f4b960988
parent 4935cbc6
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -1413,6 +1413,7 @@ public final class AppRestrictionController {
            refreshAppRestrictionLevelForUser(userId, REASON_MAIN_FORCED_BY_USER,
                    REASON_SUB_FORCED_USER_FLAG_INTERACTION);
        }
        if (!mInjector.isTest()) {
            // Load the previously saved levels and update the current levels if needed.
            mRestrictionSettings.scheduleLoadFromXml();
            // Also save the current levels right away.
@@ -1420,6 +1421,7 @@ public final class AppRestrictionController {
                mRestrictionSettings.schedulePersistToXml(userId);
            }
        }
    }

    private void initSystemModuleNames() {
        final PackageManager pm = mInjector.getPackageManager();
@@ -2822,6 +2824,10 @@ public final class AppRestrictionController {
        @CurrentTimeMillisLong long currentTimeMillis() {
            return System.currentTimeMillis();
        }

        boolean isTest() {
            return false;
        }
    }

    private void registerForSystemBroadcasts() {
+5 −0
Original line number Diff line number Diff line
@@ -3056,6 +3056,11 @@ public final class BackgroundRestrictionTest {
        long currentTimeMillis() {
            return mCurrentTimeMillis;
        }

        @Override
        boolean isTest() {
            return true;
        }
    }

    private class TestBaseTrackerInjector<T extends BaseAppStatePolicy>