MCPcopy Index your code
hub / github.com/callstack/agent-device / fillAndroid

Function fillAndroid

src/platforms/android/input-actions.ts:124–191  ·  view source on GitHub ↗
(
  device: DeviceInfo,
  x: number,
  y: number,
  text: string,
  delayMs = 0,
)

Source from the content-addressed store, hash-verified

122}
123
124export async function fillAndroid(
125 device: DeviceInfo,
126 x: number,
127 y: number,
128 text: string,
129 delayMs = 0,
130): Promise<void> {
131 const providerText = resolveAndroidTextInjector(device);
132 if (providerText) {
133 await providerText({ action: 'fill', target: { x, y }, text, delayMs });
134 emitAndroidTextDiagnostic('fill', 'provider-native', text);
135 const verification = await verifyAndroidFilledText(device, x, y, text);
136 if (verification.ok) return;
137 throwAndroidFillFailure(text, verification);
138 }
139 assertAndroidShellTextSupported(text);
140
141 const textCodePointLength = Array.from(text).length;
142 const attempts: Array<{
143 clearPadding: number;
144 minClear: number;
145 maxClear: number;
146 chunkSize: number;
147 inputDelayMs: number;
148 }> = [
149 {
150 clearPadding: 12,
151 minClear: 8,
152 maxClear: 48,
153 chunkSize: delayMs > 0 ? 1 : ANDROID_INPUT_TEXT_CHUNK_SIZE,
154 inputDelayMs: delayMs,
155 },
156 {
157 clearPadding: 24,
158 minClear: 16,
159 maxClear: 96,
160 chunkSize: delayMs > 0 ? 1 : 4,
161 inputDelayMs: delayMs > 0 ? delayMs : 15,
162 },
163 ];
164
165 let lastVerification: AndroidFillVerification | null = null;
166
167 for (const attempt of attempts) {
168 await focusAndroid(device, x, y);
169 await assertAndroidShellInputIsAppOwned(device, 'fill');
170 const clearCount = clampCount(
171 textCodePointLength + attempt.clearPadding,
172 attempt.minClear,
173 attempt.maxClear,
174 );
175 await clearFocusedText(device, clearCount);
176 await typeAndroidShell(device, {
177 action: 'fill',
178 text,
179 chunkSize: attempt.chunkSize,
180 delayMs: attempt.inputDelayMs,
181 });

Callers 3

createAndroidInteractorFunction · 0.90
index.test.tsFile · 0.90

Calls 10

verifyAndroidFilledTextFunction · 0.90
throwAndroidFillFailureFunction · 0.85
focusAndroidFunction · 0.85
clampCountFunction · 0.85
clearFocusedTextFunction · 0.85
typeAndroidShellFunction · 0.85

Tested by

no test coverage detected