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

Commit 0de748d8 authored by yuemingw's avatar yuemingw Committed by Yueming Wang
Browse files

Implement DevicePolicyManager.setSystemSettings.

b/67627818
Bug: 67627818
Test: runtest -x services/tests/servicestests/src/
com/android/server/devicepolicy/DevicePolicyManagerTest.java

design doc: https://docs.google.com/document/d/
1rvEg5jE3lMhjH-OA0iTLBUY2opM96fg7BrP81MoPnmg/edit#

Change-Id: If5f5c280957085480872f2d59ed59309cf288145
parent 5826e469
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6465,6 +6465,7 @@ package android.app.admin {
    method public void setShortSupportMessage(android.content.ComponentName, java.lang.CharSequence);
    method public boolean setStatusBarDisabled(android.content.ComponentName, boolean);
    method public int setStorageEncryption(android.content.ComponentName, boolean);
    method public void setSystemSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public void setSystemUpdatePolicy(android.content.ComponentName, android.app.admin.SystemUpdatePolicy);
    method public boolean setTime(android.content.ComponentName, long);
    method public boolean setTimeZone(android.content.ComponentName, java.lang.String);
+32 −1
Original line number Diff line number Diff line
@@ -6667,7 +6667,7 @@ public class DevicePolicyManager {
    }

    /**
     * Called by device owners to update {@link android.provider.Settings.Global} settings.
     * Called by device owner to update {@link android.provider.Settings.Global} settings.
     * Validation that the value of the setting is in the correct form for the setting type should
     * be performed by the caller.
     * <p>
@@ -6715,6 +6715,37 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Called by device owner to update {@link android.provider.Settings.System} settings.
     * Validation that the value of the setting is in the correct form for the setting type should
     * be performed by the caller.
     * <p>
     * The settings that can be updated with this method are:
     * <ul>
     * <li>{@link android.provider.Settings.System#SCREEN_BRIGHTNESS}</li>
     * <li>{@link android.provider.Settings.System#SCREEN_BRIGHTNESS_MODE}</li>
     * <li>{@link android.provider.Settings.System#SCREEN_OFF_TIMEOUT}</li>
     * </ul>
     * <p>
     *
     * @see android.provider.Settings.System#SCREEN_OFF_TIMEOUT
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param setting The name of the setting to update.
     * @param value The value to update the setting to.
     * @throws SecurityException if {@code admin} is not a device owner.
     */
    public void setSystemSetting(@NonNull ComponentName admin, @NonNull String setting,
            String value) {
        throwIfParentInstance("setSystemSetting");
        if (mService != null) {
            try {
                mService.setSystemSetting(admin, setting, value);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Called by device owner to set the system wall clock time. This only takes effect if called
     * when {@link android.provider.Settings.Global#AUTO_TIME} is 0, otherwise {@code false} will be
+1 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ interface IDevicePolicyManager {
    int getLockTaskFeatures(in ComponentName who);

    void setGlobalSetting(in ComponentName who, in String setting, in String value);
    void setSystemSetting(in ComponentName who, in String setting, in String value);
    void setSecureSetting(in ComponentName who, in String setting, in String value);

    boolean setTime(in ComponentName who, long millis);
+4 −0
Original line number Diff line number Diff line
@@ -3123,6 +3123,10 @@ public final class Settings {
         * to dream after a period of inactivity.  This value is also known as the
         * user activity timeout period since the screen isn't necessarily turned off
         * when it expires.
         *
         * <p>
         * This value is bounded by maximum timeout set by
         * {@link android.app.admin.DevicePolicyManager#setMaximumTimeToLock(ComponentName, long)}.
         */
        public static final String SCREEN_OFF_TIMEOUT = "screen_off_timeout";

+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.server.devicepolicy;

import android.app.admin.IDevicePolicyManager;
import android.content.ComponentName;

import com.android.internal.R;
import com.android.server.SystemService;
@@ -54,4 +55,6 @@ abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub {
     * @see {@link SystemService#onStopUser}
     */
    abstract void handleStopUser(int userId);
    
    public void setSystemSetting(ComponentName who, String setting, String value){}
}
Loading