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

Commit f34d0ec7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Initialize the app last used timestamps to 0 in test setup." into tm-dev am: 7bcee6bc

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

Change-Id: I2cf7e1c11c379846bd9d18f7ba585911e2443c32
parents 9f52a9ee 7bcee6bc
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2103,6 +2103,13 @@ public class AppStandbyController
                .sendToTarget();
    }

    @VisibleForTesting
    AppIdleHistory getAppIdleHistoryForTest() {
        synchronized (mAppIdleLock) {
            return mAppIdleHistory;
        }
    }

    @Override
    public void dumpUsers(IndentingPrintWriter idpw, int[] userIds, List<String> pkgs) {
        synchronized (mAppIdleLock) {
+25 −2
Original line number Diff line number Diff line
@@ -512,8 +512,30 @@ public class AppStandbyControllerTests {
        return controller;
    }

    private long getCurrentTime() {
        return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
    private void setupInitialUsageHistory() throws Exception {
        final int[] userIds = new int[] { USER_ID, USER_ID2, USER_ID3 };
        final String[] packages = new String[] {
                PACKAGE_1,
                PACKAGE_2,
                PACKAGE_EXEMPTED_1,
                PACKAGE_SYSTEM_HEADFULL,
                PACKAGE_SYSTEM_HEADLESS,
                PACKAGE_WELLBEING,
                PACKAGE_BACKGROUND_LOCATION,
                ADMIN_PKG,
                ADMIN_PKG2,
                ADMIN_PKG3
        };
        for (int userId : userIds) {
            for (String pkg : packages) {
                final AppIdleHistory.AppUsageHistory usageHistory = mController
                        .getAppIdleHistoryForTest().getAppUsageHistory(
                                pkg, userId, mInjector.mElapsedRealtime);
                usageHistory.lastUsedElapsedTime = 0;
                usageHistory.lastUsedByUserElapsedTime = 0;
                usageHistory.lastUsedScreenTime = 0;
            }
        }
    }

    @Before
@@ -524,6 +546,7 @@ public class AppStandbyControllerTests {
        MyContextWrapper myContext = new MyContextWrapper(InstrumentationRegistry.getContext());
        mInjector = new MyInjector(myContext, Looper.getMainLooper());
        mController = setupController();
        setupInitialUsageHistory();
    }

    @After