Update the biometric unlock logo to Private Space logo

All activities that use biometric login through the CDCA class show a
Settings icon in the prompt. This cl adds a capability for the client of
the CDCA to set icon and icon description as extras to the unlock
intent.

Screenshot: http://shortn/_OpKTYFtddM

Bug: 333528540
Test: Manually verified on the device

Change-Id: Id7b5a3fe575069bef1810769e4f437e717d2d3c6
This commit is contained in:
Olivier Nshimiye
2024-04-17 12:05:36 +00:00
parent 7030928506
commit 14d4b41363
3 changed files with 50 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ import android.hardware.biometrics.PromptInfo;
import android.multiuser.Flags; import android.multiuser.Flags;
import android.os.Bundle; import android.os.Bundle;
import android.os.CancellationSignal; import android.os.CancellationSignal;
import android.text.TextUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@@ -149,6 +150,13 @@ public class BiometricFragment extends InstrumentedFragment {
.setShowEmergencyCallButton(promptInfo.isShowEmergencyCallButton()) .setShowEmergencyCallButton(promptInfo.isShowEmergencyCallButton())
.setReceiveSystemEvents(true) .setReceiveSystemEvents(true)
.setComponentNameForConfirmDeviceCredentialActivity(callingActivity); .setComponentNameForConfirmDeviceCredentialActivity(callingActivity);
if (promptInfo.getLogoRes() != 0){
promptBuilder.setLogoRes(promptInfo.getLogoRes());
}
String logoDescription = promptInfo.getLogoDescription();
if (!TextUtils.isEmpty(logoDescription)) {
promptBuilder.setLogoDescription(logoDescription);
}
if (android.os.Flags.allowPrivateProfile() && Flags.enablePrivateSpaceFeatures() if (android.os.Flags.allowPrivateProfile() && Flags.enablePrivateSpaceFeatures()
&& Flags.enableBiometricsToUnlockPrivateSpace()) { && Flags.enableBiometricsToUnlockPrivateSpace()) {

View File

@@ -20,6 +20,7 @@ package com.android.settings.password;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PASSWORD_HEADER; import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PASSWORD_HEADER;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PATTERN_HEADER; import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PATTERN_HEADER;
import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PIN_HEADER; import static android.app.admin.DevicePolicyResources.Strings.Settings.CONFIRM_WORK_PROFILE_PIN_HEADER;
import static android.Manifest.permission.SET_BIOMETRIC_DIALOG_ADVANCED;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import android.app.Activity; import android.app.Activity;
@@ -31,6 +32,7 @@ import android.app.trust.TrustManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.UserProperties; import android.content.pm.UserProperties;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Color; import android.graphics.Color;
@@ -44,6 +46,7 @@ import android.os.Looper;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
@@ -65,6 +68,12 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
private static final String TAG_BIOMETRIC_FRAGMENT = "fragment"; private static final String TAG_BIOMETRIC_FRAGMENT = "fragment";
/** Use this extra value to provide a custom logo for the biometric prompt. **/
public static final String CUSTOM_BIOMETRIC_PROMPT_LOGO_RES_ID_KEY = "custom_logo_res_id";
/** Use this extra value to provide a custom logo description for the biometric prompt. **/
public static final String CUSTOM_BIOMETRIC_PROMPT_LOGO_DESCRIPTION_KEY =
"custom_logo_description";
public static class InternalActivity extends ConfirmDeviceCredentialActivity { public static class InternalActivity extends ConfirmDeviceCredentialActivity {
} }
@@ -202,6 +211,21 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
promptInfo.setDescription(mDetails); promptInfo.setDescription(mDetails);
promptInfo.setDisallowBiometricsIfPolicyExists(mCheckDevicePolicyManager); promptInfo.setDisallowBiometricsIfPolicyExists(mCheckDevicePolicyManager);
if (android.multiuser.Flags.enablePrivateSpaceFeatures()
&& android.multiuser.Flags.usePrivateSpaceIconInBiometricPrompt()
&& hasSetBiometricDialogAdvanced(mContext, getLaunchedFromUid())
) {
int iconResId = intent.getIntExtra(CUSTOM_BIOMETRIC_PROMPT_LOGO_RES_ID_KEY, 0);
if (iconResId != 0) {
promptInfo.setLogoRes(iconResId);
}
String logoDescription = intent.getStringExtra(
CUSTOM_BIOMETRIC_PROMPT_LOGO_DESCRIPTION_KEY);
if (!TextUtils.isEmpty(logoDescription)) {
promptInfo.setLogoDescription(logoDescription);
}
}
final int policyType = mDevicePolicyManager.getManagedSubscriptionsPolicy().getPolicyType(); final int policyType = mDevicePolicyManager.getManagedSubscriptionsPolicy().getPolicyType();
if (isEffectiveUserManagedProfile if (isEffectiveUserManagedProfile
@@ -409,6 +433,14 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
} }
} }
/**
* Checks if the calling uid has the permission to set biometric dialog icon and description.
*/
private static boolean hasSetBiometricDialogAdvanced(@NonNull Context context, int callingUid) {
return context.checkPermission(SET_BIOMETRIC_DIALOG_ADVANCED, /* pid */ -1, callingUid)
== PackageManager.PERMISSION_GRANTED;
}
// User could be locked while Effective user is unlocked even though the effective owns the // User could be locked while Effective user is unlocked even though the effective owns the
// credential. Otherwise, biometric can't unlock fbe/keystore through // credential. Otherwise, biometric can't unlock fbe/keystore through
// verifyTiedProfileChallenge. In such case, we also wanna show the user message that // verifyTiedProfileChallenge. In such case, we also wanna show the user message that

View File

@@ -20,6 +20,8 @@ import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
import static com.android.internal.app.SetScreenLockDialogActivity.LAUNCH_REASON_PRIVATE_SPACE_SETTINGS_ACCESS; import static com.android.internal.app.SetScreenLockDialogActivity.LAUNCH_REASON_PRIVATE_SPACE_SETTINGS_ACCESS;
import static com.android.settings.activityembedding.EmbeddedDeepLinkUtils.tryStartMultiPaneDeepLink; import static com.android.settings.activityembedding.EmbeddedDeepLinkUtils.tryStartMultiPaneDeepLink;
import static com.android.settings.password.ConfirmDeviceCredentialActivity.CUSTOM_BIOMETRIC_PROMPT_LOGO_DESCRIPTION_KEY;
import static com.android.settings.password.ConfirmDeviceCredentialActivity.CUSTOM_BIOMETRIC_PROMPT_LOGO_RES_ID_KEY;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.KeyguardManager; import android.app.KeyguardManager;
@@ -228,6 +230,14 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
private void authenticatePrivateSpaceEntry() { private void authenticatePrivateSpaceEntry() {
Intent credentialIntent = mPrivateSpaceMaintainer.getPrivateProfileLockCredentialIntent(); Intent credentialIntent = mPrivateSpaceMaintainer.getPrivateProfileLockCredentialIntent();
if (credentialIntent != null) { if (credentialIntent != null) {
if (android.multiuser.Flags.usePrivateSpaceIconInBiometricPrompt()) {
credentialIntent.putExtra(CUSTOM_BIOMETRIC_PROMPT_LOGO_RES_ID_KEY,
com.android.internal.R.drawable.stat_sys_private_profile_status);
credentialIntent.putExtra(CUSTOM_BIOMETRIC_PROMPT_LOGO_DESCRIPTION_KEY,
getApplicationContext().getString(
com.android.internal.R.string.private_space_biometric_prompt_title
));
}
mVerifyDeviceLock.launch(credentialIntent); mVerifyDeviceLock.launch(credentialIntent);
} else { } else {
Log.e(TAG, "verifyCredentialIntent is null even though device lock is set"); Log.e(TAG, "verifyCredentialIntent is null even though device lock is set");