device-shots 0.5.9 → 0.5.10
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 +29 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -337,31 +337,47 @@ async function discoverAndroidDevices(bundleId) {
|
|
|
337
337
|
function sleep(ms) {
|
|
338
338
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
339
339
|
}
|
|
340
|
-
async function
|
|
340
|
+
async function demoBroadcast(serial, extras) {
|
|
341
341
|
const adb = getAdbPath();
|
|
342
|
-
const
|
|
342
|
+
const cmd = `am broadcast -a com.android.systemui.demo ${extras}`;
|
|
343
|
+
const { stdout, stderr } = await run(adb, ["-s", serial, "shell", "sh", "-c", cmd]);
|
|
343
344
|
return stdout || stderr;
|
|
344
345
|
}
|
|
345
346
|
async function setAndroidDemoMode(serial, time = "9:30") {
|
|
346
347
|
const hhmm = time.replace(":", "");
|
|
347
|
-
const
|
|
348
|
-
await
|
|
349
|
-
await
|
|
350
|
-
await
|
|
348
|
+
const adb = getAdbPath();
|
|
349
|
+
await run(adb, ["-s", serial, "shell", "settings", "put", "global", "sysui_demo_allowed", "1"]);
|
|
350
|
+
await run(adb, ["-s", serial, "shell", "settings", "put", "global", "sysui_tuner_demo_on", "1"]);
|
|
351
|
+
await sleep(500);
|
|
352
|
+
let result = await demoBroadcast(serial, "-e command enter");
|
|
353
|
+
process.stderr.write(`[demo] enter: ${result.trim()}
|
|
354
|
+
`);
|
|
351
355
|
await sleep(1e3);
|
|
352
|
-
await
|
|
356
|
+
result = await demoBroadcast(serial, `-e command clock -e hhmm ${hhmm}`);
|
|
357
|
+
process.stderr.write(`[demo] clock: ${result.trim()}
|
|
358
|
+
`);
|
|
353
359
|
await sleep(300);
|
|
354
|
-
await
|
|
360
|
+
result = await demoBroadcast(serial, "-e command network -e wifi show -e level 4");
|
|
361
|
+
process.stderr.write(`[demo] wifi: ${result.trim()}
|
|
362
|
+
`);
|
|
355
363
|
await sleep(300);
|
|
356
|
-
await
|
|
364
|
+
result = await demoBroadcast(serial, "-e command network -e mobile show -e datatype none -e level 4");
|
|
365
|
+
process.stderr.write(`[demo] mobile: ${result.trim()}
|
|
366
|
+
`);
|
|
357
367
|
await sleep(300);
|
|
358
|
-
await
|
|
368
|
+
result = await demoBroadcast(serial, "-e command battery -e level 100 -e plugged false");
|
|
369
|
+
process.stderr.write(`[demo] battery: ${result.trim()}
|
|
370
|
+
`);
|
|
359
371
|
await sleep(300);
|
|
360
|
-
await
|
|
372
|
+
result = await demoBroadcast(serial, "-e command notifications -e visible false");
|
|
373
|
+
process.stderr.write(`[demo] notif: ${result.trim()}
|
|
374
|
+
`);
|
|
361
375
|
await sleep(1e3);
|
|
362
376
|
}
|
|
363
377
|
async function clearAndroidDemoMode(serial) {
|
|
364
|
-
await
|
|
378
|
+
await demoBroadcast(serial, "-e command exit");
|
|
379
|
+
const adb = getAdbPath();
|
|
380
|
+
await run(adb, ["-s", serial, "shell", "settings", "put", "global", "sysui_tuner_demo_on", "0"]);
|
|
365
381
|
}
|
|
366
382
|
async function captureAndroidScreenshot(serial, outputPath) {
|
|
367
383
|
const adb = getAdbPath();
|
|
@@ -845,7 +861,7 @@ async function frameCommand(dir, options) {
|
|
|
845
861
|
var program = new Command();
|
|
846
862
|
program.name("device-shots").description(
|
|
847
863
|
"Capture and frame mobile app screenshots from iOS simulators and Android emulators"
|
|
848
|
-
).version("0.5.
|
|
864
|
+
).version("0.5.10");
|
|
849
865
|
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) => {
|
|
850
866
|
await captureCommand({ name, ...opts });
|
|
851
867
|
});
|