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

Commit dd2c9da6 authored by Yanye Li's avatar Yanye Li
Browse files

DeviceState: Add a 2nd stage initialization

To solve a circular dependency of multiple system services, add
a 2nd stage initialization so that DeviceState can depend on
services that are initialized after it.

onBootPhase is inherited from SystemService and PHASE_SYSTEM_SERVICES_READY indicates all services are ready to
be used.

Bug: 378932403
Change-Id: Ifb2b12b9786a7656d7a1cff6070804dc2a0ebc37
Test: Update image to AL. Check log & check cmd device_state
Flag: EXEMPT bugfix
parent 0d464ac3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -312,6 +312,13 @@ public final class DeviceStateManagerService extends SystemService {
                mProcessObserver);
    }

    @Override
    public void onBootPhase(int phase) {
        if (phase == PHASE_SYSTEM_SERVICES_READY) {
            mDeviceStatePolicy.getDeviceStateProvider().onSystemReady();
        }
    }

    @VisibleForTesting
    Handler getHandler() {
        return mHandler;
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,11 @@ public interface DeviceStateProvider extends Dumpable {
    @Retention(RetentionPolicy.SOURCE)
    @interface SupportedStatesUpdatedReason {}

    /**
     * Called when the system boot phase advances to PHASE_SYSTEM_SERVICES_READY.
     */
    default void onSystemReady() {};

    /**
     * Registers a listener for changes in provider state.
     * <p>