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

Commit a457f4e1 authored by Kweku Adams's avatar Kweku Adams
Browse files

DeviceIdleController state exit conditions tests.

This tests exit conditions and transitions (going to ACTIVE) for
each state in DeviceIdleController.

Bug: 116512267
Test: atest com.android.server.DeviceIdleControllerTest
Change-Id: I3b46ebd4e683b865e05f0a481147a96a796fe5f2
parent 002f63d0
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -666,7 +666,8 @@ public class DeviceIdleController extends SystemService
     * global Settings. Any access to this class or its fields should be done while
     * holding the DeviceIdleController lock.
     */
    private final class Constants extends ContentObserver {
    @VisibleForTesting
    final class Constants extends ContentObserver {
        // Key names stored in the settings value.
        private static final String KEY_LIGHT_IDLE_AFTER_INACTIVE_TIMEOUT
                = "light_after_inactive_to";
@@ -1529,12 +1530,17 @@ public class DeviceIdleController extends SystemService
            return (ConnectivityService) ServiceManager.getService(Context.CONNECTIVITY_SERVICE);
        }

        Constants getConstants(DeviceIdleController controller, Handler handler,
                ContentResolver resolver) {
            return controller.new Constants(handler, resolver);
        }

        LocationManager getLocationManager() {
            return mContext.getSystemService(LocationManager.class);
        }

        MyHandler getHandler(DeviceIdleController ctlr) {
            return ctlr.new MyHandler(BackgroundThread.getHandler().getLooper());
        MyHandler getHandler(DeviceIdleController controller) {
            return controller.new MyHandler(BackgroundThread.getHandler().getLooper());
        }

        PowerManager getPowerManager() {
@@ -1623,7 +1629,7 @@ public class DeviceIdleController extends SystemService
                }
            }

            mConstants = new Constants(mHandler, getContext().getContentResolver());
            mConstants = mInjector.getConstants(this, mHandler, getContext().getContentResolver());

            readConfigFileLocked();
            updateWhitelistAppIdsLocked();
@@ -2325,6 +2331,16 @@ public class DeviceIdleController extends SystemService
        }
    }

    /**
     * Must only be used in tests.
     *
     * This sets the state value directly and thus doesn't trigger any behavioral changes.
     */
    @VisibleForTesting
    void setLightStateForTest(int lightState) {
        mLightState = lightState;
    }

    @VisibleForTesting
    int getLightState() {
        return mLightState;
@@ -2556,6 +2572,12 @@ public class DeviceIdleController extends SystemService
        }
    }

    /** Must only be used in tests. */
    @VisibleForTesting
    void setActiveIdleOpsForTest(int count) {
        mActiveIdleOpCount = count;
    }

    void setJobsActive(boolean active) {
        synchronized (this) {
            mJobsActive = active;
+527 −6

File changed.

Preview size limit exceeded, changes collapsed.