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

Commit 045f396b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27881172',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27881172', 'googleplex-android-review.googlesource.com/28359704', 'googleplex-android-review.googlesource.com/28598475'] into 24Q3-release.

Change-Id: I2215cc9e89b78014f2c90b38bd03e1a058ad6bd7
parents 474f340c 87538f09
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import com.android.systemui.biometrics.shared.model.AuthenticationReason
import com.android.systemui.biometrics.shared.model.AuthenticationReason.SettingsOperations
import com.android.systemui.biometrics.shared.model.AuthenticationState
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.shared.model.AcquiredFingerprintAuthenticationStatus
@@ -49,6 +48,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
@@ -85,7 +85,7 @@ constructor(
     *   onAcquired in [FingerprintManager.EnrollmentCallback] and [FaceManager.EnrollmentCallback]
     */
    private val authenticationState: Flow<AuthenticationState> =
        conflatedCallbackFlow {
        callbackFlow {
                val updateAuthenticationState = { state: AuthenticationState ->
                    Log.d(TAG, "authenticationState updated: $state")
                    trySendWithFailureLogging(state, TAG, "Error sending AuthenticationState state")
@@ -169,7 +169,9 @@ constructor(
                        }
                    }

                updateAuthenticationState(AuthenticationState.Idle(AuthenticationReason.NotRunning))
                updateAuthenticationState(
                    AuthenticationState.Idle(requestReason = AuthenticationReason.NotRunning)
                )
                biometricManager?.registerAuthenticationStateListener(authenticationStateListener)
                awaitClose {
                    biometricManager?.unregisterAuthenticationStateListener(
@@ -180,23 +182,32 @@ constructor(
            .distinctUntilChanged()
            .shareIn(applicationScope, started = SharingStarted.Eagerly, replay = 1)

    override val fingerprintAuthenticationReason: Flow<AuthenticationReason> =
    private val fingerprintAuthenticationState: Flow<AuthenticationState> =
        authenticationState
            .filter {
                it.biometricSourceType == null ||
                    it.biometricSourceType == BiometricSourceType.FINGERPRINT
            }
            .onEach { Log.d(TAG, "fingerprintAuthenticationState updated: $it") }

    private val fingerprintRunningState: Flow<AuthenticationState> =
        fingerprintAuthenticationState
            .filter {
                it is AuthenticationState.Idle ||
                    (it is AuthenticationState.Started &&
                        it.biometricSourceType == BiometricSourceType.FINGERPRINT) ||
                    (it is AuthenticationState.Stopped &&
                        it.biometricSourceType == BiometricSourceType.FINGERPRINT)
                    it is AuthenticationState.Started ||
                    it is AuthenticationState.Stopped
            }
            .onEach { Log.d(TAG, "fingerprintRunningState updated: $it") }

    override val fingerprintAuthenticationReason: Flow<AuthenticationReason> =
        fingerprintRunningState
            .map { it.requestReason }
            .onEach { Log.d(TAG, "fingerprintAuthenticationReason updated: $it") }

    override val fingerprintAcquiredStatus: Flow<FingerprintAuthenticationStatus> =
        authenticationState
            .filterIsInstance<AuthenticationState.Acquired>()
            .filter { it.biometricSourceType == BiometricSourceType.FINGERPRINT }
            .map { AcquiredFingerprintAuthenticationStatus(it.requestReason, it.acquiredInfo) }
        fingerprintAuthenticationState.filterIsInstance<AuthenticationState.Acquired>().map {
            AcquiredFingerprintAuthenticationStatus(it.requestReason, it.acquiredInfo)
        }

    companion object {
        private const val TAG = "BiometricStatusRepositoryImpl"
+15 −8
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ import android.hardware.biometrics.BiometricSourceType
 * authentication.
 */
sealed interface AuthenticationState {
    /** Indicates [BiometricSourceType] of authentication state update, null in idle auth state. */
    val biometricSourceType: BiometricSourceType?

    /**
     * Indicates [AuthenticationReason] from [BiometricRequestConstants.RequestReason] for
     * requesting auth
@@ -43,7 +46,7 @@ sealed interface AuthenticationState {
     *   message.
     */
    data class Acquired(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        override val requestReason: AuthenticationReason,
        val acquiredInfo: Int
    ) : AuthenticationState
@@ -59,7 +62,7 @@ sealed interface AuthenticationState {
     * @param requestReason reason from [BiometricRequestConstants.RequestReason] for authentication
     */
    data class Error(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        val errString: String?,
        val errCode: Int,
        override val requestReason: AuthenticationReason,
@@ -73,7 +76,7 @@ sealed interface AuthenticationState {
     * @param userId The user id for the requested authentication
     */
    data class Failed(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        override val requestReason: AuthenticationReason,
        val userId: Int
    ) : AuthenticationState
@@ -87,7 +90,7 @@ sealed interface AuthenticationState {
     * @param requestReason reason from [BiometricRequestConstants.RequestReason] for authentication
     */
    data class Help(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        val helpString: String?,
        val helpCode: Int,
        override val requestReason: AuthenticationReason,
@@ -96,9 +99,13 @@ sealed interface AuthenticationState {
    /**
     * Authentication state when no auth is running
     *
     * @param biometricSourceType null
     * @param requestReason [AuthenticationReason.NotRunning]
     */
    data class Idle(override val requestReason: AuthenticationReason) : AuthenticationState
    data class Idle(
        override val biometricSourceType: BiometricSourceType? = null,
        override val requestReason: AuthenticationReason
    ) : AuthenticationState

    /**
     * AuthenticationState when auth is started
@@ -107,7 +114,7 @@ sealed interface AuthenticationState {
     * @param requestReason reason from [BiometricRequestConstants.RequestReason] for authentication
     */
    data class Started(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        override val requestReason: AuthenticationReason
    ) : AuthenticationState

@@ -118,7 +125,7 @@ sealed interface AuthenticationState {
     * @param requestReason [AuthenticationReason.NotRunning]
     */
    data class Stopped(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        override val requestReason: AuthenticationReason
    ) : AuthenticationState

@@ -131,7 +138,7 @@ sealed interface AuthenticationState {
     * @param userId The user id for the requested authentication
     */
    data class Succeeded(
        val biometricSourceType: BiometricSourceType,
        override val biometricSourceType: BiometricSourceType,
        val isStrongBiometric: Boolean,
        override val requestReason: AuthenticationReason,
        val userId: Int
+19 −0
Original line number Diff line number Diff line
@@ -236,6 +236,25 @@ public class PlatformCompat extends IPlatformCompat.Stub {
        return enabled;
    }

    /**
     * Internal version of {@link #isChangeEnabledByUid(long, int)}.
     *
     * <p>Does not perform costly permission check and logging.
     */
    public boolean isChangeEnabledByUidInternalNoLogging(long changeId, int uid) {
        String[] packages = mContext.getPackageManager().getPackagesForUid(uid);
        if (packages == null || packages.length == 0) {
            return mCompatConfig.defaultChangeIdValue(changeId);
        }
        boolean enabled = true;
        final int userId = UserHandle.getUserId(uid);
        for (String packageName : packages) {
            final var appInfo = getApplicationInfo(packageName, userId);
            enabled &= isChangeEnabledInternalNoLogging(changeId, appInfo);
        }
        return enabled;
    }

    @Override
    @EnforcePermission(OVERRIDE_COMPAT_CHANGE_CONFIG)
    public void setOverrides(CompatibilityChangeConfig overrides, String packageName) {
+6 −4
Original line number Diff line number Diff line
@@ -126,10 +126,12 @@ final class ResolveIntentHelper {
                    userId, resolveForStart, /*allowDynamicSplits*/ true);
            Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);

            if (resolveForStart) {
                var args = new SaferIntentUtils.IntentArgs(intent, resolvedType,
                    false /* isReceiver */, resolveForStart, filterCallingUid, callingPid);
                        false /* isReceiver */, true, filterCallingUid, callingPid);
                args.platformCompat = mPlatformCompat;
                SaferIntentUtils.filterNonExportedComponents(args, query);
            }

            final boolean queryMayBeFiltered =
                    UserHandle.getAppId(filterCallingUid) >= Process.FIRST_APPLICATION_UID
+4 −2
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class SaferIntentUtils {
    @Disabled
    private static final long ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS = 161252188;

    @Nullable
    private static ParsedMainComponent infoToComponent(
            ComponentInfo info, ComponentResolverApi resolver, boolean isReceiver) {
        if (info instanceof ActivityInfo) {
@@ -186,7 +187,7 @@ public class SaferIntentUtils {
        }

        boolean isChangeEnabled(long changeId) {
            return platformCompat == null || platformCompat.isChangeEnabledByUidInternal(
            return platformCompat == null || platformCompat.isChangeEnabledByUidInternalNoLogging(
                    changeId, callingUid);
        }

@@ -233,7 +234,8 @@ public class SaferIntentUtils {
                }
                final ParsedMainComponent comp = infoToComponent(
                        resolveInfo.getComponentInfo(), resolver, args.isReceiver);
                if (!comp.getIntents().isEmpty() && args.intent.getAction() == null) {
                if (comp != null && !comp.getIntents().isEmpty()
                        && args.intent.getAction() == null) {
                    match = false;
                }
            } else if (c instanceof IntentFilter) {