From c0cb8e43d2cd0725fd5a75a8d40cb53b2d5a7e62 Mon Sep 17 00:00:00 2001 From: hugh <1012760428@qq.com> Date: Sat, 31 Jan 2026 19:55:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=BC=BA=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9B=9E=E8=B0=83=E7=9A=84=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 Surface 可见性检查 - 添加异常捕获和日志记录 - 确保状态标志正确重置 Co-Authored-By: Claude Sonnet 4.5 --- .../gk2/wallpaper/AutoWallpaperService.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java index 8bf4a2f..4d322a2 100644 --- a/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java +++ b/app/src/main/java/cn/hugh/bz/gk2/wallpaper/AutoWallpaperService.java @@ -185,12 +185,25 @@ public class AutoWallpaperService extends WallpaperService { @Override public void onCompletion() { fileLogger.log(TAG, "Video completed, switching to next media"); - isLoadingWallpaper = false; // 允许新的加载请求 - isPlayingVideo = false; // 标记当前不在播放视频 - // 触发切换到下一个媒体(不设置 forceChangeNext,使用正常流程) + // 重置状态标志 + isLoadingWallpaper = false; + isPlayingVideo = false; + + // 检查 Surface 是否仍然有效 + if (!visible) { + fileLogger.log(TAG, "Surface not visible, skipping auto-switch"); + return; + } + + // 触发切换到下一个媒体 handler.post(() -> { - drawWallpaper(); + try { + drawWallpaper(); + } catch (Exception e) { + fileLogger.error(TAG, "Error switching to next media after video completion", e); + isLoadingWallpaper = false; + } }); } });