From a4a55a9537f19ed6eb7b6a67b4aa61556729cada Mon Sep 17 00:00:00 2001 From: MrSluffy Date: Sat, 8 Jun 2024 08:52:09 +0800 Subject: [PATCH 1/3] Fixe crashes below Q - Closes : #4448 --- .../src/com/android/launcher3/QuickstepTransitionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 1baf7925e9a..526922e8409 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1154,7 +1154,7 @@ public void registerRemoteTransitions() { if (ENABLE_SHELL_TRANSITIONS && LawnchairQuickstepCompat.ATLEAST_U) SystemUiProxy.INSTANCE.get(mLauncher).shareTransactionQueue(); - if (hasControlRemoteAppTransitionPermission()) { + if (hasControlRemoteAppTransitionPermission() && LawnchairQuickstepCompat.ATLEAST_Q) { mWallpaperOpenTransitionRunner = createWallpaperOpenRunner(false /* fromUnlock */); mLauncherOpenTransition = LawnchairQuickstepCompat.getRemoteTransitionCompat().getRemoteTransition( new LauncherAnimationRunner(mHandler, mWallpaperOpenTransitionRunner, From dfa7645f2cdd174ec23f44a8f4c8b904b981e3b3 Mon Sep 17 00:00:00 2001 From: MrSluffy Date: Sat, 8 Jun 2024 09:02:13 +0800 Subject: [PATCH 2/3] Add throwable error - Closes : #4416 --- .../launcher3/uioverrides/QuickstepWidgetHolder.java | 6 +++++- src/com/android/launcher3/widget/LauncherWidgetHolder.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java index 9dbca581fb8..ac0164a5f04 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java @@ -222,7 +222,11 @@ public void stopListening() { return; } - sWidgetHost.setAppWidgetHidden(); + try { + sWidgetHost.setAppWidgetHidden(); + } catch (Throwable t) { + // Ignore + } setListeningFlag(false); } diff --git a/src/com/android/launcher3/widget/LauncherWidgetHolder.java b/src/com/android/launcher3/widget/LauncherWidgetHolder.java index ad7f7c3e7fc..8c15294bd61 100644 --- a/src/com/android/launcher3/widget/LauncherWidgetHolder.java +++ b/src/com/android/launcher3/widget/LauncherWidgetHolder.java @@ -342,7 +342,11 @@ public void stopListening() { } } } - mWidgetHost.stopListening(); + try { + mWidgetHost.stopListening(); + } catch (Throwable t) { + // Ignore + } setListeningFlag(false); } From c64e205509ed131529938353f6e101f999d64bb4 Mon Sep 17 00:00:00 2001 From: MrSluffy Date: Sat, 8 Jun 2024 09:58:58 +0800 Subject: [PATCH 3/3] Fixed Global search regressions - Closes : #4438 - Fixes crash : java.util.NoSuchElementException: List is empty. at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:221) at app.lawnchair.search.algorithms.LawnchairLocalSearchAlgorithm.getResult(LawnchairLocalSearchAlgorithm.kt:179) at app.lawnchair.search.algorithms.LawnchairLocalSearchAlgorithm.access$getResult(LawnchairLocalSearchAlgorithm.kt:63) at app.lawnchair.search.algorithms.LawnchairLocalSearchAlgorithm$getResult$1.invokeSuspend(Unknown Source:15) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) at android.os.Handler.handleCallback(Handler.java:959) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8501) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@bb7af8b, Dispatchers.Main] --- .../algorithms/LawnchairAppSearchAlgorithm.kt | 14 ++++++---- .../LawnchairLocalSearchAlgorithm.kt | 28 +++++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lawnchair/src/app/lawnchair/search/algorithms/LawnchairAppSearchAlgorithm.kt b/lawnchair/src/app/lawnchair/search/algorithms/LawnchairAppSearchAlgorithm.kt index c4cfd6960c5..2bf0e3ef2ee 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/LawnchairAppSearchAlgorithm.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/LawnchairAppSearchAlgorithm.kt @@ -98,12 +98,14 @@ class LawnchairAppSearchAlgorithm(context: Context) : LawnchairSearchAlgorithm(c } if (appResults.size == 1 && context.isDefaultLauncher()) { - val singleAppResult = appResults.first() - val shortcuts = getShortcuts(singleAppResult) - if (shortcuts.isNotEmpty()) { - searchTargets.add(generateSearchTarget.getHeaderTarget(SPACE)) - searchTargets.add(createSearchTarget(singleAppResult, true)) - searchTargets.addAll(shortcuts.map(::createSearchTarget)) + val singleAppResult = appResults.firstOrNull() + val shortcuts = singleAppResult?.let { getShortcuts(it) } + if (shortcuts != null) { + if (shortcuts.isNotEmpty()) { + searchTargets.add(generateSearchTarget.getHeaderTarget(SPACE)) + searchTargets.add(createSearchTarget(singleAppResult, true)) + searchTargets.addAll(shortcuts.map(::createSearchTarget)) + } } } diff --git a/lawnchair/src/app/lawnchair/search/algorithms/LawnchairLocalSearchAlgorithm.kt b/lawnchair/src/app/lawnchair/search/algorithms/LawnchairLocalSearchAlgorithm.kt index 87b21cabcfc..2cce6cf8e1a 100644 --- a/lawnchair/src/app/lawnchair/search/algorithms/LawnchairLocalSearchAlgorithm.kt +++ b/lawnchair/src/app/lawnchair/search/algorithms/LawnchairLocalSearchAlgorithm.kt @@ -160,12 +160,14 @@ class LawnchairLocalSearchAlgorithm(context: Context) : LawnchairSearchAlgorithm } if (appResults.size == 1 && searchApps && context.isDefaultLauncher()) { - val singleAppResult = appResults.first() - val shortcuts = getShortcuts(singleAppResult) - if (shortcuts.isNotEmpty()) { - searchTargets.add(generateSearchTarget.getHeaderTarget(SPACE)) - searchTargets.add(createSearchTarget(singleAppResult, true)) - searchTargets.addAll(shortcuts.map(::createSearchTarget)) + val singleAppResult = appResults.firstOrNull() + val shortcuts = singleAppResult?.let { getShortcuts(it) } + if (shortcuts != null) { + if (shortcuts.isNotEmpty()) { + searchTargets.add(generateSearchTarget.getHeaderTarget(SPACE)) + searchTargets.add(createSearchTarget(singleAppResult, true)) + searchTargets.addAll(shortcuts.map(::createSearchTarget)) + } } } @@ -176,9 +178,9 @@ class LawnchairLocalSearchAlgorithm(context: Context) : LawnchairSearchAlgorithm searchTargets.addAll(suggestions.map { generateSearchTarget.getSuggestionTarget(it.resultData as String) }) } - val calculator = filterByType(localSearchResults, CALCULATOR).first() - val calcData = calculator.resultData as Calculation - if (calcData.isValid) { + val calculator = filterByType(localSearchResults, CALCULATOR).firstOrNull() + val calcData = calculator?.resultData as? Calculation + if (calcData != null && calcData.isValid) { val calculatorHeader = generateSearchTarget.getHeaderTarget(context.getString(R.string.all_apps_search_result_calculator)) searchTargets.add(calculatorHeader) searchTargets.add( @@ -321,8 +323,12 @@ class LawnchairLocalSearchAlgorithm(context: Context) : LawnchairSearchAlgorithm } val settingsDeferred = async { - findSettingsByNameAndAction(query, maxSettingsEntryCount) - .map { SearchResult(SETTINGS, it) } + if (prefs.searchResultSettingsEntry.get()) { + findSettingsByNameAndAction(query, maxSettingsEntryCount) + .map { SearchResult(SETTINGS, it) } + } else { + emptyList() + } } val startPageSuggestionsDeferred = async {