Closed Bug 1527022 Opened 5 years ago Closed 1 year ago

NoSuchMethodException in AccessibilityTest.getChildId on Android API 28

Categories

(GeckoView :: General, defect, P3)

Unspecified
Android

Tracking

(firefox-esr60 wontfix, firefox65 wontfix, firefox66 wontfix, firefox67 wontfix, firefox110 wontfix, firefox111 wontfix, firefox112 fixed)

RESOLVED FIXED
112 Branch
Tracking Status
firefox-esr60 --- wontfix
firefox65 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox110 --- wontfix
firefox111 --- wontfix
firefox112 --- fixed

People

(Reporter: mbrubeck, Assigned: m_kato)

References

(Blocks 2 open bugs, )

Details

(Whiteboard: [sci-exclude])

Attachments

(1 file)

Running the geckoview-junit AccessibilityTest on an emulator with Android 9.0 ("P", api level 28) causes most tests to fail with the following exception:

java.lang.NoSuchMethodException: getChildNodeIds []
at java.lang.Class.getMethod(Class.java:2068)
at java.lang.Class.getMethod(Class.java:1690)
at org.mozilla.geckoview.test.AccessibilityTest.getChildId(AccessibilityTest.kt:88)
Assignee: nobody → eitan

The method is still there in API 28. Matt said it might be that Android 9 somehow restricts access to @hide public methods?

Running this on the target device makes the test pass: adb shell settings put global hidden_api_policy_p_apps 1.

OS: All → Android
Priority: -- → P2

I'm going to unassign myself from this. Looks like the adb shell command above will make this work locally on API 28+ emulators. If we ever start using that API or higher in CI, we may need to put this in some harness script, or revisit.

I hesitate to @SdkSuppress it. I'll leave this up to the geckoview team.

Assignee: eitan → nobody
Whiteboard: [sci-exclude]
Rank: 40
Priority: P2 → P3

(In reply to Eitan Isaacson [:eeejay] from comment #3)

I'm going to unassign myself from this. Looks like the adb shell command above will make this work locally on API 28+ emulators. If we ever start using that API or higher in CI, we may need to put this in some harness script, or revisit.

I hesitate to @SdkSuppress it. I'll leave this up to the geckoview team.

so I've been thinking about this again, because I want to start running our tests on higher API levels.

I'm a little bit worried about enabling hidden APIs in our tests because it might make us miss legitimate bugs where we're using an hidden API by mistake.

Eitan, is there any way we can use a public API for these tests instead?

Flags: needinfo?(eitan)

We would need to elevate the access to SessionAccessibility and have some special methods there for testing purposes only. I don't love that. What I like about our current setup is that it is a black box test that has the same access as an accessibility service has. I haven't looked into this issue in years, and I wonder if there is another solution to this that we didn't have back them.

Flags: needinfo?(eitan)

This doc suggests that maybe we could get the same kind of coverage with something like Espresso? Would mean rewriting a lot of this..
https://developer.android.com/guide/topics/ui/accessibility/testing#espresso

We could potentially split out the Accessibility tests in its own job that is allowed to access hidden Android APIs.

Severity: normal → S3
See Also: → 1797617
Blocks: 1719762
Rank: 40 → 333
Blocks: 1810398

I may find a workaround. Try it

Assignee: nobody → m_kato

When getting virtual ID of a11y tree, we use internal method via
reflection. But AccessibilityNodeInfo.getChildId is hidden now.

As workaround, since mChildNodeIds is still @UnsupportedAppUsage,
we can use it to get child node id.

This has another fix. Clipboard access requires foreground on Android 10+.
So we have to set window foucs when using clipboard.

Also, AccessibilityTest won't work on Android 12 since more methods
seem to be hidden from Android 12.
(by @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R)).

Attachment #9319098 - Attachment description: Bug 1527022 - Pass AccessibilityTest until Android 11 or early. r=#geckoview-reviewers,eeejay! → Bug 1527022 - Pass AccessibilityTest on Android 11 or early. r=#geckoview-reviewers,eeejay!
Pushed by m_kato@ga2.so-net.ne.jp:
https://hg.mozilla.org/integration/autoland/rev/2d4e1b0eff7d
Pass AccessibilityTest on Android 11 or early. r=eeejay,geckoview-reviewers,owlish
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch

No need to uplift this test fix to Beta 111.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: