Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 01ed77e9aeafebf441ab9c4f1119f672796a72d2
Author: Chris Craik <ccraik@google.com>
Date: Thu Aug 18 10:52:02 2022
Add leanback fallback for startActivityAndWait
Fixes:242899915
Test: ./gradlew bench:b-m:cC
Change-Id: Ie4c1aed8b20b6a077c8f64ce968b1944e223aa2e
M benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/MacrobenchmarkScope.kt
https://android-review.googlesource.com/2189720
Branch: androidx-main
commit 01ed77e9aeafebf441ab9c4f1119f672796a72d2
Author: Chris Craik <ccraik@google.com>
Date: Thu Aug 18 10:52:02 2022
Add leanback fallback for startActivityAndWait
Fixes:242899915
Test: ./gradlew bench:b-m:cC
Change-Id: Ie4c1aed8b20b6a077c8f64ce968b1944e223aa2e
M benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/MacrobenchmarkScope.kt
an...@mutualmobile.com <an...@mutualmobile.com> #3
I just created a new Project from Android Dolphin , with 7.3.0-rc01 gradle plugin and 1.7.0 kotlin version. I still can't see getLeanbackLaunchIntentForPackage(). What could be the issue?
cc...@google.com <cc...@google.com> #4
To get this fix, you'll need to update benchmark dependencies to 1.2.0-alpha03
, just
As a workaround on older versions, you can copy the method with the fix into a new extension:
public fun MacrobenchmarkScope.startActivityAndWaitWorkaround(
block: (Intent) -> Unit = {}
) {
val intent = context.packageManager.getLaunchIntentForPackage(packageName)
?: context.packageManager.getLeanbackLaunchIntentForPackage(packageName)
?: throw IllegalStateException("Unable to acquire intent for package $packageName")
block(intent)
startActivityAndWait(intent)
}
na...@google.com <na...@google.com> #5
This bug was linked in a change in the following release(s):
androidx.benchmark:benchmark-macro:1.2.0-alpha03
Description
Component used: Macrobenchmark module Version used: benchmark-macro-junit4:1.2.0-alpha01 Devices/Android versions reproduced on: Android TV
Running macrobenchmark test on any AndroidTV application which doesn't have
<category android:name="android.intent.category.LAUNCHER" />
but instead has only<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
for the launcher activity, will result in Unable to acquire intent for package becauseMacroBenchmarkScope.startActivityAndWait()
is relying only oncontext.packageManager.getLaunchIntentForPackage()
and not ongetLeanbackLaunchIntentForPackage()
Instead of throwing exception immediately, you could try to grab launch intent by calling
getLeanbackLaunchIntentForPackage()
if the first one fails.