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

Commit 5d8e963c authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Part3 - Don't add padlock if the restriction is not set by admin." into nyc-dev

parents 1b596918 9e9e63b7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
        android:key="network_reset"
        android:title="@string/reset_network_title"
        settings:keywords="@string/keywords_network_reset"
        settings:userRestriction="no_network_reset"
        settings:useAdminDisabledSummary="true"
        android:fragment="com.android.settings.ResetNetwork" />

+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
    <com.android.settingslib.RestrictedPreference
            android:key="remove_user"
            android:title="@string/user_remove_user"
            settings:userRestriction="no_remove_user"
            settings:useAdminDisabledSummary="true" />

</PreferenceScreen>
+17 −6
Original line number Diff line number Diff line
@@ -81,7 +81,9 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
    private UserManager mUm;

    private EnforcedAdmin mFunDisallowedAdmin;
    private boolean mFunDisallowedBySystem;
    private EnforcedAdmin mDebuggingFeaturesDisallowedAdmin;
    private boolean mDebuggingFeaturesDisallowedBySystem;

    @Override
    protected int getMetricsCategory() {
@@ -192,8 +194,12 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
        mDevHitToast = null;
        mFunDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(
                getActivity(), UserManager.DISALLOW_FUN, UserHandle.myUserId());
        mFunDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
                getActivity(), UserManager.DISALLOW_FUN, UserHandle.myUserId());
        mDebuggingFeaturesDisallowedAdmin = RestrictedLockUtils.checkIfRestrictionEnforced(
                getActivity(), UserManager.DISALLOW_DEBUGGING_FEATURES, UserHandle.myUserId());
        mDebuggingFeaturesDisallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
                getActivity(), UserManager.DISALLOW_DEBUGGING_FEATURES, UserHandle.myUserId());
    }

    @Override
@@ -202,9 +208,11 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
            System.arraycopy(mHits, 1, mHits, 0, mHits.length-1);
            mHits[mHits.length-1] = SystemClock.uptimeMillis();
            if (mHits[0] >= (SystemClock.uptimeMillis()-500)) {
                if (mFunDisallowedAdmin != null) {
                if (mUm.hasUserRestriction(UserManager.DISALLOW_FUN)) {
                    if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
                        RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
                                mFunDisallowedAdmin);
                    }
                    Log.d(LOG_TAG, "Sorry, no fun for you!");
                    return false;
                }
@@ -228,9 +236,12 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment implements In
                return true;
            }

            if (mDebuggingFeaturesDisallowedAdmin != null) {
            if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
                if (mDebuggingFeaturesDisallowedAdmin != null &&
                        !mDebuggingFeaturesDisallowedBySystem) {
                    RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(),
                            mDebuggingFeaturesDisallowedAdmin);
                }
                return true;
            }

+9 −6
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedPreference;

import java.util.ArrayList;
@@ -186,12 +187,6 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
            // Hide the item if data management intent is not supported by transport.
            getPreferenceScreen().removePreference(mManageData);
        }

        RestrictedPreference networkResetPref = (RestrictedPreference) findPreference(
                NETWORK_RESET);
        if (networkResetPref != null) {
            networkResetPref.checkRestrictionAndSetDisabled(UserManager.DISALLOW_NETWORK_RESET);
        }
    }

    private void setConfigureSummary(String summary) {
@@ -315,5 +310,13 @@ public class PrivacySettings extends SettingsPreferenceFragment implements Index
            nonVisibleKeys.add(AUTO_RESTORE);
            nonVisibleKeys.add(CONFIGURE_ACCOUNT);
        }
        if (RestrictedLockUtils.hasBaseUserRestriction(context,
                UserManager.DISALLOW_FACTORY_RESET, UserHandle.myUserId())) {
            nonVisibleKeys.add(FACTORY_RESET);
        }
        if (RestrictedLockUtils.hasBaseUserRestriction(context,
                UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) {
            nonVisibleKeys.add(NETWORK_RESET);
        }
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
    @Override
    protected void onDataSetChanged() {
        highlightPreferenceIfNeeded();
        if (mAdminSupportDetails != null && isUiRestricted()) {
        if (mAdminSupportDetails != null && isUiRestrictedByOnlyAdmin()) {
            updateAdminSupportDetailsView();
            setEmptyView(mAdminSupportDetails);
        } else if (mEmptyTextView != null) {
@@ -266,4 +266,9 @@ public abstract class RestrictedSettingsFragment extends SettingsPreferenceFragm
    protected boolean isUiRestricted() {
        return isRestrictedAndNotProviderProtected() || !hasChallengeSucceeded();
    }

    protected boolean isUiRestrictedByOnlyAdmin() {
        return isUiRestricted() && !mUserManager.hasBaseUserRestriction(mRestrictionKey,
                UserHandle.of(UserHandle.myUserId()));
    }
}
Loading