aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/invalid/lena/scrcpy/Sessions.java
diff options
context:
space:
mode:
authorLena <lena@omega>2026-07-01 00:00:00 +0000
committerLena <lena@omega>2026-07-01 00:00:00 +0000
commitff7acf898b48359275a5b09b82ed926a945233f8 (patch)
tree5e45b04be22cb1531f075ec35eb6f91518e09165 /app/src/main/java/invalid/lena/scrcpy/Sessions.java
parentbddc306de0cebde44f99b3a9c4ddba130946bef3 (diff)
downloadscrcpy-android-ff7acf898b48359275a5b09b82ed926a945233f8.tar.gz
app: fix session lifecycle, teardown, and opus playback
Opus playback never worked: feed() called dequeueInputBuffer() on a codec in async-callback mode, which always throws, so every packet was silently dropped. Feed input through the async callback with a bounded pending queue instead. Make bring-up transactional: roll back partially opened streams and the server shell on failure, join reader threads on stop, and close the owning ADB streams before releasing sinks. Replace the openAbstract watchdog thread with a real timeout in the vendored AdbConnection.open(), which also removes the half-open stream from the lookup table on failure. Harden the activity: release owned Surfaces, gate callbacks on a destroyed flag and a session generation, serialize reconnect, and handle target replacement via singleTask + onNewIntent. Propagate device-list write failures instead of swallowing them, bound the clipboard payload and the video pending queue against hostile peers, and discard incomplete recordings instead of keeping corrupt files. Use the mediaPlayback foreground-service type; Android 15 stops dataSync services after six hours. Drop the unused ACCESS_NETWORK_STATE permission.
Diffstat (limited to 'app/src/main/java/invalid/lena/scrcpy/Sessions.java')
-rw-r--r--app/src/main/java/invalid/lena/scrcpy/Sessions.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/src/main/java/invalid/lena/scrcpy/Sessions.java b/app/src/main/java/invalid/lena/scrcpy/Sessions.java
index 95c0a1f..91144be 100644
--- a/app/src/main/java/invalid/lena/scrcpy/Sessions.java
+++ b/app/src/main/java/invalid/lena/scrcpy/Sessions.java
@@ -16,8 +16,8 @@ import android.os.IBinder;
// briefly backgrounded (rotation, IME, swipe-to-home) without the
// scrcpy server tearing down.
//
-// Type is FOREGROUND_SERVICE_DATA_SYNC: we are pulling a continuous
-// data stream (encoded video + raw PCM) from another device.
+// Type is FOREGROUND_SERVICE_MEDIA_PLAYBACK: the app continuously plays
+// remote audio/video for as long as the user keeps a mirror session open.
//
// No binder API - the service does not own Session. Mirror owns it.
public final class Sessions extends Service {
@@ -41,7 +41,7 @@ public final class Sessions extends Service {
.setContentIntent(reopenIntent())
.setOngoing(true)
.build();
- startForeground(NOTIF_ID, n, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
+ startForeground(NOTIF_ID, n, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
return START_NOT_STICKY;
}