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

Commit 16d94902 authored by Alex Chau's avatar Alex Chau
Browse files

Suppress suppressing work profile removed notification if reason is null

Bug: 114711242
Test: cts-tradefed run singleCommand cts -m CtsDevicePolicyManagerTestCases --test com.android.cts.devicepolicy.ManagedProfileTest#testWipeDataWithoutReason
Change-Id: Icea2c95272f3d3d693c3289a5c4a55761026a8f9
parent 6c109c76
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -3450,15 +3450,14 @@ public class DevicePolicyManager {
     * @param flags Bit mask of additional options: currently supported flags are
     *            {@link #WIPE_EXTERNAL_STORAGE} and {@link #WIPE_RESET_PROTECTION_DATA}.
     * @param reason a string that contains the reason for wiping data, which can be
     *                          presented to the user.
     *            presented to the user. If the string is null or empty, user won't be notified.
     * @throws SecurityException if the calling application does not own an active administrator
     *             that uses {@link DeviceAdminInfo#USES_POLICY_WIPE_DATA}
     * @throws IllegalArgumentException if the input reason string is null or empty.
     */
    public void wipeData(int flags, @NonNull CharSequence reason) {
    public void wipeData(int flags, CharSequence reason) {
        throwIfParentInstance("wipeData");
        Preconditions.checkNotNull(reason, "CharSequence is null");
        wipeDataInternal(flags, reason.toString());
        wipeDataInternal(flags, reason != null ? reason.toString() : null);
    }

    /**
@@ -3469,7 +3468,7 @@ public class DevicePolicyManager {
     * @see #wipeData(int, CharSequence)
     * @hide
     */
    private void wipeDataInternal(int flags, @NonNull String wipeReasonForUser) {
    private void wipeDataInternal(int flags, String wipeReasonForUser) {
        if (mService != null) {
            try {
                mService.wipeDataWithReason(flags, wipeReasonForUser);
+1 −2
Original line number Diff line number Diff line
@@ -5969,7 +5969,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            success = mUserManagerInternal.removeUserEvenWhenDisallowed(userId);
            if (!success) {
                Slog.w(LOG_TAG, "Couldn't remove user " + userId);
            } else if (isManagedProfile(userId)) {
            } else if (isManagedProfile(userId) && !TextUtils.isEmpty(wipeReasonForUser)) {
                sendWipeProfileNotification(wipeReasonForUser);
            }
        } catch (RemoteException re) {
@@ -5984,7 +5984,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        if (!mHasFeature) {
            return;
        }
        Preconditions.checkStringNotEmpty(wipeReasonForUser, "wipeReasonForUser is null or empty");
        enforceFullCrossUsersPermission(mInjector.userHandleGetCallingUserId());
        final ActiveAdmin admin;