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

Commit 678a57b0 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge changes from topic "kchyn-unicorn4a" into sc-dev

* changes:
  Show biometric-specific dialog when appropriate
  Add biometric strings to DeviceAdminStringProviderImpl
parents b8c610b1 0c34d259
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -10956,6 +10956,10 @@
    <string name="disabled_by_policy_title_suspend_packages">Can’t open this app</string>
    <!-- Dialog title. This dialog lets a user know that a specific setting is blocked by their credit provider. Since the user purchased the device from the credit provider, the credit provider controls what they can access. [CHAR LIMIT=50] -->
    <string name="disabled_by_policy_title_financed_device">Blocked by your credit provider</string>
    <!-- Dialog title shown when parental consent is required for the child to set up biometric authentication. [CHAR LIMIT=30] -->
    <string name="disabled_by_policy_title_biometric_parental_consent">Parent needed</string>
    <!-- Dialog content shown when parental consent is required for the child to set up biometric authentication. [CHAR LIMIT=NONE] -->
    <string name="disabled_by_policy_content_biometric_parental_consent">Hand the phone to your parent to start setting this up</string>
    <!-- Shown when the user tries to change phone settings that are blocked by their IT admin [CHAR LIMIT=200] -->
    <string name="default_admin_support_msg">If you have questions, contact your IT admin</string>
    <!-- Shown in dialog to allow user to see more information about the device admin [CHAR LIMIT=30] -->
+5 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.ParentalControlsUtilsInternal;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;

import androidx.annotation.NonNull;
@@ -49,7 +50,8 @@ public class ParentalControlsUtils {
        final UserHandle userHandle = new UserHandle(UserHandle.myUserId());
        if (ParentalControlsUtilsInternal.isTestModeEnabled(context)) {
            Log.d(TAG, "Requiring consent for test flow");
            return new RestrictedLockUtils.EnforcedAdmin(null /* ComponentName */, userHandle);
            return new RestrictedLockUtils.EnforcedAdmin(null /* ComponentName */,
                    UserManager.DISALLOW_BIOMETRIC, userHandle);
        }

        final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
@@ -69,7 +71,8 @@ public class ParentalControlsUtils {
                userHandle)) {
            final ComponentName cn =
                    ParentalControlsUtilsInternal.getSupervisionComponentName(dpm, userHandle);
            return new RestrictedLockUtils.EnforcedAdmin(cn, userHandle);
            return new RestrictedLockUtils.EnforcedAdmin(cn, UserManager.DISALLOW_BIOMETRIC,
                    userHandle);
        } else {
            return null;
        }
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public class ActionDisabledByAdminDialog extends Activity
        final RestrictedLockUtils.EnforcedAdmin enforcedAdmin =
                getAdminDetailsFromIntent(getIntent());
        final String restriction = getRestrictionFromIntent(getIntent());
        mDialogHelper = new ActionDisabledByAdminDialogHelper(this);
        mDialogHelper = new ActionDisabledByAdminDialogHelper(this, restriction);
        mDialogHelper.prepareDialogBuilder(restriction, enforcedAdmin)
                .setOnDismissListener(this)
                .show();
+8 −2
Original line number Diff line number Diff line
@@ -56,11 +56,16 @@ public final class ActionDisabledByAdminDialogHelper {
    private final Activity mActivity;

    public ActionDisabledByAdminDialogHelper(Activity activity) {
        this(activity, null /* restriction */);
    }

    public ActionDisabledByAdminDialogHelper(Activity activity, String restriction) {
        mActivity = activity;
        mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate(
                R.layout.admin_support_details_dialog, null);
        mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory
                .createInstance(mActivity, new DeviceAdminStringProviderImpl(mActivity));
                .createInstance(mActivity, restriction,
                        new DeviceAdminStringProviderImpl(mActivity));
    }

    private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) {
@@ -74,7 +79,8 @@ public final class ActionDisabledByAdminDialogHelper {
    public AlertDialog.Builder prepareDialogBuilder(String restriction,
            EnforcedAdmin enforcedAdmin) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
                .setPositiveButton(R.string.okay, null)
                .setPositiveButton(R.string.okay,
                        mActionDisabledByAdminController.getPositiveButtonListener())
                .setView(mDialogView);
        prepareDialogBuilder(builder, restriction, enforcedAdmin);
        return builder;
+10 −0
Original line number Diff line number Diff line
@@ -79,4 +79,14 @@ class DeviceAdminStringProviderImpl implements DeviceAdminStringProvider {
    public String getDisabledByPolicyTitleForFinancedDevice() {
        return mContext.getString(R.string.disabled_by_policy_title_financed_device);
    }

    @Override
    public String getDisabledBiometricsParentConsentTitle() {
        return mContext.getString(R.string.disabled_by_policy_title_biometric_parental_consent);
    }

    @Override
    public String getDisabledBiometricsParentConsentContent() {
        return mContext.getString(R.string.disabled_by_policy_content_biometric_parental_consent);
    }
}
Loading