in torchlive-cli/src/installers/android/AndroidEmulatorDeviceInstaller.ts [56:121]
async run(context: TaskContext): Promise<void> {
if (
!this.isEmulatorUpToDate() &&
!(await this.getUserConsentUpdate(context))
) {
context.update(
'[Warning] Skipping the installation/update of emulator may lead to unexpected exception when running PyTorchLive on android emulator.',
);
// wait for 2 second for user to read the warning message.
await new Promise(f => setTimeout(f, 2000));
return;
}
const cltPath = this.getCommandLineToolPath();
const abi = getAndroidEmulatorABI();
context.update(`Setting up ${this.getDescription()}`);
const cmd = `echo "no" | ${cltPath} create avd --name "${AndroidVirtualDeviceName}" --device "pixel" --force --abi google_apis/${abi} --package "system-images;android-29;google_apis;${abi}"`;
await execCommand(context, cmd);
const configPath = this._getConfigPath();
let config = ini.parse(fs.readFileSync(configPath, 'utf-8'));
config = Object.assign(config, {
'torchlive.cli.version': cliPkgInfo.version,
'PlayStore.enabled': false,
'abi.type': abi,
'avd.ini.encoding': 'UTF-8',
'disk.dataPartition.size': '16G',
'fastboot.chosenSnapshotFile': '',
'fastboot.forceChosenSnapshotBoot': 'no',
'fastboot.forceColdBoot': 'no',
'fastboot.forceFastBoot': 'yes',
'hw.accelerometer': 'yes',
'hw.arc': false,
'hw.audioInput': 'yes',
'hw.battery': 'yes',
'hw.camera.back': 'webcam0',
'hw.camera.front': 'webcam0',
'hw.cpu.arch': abi === 'arm64-v8a' ? 'arm64' : 'x86_64',
'hw.dPad': 'no',
'hw.device.hash2': 'MD5:6b5943207fe196d842659d2e43022e20',
'hw.device.manufacturer': 'Google',
'hw.gps': 'yes',
'hw.gpu.enabled': 'yes',
'hw.gpu.mode': 'host',
'hw.initialOrientation': 'Portrait',
'hw.keyboard': 'no',
'hw.lcd.density': 440,
'hw.lcd.height': 2280,
'hw.lcd.width': 1080,
'hw.mainKeys': 'no',
'hw.ramSize': 1536,
'hw.sdCard': 'yes',
'hw.sensors.orientation': 'yes',
'hw.sensors.proximity': 'yes',
'hw.trackBall': 'no',
'runtime.network.latency': 'none',
'runtime.network.speed': 'full',
showDeviceFrame: 'yes',
'tag.display': 'Google APIs',
'tag.id': 'google_apis',
'vm.heapSize': 256,
});
const configStr = ini.stringify(config);
fs.writeFileSync(configPath, configStr, {encoding: 'utf-8'});
}