device-shots 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -334,37 +334,38 @@ async function discoverAndroidDevices(bundleId) {
|
|
|
334
334
|
}
|
|
335
335
|
return devices;
|
|
336
336
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const hhmm = time.replace(":", "");
|
|
340
|
-
const commands = [
|
|
341
|
-
["settings", "put", "global", "sysui_demo_allowed", "1"],
|
|
342
|
-
["am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "enter"],
|
|
343
|
-
["am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "clock", "-e", "hhmm", hhmm],
|
|
344
|
-
["am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "wifi", "-e", "fully", "true", "-e", "wifi", "show"],
|
|
345
|
-
["am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "network", "-e", "mobile", "show", "-e", "fully", "true", "-e", "level", "4"],
|
|
346
|
-
["am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "battery", "-e", "level", "100", "-e", "plugged", "false"],
|
|
347
|
-
["am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "notifications", "-e", "visible", "false"]
|
|
348
|
-
];
|
|
349
|
-
for (const cmd of commands) {
|
|
350
|
-
await run(adb, ["-s", serial, "shell", ...cmd]);
|
|
351
|
-
}
|
|
337
|
+
function sleep(ms) {
|
|
338
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
352
339
|
}
|
|
353
|
-
async function
|
|
340
|
+
async function adbShell(serial, args) {
|
|
354
341
|
const adb = getAdbPath();
|
|
355
|
-
await run(adb, [
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
342
|
+
const { stdout, stderr } = await run(adb, ["-s", serial, "shell", ...args]);
|
|
343
|
+
return stdout || stderr;
|
|
344
|
+
}
|
|
345
|
+
async function demoBroadcast(serial, extras) {
|
|
346
|
+
await adbShell(serial, [
|
|
359
347
|
"am",
|
|
360
348
|
"broadcast",
|
|
361
349
|
"-a",
|
|
362
350
|
"com.android.systemui.demo",
|
|
363
|
-
|
|
364
|
-
"command",
|
|
365
|
-
"exit"
|
|
351
|
+
...extras
|
|
366
352
|
]);
|
|
367
353
|
}
|
|
354
|
+
async function setAndroidDemoMode(serial, time = "9:30") {
|
|
355
|
+
const hhmm = time.replace(":", "");
|
|
356
|
+
await adbShell(serial, ["settings", "put", "global", "sysui_demo_allowed", "1"]);
|
|
357
|
+
await demoBroadcast(serial, ["-e", "command", "enter"]);
|
|
358
|
+
await sleep(500);
|
|
359
|
+
await demoBroadcast(serial, ["-e", "command", "clock", "-e", "hhmm", hhmm]);
|
|
360
|
+
await demoBroadcast(serial, ["-e", "command", "network", "-e", "wifi", "show", "-e", "level", "4"]);
|
|
361
|
+
await demoBroadcast(serial, ["-e", "command", "network", "-e", "mobile", "show", "-e", "datatype", "none", "-e", "level", "4"]);
|
|
362
|
+
await demoBroadcast(serial, ["-e", "command", "battery", "-e", "level", "100", "-e", "plugged", "false"]);
|
|
363
|
+
await demoBroadcast(serial, ["-e", "command", "notifications", "-e", "visible", "false"]);
|
|
364
|
+
await sleep(1e3);
|
|
365
|
+
}
|
|
366
|
+
async function clearAndroidDemoMode(serial) {
|
|
367
|
+
await demoBroadcast(serial, ["-e", "command", "exit"]);
|
|
368
|
+
}
|
|
368
369
|
async function captureAndroidScreenshot(serial, outputPath) {
|
|
369
370
|
const adb = getAdbPath();
|
|
370
371
|
const deviceTmp = "/sdcard/screenshot_tmp.png";
|
|
@@ -847,7 +848,7 @@ async function frameCommand(dir, options) {
|
|
|
847
848
|
var program = new Command();
|
|
848
849
|
program.name("device-shots").description(
|
|
849
850
|
"Capture and frame mobile app screenshots from iOS simulators and Android emulators"
|
|
850
|
-
).version("0.5.
|
|
851
|
+
).version("0.5.8");
|
|
851
852
|
program.command("capture").description("Capture screenshots from running devices").argument("[name]", "Screenshot name").option("-b, --bundle-id <id>", "App bundle ID").option("-o, --output <dir>", "Output directory").option("-p, --platform <platform>", "ios, android, or both").option("--no-frame", "Skip framing after capture").option("--time <time>", "Status bar time", "9:41").action(async (name, opts) => {
|
|
852
853
|
await captureCommand({ name, ...opts });
|
|
853
854
|
});
|