From d83ec90fe3e6edc60925e5462d67efc53e7d83d8 Mon Sep 17 00:00:00 2001 From: ssloanRIIS Date: Mon, 23 Oct 2023 16:39:29 -0400 Subject: [PATCH 1/2] switch from /sdcard/recording to /data/local/tmp/recording --- README.md | 4 ++-- sadb.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c9a5ddc..abd9252 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ sadb scrcpy - Start scrcpy on a device sadb ip - Get the selected device's IP address -sadb screenshot myScreenshot.png +sadb screenshot -f myScreenshot.png - Take a screenshot of a device -sadb record myVideo.mp4 +sadb record -f myVideo.mp4 - Record the screen of a device (Press CTRL-C to stop recording) sadb wifi - Connect to a device via WiFi diff --git a/sadb.py b/sadb.py index 1e582dd..b075b22 100644 --- a/sadb.py +++ b/sadb.py @@ -16,7 +16,7 @@ def split_get_devices(result): def get_devices(): - result = subprocess.run(["adb", "devices"], capture_output=True, text=True) + result = subprocess.run(["adb", "devices"], capture_output=True, text=True, check=False) return split_get_devices(result.stdout) @@ -114,7 +114,7 @@ def screenshot(device, filename): def record(device, filename): if not filename: filename = "video.mp4" - remote_path = "/sdcard/screenrecord.mp4" + remote_path = "/data/local/tmp/screenrecord.mp4" cmd = ["adb", "-s", device, "shell", f"screenrecord {remote_path}"] proc = subprocess.Popen(cmd) @@ -137,6 +137,7 @@ def record(device, filename): subprocess.run(cmd) + def wifi(device): ip_address = get_ip(device) @@ -295,6 +296,7 @@ def main(): screenshot(device, args.filename) elif args.command == "record": + print(args.filename) device = select_device(devices) if device is None: return From b6d45c2a1a0720ed7a6fbed47b79231218f3fb6f Mon Sep 17 00:00:00 2001 From: Seamus Date: Mon, 23 Oct 2023 16:43:57 -0400 Subject: [PATCH 2/2] fix tests --- tests/test_commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 0314b3f..3d90452 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -92,7 +92,7 @@ def test_screenshot_custom_name(): def test_record_custom_name(): filename = "custom.mp4" - remote_path = "/sdcard/screenrecord.mp4" + remote_path = "/data/local/tmp/screenrecord.mp4" mock_proc = MagicMock() with patch("subprocess.Popen", return_value=mock_proc) as mock_popen, \ @@ -109,7 +109,7 @@ def test_record_custom_name(): def test_record_default_name(): filename = "video.mp4" - remote_path = "/sdcard/screenrecord.mp4" + remote_path = "/data/local/tmp/screenrecord.mp4" mock_proc = MagicMock() with patch("subprocess.Popen", return_value=mock_proc) as mock_popen, \