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

Commit 1c993bfb authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru Committed by Android (Google) Code Review
Browse files

Merge "resolved conflicts for merge of d26707da to master"

parents 32db57ba fa101530
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -104,8 +104,7 @@ interface IMountService
    String[] getSecureContainerList();

    /**
     * Shuts down the MountService and gracefully unmounts
     * all external media.
     * Shuts down the MountService and gracefully unmounts all external media.
     */
    void shutdown();
}
+17 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.os;

import java.io.IOException;
import android.os.ServiceManager;
import android.os.IMountService;

/**
 * Class that provides access to some of the power management functions.
@@ -97,5 +99,19 @@ public class Power
     * @throws IOException if reboot fails for some reason (eg, lack of
     *         permission)
     */
    public static native void reboot(String reason) throws IOException;
    public static void reboot(String reason) throws IOException
    {
        IMountService mSvc = IMountService.Stub.asInterface(
                ServiceManager.getService("mount"));

        if (mSvc != null) {
            try {
                mSvc.shutdown();
            } catch (Exception e) {
            }
        }
        rebootNative(reason);
    }

    private static native void rebootNative(String reason) throws IOException ;
}
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ static JNINativeMethod method_table[] = {
    { "setLastUserActivityTimeout", "(J)I", (void*)setLastUserActivityTimeout },
    { "setScreenState", "(Z)I", (void*)setScreenState },
    { "shutdown", "()V", (void*)android_os_Power_shutdown },
    { "reboot", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot },
    { "rebootNative", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot },
};

int register_android_os_Power(JNIEnv *env)
+15 −1
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ class MountService extends IMountService.Stub {
            throw new SecurityException("Requires SHUTDOWN permission");
        }

        Log.i(TAG, "Shutting down");
        Log.d(TAG, "Shutting down");
        String state = Environment.getExternalStorageState();

        if (state.equals(Environment.MEDIA_SHARED)) {
@@ -259,6 +259,20 @@ class MountService extends IMountService.Stub {
            try {
                String m = Environment.getExternalStorageDirectory().toString();
                unmountMedia(m);

                int retries = 12;
                while (!state.equals(Environment.MEDIA_UNMOUNTED) && (retries-- >=0)) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException iex) {
                        Log.e(TAG, "Interrupted while waiting for media", iex);
                        break;
                    }
                    state = Environment.getExternalStorageState();
                }
                if (retries == 0) {
                    Log.e(TAG, "Timed out waiting for media to unmount");
                }
            } catch (Exception e) {
                Log.e(TAG, "external storage unmount failed", e);
            }