From f8adb7dca7db87cd6adcd5c4747e6aa0237c63e0 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Thu, 30 Mar 2023 21:41:30 +0900 Subject: [PATCH] Ignore ActivityNotFoundException from app launch Only happens after package changes like uninstall, and before page auto refresh or close, so ignore this exception is safe. Fix: 276023155 Test: Click the open button ASAP after uninstall an app from App Info Change-Id: I62314fda0947dee5e05263d1079ff422688527c3 --- .../android/settings/spa/app/appinfo/AppLaunchButton.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/spa/app/appinfo/AppLaunchButton.kt b/src/com/android/settings/spa/app/appinfo/AppLaunchButton.kt index a1c3273eae3..c7eb02df4ef 100644 --- a/src/com/android/settings/spa/app/appinfo/AppLaunchButton.kt +++ b/src/com/android/settings/spa/app/appinfo/AppLaunchButton.kt @@ -16,6 +16,7 @@ package com.android.settings.spa.app.appinfo +import android.content.ActivityNotFoundException import android.content.Intent import android.content.pm.ApplicationInfo import androidx.compose.material.icons.Icons @@ -37,6 +38,11 @@ class AppLaunchButton(packageInfoPresenter: PackageInfoPresenter) { text = context.getString(R.string.launch_instant_app), imageVector = Icons.Outlined.Launch, ) { - context.startActivityAsUser(intent, app.userHandle) + try { + context.startActivityAsUser(intent, app.userHandle) + } catch (_: ActivityNotFoundException) { + // Only happens after package changes like uninstall, and before page auto refresh or + // close, so ignore this exception is safe. + } } }