@@ -6,8 +6,6 @@ import { buildScrollGesturePlan, type ScrollDirection } from '../../core/scroll-
66import { runAndroidAdb , sleep } from './adb.ts' ;
77import { resolveAndroidTextInjector } from './adb-executor.ts' ;
88import { getAndroidKeyboardState , type AndroidKeyboardState } from './device-input-state.ts' ;
9- import { captureAndroidUiHierarchyXml } from './snapshot.ts' ;
10- import { androidUiNodes } from './ui-hierarchy.ts' ;
119import {
1210 androidFillFailureDetails ,
1311 androidFillFailureMessage ,
@@ -208,7 +206,7 @@ export async function scrollAndroid(
208206 direction : ScrollDirection ,
209207 options ?: { amount ?: number ; pixels ?: number } ,
210208) : Promise < Record < string , unknown > > {
211- const size = await getAndroidGestureViewportSize ( device ) ;
209+ const size = await getAndroidScreenSize ( device ) ;
212210 const plan = buildScrollGesturePlan ( {
213211 direction,
214212 amount : options ?. amount ,
@@ -292,38 +290,6 @@ export async function getAndroidScreenSize(
292290 return { width : Number ( match [ 1 ] ) , height : Number ( match [ 2 ] ) } ;
293291}
294292
295- async function getAndroidGestureViewportSize (
296- device : DeviceInfo ,
297- ) : Promise < { width : number ; height : number } > {
298- try {
299- const xml = await captureAndroidUiHierarchyXml ( device ) ;
300- const viewport = largestAndroidUiNodeRect ( xml ) ;
301- if ( viewport ) return viewport ;
302- } catch ( error ) {
303- emitDiagnostic ( {
304- level : 'warn' ,
305- phase : 'android_gesture_viewport_probe_failed' ,
306- data : {
307- error : error instanceof Error ? error . message : String ( error ) ,
308- } ,
309- } ) ;
310- }
311- return await getAndroidScreenSize ( device ) ;
312- }
313-
314- function largestAndroidUiNodeRect ( xml : string ) : { width : number ; height : number } | null {
315- let largest : { width : number ; height : number ; area : number } | null = null ;
316- for ( const node of androidUiNodes ( xml ) ) {
317- const rect = node . rect ;
318- if ( ! rect || rect . width <= 0 || rect . height <= 0 ) continue ;
319- const area = rect . width * rect . height ;
320- if ( ! largest || area > largest . area ) {
321- largest = { width : rect . x + rect . width , height : rect . y + rect . height , area } ;
322- }
323- }
324- return largest ? { width : largest . width , height : largest . height } : null ;
325- }
326-
327293const ANDROID_INPUT_TEXT_CHUNK_SIZE = 8 ;
328294
329295async function typeAndroidShell (
0 commit comments