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

Commit 3e8a7090 authored by Benjamin Franz's avatar Benjamin Franz
Browse files

Add policy to set the organization name

We allow the profile owner of a managed profile to set the name of the
managed organization.

This name is used as the default header message shown in the confirm
credentials screen a.k.a. work challenge.

Bug: 26638631
Change-Id: I03c5acc9fffe06cdb9d0d60dd1580b20e21783b1
parent 2a25dd5c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5821,6 +5821,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public int getOrganizationColor(android.content.ComponentName);
    method public java.lang.String getOrganizationName(android.content.ComponentName);
    method public boolean getPackageSuspended(android.content.ComponentName, java.lang.String);
    method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
    method public long getPasswordExpiration(android.content.ComponentName);
@@ -5890,6 +5891,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOrganizationColor(android.content.ComponentName, int);
    method public void setOrganizationName(android.content.ComponentName, java.lang.String);
    method public boolean setPackageSuspended(android.content.ComponentName, java.lang.String, boolean);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
+2 −0
Original line number Diff line number Diff line
@@ -5961,6 +5961,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public int getOrganizationColor(android.content.ComponentName);
    method public java.lang.String getOrganizationName(android.content.ComponentName);
    method public boolean getPackageSuspended(android.content.ComponentName, java.lang.String);
    method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
    method public long getPasswordExpiration(android.content.ComponentName);
@@ -6036,6 +6037,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOrganizationColor(android.content.ComponentName, int);
    method public void setOrganizationName(android.content.ComponentName, java.lang.String);
    method public boolean setPackageSuspended(android.content.ComponentName, java.lang.String, boolean);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
+2 −0
Original line number Diff line number Diff line
@@ -5823,6 +5823,7 @@ package android.app.admin {
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
    method public int getOrganizationColor(android.content.ComponentName);
    method public java.lang.String getOrganizationName(android.content.ComponentName);
    method public boolean getPackageSuspended(android.content.ComponentName, java.lang.String);
    method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName);
    method public long getPasswordExpiration(android.content.ComponentName);
@@ -5892,6 +5893,7 @@ package android.app.admin {
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setOrganizationColor(android.content.ComponentName, int);
    method public void setOrganizationName(android.content.ComponentName, java.lang.String);
    method public boolean setPackageSuspended(android.content.ComponentName, java.lang.String, boolean);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
    method public void setPasswordHistoryLength(android.content.ComponentName, int);
+64 −0
Original line number Diff line number Diff line
@@ -3346,6 +3346,10 @@ public class DevicePolicyManager {
     * <p>If the device owner information contains only whitespaces then the message on the lock
     * screen will be blank and the user will not be allowed to change it.
     *
     * <p>If the device owner information needs to be localized, it is the responsibility of the
     * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
     * and set a new version of this string accordingly.
     *
     * @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.
@@ -5211,6 +5215,10 @@ public class DevicePolicyManager {
     *  for support."
     * If the message is longer than 200 characters it may be truncated.
     *
     * <p>If the short support message needs to be localized, it is the responsibility of the
     * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
     * and set a new version of this string accordingly.
     *
     * @see #setLongSupportMessage
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -5250,6 +5258,10 @@ public class DevicePolicyManager {
     * Called by a device admin to set the long support message. This will
     * be displayed to the user in the device administators settings screen.
     *
     * <p>If the long support message needs to be localized, it is the responsibility of the
     * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
     * and set a new version of this string accordingly.
     *
     * @see #setShortSupportMessage
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -5413,6 +5425,58 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Called by a profile owner of a managed profile to set the name of the organization under
     * management.
     *
     * <p>If the organization name needs to be localized, it is the responsibility of the
     * {@link DeviceAdminReceiver} to listen to the {@link Intent#ACTION_LOCALE_CHANGED} broadcast
     * and set a new version of this string accordingly.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param title The organization name or {@code null} to clear a previously set name.
     */
    public void setOrganizationName(@NonNull ComponentName admin, @Nullable String title) {
        try {
            mService.setOrganizationName(admin, title);
        } catch (RemoteException re) {
            Log.w(TAG, REMOTE_EXCEPTION_MESSAGE);
        }
    }

    /**
     * Called by a profile owner of a managed profile to retrieve the name of the organization
     * under management.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @return The organization name or {@code null} if none is set.
     */
    public String getOrganizationName(@NonNull ComponentName admin) {
        try {
            return mService.getOrganizationName(admin);
        } catch (RemoteException re) {
            Log.w(TAG, REMOTE_EXCEPTION_MESSAGE);
            return null;
        }
    }

    /**
     * Retrieve the default title message used in the confirm credentials screen for a given user.
     *
     * @param userHandle The user id of the user we're interested in.
     * @return The organization name or {@code null} if none is set.
     *
     * @hide
     */
    public String getOrganizationNameForUser(int userHandle) {
        try {
            return mService.getOrganizationNameForUser(userHandle);
        } catch (RemoteException re) {
            Log.w(TAG, REMOTE_EXCEPTION_MESSAGE);
            return null;
        }
    }

    /**
     * @return the {@link UserProvisioningState} for the current user - for unmanaged users will
     *         return {@link #STATE_USER_UNMANAGED}
+4 −0
Original line number Diff line number Diff line
@@ -276,6 +276,10 @@ interface IDevicePolicyManager {
    int getOrganizationColor(in ComponentName admin);
    int getOrganizationColorForUser(int userHandle);

    void setOrganizationName(in ComponentName admin, in String title);
    String getOrganizationName(in ComponentName admin);
    String getOrganizationNameForUser(int userHandle);

    int getUserProvisioningState();
    void setUserProvisioningState(int state, int userHandle);

Loading