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

Commit f00c4faf authored by Meng Wang's avatar Meng Wang
Browse files

Do not use hidden API UserManager.hasUserRestriction

Bug: 137202333
Test: make
Merged-In: I53d8003787a6e0903d3512b545ad61248d387c87
Change-Id: I53d8003787a6e0903d3512b545ad61248d387c87
parent f00698cb
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1166,7 +1166,7 @@ public abstract class InboundSmsHandler extends StateMachine {
                UserHandle targetUser = UserHandle.of(users[i]);
                if (users[i] != UserHandle.USER_SYSTEM) {
                    // Is the user not allowed to use SMS?
                    if (mUserManager.hasUserRestriction(UserManager.DISALLOW_SMS, targetUser)) {
                    if (hasUserRestriction(UserManager.DISALLOW_SMS, targetUser)) {
                        continue;
                    }
                    // Skip unknown users and managed profiles as well
@@ -1195,6 +1195,12 @@ public abstract class InboundSmsHandler extends StateMachine {
        }
    }

    private boolean hasUserRestriction(String restrictionKey, UserHandle userHandle) {
        final List<UserManager.EnforcingUser> sources = mUserManager
                .getUserRestrictionSources(restrictionKey, userHandle);
        return (sources != null && !sources.isEmpty());
    }

    /**
     * Helper for {@link SmsBroadcastUndelivered} to delete an old message in the raw table.
     */