device-shots 0.5.8 → 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 +18 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -337,34 +337,31 @@ async function discoverAndroidDevices(bundleId) {
337
337
  function sleep(ms) {
338
338
  return new Promise((resolve) => setTimeout(resolve, ms));
339
339
  }
340
- async function adbShell(serial, args) {
340
+ async function adbExec(serial, args) {
341
341
  const adb = getAdbPath();
342
- const { stdout, stderr } = await run(adb, ["-s", serial, "shell", ...args]);
342
+ const { stdout, stderr } = await run(adb, ["-s", serial, ...args]);
343
343
  return stdout || stderr;
344
344
  }
345
- async function demoBroadcast(serial, extras) {
346
- await adbShell(serial, [
347
- "am",
348
- "broadcast",
349
- "-a",
350
- "com.android.systemui.demo",
351
- ...extras
352
- ]);
353
- }
354
345
  async function setAndroidDemoMode(serial, time = "9:30") {
355
346
  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"]);
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"]);
364
361
  await sleep(1e3);
365
362
  }
366
363
  async function clearAndroidDemoMode(serial) {
367
- await demoBroadcast(serial, ["-e", "command", "exit"]);
364
+ await adbExec(serial, ["shell", "am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "exit"]);
368
365
  }
369
366
  async function captureAndroidScreenshot(serial, outputPath) {
370
367
  const adb = getAdbPath();
@@ -848,7 +845,7 @@ async function frameCommand(dir, options) {
848
845
  var program = new Command();
849
846
  program.name("device-shots").description(
850
847
  "Capture and frame mobile app screenshots from iOS simulators and Android emulators"
851
- ).version("0.5.8");
848
+ ).version("0.5.9");
852
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) => {
853
850
  await captureCommand({ name, ...opts });
854
851
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "device-shots",
3
- "version": "0.5.8",
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": {