diff options
| author | 2024-08-09 20:54:28 +0000 | |
|---|---|---|
| committer | 2024-08-09 20:54:28 +0000 | |
| commit | 045f396b67c9da97c5b2f667dc79ab71f1a36e02 (patch) | |
| tree | deecf92a99c7544661e5f8b389b61e3947e7c82a | |
| parent | 474f340c80c5764cfbf0772984c7538838656ac5 (diff) | |
| parent | 87538f0991e8ade5e9e534b8b4a44e2fb434e81b (diff) | |
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
5 files changed, 67 insertions, 26 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/BiometricStatusRepository.kt b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/BiometricStatusRepository.kt index ca03a00cca0c..da270c08f281 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/BiometricStatusRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/BiometricStatusRepository.kt @@ -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" diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/AuthenticationState.kt b/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/AuthenticationState.kt index 5ceae36dadb6..81ea6a9c15b0 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/AuthenticationState.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/shared/model/AuthenticationState.kt @@ -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 diff --git a/services/core/java/com/android/server/compat/PlatformCompat.java b/services/core/java/com/android/server/compat/PlatformCompat.java index f8fd0a0790e0..df49affa4d6f 100644 --- a/services/core/java/com/android/server/compat/PlatformCompat.java +++ b/services/core/java/com/android/server/compat/PlatformCompat.java @@ -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) { diff --git a/services/core/java/com/android/server/pm/ResolveIntentHelper.java b/services/core/java/com/android/server/pm/ResolveIntentHelper.java index 69490a81fc86..5b4f310655cd 100644 --- a/services/core/java/com/android/server/pm/ResolveIntentHelper.java +++ b/services/core/java/com/android/server/pm/ResolveIntentHelper.java @@ -126,10 +126,12 @@ final class ResolveIntentHelper { userId, resolveForStart, /*allowDynamicSplits*/ true); Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); - var args = new SaferIntentUtils.IntentArgs(intent, resolvedType, - false /* isReceiver */, resolveForStart, filterCallingUid, callingPid); - args.platformCompat = mPlatformCompat; - SaferIntentUtils.filterNonExportedComponents(args, query); + if (resolveForStart) { + var args = new SaferIntentUtils.IntentArgs(intent, resolvedType, + false /* isReceiver */, true, filterCallingUid, callingPid); + args.platformCompat = mPlatformCompat; + SaferIntentUtils.filterNonExportedComponents(args, query); + } final boolean queryMayBeFiltered = UserHandle.getAppId(filterCallingUid) >= Process.FIRST_APPLICATION_UID diff --git a/services/core/java/com/android/server/pm/SaferIntentUtils.java b/services/core/java/com/android/server/pm/SaferIntentUtils.java index 8175321ea293..9a7ba0f082ea 100644 --- a/services/core/java/com/android/server/pm/SaferIntentUtils.java +++ b/services/core/java/com/android/server/pm/SaferIntentUtils.java @@ -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) { |