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

Commit bfd22908 authored by Andrei Stingaceanu's avatar Andrei Stingaceanu Committed by Android (Google) Code Review
Browse files

Merge "Introduce APIs in DPM for setting/getting the device owner info"

parents a17d8766 6644cd96
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5707,6 +5707,7 @@ package android.app.admin {
    method public boolean getCrossProfileCallerIdDisabled(android.content.ComponentName);
    method public java.util.List<java.lang.String> getCrossProfileWidgetProviders(android.content.ComponentName);
    method public int getCurrentFailedPasswordAttempts();
    method public java.lang.String getDeviceOwnerLockScreenInfo();
    method public java.util.List<byte[]> getInstalledCaCerts(android.content.ComponentName);
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
@@ -5759,6 +5760,7 @@ package android.app.admin {
    method public void setCameraDisabled(android.content.ComponentName, boolean);
    method public void setCertInstallerPackage(android.content.ComponentName, java.lang.String) throws java.lang.SecurityException;
    method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
    method public boolean setDeviceOwnerLockScreenInfo(android.content.ComponentName, java.lang.String);
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
+2 −0
Original line number Diff line number Diff line
@@ -5833,6 +5833,7 @@ package android.app.admin {
    method public deprecated java.lang.String getDeviceInitializerApp();
    method public deprecated android.content.ComponentName getDeviceInitializerComponent();
    method public java.lang.String getDeviceOwner();
    method public java.lang.String getDeviceOwnerLockScreenInfo();
    method public java.util.List<byte[]> getInstalledCaCerts(android.content.ComponentName);
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
@@ -5891,6 +5892,7 @@ package android.app.admin {
    method public void setCameraDisabled(android.content.ComponentName, boolean);
    method public void setCertInstallerPackage(android.content.ComponentName, java.lang.String) throws java.lang.SecurityException;
    method public void setCrossProfileCallerIdDisabled(android.content.ComponentName, boolean);
    method public boolean setDeviceOwnerLockScreenInfo(android.content.ComponentName, java.lang.String);
    method public void setGlobalSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public boolean setKeyguardDisabled(android.content.ComponentName, boolean);
    method public void setKeyguardDisabledFeatures(android.content.ComponentName, int);
+36 −3
Original line number Diff line number Diff line
@@ -2869,9 +2869,6 @@ public class DevicePolicyManager {
     */
    public boolean setProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName,
            int userHandle) throws IllegalArgumentException {
        if (admin == null) {
            throw new NullPointerException("admin cannot be null");
        }
        if (mService != null) {
            try {
                if (ownerName == null) {
@@ -2886,6 +2883,42 @@ public class DevicePolicyManager {
        return false;
    }

    /**
     * Sets the device owner information to be shown on the lock screen.
     *
     * <p>If the device owner information is {@code null} or empty then the device owner info is
     * cleared and the user owner info is shown on the lock screen if it is set.
     *
     * @param admin The name of the admin component to check.
     * @param info Device owner information which will be displayed instead of the user
     * owner info.
     * @return Whether the device owner information has been set.
     */
    public boolean setDeviceOwnerLockScreenInfo(@NonNull ComponentName admin, String info) {
        if (mService != null) {
            try {
                return mService.setDeviceOwnerLockScreenInfo(admin, info);
            } catch (RemoteException re) {
                Log.w(TAG, "Failed talking with device policy service", re);
            }
        }
        return false;
    }

    /**
     * @return The device owner information. If it is not set returns {@code null}.
     */
    public String getDeviceOwnerLockScreenInfo() {
        if (mService != null) {
            try {
                return mService.getDeviceOwnerLockScreenInfo();
            } catch (RemoteException re) {
                Log.w(TAG, "Failed talking with device policy service", re);
            }
        }
        return null;
    }

    /**
     * Sets the enabled state of the profile. A profile should be enabled only once it is ready to
     * be used. Only the profile owner can call this.
+3 −0
Original line number Diff line number Diff line
@@ -127,6 +127,9 @@ interface IDevicePolicyManager {
    void clearProfileOwner(in ComponentName who);
    boolean hasUserSetupCompleted();

    boolean setDeviceOwnerLockScreenInfo(in ComponentName who, String deviceOwnerInfo);
    String getDeviceOwnerLockScreenInfo();

    boolean installCaCert(in ComponentName admin, in byte[] certBuffer);
    void uninstallCaCerts(in ComponentName admin, in String[] aliases);
    void enforceCanManageCaCerts(in ComponentName admin);
+25 −0
Original line number Diff line number Diff line
@@ -126,6 +126,8 @@ public class LockPatternUtils {
    private static final String LOCK_SCREEN_OWNER_INFO_ENABLED =
            Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED;

    private static final String LOCK_SCREEN_DEVICE_OWNER_INFO = "lockscreen.device_owner_info";

    private static final String ENABLED_TRUST_AGENTS = "lockscreen.enabledtrustagents";

    // Maximum allowed number of repeated or ordered characters in a sequence before we'll
@@ -577,6 +579,29 @@ public class LockPatternUtils {
        return getBoolean(LOCK_SCREEN_OWNER_INFO_ENABLED, false, userId);
    }

    /**
     * Sets the device owner information. If the information is {@code null} or empty then the
     * device owner info is cleared.
     *
     * @param info Device owner information which will be displayed instead of the user
     * owner info.
     */
    public void setDeviceOwnerInfo(String info) {
        if (info != null && info.isEmpty()) {
            info = null;
        }

        setString(LOCK_SCREEN_DEVICE_OWNER_INFO, info, UserHandle.USER_SYSTEM);
    }

    public String getDeviceOwnerInfo() {
        return getString(LOCK_SCREEN_DEVICE_OWNER_INFO, UserHandle.USER_SYSTEM);
    }

    public boolean isDeviceOwnerInfoEnabled() {
        return getDeviceOwnerInfo() != null;
    }

    /**
     * Compute the password quality from the given password string.
     */
Loading