From f4b71266faeff9e77709349d52aa762547cd718f Mon Sep 17 00:00:00 2001 From: caizhixing Date: Wed, 11 Nov 2026 02:38:26 -0800 Subject: [PATCH] fix: crash when starting home with fade-out remote transition on Android 14+ (#7528) Co-authored-by: caizhixing --- .../launcher3/uioverrides/SystemApiWrapper.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt index 81b1330e75..8eb5dc141a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt @@ -25,6 +25,7 @@ import android.content.Intent import android.content.pm.ActivityInfo import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps +import android.content.pm.PackageManager import android.content.pm.ShortcutInfo import android.graphics.Bitmap import android.graphics.Rect @@ -59,6 +60,9 @@ import javax.inject.Inject import app.lawnchair.LawnchairApp +private const val CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS = + "android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS" + /** A wrapper for the hidden API calls */ @LauncherAppSingleton open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Context?) : @@ -75,6 +79,17 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con } override fun createFadeOutAnimOptions(): ActivityOptions { + // Since Android 14, starting an activity with a RemoteTransition in its options + // requires the CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS permission, which cannot be + // granted to third-party apps; the system throws SecurityException at startActivity + // otherwise. Fall back to the default fade-out animation when it isn't held. + if ( + Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && + mContext.checkSelfPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS) != + PackageManager.PERMISSION_GRANTED + ) { + return super.createFadeOutAnimOptions() + } return try { ActivityOptions.makeBasic().apply { remoteTransition = RemoteTransition(FadeOutRemoteTransition(), "FadeOut")