Просмотр исходного кода

feat(AutoCheckinBigGod): 完成任务后恢复阴阳师前台状态

-新增 cleanup 收尾恢复逻辑,任务结束时主动拉起阴阳师前台
-按理可以直接注释#124行,但相比直接注释,该方案更保守
yuyuyuyuyu 7 месяцев назад
Родитель
Сommit
a49c13ba5a
1 измененных файлов с 10 добавлено и 3 удалено
  1. 10 3
      tasks/AutoCheckinBigGod/script_task.py

+ 10 - 3
tasks/AutoCheckinBigGod/script_task.py

@@ -141,7 +141,7 @@ class ScriptTask(BaseTask):
 
         if not rewards:
             logger.info('没有可领取的礼包')
-            self._cleanup()
+            self._cleanup(restore_game=True)
             self.set_next_run('AutoCheckinBigGod', success=True, finish=True)
             raise TaskEnd('AutoCheckinBigGod')
 
@@ -154,13 +154,13 @@ class ScriptTask(BaseTask):
             time.sleep(0.5)
 
         logger.info(f'完成! 成功领取 {success_count}/{len(rewards)} 个礼包')
-        self._cleanup()
+        self._cleanup(restore_game=True)
         self.set_next_run('AutoCheckinBigGod', success=True, finish=True)
         raise TaskEnd('AutoCheckinBigGod')
 
     # ======================== 清理 ========================
 
-    def _cleanup(self):
+    def _cleanup(self, restore_game=False):
         logger.info('清理:关闭大神APP和Frida Server...')
         try:
             if self._frida_session is not None:
@@ -178,6 +178,13 @@ class ScriptTask(BaseTask):
         except Exception:
             pass
 
+        if restore_game:
+            try:
+                self.device.app_start()
+                logger.info('已返回阴阳师前台')
+            except Exception as e:
+                logger.warning(f'返回阴阳师失败: {e}')
+
     # ======================== ADB 操作 ========================
 
     def _adb_cmd(self, args, timeout=10):