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

Commit 50a21f4d authored by Doug Zongker's avatar Doug Zongker
Browse files

add reboot() method to PowerManager

In order to unbundle System Update, we need some to expose in the SDK
some way to reboot the device into recovery.  Add a reboot() method to
PowerManager, protected by the android.permission.REBOOT permission.
parent 793810f6
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -106250,6 +106250,19 @@
<parameter name="tag" type="java.lang.String">
</parameter>
</method>
<method name="reboot"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="reason" type="java.lang.String">
</parameter>
</method>
<method name="userActivity"
 return="void"
 abstract="false"
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ interface IPowerManager
    void preventScreenOn(boolean prevent);
    void setScreenBrightnessOverride(int brightness);
    boolean isScreenOn();
    void reboot(String reason);

    // sets the brightness of the backlights (screen, keyboard, button) 0-255
    void setBacklightBrightness(int brightness);
+16 −1
Original line number Diff line number Diff line
@@ -465,6 +465,22 @@ public class PowerManager
        }
    }

    /**
     * Reboot the device.  Will not return if the reboot is
     * successful.  Requires the {@link android.Manifest#REBOOT}
     * permission.
     *
     * @param reason code to pass to the kernel (e.g., "recovery") to
     *               request special boot modes, or null.
     */
    public void reboot(String reason)
    {
        try {
            mService.reboot(reason);
        } catch (RemoteException e) {
        }
    }

    private PowerManager()
    {
    }
@@ -488,4 +504,3 @@ public class PowerManager
    IPowerManager mService;
    Handler mHandler;
}
+2 −2
Original line number Diff line number Diff line
@@ -943,7 +943,7 @@
    <permission android:name="android.permission.DELETE_CACHE_FILES"
        android:label="@string/permlab_deleteCacheFiles"
        android:description="@string/permdesc_deleteCacheFiles"
        android:protectionLevel="signature" />
        android:protectionLevel="signatureOrSystem" />

    <!-- Allows an application to delete packages. -->
    <permission android:name="android.permission.DELETE_PACKAGES"
@@ -981,7 +981,7 @@
    <permission android:name="android.permission.REBOOT"
        android:label="@string/permlab_reboot"
        android:description="@string/permdesc_reboot"
        android:protectionLevel="signature" />
        android:protectionLevel="signatureOrSystem" />

   <!-- Allows low-level access to power management -->
    <permission android:name="android.permission.DEVICE_POWER"
+15 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import static android.provider.Settings.System.STAY_ON_WHILE_PLUGGED_IN;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -2090,6 +2091,20 @@ class PowerManagerService extends IPowerManager.Stub
        }
    }
    
    /**
     * Reboot the device immediately, passing 'reason' (may be null)
     * to the underlying __reboot system call.  Should not return.
     */
    public void reboot(String reason)
    {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);
        try {
            Power.reboot(reason);
        } catch (IOException e) {
            Log.e(TAG, "reboot failed", e);
        }
    }

    /**
     * Returns the time the screen has been on since boot, in millis.
     * @return screen on time