From 1aa790501f5b67cc81539875d25af1965038f0c3 Mon Sep 17 00:00:00 2001 From: Ricky Wai Date: Thu, 17 Mar 2022 18:20:21 +0000 Subject: [PATCH] Update restricted setting dialog, unlock toast, and menu strings Bug: 224970895 Bug: 224992636 Bug: 224970884 Bug: 224988456 Test: Can see updated strings and toast in UI Change-Id: I29e257fcc15310558ae8e56cbc51de3c874471ed --- res/values/strings.xml | 8 +++++--- .../appinfo/AppInfoDashboardFragment.java | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 2d3532cc72b..80364e39d6d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4689,8 +4689,8 @@ Clear storage Uninstall updates - - Unlock restricted settings + + Allow restricted settings Some activities you\u2019ve selected open in this app by default. @@ -12184,7 +12184,9 @@ Learn more - Restricted Settings + Restricted setting + + Restricted settings allowed for %s For your security, this setting is currently unavailable. diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java index 5bc4118bfef..ac5330c4f99 100755 --- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java +++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java @@ -48,6 +48,7 @@ import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.widget.Toast; import androidx.annotation.VisibleForTesting; @@ -443,14 +444,14 @@ public class AppInfoDashboardFragment extends DashboardFragment }; final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context) - .setTitle(context.getText(R.string.app_restricted_settings_lockscreen_title)); + .setUseDefaultTitle(); // use default title if title is null/empty - if (context.getSystemService(BiometricManager.class).canAuthenticate( - BiometricManager.Authenticators.DEVICE_CREDENTIAL - | BiometricManager.Authenticators.BIOMETRIC_WEAK) - == BiometricManager.BIOMETRIC_SUCCESS) { - builder.setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL - | BiometricManager.Authenticators.BIOMETRIC_WEAK); + final BiometricManager bm = context.getSystemService(BiometricManager.class); + final int authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL + | BiometricManager.Authenticators.BIOMETRIC_WEAK; + if (bm.canAuthenticate(authenticators) == BiometricManager.BIOMETRIC_SUCCESS) { + builder.setAllowedAuthenticators(authenticators); + builder.setSubtitle(bm.getStrings(authenticators).getPromptMessage()); } final BiometricPrompt bp = builder.build(); @@ -481,6 +482,10 @@ public class AppInfoDashboardFragment extends DashboardFragment getPackageName(), AppOpsManager.MODE_ALLOWED); getActivity().invalidateOptionsMenu(); + final String toastString = getContext().getString( + R.string.toast_allows_restricted_settings_successfully, + mAppEntry.label); + Toast.makeText(getContext(), toastString, Toast.LENGTH_LONG).show(); }); return true; }