Skip to content

Commit 23827c7

Browse files
Add missing IntentMonitor for startActivity with user overload
With the current code, any calls to startActivityAsUser will be missed by espresso-intent or similar intent monitoring facilities. PiperOrigin-RevId: 775965469
1 parent d03aca3 commit 23827c7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

runner/monitor/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
**Bug Fixes**
88

9+
* Fixes missing IntentMonitor for startActivity with user overload. Now it's
10+
possible to intercept intents started with startActivityAsUser.
11+
912
**New Features**
1013

1114
**Breaking Changes**

runner/monitor/java/androidx/test/runner/MonitoringInstrumentation.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,12 @@ public ActivityResult execStartActivity(
622622
int requestCode,
623623
Bundle options,
624624
UserHandle user) {
625+
intentMonitor.signalIntent(intent);
626+
ActivityResult ar = stubResultFor(intent);
627+
if (ar != null) {
628+
Log.i(TAG, String.format("Stubbing intent %s", intent));
629+
return ar;
630+
}
625631
return super.execStartActivity(
626632
who, contextThread, token, target, intent, requestCode, options, user);
627633
}

0 commit comments

Comments
 (0)