Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static void appendNode(
appendAttribute(xml, "visible-to-user", Boolean.toString(node.isVisibleToUser()));
appendDrawingOrderAttribute(xml, node);
appendTrueAttribute(xml, "clickable", node.isClickable());
appendAttribute(xml, "long-clickable", Boolean.toString(node.isLongClickable()));
appendAttribute(xml, "enabled", Boolean.toString(node.isEnabled()));
appendTrueAttribute(xml, "focusable", node.isFocusable());
appendTrueAttribute(xml, "focused", node.isFocused());
Expand Down Expand Up @@ -188,8 +189,6 @@ private static boolean isHeading(AccessibilityNodeInfo node) {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && node.isHeading();
}

// Declared residue (agent-device #1832): long-clickable is not serialized. Adding it is a helper
// protocol change (new attribute + host parser + field on the wire node).
private static void appendDrawingOrderAttribute(StringBuilder xml, AccessibilityNodeInfo node) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
appendAttribute(xml, "drawing-order", Integer.toString(node.getDrawingOrder()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ const PRESENTATION_SCALAR_FIELDS = {
roleDescription: true,
placeholder: true,
hittable: true,
clickable: true,
focusable: true,
longClickable: true,
scrollable: true,
bundleId: true,
systemBar: true,
appName: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/kernel/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ export type RawSnapshotNode = {
/** UIKit `isUserInteractionEnabled`; absent means the producer did not read it, not false. */
userInteractionEnabled?: boolean;
hittable?: boolean;
clickable?: boolean;
focusable?: boolean;
longClickable?: boolean;
scrollable?: boolean;
depth?: number;
parentIndex?: number;
pid?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ afterEach(() => {
test('retains Android helper clickable facts from the same hierarchy projection', () => {
const built = buildUiHierarchySnapshot(
parseUiHierarchyTree(`<hierarchy>
<node resource-id="true-node" bounds="[0,0][20,20]" clickable="true" />
<node resource-id="false-node" bounds="[0,20][20,40]" clickable="false" focusable="true" />
<node resource-id="absent-node" bounds="[0,40][20,60]" />
<node resource-id="true-node" bounds="[0,0][20,20]" clickable="true" long-clickable="true" />
<node resource-id="false-node" bounds="[0,20][20,40]" clickable="false" long-clickable="false" focusable="true" />
<node resource-id="absent-node" bounds="[0,40][20,60]" scrollable="true" />
</hierarchy>`),
undefined,
{ raw: true },
Expand All @@ -63,11 +63,23 @@ test('retains Android helper clickable facts from the same hierarchy projection'
],
);
assert.equal(publicSnapshot.nodes[1]?.hittable, true);
assert.equal('clickable' in (publicSnapshot.nodes[1] ?? {}), false);
assert.deepEqual(
publicSnapshot.nodes.map((node) => [node.clickable, node.focusable, node.scrollable]),
[
[true, false, false],
[false, true, false],
[false, false, true],
],
);
assert.deepEqual(
publicSnapshot.nodes.map((node) => node.longClickable),
[true, false, undefined],
);
assert.equal('longClickable' in (publicSnapshot.nodes[2] ?? {}), false);
assert.equal(readSnapshotClickabilityEvidence(publicSnapshot), undefined);
});

test('snapshotAndroid captures the hierarchy once and retains clickability off-wire', async () => {
test('snapshotAndroid captures the hierarchy once and publishes the clickability it retains', async () => {
let hierarchyCaptures = 0;
const helperAdb: AndroidAdbExecutor = async (args) => {
if (args.includes('--show-versioncode')) {
Expand Down Expand Up @@ -119,7 +131,10 @@ test('snapshotAndroid captures the hierarchy once and retains clickability off-w
[2, 2],
],
);
assert.equal(JSON.stringify(result).includes('clickable'), false);
assert.deepEqual(
result.nodes.map((node) => node.clickable),
[false, true, false],
);
assert.equal(JSON.stringify(result).includes('sourceIndexByNodeIndex'), false);
});

Expand Down
4 changes: 4 additions & 0 deletions packages/platform-android/src/ui-hierarchy-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ function createAndroidRawSnapshotNode(
focused: node.focused,
visibleToUser: node.visibleToUser,
hittable: isAgentTarget(node) || undefined,
clickable: node.clickable,
focusable: node.focusable,
...(node.longClickable === undefined ? {} : { longClickable: node.longClickable }),
scrollable: node.scrollable === true,
depth: compactedAndroidNodeDepth(state.nodes, parentIndex),
parentIndex,
...androidScrollActionHints(node, state.hidden),
Expand Down
1 change: 1 addition & 0 deletions packages/platform-android/src/ui-hierarchy-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type AndroidUiHierarchy = {
// encodings of one control opposite answers.
clickable: boolean;
focusable: boolean;
longClickable?: boolean;
depth: number;
parentIndex?: number;
scrollable?: boolean;
Expand Down
3 changes: 3 additions & 0 deletions packages/platform-android/src/ui-hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type AndroidUiNodeMetadata = {
bounds: string | null;
rect?: Rect;
clickable?: boolean;
longClickable?: boolean;
enabled?: boolean;
visibleToUser?: boolean;
drawingOrder?: number;
Expand Down Expand Up @@ -166,6 +167,7 @@ function readNodeAttributes(node: string): Omit<AndroidUiNodeMetadata, 'rect'> {
className: getAttr('class'),
bounds: getAttr('bounds'),
clickable: boolAttr('clickable'),
...optionalBoolAttr('longClickable', 'long-clickable'),
enabled: boolAttr('enabled'),
focusable: boolAttr('focusable'),
focused: boolAttr('focused'),
Expand Down Expand Up @@ -350,6 +352,7 @@ function normalizeAndroidUiHierarchyNode(
focused: attrs.focused,
visibleToUser: attrs.visibleToUser,
clickable: attrs.clickable === true,
longClickable: attrs.longClickable,
focusable: attrs.focusable === true,
scrollable: attrs.scrollable,
canScrollForward: attrs.canScrollForward,
Expand Down
Loading