1import { AppIdResolver } from '../AppIdResolver'; 2import { BaseOpenInCustomProps, BaseResolveDeviceProps, PlatformManager } from '../PlatformManager'; 3import { AndroidAppIdResolver } from './AndroidAppIdResolver'; 4import { AndroidDeviceManager } from './AndroidDeviceManager'; 5import { Device } from './adb'; 6import { startAdbReverseAsync } from './adbReverse'; 7 8interface AndroidOpenInCustomProps extends BaseOpenInCustomProps { 9 launchActivity?: string; 10} 11 12export class AndroidPlatformManager extends PlatformManager<Device, AndroidOpenInCustomProps> { 13 constructor( 14 protected projectRoot: string, 15 protected port: number, 16 options: { 17 /** Get the base URL for the dev server hosting this platform manager. */ 18 getDevServerUrl: () => string | null; 19 /** Expo Go URL. */ 20 getExpoGoUrl: () => string | null; 21 /** Dev Client URL. */ 22 getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null; 23 } 24 ) { 25 super(projectRoot, { 26 platform: 'android', 27 ...options, 28 resolveDeviceAsync: AndroidDeviceManager.resolveAsync, 29 }); 30 } 31 32 async openAsync( 33 options: 34 | { runtime: 'expo' | 'web' } 35 | { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> }, 36 resolveSettings?: Partial<BaseResolveDeviceProps<Device>> 37 ): Promise<{ url: string }> { 38 await startAdbReverseAsync([this.port]); 39 return super.openAsync(options, resolveSettings); 40 } 41 42 _getAppIdResolver(): AppIdResolver { 43 return new AndroidAppIdResolver(this.projectRoot); 44 } 45 46 _resolveAlternativeLaunchUrl( 47 applicationId: string, 48 props?: Partial<AndroidOpenInCustomProps> 49 ): string { 50 return props?.launchActivity ?? `${applicationId}/.MainActivity`; 51 } 52} 53