-
Notifications
You must be signed in to change notification settings - Fork 38
fix(android): keep scanning mCurrentFocus across every display #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gmegidish
merged 1 commit into
mobile-next:main
from
akexorcist:fix/foreground-app-multi-display
Sep 16, 2026
+80
−14
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package devices | ||
|
|
||
| import "testing" | ||
|
|
||
| func Test_parseForegroundComponent(t *testing.T) { //nolint:funlen | ||
| tests := []struct { | ||
| name string | ||
| input string | ||
| wantPackage string | ||
| wantActivity string | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "single display", | ||
| input: " mCurrentFocus=Window{9c8e10c u0 com.example.app/com.example.app.MainActivity}", | ||
| wantPackage: "com.example.app", | ||
| wantActivity: "com.example.app.MainActivity", | ||
| }, | ||
| { | ||
| name: "multi display with a null before the focused one", | ||
| input: " mCurrentFocus=null\n" + | ||
| " mCurrentFocus=Window{d0ebdc2 u0 com.example.app/com.example.app.MainActivity}", | ||
| wantPackage: "com.example.app", | ||
| wantActivity: "com.example.app.MainActivity", | ||
| }, | ||
| { | ||
| name: "every display unfocused", | ||
| input: " mCurrentFocus=null\n mCurrentFocus=null", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "no mCurrentFocus line at all", | ||
| input: "Display: mDisplayId=0\n mBaseDisplayWidth=1080", | ||
| wantErr: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| pkg, activity, err := parseForegroundComponent(tt.input) | ||
| if tt.wantErr { | ||
| if err == nil { | ||
| t.Fatalf("parseForegroundComponent() expected an error, got %q/%q", pkg, activity) | ||
| } | ||
| return | ||
| } | ||
| if err != nil { | ||
| t.Fatalf("parseForegroundComponent() error = %v", err) | ||
| } | ||
| if pkg != tt.wantPackage || activity != tt.wantActivity { | ||
| t.Errorf("parseForegroundComponent() = %q/%q, want %q/%q", | ||
| pkg, activity, tt.wantPackage, tt.wantActivity) | ||
| } | ||
| }) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: mobile-next/mobilecli
Length of output: 5336
🏁 Script executed:
Repository: mobile-next/mobilecli
Length of output: 8297
🏁 Script executed:
Repository: mobile-next/mobilecli
Length of output: 291
🏁 Script executed:
Repository: mobile-next/mobilecli
Length of output: 10010
Reject empty component fields before returning.
A malformed
mCurrentFocusline such asmCurrentFocus=Window{... u0 /BrokenActivity}passes the current slash check.parseForegroundComponentreturns an empty package, andgetForegroundComponentdoes not scan a later valid display entry.GetForegroundAppthen passes the empty package toGetAppVersion.Require text on both sides of
/, and add this case before a valid multi-display entry in the table test.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents