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

Commit 325fa50d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow setting managing organization for the device"

parents fd4f73c7 365a3db4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6205,6 +6205,7 @@ package android.app.admin {
    method public java.lang.String getDeviceOwner();
    method public java.lang.CharSequence getDeviceOwnerLockScreenInfo();
    method public java.lang.String getDeviceOwnerNameOnAnyUser();
    method public java.lang.CharSequence getDeviceOwnerOrganizationName();
    method public java.util.List<byte[]> getInstalledCaCerts(android.content.ComponentName);
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public java.lang.CharSequence getLongSupportMessage(android.content.ComponentName);
+1 −0
Original line number Diff line number Diff line
@@ -6046,6 +6046,7 @@ package android.app.admin {
    method public java.util.List<java.lang.String> getCrossProfileWidgetProviders(android.content.ComponentName);
    method public int getCurrentFailedPasswordAttempts();
    method public java.lang.CharSequence getDeviceOwnerLockScreenInfo();
    method public java.lang.CharSequence getDeviceOwnerOrganizationName();
    method public java.util.List<byte[]> getInstalledCaCerts(android.content.ComponentName);
    method public int getKeyguardDisabledFeatures(android.content.ComponentName);
    method public long getLastBugReportRequestTime();
+21 −2
Original line number Diff line number Diff line
@@ -6424,7 +6424,7 @@ public class DevicePolicyManager {
    }

    /**
     * Called by a profile owner of a managed profile to set the name of the organization under
     * Called by the device owner or profile owner to set the name of the organization under
     * management.
     * <p>
     * If the organization name needs to be localized, it is the responsibility of the
@@ -6433,7 +6433,7 @@ public class DevicePolicyManager {
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param title The organization name or {@code null} to clear a previously set name.
     * @throws SecurityException if {@code admin} is not a profile owner.
     * @throws SecurityException if {@code admin} is not a device or profile owner.
     */
    public void setOrganizationName(@NonNull ComponentName admin, @Nullable CharSequence title) {
        throwIfParentInstance("setOrganizationName");
@@ -6461,6 +6461,25 @@ public class DevicePolicyManager {
        }
    }

    /**
     * Called by the system to retrieve the name of the organization managing the device.
     *
     * @return The organization name or {@code null} if none is set.
     * @throws SecurityException if the caller is not the device owner, does not hold the
     *         MANAGE_USERS permission and is not the system.
     *
     * @hide
     */
    @SystemApi
    @TestApi
    public @Nullable CharSequence getDeviceOwnerOrganizationName() {
        try {
            return mService.getDeviceOwnerOrganizationName();
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
    }

    /**
     * Retrieve the default title message used in the confirm credentials screen for a given user.
     *
+1 −0
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ interface IDevicePolicyManager {

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

    int getUserProvisioningState();
+13 −1
Original line number Diff line number Diff line
@@ -9126,7 +9126,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        Preconditions.checkNotNull(who, "ComponentName is null");
        final int userHandle = mInjector.userHandleGetCallingUserId();
        enforceManagedProfile(userHandle, "set organization name");

        synchronized (this) {
            ActiveAdmin admin = getActiveAdminForCallerLocked(who,
                    DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -9152,6 +9152,18 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
    }

    @Override
    public CharSequence getDeviceOwnerOrganizationName() {
        if (!mHasFeature) {
            return null;
        }
        enforceDeviceOwnerOrManageUsers();
        synchronized(this) {
            final ActiveAdmin deviceOwnerAdmin = getDeviceOwnerAdminLocked();
            return deviceOwnerAdmin == null ? null : deviceOwnerAdmin.organizationName;
        }
    }

    @Override
    public CharSequence getOrganizationNameForUser(int userHandle) {
        if (!mHasFeature) {
Loading