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

Commit 09e8b7d8 authored by Neil Fuller's avatar Neil Fuller
Browse files

Add new permissions

This adds new permissions required when setting the time /zone in
response to telephony signals and when setting the time / zone manually
along the lines of "principle of least privilege".

The intent is to later restrict the number of distinct processes that
can manipulate the device system clock / time zone property directly so
that all time changes go through the time / time zone detector services,
which can enforce policy, log the reasons for changes, and so on.

Bug: 140712361
Test: atest com.android.server.timedetector
Change-Id: Iabd3a5f449ad2ef2b6581475ef2535a4a8a88ef9
parent ea0124cd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class TimeDetector {
     * signal if better signals are available such as those that come from more reliable sources or
     * were determined more recently.
     */
    @RequiresPermission(android.Manifest.permission.SET_TIME)
    @RequiresPermission(android.Manifest.permission.SUGGEST_PHONE_TIME_AND_ZONE)
    public void suggestPhoneTime(@NonNull PhoneTimeSuggestion timeSuggestion) {
        if (DEBUG) {
            Log.d(TAG, "suggestPhoneTime called: " + timeSuggestion);
@@ -63,7 +63,7 @@ public class TimeDetector {
    /**
     * Suggests the user's manually entered current time to the detector.
     */
    @RequiresPermission(android.Manifest.permission.SET_TIME)
    @RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
    public void suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion) {
        if (DEBUG) {
            Log.d(TAG, "suggestManualTime called: " + timeSuggestion);
+2 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class TimeZoneDetector {
     * detector may ignore the signal based on system settings, whether better information is
     * available, and so on.
     */
    @RequiresPermission(android.Manifest.permission.SET_TIME_ZONE)
    @RequiresPermission(android.Manifest.permission.SUGGEST_PHONE_TIME_AND_ZONE)
    public void suggestPhoneTimeZone(@NonNull PhoneTimeZoneSuggestion timeZoneSuggestion) {
        if (DEBUG) {
            Log.d(TAG, "suggestPhoneTimeZone called: " + timeZoneSuggestion);
@@ -63,7 +63,7 @@ public class TimeZoneDetector {
     * Suggests the current time zone, determined for the user's manually information, to the
     * detector. The detector may ignore the signal based on system settings.
     */
    @RequiresPermission(android.Manifest.permission.SET_TIME_ZONE)
    @RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
    public void suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion) {
        if (DEBUG) {
            Log.d(TAG, "suggestManualTimeZone called: " + timeZoneSuggestion);
+20 −6
Original line number Diff line number Diff line
@@ -2515,17 +2515,17 @@
    <permission android:name="android.permission.READ_WALLPAPER_INTERNAL"
        android:protectionLevel="signature|privileged" />

    <!-- ============================================ -->
    <!-- Permissions for changing the system clock -->
    <!-- ============================================ -->
    <!-- ===================================================== -->
    <!-- Permissions for changing the system clock / time zone -->
    <!-- ===================================================== -->
    <eat-comment />

    <!-- Allows applications to set the system time.
    <!-- Allows applications to set the system time directly.
         <p>Not for use by third-party applications. -->
    <permission android:name="android.permission.SET_TIME"
        android:protectionLevel="signature|privileged" />

    <!-- Allows applications to set the system time zone.
    <!-- Allows applications to set the system time zone directly.
         <p>Not for use by third-party applications.
    -->
    <permission android:name="android.permission.SET_TIME_ZONE"
@@ -2533,6 +2533,20 @@
        android:description="@string/permdesc_setTimeZone"
        android:protectionLevel="signature|privileged" />

    <!-- Allows telephony to suggest the time / time zone.
         <p>Not for use by third-party applications.
         @hide
     -->
    <permission android:name="android.permission.SUGGEST_PHONE_TIME_AND_ZONE"
        android:protectionLevel="signature|telephony" />

    <!-- Allows applications like settings to suggest the user's manually chosen time / time zone.
         <p>Not for use by third-party applications.
         @hide
    -->
    <permission android:name="android.permission.SUGGEST_MANUAL_TIME_AND_ZONE"
        android:protectionLevel="signature" />

    <!-- ==================================================== -->
    <!-- Permissions related to changing status bar   -->
    <!-- ==================================================== -->
+1 −1
Original line number Diff line number Diff line
@@ -41,8 +41,8 @@
        <permission name="android.permission.PACKAGE_USAGE_STATS"/>
        <permission name="android.permission.READ_SEARCH_INDEXABLES"/>
        <permission name="android.permission.REBOOT"/>
        <permission name="android.permission.SET_TIME"/>
        <permission name="android.permission.STATUS_BAR"/>
        <permission name="android.permission.SUGGEST_MANUAL_TIME_AND_ZONE"/>
        <permission name="android.permission.TETHER_PRIVILEGED"/>
        <permission name="android.permission.USE_RESERVED_DISK"/>
        <permission name="android.permission.USER_ACTIVITY"/>
+1 −1
Original line number Diff line number Diff line
@@ -155,12 +155,12 @@ applications that come with the platform
        <permission name="android.permission.REGISTER_CALL_PROVIDER"/>
        <permission name="android.permission.REGISTER_SIM_SUBSCRIPTION"/>
        <permission name="android.permission.SEND_RESPOND_VIA_MESSAGE"/>
        <permission name="android.permission.SET_TIME"/>
        <permission name="android.permission.SET_TIME_ZONE"/>
        <permission name="android.permission.SHUTDOWN"/>
        <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"/>
        <permission name="android.permission.STATUS_BAR"/>
        <permission name="android.permission.STOP_APP_SWITCHES"/>
        <permission name="android.permission.SUGGEST_PHONE_TIME_AND_ZONE"/>
        <permission name="android.permission.UPDATE_APP_OPS_STATS"/>
        <permission name="android.permission.UPDATE_DEVICE_STATS"/>
        <permission name="android.permission.UPDATE_LOCK"/>
Loading