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

Commit fafb041b authored by San Mehat's avatar San Mehat
Browse files

MountService: Move boot-time mount to a thread - avoids ANR at boot



Signed-off-by: default avatarSan Mehat <san@google.com>
parent 8a032a3b
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -150,13 +150,23 @@ class MountService extends IMountService.Stub
                    notifyVolumeStateChange(null, "/sdcard", VolumeState.NoMedia, VolumeState.Mounted);
                    return;
                }
                new Thread() {
                    public void run() {
                        try {
                            String path = Environment.getExternalStorageDirectory().getPath();
                if (getVolumeState(path).equals(Environment.MEDIA_UNMOUNTED)) {
                            if (getVolumeState(
                                    Environment.getExternalStorageDirectory().getPath()).equals(
                                            Environment.MEDIA_UNMOUNTED)) {
                                int rc = doMountVolume(path);
                                if (rc != StorageResultCode.OperationSucceeded) {
                                    Log.e(TAG, String.format("Boot-time mount failed (%d)", rc));
                                }
                            }
                        } catch (Exception ex) {
                            Log.e(TAG, "Boot-time mount exception", ex);
                        }
                    }
                }.start();
            }
        }
    };