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

Commit 93b4e725 authored by Rafael Prado's avatar Rafael Prado
Browse files

Allow callers that have SET_TIME and SET_TIME_ZONE permissions to call...

Allow callers that have SET_TIME and SET_TIME_ZONE permissions to call getAutoTimeEnabled and getAutoTimeZoneEnabled respectively.

Test: btest TimeTest
Flag: android.app.admin.flags.set_auto_time_enabled_coexistence
Flag: android.app.admin.flags.set_auto_time_zone_enabled_coexistence
Bug: 359188869
Bug: 371165720
Change-Id: Ib7cba61a6106703914eee1082605ac5f3d6bf6ce
parent c9b66b17
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -9085,11 +9085,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        CallerIdentity caller = getCallerIdentity(who);
        if (!Flags.setAutoTimeEnabledCoexistence()) {
        if (Flags.setAutoTimeEnabledCoexistence()) {
            Preconditions.checkCallAuthorization(hasPermission(SET_TIME, caller.getPackageName()));
        } else {
            Objects.requireNonNull(who, "ComponentName is null");
        }
            Preconditions.checkCallAuthorization(isProfileOwnerOnUser0(caller)
                || isProfileOwnerOfOrganizationOwnedDevice(caller) || isDefaultDeviceOwner(caller));
        }
        return mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) > 0;
    }
@@ -9166,10 +9168,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        CallerIdentity caller = getCallerIdentity(who);
        if (!Flags.setAutoTimeZoneEnabledCoexistence()) {
        Objects.requireNonNull(who, "ComponentName is null");
        }
        Preconditions.checkCallAuthorization(isProfileOwnerOnUser0(caller)
                || isProfileOwnerOfOrganizationOwnedDevice(caller) || isDefaultDeviceOwner(
                caller));
@@ -9193,10 +9192,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        CallerIdentity caller = getCallerIdentity(who);
        if (Flags.setAutoTimeZoneEnabledCoexistence()) {
            Preconditions.checkCallAuthorization(
                hasPermission(SET_TIME_ZONE, caller.getPackageName()));
        } else {
            Objects.requireNonNull(who, "ComponentName is null");
            Preconditions.checkCallAuthorization(isProfileOwnerOnUser0(caller)
                || isProfileOwnerOfOrganizationOwnedDevice(caller) || isDefaultDeviceOwner(
                caller));
        }
        return mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) > 0;
    }