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

Commit 36dd6b15 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Unrestrict granted ECM setting for older implementation" into main

parents 24b9ddd7 a2dddab3
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -41,10 +41,23 @@ public class RestrictedDropDownPreference extends DropDownPreference implements
     * package. Marks the preference as disabled if so.
     * package. Marks the preference as disabled if so.
     * @param settingIdentifier The key identifying the setting
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     * @param packageName the package to check the settingIdentifier for
     * @param settingEnabled Whether the setting in question is enabled
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName, boolean settingEnabled) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, settingEnabled);
    }

    /**
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * package. Marks the preference as disabled if so.
     * TODO b/390196024: remove this and update all callers to use the "settingEnabled" version
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     */
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName) {
            @NonNull String packageName) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName);
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, false);
    }
    }


    @Override
    @Override
+14 −1
Original line number Original line Diff line number Diff line
@@ -107,12 +107,25 @@ public class RestrictedPreference extends TwoTargetPreference implements
    /**
    /**
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * package. Marks the preference as disabled if so.
     * package. Marks the preference as disabled if so.
     * TODO b/390196024: remove this and update all callers to use the "settingEnabled" version
     * @param settingIdentifier The key identifying the setting
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     * @param packageName the package to check the settingIdentifier for
     */
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName) {
            @NonNull String packageName) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName);
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, false);
    }

    /**
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * package. Marks the preference as disabled if so.
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     * @param settingEnabled Whether the setting in question is enabled
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName, boolean settingEnabled) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, settingEnabled);
    }
    }


    @Override
    @Override
+18 −1
Original line number Original line Diff line number Diff line
@@ -204,15 +204,32 @@ public class RestrictedPreferenceHelper {
     * package. Marks the preference as disabled if so.
     * package. Marks the preference as disabled if so.
     * @param settingIdentifier The key identifying the setting
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     * @param packageName the package to check the settingIdentifier for
     * @param settingEnabled Whether the setting in question is enabled
     */
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName) {
            @NonNull String packageName, boolean settingEnabled) {
        updatePackageDetails(packageName, android.os.Process.INVALID_UID);
        updatePackageDetails(packageName, android.os.Process.INVALID_UID);
        if (settingEnabled) {
            setDisabledByEcm(null);
            return;
        }
        Intent intent = RestrictedLockUtilsInternal.checkIfRequiresEnhancedConfirmation(
        Intent intent = RestrictedLockUtilsInternal.checkIfRequiresEnhancedConfirmation(
                mContext, settingIdentifier, packageName);
                mContext, settingIdentifier, packageName);
        setDisabledByEcm(intent);
        setDisabledByEcm(intent);
    }
    }


    /**
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * package. Marks the preference as disabled if so.
     * TODO b/390196024: remove this and update all callers to use the "settingEnabled" version
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName) {
        checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, false);
    }

    /**
    /**
     * @return EnforcedAdmin if we have been passed the restriction in the xml.
     * @return EnforcedAdmin if we have been passed the restriction in the xml.
     */
     */
+4 −3
Original line number Original line Diff line number Diff line
@@ -134,10 +134,11 @@ public class RestrictedSelectorWithWidgetPreference extends SelectorWithWidgetPr
     *
     *
     * @param settingIdentifier The key identifying the setting
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     * @param packageName the package to check the settingIdentifier for
     * @param settingEnabled Whether the setting in question is enabled
     */
     */
    public void checkEcmRestrictionAndSetDisabled(
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String settingIdentifier, @NonNull String packageName) {
            @NonNull String packageName, boolean settingEnabled) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName);
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, settingEnabled);
    }
    }


    @Override
    @Override
+15 −2
Original line number Original line Diff line number Diff line
@@ -220,10 +220,23 @@ public class RestrictedSwitchPreference extends SwitchPreferenceCompat implement
     * package. Marks the preference as disabled if so.
     * package. Marks the preference as disabled if so.
     * @param settingIdentifier The key identifying the setting
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     * @param packageName the package to check the settingIdentifier for
     * @param settingEnabled Whether the setting in question is enabled
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName, boolean settingEnabled) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, settingEnabled);
    }

    /**
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * package. Marks the preference as disabled if so.
     * TODO b/390196024: remove this and update all callers to use the "settingEnabled" version
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     */
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName) {
            @NonNull String packageName) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName);
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName, false);
    }
    }


    @Override
    @Override