diff --git a/src/lib/components/dashboard-quick-adb.svelte b/src/lib/components/dashboard-quick-adb.svelte index 914bb52..f3faae4 100644 --- a/src/lib/components/dashboard-quick-adb.svelte +++ b/src/lib/components/dashboard-quick-adb.svelte @@ -105,9 +105,7 @@ if (instance) { try { // bypass - await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass', { - bypass: true - }); + await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass'); } catch (e) {} let result = await adb.executeCmd( @@ -132,9 +130,7 @@ try { // bypass - await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass', { - bypass: true - }); + await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass'); } catch (e) {} setTimeout(async () => { diff --git a/src/lib/core/adb/adb.ts b/src/lib/core/adb/adb.ts index 43aff45..94a4bf7 100644 --- a/src/lib/core/adb/adb.ts +++ b/src/lib/core/adb/adb.ts @@ -396,8 +396,8 @@ function sanitizeAdbCommand(command: string): string { return command; } -export async function executeCmd(command: string, { bypass = false }) { - command = !bypass ? sanitizeAdbCommand(command) : command; +export async function executeCmd(command: string, block: boolean = false) { + command = block ? sanitizeAdbCommand(command) : command; let instance = getAdbInstance(); if (!instance) { @@ -448,7 +448,7 @@ export async function executeCmd(command: string, { bypass = false }) { export async function goToMachineHome() { if (!getAdbInstance()) return; try { - await executeCmd('input keyevent KEYCODE_HOME', { bypass: true }); + await executeCmd('input keyevent KEYCODE_HOME'); } catch (e) { console.error('[goToMachineHome] error', e); } @@ -700,14 +700,7 @@ async function connectToAndroidServer(maxRetries = 5) { handleAdbPayload(new TextDecoder().decode(raw)); } }; - - // logger.info("prep post "); - // worker.postMessage({ stream }, [stream]); } - - // const reader = stream.readable.getReader(); - - // logger.info('checking on writer ', writer); adbWriter.set(writer); if (writer) { @@ -723,45 +716,6 @@ async function connectToAndroidServer(maxRetries = 5) { (worker as any).postMessage({ type: 'CHUNK', payload: value }, [value.buffer]); } })(); - - // const textDecoder = new TextDecoder(); - // let buffer = ''; - - // (async () => { - // try { - // while (true) { - // const { value, done } = await reader.read(); - // if (done) break; - - // // decode chunk - // buffer += textDecoder.decode(value, { stream: true }); - - // let lines = buffer.split('\n'); - - // // save potential incomplete - // buffer = lines.pop() ?? ''; - - // for (const line of lines) { - // if (line.trim() === '') continue; - - // GlobalEventBus.emit('adb:raw-payload', line); - // handleAdbPayload(line); - // } - - // // GlobalEventBus.emit('adb:raw-payload', new TextDecoder().decode(value)); - // // handleAdbPayload(new TextDecoder().decode(value)); - // } - // } catch (e) { - // logger.error('read error', e); - // if (isRecoverableError(e)) { - // void connectToAndroidServer(); - // } - // } finally { - // adbWriter.set(null); - // addNotification('WARN:Brewing Mode T Offline ...'); - // reader.cancel().catch(() => {}); - // } - // })(); return; } else { addNotification('WARN:Brewing Mode T unavailable'); diff --git a/src/lib/core/stores/remoteShellStore.ts b/src/lib/core/stores/remoteShellStore.ts index 2ec8c4d..57385d8 100644 --- a/src/lib/core/stores/remoteShellStore.ts +++ b/src/lib/core/stores/remoteShellStore.ts @@ -5,9 +5,21 @@ import { addNotification } from './noti'; // Commands that modify device state — always require explicit user confirmation. const DANGEROUS_COMMAND_PREFIXES = [ - 'rm', 'reboot', 'reboot-bootloader', 'flash', 'format', - 'mount', 'unmount', 'dd', 'mkfs', 'wipe', - 'install', 'uninstall', 'pm ', 'am ', 'svc ', + 'rm', + 'reboot', + 'reboot-bootloader', + 'flash', + 'format', + 'mount', + 'unmount', + 'dd', + 'mkfs', + 'wipe', + 'install', + 'uninstall', + 'pm ', + 'am ', + 'svc ' ]; function isDangerousCommand(command: string): boolean { @@ -151,13 +163,15 @@ async function executeAndRespond(req: RemoteShellRequest) { * Uses the simpler executeCmd() which properly captures exitCode and stderr. */ async function executeDirect(req: RemoteShellRequest) { - const result = await executeCmd(req.commandInput); + const result = await executeCmd(req.commandInput, true); const output = result.output ?? ''; const error = result.error ?? ''; const exitCode = result.exitCode ?? (error ? 1 : 0); const success = exitCode === 0; - addNotification(`${success ? 'INFO' : 'ERR'}:Remote shell command ${success ? 'completed' : 'failed'}`); + addNotification( + `${success ? 'INFO' : 'ERR'}:Remote shell command ${success ? 'completed' : 'failed'}` + ); remoteShellRequest.set({ ...req, diff --git a/src/routes/(authed)/tools/brew/+page.svelte b/src/routes/(authed)/tools/brew/+page.svelte index 111e8a7..42485f9 100644 --- a/src/routes/(authed)/tools/brew/+page.svelte +++ b/src/routes/(authed)/tools/brew/+page.svelte @@ -291,14 +291,11 @@ if (instance) { try { // bypass - await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass', { - bypass: true - }); + 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', - { bypass: true } + 'am start -n com.forthvending.coffeemain/com.forthvending.coffeemain.MainActivity' ); // if (result?.output) { // toast.success('Open app success!'); @@ -319,15 +316,13 @@ try { // bypass - await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass', { - bypass: true - }); + await adb.executeCmd('echo -n hurr > /sdcard/coffeevending/ignore_pass'); } catch (e) {} setTimeout(async () => { try { // bypass - await adb.executeCmd('input tap 336 795', { bypass: true }); + await adb.executeCmd('input tap 336 795'); } catch (e) {} }, 3000); }