diff --git a/src/routes/(authed)/tools/brew/+page.svelte b/src/routes/(authed)/tools/brew/+page.svelte index eddda99..e5e4c92 100644 --- a/src/routes/(authed)/tools/brew/+page.svelte +++ b/src/routes/(authed)/tools/brew/+page.svelte @@ -183,6 +183,7 @@ await startFetchRecipeFromMachine(); await loadEssentialFiles(); await loadStagedMenusFromAndroid(); + await openBrewApp(); } async function tryAutoConnect() { @@ -233,6 +234,55 @@ } } + async function openBrewApp() { + try { + let instance = adb.getAdbInstance(); + if (instance) { + try { + // bypass + await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass'); + } catch (e) {} + + let result = await adb.executeCmd( + 'am start -n com.forthvending.coffeemain/com.forthvending.coffeemain.MainActivity' + ); + // if (result?.output) { + // toast.success('Open app success!'); + // machineStatus = 'open app success, check the screen and put the password'; + // } else if (result?.error) { + // // case usb connection cutoff + // if (result.error === 'ExactReadableEndedError') { + // toast.warning('Connection unstable'); + // machineStatus = 'app maybe opened, check the screen'; + // } else { + // throw new Error(`Exit ${result.exitCode}. ${result.error}`); + // } + // } else { + // throw new Error('Instance not found or error while executing'); + // } + + // hasOpenedBrewOnce = true; + + try { + // bypass + await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass'); + } catch (e) {} + + setTimeout(async () => { + try { + // bypass + await adb.executeCmd('input tap 336 795'); + } catch (e) {} + }, 3000); + } + } catch (e: any) { + // machineStatus = 'Cannot open brew app'; + // toast.error('Error while trying to open brew app, please check the screen. ', { + // description: e.toString() + // }); + } + } + async function ensureAndroidSocket() { if (isAdbWriterAvailable()) return true;