Snap for 11465908 from faba808e5e805602477e6bd6efebd536cae06fd2 to 24Q2-release

Change-Id: I2665d9b406a9c13af2d985a8002dfbe9652fad45
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
index 379ce80..90a1feb 100644
--- a/src/com/android/settings/password/BiometricFragment.java
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -21,6 +21,7 @@
 import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
 import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
 import android.hardware.biometrics.PromptInfo;
+import android.multiuser.Flags;
 import android.os.Bundle;
 import android.os.CancellationSignal;
 
@@ -140,8 +141,14 @@
                 .setDisallowBiometricsIfPolicyExists(
                         promptInfo.isDisallowBiometricsIfPolicyExists())
                 .setShowEmergencyCallButton(promptInfo.isShowEmergencyCallButton())
-                .setReceiveSystemEvents(true)
-                .setAllowBackgroundAuthentication(true);
+                .setReceiveSystemEvents(true);
+
+        if (Flags.enableBiometricsToUnlockPrivateSpace()) {
+            promptBuilder = promptBuilder.setAllowBackgroundAuthentication(true /* allow */,
+                    promptInfo.shouldUseParentProfileForDeviceCredential());
+        } else {
+            promptBuilder = promptBuilder.setAllowBackgroundAuthentication(true /* allow */);
+        }
 
         // Check if the default subtitle should be used if subtitle is null/empty
         if (promptInfo.isUseDefaultSubtitle()) {
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 4a760ad..f2ebd1f 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -311,6 +311,7 @@
             mForceVerifyPath = userProperties.isCredentialShareableWithParent();
             if (android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
                     && isBiometricAllowed(effectiveUserId, mUserId)) {
+                promptInfo.setUseParentProfileForDeviceCredential(true);
                 showBiometricPrompt(promptInfo, effectiveUserId);
                 launchedBiometric = true;
             } else {
diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppButtonsTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppButtonsTest.kt
index c742bd7..69acee8 100644
--- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppButtonsTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/AppButtonsTest.kt
@@ -24,6 +24,7 @@
 import android.content.pm.PackageInfo
 import android.content.pm.PackageInstaller
 import android.content.pm.PackageManager
+import android.platform.test.flag.junit.SetFlagsRule
 import androidx.compose.ui.test.assertIsDisplayed
 import androidx.compose.ui.test.assertIsEnabled
 import androidx.compose.ui.test.assertIsNotDisplayed
@@ -34,6 +35,7 @@
 import androidx.test.ext.junit.runners.AndroidJUnit4
 import com.android.dx.mockito.inline.extended.ExtendedMockito
 import com.android.settings.R
+import com.android.settings.flags.Flags as SettingsFlags
 import com.android.settingslib.applications.AppUtils
 import com.android.settingslib.spa.testutils.delay
 import kotlinx.coroutines.flow.MutableStateFlow
@@ -54,6 +56,8 @@
     @get:Rule
     val composeTestRule = createComposeRule()
 
+    @get:Rule val setFlagsRule: SetFlagsRule = SetFlagsRule()
+
     private lateinit var mockSession: MockitoSession
 
     @Spy
@@ -113,6 +117,7 @@
     fun launchButton_displayed_archivingDisabled() {
         whenever(packageManager.getLaunchIntentForPackage(PACKAGE_NAME)).thenReturn(Intent())
         featureFlags.setFlag(Flags.FLAG_ARCHIVING, false)
+        setFlagsRule.disableFlags(SettingsFlags.FLAG_APP_ARCHIVING)
         setContent()
 
         composeTestRule.onNodeWithText(context.getString(R.string.launch_instant_app))