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

Commit 0fe4ba28 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan
Browse files

framework: Add a version of Environment.getExternalStorageState which accepts a path parameter

Required for improved media scanner on devices with emmc

Change-Id: Id215238f3503221b06459dfa241c2c52ea6a0baa
parent c8e3afba
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -416,11 +416,18 @@ public class Environment {
     * <p>See {@link #getExternalStorageDirectory()} for more information.
     * <p>See {@link #getExternalStorageDirectory()} for more information.
     */
     */
    public static String getExternalStorageState() {
    public static String getExternalStorageState() {
        return getExternalStorageState(getExternalStorageDirectory().toString());
    }

    /**
     * Gets the current state of the specified "external" storage device.
     * @hide
     */
    public static String getExternalStorageState(String path) {
        try {
        try {
            IMountService mountService = IMountService.Stub.asInterface(ServiceManager
            IMountService mountService = IMountService.Stub.asInterface(ServiceManager
                    .getService("mount"));
                    .getService("mount"));
            return mountService.getVolumeState(getExternalStorageDirectory()
            return mountService.getVolumeState(path);
                    .toString());
        } catch (Exception rex) {
        } catch (Exception rex) {
            return Environment.MEDIA_REMOVED;
            return Environment.MEDIA_REMOVED;
        }
        }