Skip to content

Commit

Permalink
Merge pull request #2267 from android/axt_2024_05_14_stable_release_b…
Browse files Browse the repository at this point in the history
…ranch_in_progress

Cherry pick 'Fix ActivityInvoker$-CC class not found errors' to axt_2024_05_14_stable_release_branch
  • Loading branch information
brettchabot authored Aug 13, 2024
2 parents 764afb9 + efbf44c commit 4e9874a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runner/monitor/java/androidx/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ kt_android_library(
"internal/runner/runtime/ExposedInstrumentationApi.java",
"internal/runner/hidden/ExposedInstrumentationApi.java",
"internal/platform/app/ActivityInvoker$$CC.java",
"internal/platform/app/ActivityInvokerDesugar.java",
],
),
tags = ["alt_dep=//runner/monitor"],
Expand Down Expand Up @@ -81,6 +82,7 @@ android_library(
srcs = [
# only needed for external release backwards compatibility
"internal/platform/app/ActivityInvoker$$CC.java",
"internal/platform/app/ActivityInvokerDesugar.java",
],
custom_package = "androidx.test.monitor",
manifest = "AndroidManifest.xml",
Expand All @@ -107,6 +109,7 @@ axt_android_aar(
"androidx.test.platform",
"androidx.test.runner",
],
jarjar_rule = ":jarjar.txt",
included_dep = ":monitor_release_lib",
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package androidx.test.internal.platform.app;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;

/**
* Handles default implementation for ActivityInvoker#getIntentForActivity
*
* <p> See the {@link ActivityInvoker$$CC} javadoc for prior history.
*
* <p> Starting in androidx.test:monitor:1.6.X, a new version of the desugar tooling was used
* that generated a ActivityInvoker$-CC class. Class names with hyphens are rejected by javac,
* so we cannot directly declare a ActivityInvoker$-CC class here. So instead we use a
* placeholder name, and use jarjar to rename the class after the javac step.
*
* @hide
*/
@RestrictTo(Scope.LIBRARY_GROUP)
public final class ActivityInvokerDesugar {

private ActivityInvokerDesugar() {}

public static Intent $default$getIntentForActivity(ActivityInvoker invoker,
Class<? extends Activity> activityClass) {
Intent intent =
Intent.makeMainActivity(
new ComponentName(getInstrumentation().getTargetContext(), activityClass));
if (getInstrumentation().getTargetContext().getPackageManager().resolveActivity(intent, 0)
!= null) {
return intent;
}
return Intent.makeMainActivity(
new ComponentName(getInstrumentation().getContext(), activityClass));
}
}
1 change: 1 addition & 0 deletions runner/monitor/java/androidx/test/jarjar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rule androidx.test.internal.platform.app.ActivityInvokerDesugar androidx.test.internal.platform.app.ActivityInvoker$-CC

0 comments on commit 4e9874a

Please sign in to comment.