fix: default parameter for exec cmd

- change: from bypass to block.

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-07-02 13:57:45 +07:00
parent 54a5813d06
commit fbbf0c12f4
4 changed files with 28 additions and 69 deletions

View file

@ -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 () => {

View file

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

View file

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

View file

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