device-shots 0.5.9 → 0.5.11

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 +25 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -337,31 +337,38 @@ async function discoverAndroidDevices(bundleId) {
337
337
  function sleep(ms) {
338
338
  return new Promise((resolve) => setTimeout(resolve, ms));
339
339
  }
340
- async function adbExec(serial, args) {
340
+ async function demoBroadcast(serial, extras) {
341
341
  const adb = getAdbPath();
342
- const { stdout, stderr } = await run(adb, ["-s", serial, ...args]);
343
- return stdout || stderr;
342
+ await run(adb, [
343
+ "-s",
344
+ serial,
345
+ "shell",
346
+ "am",
347
+ "broadcast",
348
+ "-a",
349
+ "com.android.systemui.demo",
350
+ ...extras
351
+ ]);
344
352
  }
345
353
  async function setAndroidDemoMode(serial, time = "9:30") {
346
354
  const hhmm = time.replace(":", "");
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"]);
355
+ const adb = getAdbPath();
356
+ await run(adb, ["-s", serial, "shell", "settings", "put", "global", "sysui_demo_allowed", "1"]);
357
+ await run(adb, ["-s", serial, "shell", "settings", "put", "global", "sysui_tuner_demo_on", "1"]);
358
+ await sleep(500);
359
+ await demoBroadcast(serial, ["--es", "command", "enter"]);
351
360
  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 demoBroadcast(serial, ["--es", "command", "clock", "--es", "hhmm", hhmm]);
362
+ await demoBroadcast(serial, ["--es", "command", "network", "--es", "wifi", "show", "--es", "level", "4"]);
363
+ await demoBroadcast(serial, ["--es", "command", "network", "--es", "mobile", "show", "--es", "datatype", "none", "--es", "level", "4"]);
364
+ await demoBroadcast(serial, ["--es", "command", "battery", "--es", "level", "100", "--es", "plugged", "false"]);
365
+ await demoBroadcast(serial, ["--es", "command", "notifications", "--es", "visible", "false"]);
361
366
  await sleep(1e3);
362
367
  }
363
368
  async function clearAndroidDemoMode(serial) {
364
- await adbExec(serial, ["shell", "am", "broadcast", "-a", "com.android.systemui.demo", "-e", "command", "exit"]);
369
+ await demoBroadcast(serial, ["--es", "command", "exit"]);
370
+ const adb = getAdbPath();
371
+ await run(adb, ["-s", serial, "shell", "settings", "put", "global", "sysui_tuner_demo_on", "0"]);
365
372
  }
366
373
  async function captureAndroidScreenshot(serial, outputPath) {
367
374
  const adb = getAdbPath();
@@ -845,7 +852,7 @@ async function frameCommand(dir, options) {
845
852
  var program = new Command();
846
853
  program.name("device-shots").description(
847
854
  "Capture and frame mobile app screenshots from iOS simulators and Android emulators"
848
- ).version("0.5.9");
855
+ ).version("0.5.11");
849
856
  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
857
  await captureCommand({ name, ...opts });
851
858
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "device-shots",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "description": "Capture and frame mobile app screenshots from iOS simulators and Android emulators",
5
5
  "type": "module",
6
6
  "bin": {