device-shots 0.5.7 → 0.5.9

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -334,49 +334,34 @@ async function discoverAndroidDevices(bundleId) {
334
334
  }
335
335
  return devices;
336
336
  }
337
- async function adbShell(serial, cmd) {
338
- const adb = getAdbPath();
339
- const { stdout, stderr } = await run(adb, ["-s", serial, "shell", cmd]);
340
- return stdout || stderr;
341
- }
342
337
  function sleep(ms) {
343
338
  return new Promise((resolve) => setTimeout(resolve, ms));
344
339
  }
340
+ async function adbExec(serial, args) {
341
+ const adb = getAdbPath();
342
+ const { stdout, stderr } = await run(adb, ["-s", serial, ...args]);
343
+ return stdout || stderr;
344
+ }
345
345
  async function setAndroidDemoMode(serial, time = "9:30") {
346
346
  const hhmm = time.replace(":", "");
347
- await adbShell(serial, "settings put global sysui_demo_allowed 1");
348
- await adbShell(
349
- serial,
350
- "am broadcast -a com.android.systemui.demo -e command enter"
351
- );
352
- await sleep(500);
353
- await adbShell(
354
- serial,
355
- `am broadcast -a com.android.systemui.demo -e command clock -e hhmm ${hhmm}`
356
- );
357
- await adbShell(
358
- serial,
359
- "am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4"
360
- );
361
- await adbShell(
362
- serial,
363
- "am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4"
364
- );
365
- await adbShell(
366
- serial,
367
- "am broadcast -a com.android.systemui.demo -e command battery -e level 100 -e plugged false"
368
- );
369
- await adbShell(
370
- serial,
371
- "am broadcast -a com.android.systemui.demo -e command notifications -e visible false"
372
- );
373
- await sleep(500);
347
+ const ACTION = "com.android.systemui.demo";
348
+ await adbExec(serial, ["shell", "settings", "put", "global", "sysui_demo_allowed", "1"]);
349
+ await sleep(300);
350
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", ACTION, "-e", "command", "enter"]);
351
+ await sleep(1e3);
352
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", ACTION, "-e", "command", "clock", "-e", "hhmm", hhmm]);
353
+ await sleep(300);
354
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", ACTION, "-e", "command", "network", "-e", "wifi", "show", "-e", "level", "4"]);
355
+ await sleep(300);
356
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", ACTION, "-e", "command", "network", "-e", "mobile", "show", "-e", "datatype", "none", "-e", "level", "4"]);
357
+ await sleep(300);
358
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", ACTION, "-e", "command", "battery", "-e", "level", "100", "-e", "plugged", "false"]);
359
+ await sleep(300);
360
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", ACTION, "-e", "command", "notifications", "-e", "visible", "false"]);
361
+ await sleep(1e3);
374
362
  }
375
363
  async function clearAndroidDemoMode(serial) {
376
- await adbShell(
377
- serial,
378
- "am broadcast -a com.android.systemui.demo -e command exit"
379
- );
364
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "exit"]);
380
365
  }
381
366
  async function captureAndroidScreenshot(serial, outputPath) {
382
367
  const adb = getAdbPath();
@@ -860,7 +845,7 @@ async function frameCommand(dir, options) {
860
845
  var program = new Command();
861
846
  program.name("device-shots").description(
862
847
  "Capture and frame mobile app screenshots from iOS simulators and Android emulators"
863
- ).version("0.5.7");
848
+ ).version("0.5.9");
864
849
  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) => {
865
850
  await captureCommand({ name, ...opts });
866
851
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "device-shots",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "Capture and frame mobile app screenshots from iOS simulators and Android emulators",
5
5
  "type": "module",
6
6
  "bin": {