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

Commit 4adc0da1 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Hide VPN "settings" button when VPN is restricted"

parents 2fb58136 80d50536
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -140,13 +140,13 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
        mDialog.setTitle(getTitle(deviceOwner));
        mDialog.setMessage(getMessage(deviceOwner, profileOwner, primaryVpn, profileVpn, managed));
        mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(), this);
        if (mSecurityController.isVpnEnabled()) {
            mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getNegativeButton(), this);
        if (mSecurityController.isVpnEnabled() && !mSecurityController.isVpnRestricted()) {
            mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
        }
        mDialog.show();
    }

    private String getNegativeButton() {
    private String getSettingsButton() {
        return mContext.getString(R.string.status_bar_settings_settings_button);
    }

+5 −0
Original line number Diff line number Diff line
@@ -159,6 +159,11 @@ public class CustomQSTileHost extends QSTileHost {
            return false;
        }

        @Override
        public boolean isVpnRestricted() {
            return false;
        }

        @Override
        public String getPrimaryVpnName() {
            return null;
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ public interface SecurityController {
    String getDeviceOwnerName();
    String getProfileOwnerName();
    boolean isVpnEnabled();
    boolean isVpnRestricted();
    String getPrimaryVpnName();
    String getProfileVpnName();
    void onUserSwitched(int newUserId);
+7 −0
Original line number Diff line number Diff line
@@ -161,6 +161,13 @@ public class SecurityControllerImpl implements SecurityController {
        return false;
    }

    @Override
    public boolean isVpnRestricted() {
        UserHandle currentUser = new UserHandle(mCurrentUserId);
        return mUserManager.getUserInfo(mCurrentUserId).isRestricted()
                || mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN, currentUser);
    }

    @Override
    public void removeCallback(SecurityControllerCallback callback) {
        synchronized (mCallbacks) {
+5 −0
Original line number Diff line number Diff line
@@ -349,6 +349,11 @@ public class QsTuner extends Fragment implements Callback {
                return false;
            }

            @Override
            public boolean isVpnRestricted() {
                return false;
            }

            @Override
            public String getPrimaryVpnName() {
                return null;