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

Commit 7e56f8da authored by Kevin Han's avatar Kevin Han
Browse files

Fix broken hibernation test

ag/14203210 made isAppHibernationEnabled use a cached value rather than
query device config every time. This happened to break a test that
relied on mocking the DeviceConfig value. We update the static value
directly to ensure the feature is enabled in the test.

Bug: 185730191
Test: atest PackageManagerServiceHibernationTests
Change-Id: Icf7d5bedba69cc5af7df2d38bf5088cb08b5cfb6
parent d560996d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ public final class AppHibernationService extends SystemService {
    private final boolean mOatArtifactDeletionEnabled;

    @VisibleForTesting
    static boolean sIsServiceEnabled;
    public static boolean sIsServiceEnabled;

    /**
     * Initializes the system service.
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import com.android.server.apphibernation.AppHibernationManagerInternal
import com.android.server.apphibernation.AppHibernationService
import com.android.server.extendedtestutils.wheneverStatic
import com.android.server.testutils.whenever
import org.junit.Assert.assertFalse
@@ -61,6 +62,7 @@ class PackageManagerServiceHibernationTests {
        MockitoAnnotations.initMocks(this)
        wheneverStatic { DeviceConfig.getBoolean(
            NAMESPACE_APP_HIBERNATION, KEY_APP_HIBERNATION_ENABLED, false) }.thenReturn(true)
        AppHibernationService.sIsServiceEnabled = true
        rule.system().stageNominalSystemState()
        whenever(rule.mocks().injector.getLocalService(AppHibernationManagerInternal::class.java))
            .thenReturn(appHibernationManager)