add: open brew app when enter brew

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-06-10 16:54:43 +07:00
parent 9dc1e65f5e
commit b3024e92c7

View file

@ -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;