hmz 8de61173e0 修复应用宝一条龙任务恢复、常亮及公共浏览安装流程
完善惊喜任务逐项执行和存储授权,兼容微信浏览入口及应用推荐下载落点。增加重复运行保护、投影恢复和任务完成复核,并保留原有安装适配。

验证:59项离线回归通过,生成文件一致性、语法及差异空白检查通过。
2026-11-18 16:05:57 +08:00

34 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 重复引擎不申请投影、不操作手机、不覆盖运行状态。
function enterYibaoRunGuard(runtime) {
var lease=runtime.tryAcquire();
if(lease)return lease;
runtime.notify();
// AutoJs6旧宿主在引擎退出时可能回收共享图片;等正在执行的任务完成再退出重复引擎。
while(!(lease=runtime.tryAcquire()))runtime.wait();
lease.release();
return null;
}
function acquireYibaoWorkflowLease() {
var lockPath="/sdcard/Download/autojs-yibao-workflow.lock";
return enterYibaoRunGuard({
tryAcquire:function(){
var file=new java.io.RandomAccessFile(lockPath,"rw"),channel=file.getChannel(),lock=null;
try {
try {lock=channel.tryLock();}
catch(error){if(!/OverlappingFileLockException/.test(String(error)))throw error;}
if(!lock){channel.close();file.close();return null;}
var released=false;
return {release:function(){
if(released)return;released=true;
try{lock.release();}finally{try{channel.close();}finally{file.close();}}
}};
}catch(error){try{channel.close();}finally{file.close();}throw error;}
},
notify:function(){
console.log("[应用宝] 已有任务运行,本次重复启动不申请截图、不重开应用,等待原任务结束后退出。");
toast("应用宝任务正在运行,请勿重复启动");
},
wait:function(){sleep(1000);}
});
}