MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / rotate_by_quarter_turns

Method rotate_by_quarter_turns

packages/server/src/android.rs:582–628  ·  view source on GitHub ↗
(&self, id: &str, delta: i16)

Source from the content-addressed store, hash-verified

580 }
581
582 fn rotate_by_quarter_turns(&self, id: &str, delta: i16) -> Result<(), AppError> {
583 let serial = self.serial_for_id(id)?;
584 self.invalidate_display_metrics_for_serial(&serial);
585 let current = self
586 .display_metrics_for_serial(&serial)
587 .map(|metrics| metrics.rotation_quarter_turns)
588 .unwrap_or(0);
589 let next = (i16::try_from(current).unwrap_or(0) + delta).rem_euclid(4) as u16;
590 let rotation = next.to_string();
591 let _ = self.run_adb([
592 "-s",
593 &serial,
594 "shell",
595 "cmd",
596 "window",
597 "set-ignore-orientation-request",
598 "-d",
599 "0",
600 "true",
601 ]);
602 let _ = self.run_adb([
603 "-s",
604 &serial,
605 "shell",
606 "cmd",
607 "window",
608 "fixed-to-user-rotation",
609 "-d",
610 "0",
611 "enabled",
612 ]);
613 self.run_adb([
614 "-s",
615 &serial,
616 "shell",
617 "cmd",
618 "window",
619 "user-rotation",
620 "-d",
621 "0",
622 "lock",
623 &rotation,
624 ])?;
625 self.invalidate_display_metrics_for_serial(&serial);
626 self.wait_for_display_rotation(&serial, next);
627 Ok(())
628 }
629
630 fn wait_for_display_rotation(&self, serial: &str, rotation: u16) {
631 let deadline = Instant::now() + Duration::from_secs(4);

Callers 2

rotate_rightMethod · 0.80
rotate_leftMethod · 0.80

Calls 5

serial_for_idMethod · 0.80
run_adbMethod · 0.80

Tested by

no test coverage detected