From 3c2194940ca57b45b66a6344ad67e9c9f0b861bd Mon Sep 17 00:00:00 2001
From: Dana <Dana_Lee1016@126.com>
Date: 星期四, 29 一月 2026 13:28:18 +0800
Subject: [PATCH] 1.修改水印 usb
---
app/src/main/java/com/safeluck/floatwindow/FloatingService.java | 52 +++++++++++++++++++++++++---------------------------
1 files changed, 25 insertions(+), 27 deletions(-)
diff --git a/app/src/main/java/com/safeluck/floatwindow/FloatingService.java b/app/src/main/java/com/safeluck/floatwindow/FloatingService.java
index c714a00..5e6da98 100644
--- a/app/src/main/java/com/safeluck/floatwindow/FloatingService.java
+++ b/app/src/main/java/com/safeluck/floatwindow/FloatingService.java
@@ -86,9 +86,7 @@
NONE,
USB_PUSH,
USB_RECORD,
- ANDROID_RECORD,
- P2_USB_PUSH,
- P2_USB_RECORD
+ ANDROID_RECORD
}
// AIDL Binder
@@ -107,9 +105,9 @@
}
@Override
- public void stopMedia() throws RemoteException {
+ public void stopMedia(MediaArgu media) throws RemoteException {
Timber.d("stopMedia called via AIDL");
- FloatingService.this.stopMedia();
+ FloatingService.this.stopMedia(media);
}
@Override
@@ -190,14 +188,12 @@
return;
}
- // usbCameraId == 2锛氳蛋 P2 璺ㄨ繘绋嬫湇鍔★紝鏀寔涓よ矾 USB 鍚屾椂宸ヤ綔
+ // usbCameraId == 2锛氳蛋 P2 璺ㄨ繘绋嬫湇鍔★紝鏀寔涓よ矾 USB 鍚屾椂宸ヤ綔锛堟湰 Service 涓嶅啀璺熻釜鍏剁姸鎬侊級
if (media.isUsedOutCamera() && media.getUsbCameraId() == 2) {
- stopCurrentManager();
ensureP2Bound();
if (p2Service != null) {
try {
p2Service.startMedia(media);
- currentManagerType = media.isPush() ? ManagerType.P2_USB_PUSH : ManagerType.P2_USB_RECORD;
} catch (RemoteException e) {
Timber.e(e, "startMedia forward to P2 failed");
notifyCallback(1, -3, "鍚姩P2鏈嶅姟澶辫触: " + e.getMessage());
@@ -205,7 +201,6 @@
} else {
// 绛夊緟杩炴帴瀹屾垚鍚庢墽琛�
pendingP2StartMedia = media;
- currentManagerType = media.isPush() ? ManagerType.P2_USB_PUSH : ManagerType.P2_USB_RECORD;
}
return;
}
@@ -242,7 +237,7 @@
}
/**
- * 鍋滄褰撳墠绠$悊鍣�
+ * 鍋滄褰撳墠鏈湴绠$悊鍣紙浠呯鐞嗘湰杩涚▼涓殑 USB(P1)/Android 褰曞儚鎴栨帹娴侊級
*/
private void stopCurrentManager() {
switch (currentManagerType) {
@@ -261,18 +256,6 @@
androidCameraRecordManager.stopRecord();
}
break;
- case P2_USB_PUSH:
- case P2_USB_RECORD:
- if (p2Service != null) {
- try {
- p2Service.stopMedia();
- } catch (RemoteException e) {
- Timber.e(e, "stopMedia forward to P2 failed");
- }
- } else {
- pendingP2StartMedia = null;
- }
- break;
case NONE:
break;
}
@@ -280,11 +263,26 @@
}
/**
- * 鍋滄濯掍綋
+ * 鍋滄濯掍綋锛堥�氳繃 AIDL 璋冪敤锛屽甫 MediaArgu锛岀敤浜庡尯鍒� P1/P2锛�
*/
- private void stopMedia() {
- Timber.d("stopMedia called");
- stopCurrentManager();
+ private void stopMedia(MediaArgu media) {
+ Timber.d("stopMedia called, media=%s", media);
+ if (media != null && media.isUsedOutCamera() && media.getUsbCameraId() == 2) {
+ // P2 USB 鎽勫儚澶寸敱 P2UsbCameraVideoService 绠$悊
+ ensureP2Bound();
+ if (p2Service != null) {
+ try {
+ p2Service.stopMedia(media);
+ } catch (RemoteException e) {
+ Timber.e(e, "stopMedia forward to P2 failed");
+ }
+ } else {
+ pendingP2StartMedia = null;
+ }
+ } else {
+ // 鍏朵粬鎯呭喌锛堝寘鎷� P1 USB 涓� Android 鐩告満锛夌敱鏈� Service 鑷繁绠$悊
+ stopCurrentManager();
+ }
}
@Override
@@ -296,7 +294,7 @@
@Override
public void onDestroy() {
super.onDestroy();
- stopMedia();
+ stopCurrentManager();
mCallbacks.kill();
if (p2Bound) {
try {
--
Gitblit v1.8.0