Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyJiangWJ committed Dec 26, 2023
2 parents 01cdc48 + 1f8dfe5 commit 4d3ed0d
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 47 deletions.
7 changes: 5 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2019-12-09 20:42:08
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-11-20 22:20:53
* @Last Modified time: 2023-12-10 00:14:49
* @Description:
*/
require('./lib/Runtimes.js')(global)
Expand All @@ -12,6 +12,7 @@ let is_pro = !!Object.prototype.toString.call(com.stardust.autojs.core.timing.Ti
let default_config = {
unlock_device_flag: 'normal',
password: '',
infinite_retry_unlock: false,
is_alipay_locked: false,
alipay_lock_password: '',
color_offset: 20,
Expand Down Expand Up @@ -261,6 +262,8 @@ let default_config = {
noneed_resolve_dex: false,
// 标记是否清除webview缓存
clear_webview_cache: false,
// 邀请好友获取巡护机会
invite_friends_gaint_chance: false,
// 更新后需要强制执行的标记
updated_temp_flag_13732: true,
// 多账号管理
Expand All @@ -283,7 +286,7 @@ let default_config = {
// 双击卡使用时间段
duplicate_card_using_time_ranges: '00:00-00:10',
// 代码版本
code_version: 'v1.4.1',
code_version: 'v1.4.2',
}
// 文件更新后直接生效,不使用缓存的值
let no_cache_configs = ['release_access_token', 'code_version']
Expand Down
4 changes: 2 additions & 2 deletions core/BaseScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2019-12-18 14:17:09
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-11-03 23:07:21
* @Last Modified time: 2023-11-22 21:17:05
* @Description: 能量收集和扫描基类,负责通用方法和执行能量球收集
*/
importClass(java.util.concurrent.LinkedBlockingQueue)
Expand Down Expand Up @@ -135,7 +135,7 @@ const BaseScanner = function () {
this.collectByOneKeyCollect()
return
}
if (YoloDetection.enabled && _config.detect_ball_by_yolo) {
if (YoloDetection.enabled) {
this.checkAndCollectByYolo(isOwn)
} else {
this.checkAndCollectByHough(isOwn)
Expand Down
2 changes: 1 addition & 1 deletion core/StrollScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2020-09-07 13:06:32
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-08-15 13:44:40
* @Last Modified time: 2023-12-12 09:27:33
* @Description: 逛一逛收集器
*/
let { config: _config, storage_name: _storage_name } = require('../config.js')(runtime, global)
Expand Down
18 changes: 14 additions & 4 deletions lib/PrintExceptionStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ importClass(java.io.PrintWriter)
importClass(java.io.BufferedReader)
importClass(java.lang.StringBuilder)

module.exports = function printExceptionStack(e) {
module.exports = function printExceptionStack(e, logger) {
logger = logger || new DefaultLogger()
if (e) {
console.error(util.format('fileName: %s line:%s typeof e:%s', e.fileName, e.lineNumber, typeof e))
logger.errorInfo(util.format('fileName: %s line:%s typeof e:%s', e.fileName, e.lineNumber, typeof e))
let throwable = null
if (e.javaException) {
throwable = e.javaException
Expand All @@ -24,13 +25,22 @@ module.exports = function printExceptionStack(e) {
while ((line = bufferedReader.readLine()) != null) {
scriptTrace.append("\n").append(line)
}
console.error(scriptTrace.toString())
logger.errorInfo(scriptTrace.toString())
} else {
let funcs = Object.getOwnPropertyNames(e)
for (let idx in funcs) {
let func_name = funcs[idx]
console.verbose(func_name)
logger.debugInfo(func_name)
}
}
}
}

function DefaultLogger() {
this.errorInfo = function(str) {
console.error(str)
}
this.debugInfo = function(str) {
console.verbose(str)
}
}
6 changes: 4 additions & 2 deletions lib/ProjectWidgetUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,10 @@ const ProjectWidgetUtils = function () {
warningFloaty.addRectangle('立即使用', this.boundsToRegion(useConfirm.bounds()))
automator.clickRandomRegion(this.boundsToRegion(useConfirm.bounds()))
sleep(500)
this.checkIsDuplicateCardUsed()
return true
let useSuccess = this.checkIsDuplicateCardUsed()
// 部分人反馈有动画需要等待,增加延迟
sleep(1500)
return useSuccess
}
} else {
warningFloaty.addText('OCR未找到目标', { x: 300, y: 1000 })
Expand Down
6 changes: 3 additions & 3 deletions lib/Unlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: TonyJiangWJ
* @Date: 2019-11-05 09:12:00
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-11-07 13:49:26
* @Last Modified time: 2023-12-10 00:12:55
* @Description:
*/
let { config: _config, storageName: _storageName } = require('../config.js')(runtime, global)
Expand Down Expand Up @@ -160,14 +160,14 @@ function Unlocker () {
this.failed = function () {
automator.back()
this.reTry++
if (this.reTry > 3) {
if (this.reTry > 3 && !_config.infinite_retry_unlock) {
logInfo('解锁失败达到三次,停止运行')
_config.resetBrightness && _config.resetBrightness()
_runningQueueDispatcher.removeRunningTask()
this.saveNeedRelock(true)
exit()
} else {
let sleepMs = 5000 * this.reTry
let sleepMs = 5000 * (this.reTry > 3?3:this.reTry)
logInfo('解锁失败,' + sleepMs + 'ms之后重试')
sleep(sleepMs)
this.run_unlock()
Expand Down
Binary file modified lib/download.dex
Binary file not shown.
1 change: 1 addition & 0 deletions lib/prototype/RunningQueueDispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ function RunningQueueDispatcher () {
if (this.lock()) {
_logUtils.debugInfo('当前无任务等待,直接执行:' + JSON.stringify(taskInfo))
this.doAddRunningTask(taskInfo)
global._running_status = true
this.unlock()
} else {
_logUtils.errorInfo('获取锁失败,无法继续执行任务:' + JSON.stringify(taskInfo))
Expand Down
11 changes: 6 additions & 5 deletions lib/prototype/WarningFloaty.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* @Author: TonyJiangWJ
* @Date: 2023-07-05 15:54:16
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2023-10-24 17:50:22
* @Last Modified time: 2023-11-27 09:46:55
* @Description:
*/

let { config } = require('../../config.js')(runtime, global)
let sRequire = require('../SingletonRequirer.js')(runtime, global)
let { debugInfo, warnInfo, errorInfo, infoLog, logInfo, debugForDev } = sRequire('LogUtils')
let commonFunction = sRequire('CommonFunction')
let LogUtils = sRequire('LogUtils')
let { debugInfo, warnInfo, errorInfo, infoLog, logInfo, debugForDev } = LogUtils
let printExceptionStack = require('../PrintExceptionStack')
let CanvasDrawer = require('../CanvasDrawer.js')

function WarningFloaty () {
Expand Down Expand Up @@ -69,8 +70,8 @@ function WarningFloaty () {
debugInfo(['no match draw event for {}', drawInfo.type], true)
}
} catch (e) {
errorInfo('执行异常' + e)
commonFunction.printExceptionStack(e)
errorInfo('执行异常' + e + e.stack)
printExceptionStack(e, LogUtils)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion lib/prototype/YoloDetectionUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (yoloSupport && !files.exists(modelPath)) {
}

function YoloDetection() {
this.enabled = yoloSupport
this.enabled = yoloSupport && config.detect_ball_by_yolo
if (yoloSupport) {
let predictor = new YoloV8Predictor(modelPath)
predictor.setShapeSize(320, 320)
Expand Down
4 changes: 2 additions & 2 deletions project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ignore": [
"build"
],
"versionName": "1.4.1",
"versionName": "1.4.2",
"packageName": "com.tony.ant.forest",
"versionCode": 1400
"versionCode": 1420
}
4 changes: 2 additions & 2 deletions unit/循环切换小号并大号浇水.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
let { config } = require('../config.js')(runtime, global)
let singletonRequire = require('../lib/SingletonRequirer.js')(runtime, global)
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
runningQueueDispatcher.addRunningTask()
let accountChange = require('../lib/AlipayAccountManage.js')
let logUtils = singletonRequire('LogUtils')
let floatyInstance = singletonRequire('FloatyUtil')
let commonFunctions = singletonRequire('CommonFunction')
let widgetUtils = singletonRequire('WidgetUtils')
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
let fileUtils = singletonRequire('FileUtils')
let automator = singletonRequire('Automator')
let unlocker = require('../lib/Unlock.js')
let { openFriendHome, doWaterFriend, openAndWaitForPersonalHome, getSignReward } = require('./waterFriend.js')
config.not_lingering_float_window = true
config.targetWateringAmount = 66
runningQueueDispatcher.addRunningTask()
// 注册自动移除运行中任务
commonFunctions.registerOnEngineRemoved(function () {
if (config.auto_lock && unlocker.needRelock() === true) {
Expand Down
5 changes: 3 additions & 2 deletions unit/循环切换小号并执行能量雨收集.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
let { config } = require('../config.js')(runtime, global)
let singletonRequire = require('../lib/SingletonRequirer.js')(runtime, global)
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
runningQueueDispatcher.addRunningTask()
let accountChange = require('../lib/AlipayAccountManage.js')
let logUtils = singletonRequire('LogUtils')
let floatyInstance = singletonRequire('FloatyUtil')
let commonFunctions = singletonRequire('CommonFunction')
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
let fileUtils = singletonRequire('FileUtils')
let automator = singletonRequire('Automator')
let widgetUtils = singletonRequire('WidgetUtils')
let unlocker = require('../lib/Unlock.js')
let { openFriendHome, doWaterFriend, openAndWaitForPersonalHome } = require('./waterFriend.js')
config.not_lingering_float_window = true
runningQueueDispatcher.addRunningTask()

// 注册自动移除运行中任务
commonFunctions.registerOnEngineRemoved(function () {
if (config.auto_lock && unlocker.needRelock() === true) {
Expand Down
4 changes: 2 additions & 2 deletions unit/循环切换小号并收集能量.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
let { config } = require('../config.js')(runtime, global)
let singletonRequire = require('../lib/SingletonRequirer.js')(runtime, global)
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
runningQueueDispatcher.addRunningTask()
let accountChange = require('../lib/AlipayAccountManage.js')
let logUtils = singletonRequire('LogUtils')
let floatyInstance = singletonRequire('FloatyUtil')
let commonFunctions = singletonRequire('CommonFunction')
let widgetUtils = singletonRequire('WidgetUtils')
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
let fileUtils = singletonRequire('FileUtils')
let automator = singletonRequire('Automator')
let unlocker = require('../lib/Unlock.js')
Expand All @@ -14,7 +15,6 @@ let resourceMonitor = require('../lib/ResourceMonitor.js')(runtime, global)
let OpenCvUtil = require('../lib/OpenCvUtil.js')
let { openFriendHome, doWaterFriend, openAndWaitForPersonalHome, getSignReward } = require('./waterFriend.js')
config.not_lingering_float_window = true
runningQueueDispatcher.addRunningTask()
// 注册自动移除运行中任务
commonFunctions.registerOnEngineRemoved(function () {
if (config.auto_lock && unlocker.needRelock() === true) {
Expand Down
8 changes: 5 additions & 3 deletions unit/循环切换小号用于同步数据.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
let { config } = require('../config.js')(runtime, global)
let singletonRequire = require('../lib/SingletonRequirer.js')(runtime, global)
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
runningQueueDispatcher.addRunningTask()
let accountChange = require('../lib/AlipayAccountManage.js')
let logUtils = singletonRequire('LogUtils')
let floatyInstance = singletonRequire('FloatyUtil')
let commonFunctions = singletonRequire('CommonFunction')
let widgetUtils = singletonRequire('WidgetUtils')
let fileUtils = singletonRequire('FileUtils')
let automator = singletonRequire('Automator')
let runningQueueDispatcher = singletonRequire('RunningQueueDispatcher')
let unlocker = require('../lib/Unlock.js')
config.not_lingering_float_window = true

runningQueueDispatcher.addRunningTask()
// 注册自动移除运行中任务
commonFunctions.registerOnEngineRemoved(function () {
if (config.auto_lock && unlocker.needRelock() === true) {
Expand Down Expand Up @@ -139,7 +139,9 @@ function donate() {
automator.clickCenter(donateBtn)
sleep(1000)
let okBtn = widgetUtils.widgetGetOne('知道了')
automator.clickCenter(okBtn)
if (okBtn) {
automator.clickCenter(okBtn)
}
sleep(1000)
} else {
floatyInstance.setFloatyText('未找到立即捐步按钮')
Expand Down
35 changes: 19 additions & 16 deletions unit/自动巡护.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let FloatyInstance = singletonRequire('FloatyUtil')
let logFloaty = singletonRequire('LogFloaty')
let WarningFloaty = singletonRequire('WarningFloaty')
let localOcrUtil = require('../lib/LocalOcrUtil.js')
let alipayUnlocker = singletonRequire('AlipayUnlocker')
config.buddha_like_mode = false
config.not_lingering_float_window = true

Expand Down Expand Up @@ -246,22 +247,24 @@ function prepareWalker () {
extend(InviteWalker, PatrolWalker)
InviteWalker.prototype.doOperate = function (context) {
context.currentState = 'invite'
/*
let closeInvite = widgetUtils.widgetGetById('inviteFriendDialog-close', 1000)
if (closeInvite) {
WarningFloaty.addRectangle('关闭邀请', boundsToRegion(closeInvite.bounds()))
logFloaty.pushLog('关闭邀请')
automator.clickCenter(closeInvite)
sleep(1000)
} 默认关闭邀请 */
let invite = widgetUtils.widgetGetOne('邀请TA', 1000)
if (invite) {
debugInfo('点击邀请TA')
automator.clickCenter(invite)
sleep(1000)
let continueWalk = widgetUtils.widgetGetOne('继续', 1000)
if (continueWalk) {
automator.clickCenter(continueWalk)
if (config.invite_friends_gaint_chance) {
let invite = widgetUtils.widgetGetOne('邀请TA', 1000)
if (invite) {
debugInfo('点击邀请TA')
automator.clickCenter(invite)
sleep(1000)
let continueWalk = widgetUtils.widgetGetOne('继续', 1000)
if (continueWalk) {
automator.clickCenter(continueWalk)
sleep(1000)
}
}
} else {
let closeInvite = widgetUtils.widgetGetById('inviteFriendDialog-close', 1000)
if (closeInvite) {
WarningFloaty.addRectangle('关闭邀请', boundsToRegion(closeInvite.bounds()))
logFloaty.pushLog('关闭邀请')
automator.clickCenter(closeInvite)
sleep(1000)
}
}
Expand Down
2 changes: 2 additions & 0 deletions vue_configs/js/components/configuration/CommonConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const LockConfig = {
return {
configs: {
password: '',
infinite_retry_unlock: false,
start_alipay_by_url: false,
is_alipay_locked: true,
multi_device_login: false,
Expand Down Expand Up @@ -68,6 +69,7 @@ const LockConfig = {
<div>
<van-cell-group>
<van-field v-model="configs.password" label="锁屏密码" type="password" placeholder="请输入锁屏密码" input-align="right" />
<switch-cell title="无限尝试解锁" v-model="configs.infinite_retry_unlock" />
<number-field v-model="configs.timeout_unlock" label="解锁超时时间" placeholder="请输入解锁超时时间">
<template #right-icon><span>毫秒</span></template>
</number-field>
Expand Down
33 changes: 33 additions & 0 deletions vue_configs/js/components/configuration/SampleConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,39 @@ const MagicSeaConfig = {
`
}

const PatrolWalkerConfig = {
mixins: [mixin_common],
data () {
return {
timedUnit1: '',
configs: {
invite_friends_gaint_chance: false,
}
}
},
filters: {
displayTime: value => {
if (value && value.length > 0) {
return `[${value}]`
}
return ''
}
},
mounted () {
$nativeApi.request('queryTargetTimedTaskInfo', { path: '/unit/自动巡护.js' }).then(r => this.timedUnit1 = r)
},
template: `
<div>
<tip-block>对下述文件创建每天固定时间的定时任务即可,不过建议使用github actions刷步数,然后在步数达到1万以上后再触发,以便得到最大巡护次数</tip-block>
<tip-block>unit/自动巡护.js{{timedUnit1|displayTime}}</tip-block>
<van-divider content-position="left">
自动巡护配置
</van-divider>
<switch-cell title="是否邀请好友获取巡护机会" v-model="configs.invite_friends_gaint_chance"/>
</div>
`
}

/**
* 收集配置
*/
Expand Down

0 comments on commit 4d3ed0d

Please sign in to comment.