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

@@ -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_PATTERN_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 android.app.Activity;
@@ -31,6 +32,7 @@ import android.app.trust.TrustManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.UserProperties;
import android.content.res.Configuration;
import android.graphics.Color;
@@ -44,6 +46,7 @@ import android.os.Looper;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
@@ -65,6 +68,12 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
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 {
}
@@ -202,6 +211,21 @@ public class ConfirmDeviceCredentialActivity extends FragmentActivity {
promptInfo.setDescription(mDetails);
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();
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
// credential. Otherwise, biometric can't unlock fbe/keystore through
// verifyTiedProfileChallenge. In such case, we also wanna show the user message that