device-shots 0.5.6 → 0.5.7

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 +39 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -334,36 +334,49 @@ async function discoverAndroidDevices(bundleId) {
334
334
  }
335
335
  return devices;
336
336
  }
337
- async function setAndroidDemoMode(serial, time = "9:30") {
337
+ async function adbShell(serial, cmd) {
338
338
  const adb = getAdbPath();
339
+ const { stdout, stderr } = await run(adb, ["-s", serial, "shell", cmd]);
340
+ return stdout || stderr;
341
+ }
342
+ function sleep(ms) {
343
+ return new Promise((resolve) => setTimeout(resolve, ms));
344
+ }
345
+ async function setAndroidDemoMode(serial, time = "9:30") {
339
346
  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
- }
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);
352
374
  }
353
375
  async function clearAndroidDemoMode(serial) {
354
- const adb = getAdbPath();
355
- await run(adb, [
356
- "-s",
376
+ await adbShell(
357
377
  serial,
358
- "shell",
359
- "am",
360
- "broadcast",
361
- "-a",
362
- "com.android.systemui.demo",
363
- "-e",
364
- "command",
365
- "exit"
366
- ]);
378
+ "am broadcast -a com.android.systemui.demo -e command exit"
379
+ );
367
380
  }
368
381
  async function captureAndroidScreenshot(serial, outputPath) {
369
382
  const adb = getAdbPath();
@@ -847,7 +860,7 @@ async function frameCommand(dir, options) {
847
860
  var program = new Command();
848
861
  program.name("device-shots").description(
849
862
  "Capture and frame mobile app screenshots from iOS simulators and Android emulators"
850
- ).version("0.5.6");
863
+ ).version("0.5.7");
851
864
  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
865
  await captureCommand({ name, ...opts });
853
866
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "device-shots",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Capture and frame mobile app screenshots from iOS simulators and Android emulators",
5
5
  "type": "module",
6
6
  "bin": {