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

Commit 97e44947 authored by Dan Egnor's avatar Dan Egnor
Browse files

Add an AlarmManager API to set the system time (with the proper permissions).

parent 9446c504
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -1035,6 +1035,17 @@
 visibility="public"
>
</field>
<field name="SET_TIME"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.permission.SET_TIME&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SET_TIME_ZONE"
 type="java.lang.String"
 transient="false"
@@ -18808,6 +18819,19 @@
<parameter name="operation" type="android.app.PendingIntent">
</parameter>
</method>
<method name="setTime"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="millis" type="long">
</parameter>
</method>
<method name="setTimeZone"
 return="void"
 abstract="false"
@@ -72328,7 +72352,7 @@
 type="float"
 transient="false"
 volatile="false"
 value="0.0010f"
 value="0.001f"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -209963,7 +209987,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="arg0" type="T">
<parameter name="t" type="T">
</parameter>
</method>
</interface>
+20 −1
Original line number Diff line number Diff line
@@ -278,6 +278,25 @@ public class AlarmManager
        }
    }

    /**
     * Set the system wall clock time.
     * Requires the permission android.permission.SET_TIME.
     *
     * @param millis time in milliseconds since the Epoch
     */
    public void setTime(long millis) {
        try {
            mService.setTime(millis);
        } catch (RemoteException ex) {
        }
    }

    /**
     * Set the system default time zone.
     * Requires the permission android.permission.SET_TIME_ZONE.
     *
     * @param timeZone in the format understood by {@link java.util.TimeZone}
     */
    public void setTimeZone(String timeZone) {
        try {
            mService.setTimeZone(timeZone);
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ interface IAlarmManager {
    void set(int type, long triggerAtTime, in PendingIntent operation);
    void setRepeating(int type, long triggerAtTime, long interval, in PendingIntent operation);
    void setInexactRepeating(int type, long triggerAtTime, long interval, in PendingIntent operation);
    void setTime(long millis);
    void setTimeZone(String zone);
    void remove(in PendingIntent operation);
}
+6 −0
Original line number Diff line number Diff line
@@ -679,6 +679,12 @@
        android:label="@string/permlab_setWallpaperHints"
        android:description="@string/permdesc_setWallpaperHints" />

    <!-- Allows applications to set the system time -->
    <permission android:name="android.permission.SET_TIME"
        android:protectionLevel="signatureOrSystem"
        android:label="@string/permlab_setTime"
        android:description="@string/permdesc_setTime" />

    <!-- Allows applications to set the system time zone -->
    <permission android:name="android.permission.SET_TIME_ZONE"
        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
+6 −0
Original line number Diff line number Diff line
@@ -1016,6 +1016,12 @@
        reset the system to its factory settings, erasing all data,
        configuration, and installed applications.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_setTime">set time</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_setTime">Allows an application to change
        the phone\'s clock time.</string>

    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_setTimeZone">set time zone</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
Loading