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; 21 /** Get redirect URL for native disambiguation. */ 22 getRedirectUrl: () => string | null; 23 /** Dev Client URL. */ 24 getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null; 25 } 26 ) { 27 super(projectRoot, { 28 platform: 'android', 29 ...options, 30 resolveDeviceAsync: AndroidDeviceManager.resolveAsync, 31 }); 32 } 33 34 async openAsync( 35 options: 36 | { runtime: 'expo' | 'web' } 37 | { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> }, 38 resolveSettings?: Partial<BaseResolveDeviceProps<Device>> 39 ): Promise<{ url: string }> { 40 await startAdbReverseAsync([this.port]); 41 return super.openAsync(options, resolveSettings); 42 } 43 44 _getAppIdResolver(): AppIdResolver { 45 return new AndroidAppIdResolver(this.projectRoot); 46 } 47 48 _resolveAlternativeLaunchUrl( 49 applicationId: string, 50 props?: Partial<AndroidOpenInCustomProps> 51 ): string { 52 return props?.launchActivity ?? `${applicationId}/.MainActivity`; 53 } 54} 55