@@ -5,6 +5,9 @@ import { deviceShellArgv, type ShellWord } from '@agent-device/kernel/device-she
55import { AppError } from '@agent-device/kernel/errors' ;
66import path from 'node:path' ;
77
8+ const ANDROID_APP_INSTALL_TIMEOUT_MS = 120_000 ;
9+ const ANDROID_APP_DEPLOYMENT_ADB_TIMEOUT_MS = 15_000 ;
10+
811export async function installAndroidArtifact (
912 host : PlatformRuntimeHost ,
1013 device : DeviceInfo ,
@@ -19,7 +22,7 @@ export async function installAndroidArtifact(
1922 const result = await host . androidTools . installPackage (
2023 device ,
2124 installablePath ,
22- { replace : true } ,
25+ { replace : true , timeoutMs : ANDROID_APP_INSTALL_TIMEOUT_MS } ,
2326 signal ,
2427 ) ;
2528 assertCommandSuccess ( result , 'adb install failed' ) ;
@@ -36,7 +39,13 @@ export async function uninstallAndroidPackage(
3639 packageName : string ,
3740 signal : AbortSignal ,
3841) : Promise < void > {
39- const result = await runAdb ( host , device , [ 'uninstall' , packageName ] , signal ) ;
42+ const result = await runAdb (
43+ host ,
44+ device ,
45+ [ 'uninstall' , packageName ] ,
46+ signal ,
47+ ANDROID_APP_DEPLOYMENT_ADB_TIMEOUT_MS ,
48+ ) ;
4049 if ( result . exitCode === 0 ) return ;
4150 const output = `${ result . stdout } \n${ result . stderr } ` . toLowerCase ( ) ;
4251 if ( output . includes ( 'unknown package' ) || output . includes ( 'not installed' ) ) return ;
@@ -100,7 +109,16 @@ async function installAndroidBundle(
100109 bundlePath : string ,
101110 signal : AbortSignal ,
102111) : Promise < void > {
103- if ( await host . androidTools . installBundle ( device , bundlePath , 'universal' , signal ) ) return ;
112+ if (
113+ await host . androidTools . installBundle (
114+ device ,
115+ bundlePath ,
116+ 'universal' ,
117+ { timeoutMs : ANDROID_APP_INSTALL_TIMEOUT_MS } ,
118+ signal ,
119+ )
120+ )
121+ return ;
104122 const bundletool = await host . commands . which ( 'bundletool' ) ;
105123 const jar = host . androidDeployment . bundletoolJar ;
106124 if ( ! bundletool && ! jar ) {
@@ -131,6 +149,7 @@ async function installAndroidBundle(
131149 '--mode' ,
132150 'universal' ,
133151 ] ,
152+ timeoutMs : ANDROID_APP_INSTALL_TIMEOUT_MS ,
134153 } ,
135154 signal ,
136155 ) ,
@@ -141,6 +160,7 @@ async function installAndroidBundle(
141160 {
142161 executable,
143162 args : [ ...prefix , 'install-apks' , '--apks' , apksPath , '--device-id' , device . id ] ,
163+ timeoutMs : ANDROID_APP_INSTALL_TIMEOUT_MS ,
144164 } ,
145165 signal ,
146166 ) ,
@@ -189,7 +209,7 @@ async function runAdb(
189209 device : DeviceInfo ,
190210 args : readonly string [ ] ,
191211 signal : AbortSignal ,
192- timeoutMs = 15_000 ,
212+ timeoutMs = ANDROID_APP_DEPLOYMENT_ADB_TIMEOUT_MS ,
193213) {
194214 return await host . androidTools . runAdb ( device , args , { timeoutMs, allowFailure : true } , signal ) ;
195215}
0 commit comments