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

Commit 87a38b59 authored by Yasuhiro Matsuda's avatar Yasuhiro Matsuda
Browse files

Do not broadcast VOLUME_STATE_CHANGED before boot has completed.

This is for avoiding unnecessary launch of processes which receive
VOLUME_STATE_CHANGED (e.g. com.android.externalstorage) duting boot.
This change improves boot time by ~200 ms.

BUG: 22163689
Change-Id: I76d39695552d49b6188bad8fdae81c5744013396
parent 6578ad5b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -165,6 +165,8 @@ class MountService extends IMountService.Stub
        public void onBootPhase(int phase) {
            if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) {
                mMountService.systemReady();
            } else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
                mMountService.bootCompleted();
            }
        }

@@ -405,6 +407,7 @@ class MountService extends IMountService.Stub
    private final NativeDaemonConnector mCryptConnector;

    private volatile boolean mSystemReady = false;
    private volatile boolean mBootCompleted = false;
    private volatile boolean mDaemonConnected = false;

    private PackageManagerService mPms;
@@ -1244,7 +1247,9 @@ class MountService extends IMountService.Stub

        mCallbacks.notifyVolumeStateChanged(vol, oldState, newState);

        if (isBroadcastWorthy(vol)) {
        // Do not broadcast before boot has completed to avoid launching the
        // processes that receive the intent unnecessarily.
        if (mBootCompleted && isBroadcastWorthy(vol)) {
            final Intent intent = new Intent(VolumeInfo.ACTION_VOLUME_STATE_CHANGED);
            intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.id);
            intent.putExtra(VolumeInfo.EXTRA_VOLUME_STATE, newState);
@@ -1429,6 +1434,10 @@ class MountService extends IMountService.Stub
        mHandler.obtainMessage(H_SYSTEM_READY).sendToTarget();
    }

    private void bootCompleted() {
        mBootCompleted = true;
    }

    private String getDefaultPrimaryStorageUuid() {
        if (SystemProperties.getBoolean(StorageManager.PROP_PRIMARY_PHYSICAL, false)) {
            return StorageManager.UUID_PRIMARY_PHYSICAL;