Skip to content

Commit

Permalink
2.1.6 - Alpha6 - 修复排行榜好友信息获取异常 优化排行榜页面滚动速度/排行榜页面底部监测
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMonster003 committed Jul 18, 2021
1 parent 874606d commit 642102c
Show file tree
Hide file tree
Showing 17 changed files with 194 additions and 137 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,17 @@
[comment]: <> (Version history only shows last 3 versions)

# v2.1.6
###### 2021/07/16
###### 2021/07/19
* `新增` Root权限功能配置
* `修复` 模块交叉引用导致部分模块独立引用失败的问题
* `修复` 版本忽略管理匹配输入时结果可能出现错误的问题
* `修复` 排行榜自定义标题无效导致初始状态准备失败的问题 _[`issue #498`](https://github.com/SuperMonster003/Ant-Forest/issues/498)_
* `修复` 排行榜页面更新导致的好友信息获取异常的问题 _[`issue #499`](https://github.com/SuperMonster003/Ant-Forest/issues/499)_
* `修复` 逛一逛方案获取排行榜倒计时可能出现空指针引用的问题
* `优化` 默认关闭Root权限结束应用防止Floaty结果显示异常
* `优化` 替换设备通话状态值获取方法的代码方案 (试优化)
* `优化` 逛一逛方案获取倒计时排行榜页面滚动速度
* `优化` 排行榜页面底部监测线程的内部检测逻辑

# v2.1.5
###### 2021/07/01
Expand Down
86 changes: 65 additions & 21 deletions ant-forest-launcher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Alipay ant forest intelligent collection script launcher
* @since Jul 16, 2021
* @version 2.1.6 Alpha5
* @since Jul 19, 2021
* @version 2.1.6 Alpha6
* @author SuperMonster003
* @see https://github.com/SuperMonster003/Ant-Forest
*/
Expand Down Expand Up @@ -3715,18 +3715,19 @@ let $$init = {
while (!$$flag.rl_bottom_rch) {
$$impeded('排行榜底部监测线程');
try {
return _locate() && $$link(_text).$(_height).$(_signal);
if ($$app.page.rl.isInPage() && _locate()) {
$$link(_text).$(_height).$(_signal);
break;
}
} catch (e /* TypeError: Cannot call method "childCount" of null */) {
sleep(2e3);
sleep(1.5e3);
}
sleep(480);
}

// tool function(s) //

function _locate() {
if (_list_w) {
return true;
}
debugInfo('开始定位排行榜可滚动控件');

let _sel = () => _list_w = $$sel.pickup({
Expand Down Expand Up @@ -4093,7 +4094,7 @@ let $$init = {
$$app.task_name = '好友列表数据采集'.surround('"');
messageAction('正在采集好友列表数据', 1, 1, 0, 2);

$$af.rl.swipe.toBottom();
$$af.rl.scroll.toBottom({itv: 0});

let _ls_data = _getListData();
$$sto.af.remove('friends_list_data'); // discarded data
Expand All @@ -4108,10 +4109,11 @@ let $$init = {
// tool function(s) //

function _getListData() {
let _fri = $$af._collector.fri;
let _data = [];
$$sel.get('energy_amt', 'wc').slice(1).forEach((w, i) => {
let _nick = $$sel.pickup([w, 'p2c2>0>0'], 'txt');
let _rank = i < 3 ? i + 1 : $$sel.pickup([w, 'p2c0>0'], 'txt');
let _nick = $$sel.pickup([w, _fri.getRlNickCompass(w)], 'txt');
let _rank = i < 3 ? i + 1 : $$sel.pickup([w, _fri.getRlRankNum(w)], 'txt');
_data.push({rank_num: _rank.toString(), nickname: _nick});
});

Expand Down Expand Up @@ -5014,6 +5016,37 @@ let $$af = {
},
},
fri: {
_rl_compass: {
nick: {
presets: [
'pc2>0', // since Jul 16, 2021 (around)
'pc1>0', // since Jul 16, 2021 (around)
'p2c2>0>0', // legacy
],
condition(w, c) {
return w && !$$sel.pickup([w, c], 'txt').match(/^\s*$/);
},
},
rank: {
presets: [
'pc0', // since Jul 16, 2021 (around)
'p2c0>0', // legacy
],
condition(w, c) {
let _s = w && $$sel.pickup([w, c], 'txt');
return _s && _s.match(/^\s*\d+\s*$/);
},
},
},
_getRlCompass(w, key) {
let {presets, condition} = this._rl_compass[key];
for (let c of presets) {
if (condition(w, c)) {
return c;
}
}
return presets[0];
},
_getSamples(cache_fg) {
if (cache_fg && this.rl_samples) {
return this.rl_samples;
Expand All @@ -5029,9 +5062,10 @@ let $$af = {
function _parseWidgets() {
let _smp = {};
_wc.forEach((w) => {
let _mm = +$$sel.pickup(w, 'txt').match(/\d+/)[0];
let _nick = $$sel.pickup([w, 'p2c2>0>0'], 'txt');
if (_mm && _nick) {
let _mm = Number($$sel.pickup(w, 'txt').match(/\d+/)[0]);
if (_mm) {
let _c = this.getRlNickCompass(w);
let _nick = $$sel.pickup([w, _c], 'txt', '?_nick');
_smp[_nick] = {
ts: $$app.ts + _mm * 60e3,
minute: _mm,
Expand Down Expand Up @@ -5605,7 +5639,7 @@ let $$af = {
return s.slice(s.lastIndexOf('收取')).match(/\d+(?=g)/);
}
},
/** @returns {number} amount of items added to the feed */
/** @returns {number} - amount of items added to the feed */
getEmount() {
let _w_list = this.getListWidget();
if (_w_list) {
Expand Down Expand Up @@ -5935,8 +5969,10 @@ let $$af = {
$$af.min_ctd.fri.reset();
} else if (!isFinite($$af.min_ctd.fri.value)) {
if ($$af.stroll.trigger()) {
$$toast('正在准备获取排行榜倒计时数据...', 'Long');
$$app.page.rl.launch({is_show_greeting: false});
$$af.rl.swipe.toBottom();
$$af.rl.scroll.toBottom({itv: 0});
$$toast.dismiss();
}
_fri._chkMinCtd('cache');
}
Expand Down Expand Up @@ -6172,6 +6208,12 @@ let $$af = {
reboot() {
this.init().collect();
},
getRlNickCompass(w) {
return this._getRlCompass(w, 'nick');
},
getRlRankNum(w) {
return this._getRlCompass(w, 'rank');
},
},
},
_timers_setter: {
Expand Down Expand Up @@ -6689,12 +6731,13 @@ let $$af = {
let _bt = _opt.buffer_time || _opt.bt$ || 0;
$$sleep(_bt === true || _bt === -1 ? _itv : _bt);
},
toBottom(timeout) {
toBottom(options) {
let _this = this;
let _opt = options || {};
let _thd = threadsx.start(function () {
_this.scroll({loop: () => !$$flag.rl_bottom_rch});
_this.scroll(Object.assign({loop: () => !$$flag.rl_bottom_rch}, _opt));
});
$$app.monitor.rl_bottom.start().join(timeout || 5 * 60e3);
$$app.monitor.rl_bottom.start().join(_opt.timeout || 150e3);
_thd.interrupt();
},
},
Expand Down Expand Up @@ -6779,12 +6822,13 @@ let $$af = {

return _top0;
},
toBottom(timeout) {
toBottom(options) {
let _this = this;
let _opt = options || {};
let _thd = threadsx.start(function () {
_this.swipe({loop: () => !$$flag.rl_bottom_rch});
_this.swipe(Object.assign({loop: () => !$$flag.rl_bottom_rch}, _opt));
});
$$app.monitor.rl_bottom.start().join(timeout || 5 * 60e3);
$$app.monitor.rl_bottom.start().join(_opt.timeout || 150e3);
_thd.interrupt();
},
},
Expand Down
6 changes: 5 additions & 1 deletion documents/CHANGELOG-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
******

# v2.1.6
###### 2021/07/16
###### 2021/07/19
* `新增` Root权限功能配置
* `修复` 模块交叉引用导致部分模块独立引用失败的问题
* `修复` 版本忽略管理匹配输入时结果可能出现错误的问题
* `修复` 排行榜自定义标题无效导致初始状态准备失败的问题 _[`issue #498`](https://github.com/SuperMonster003/Ant-Forest/issues/498)_
* `修复` 排行榜页面更新导致的好友信息获取异常的问题 _[`issue #499`](https://github.com/SuperMonster003/Ant-Forest/issues/499)_
* `修复` 逛一逛方案获取排行榜倒计时可能出现空指针引用的问题
* `优化` 默认关闭Root权限结束应用防止Floaty结果显示异常
* `优化` 替换设备通话状态值获取方法的代码方案 (试优化)
* `优化` 逛一逛方案获取倒计时排行榜页面滚动速度
* `优化` 排行榜页面底部监测线程的内部检测逻辑

# v2.1.5
###### 2021/07/01
Expand Down
1 change: 0 additions & 1 deletion modules/ext-a11y.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ let ext = {
/**
* @param {android.view.accessibility.AccessibilityWindowInfo} wi
* @returns {boolean}
* @private
*/
_isLatestPackage(wi) {
return wi.getRoot().getPackageName() === runtime.info.getLatestPackage();
Expand Down
2 changes: 1 addition & 1 deletion modules/ext-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,7 @@ let ext = {
},
/**
* Checks if the specified app can modify system settings.
* @return {boolean}
* @returns {boolean}
* @see https://developer.android.com/reference/android/provider/Settings.System#canWrite(android.content.Context)
*/
canWriteSystem() {
Expand Down
49 changes: 26 additions & 23 deletions modules/ext-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let BatteryManager = android.os.BatteryManager;
let ServiceManager = android.os.ServiceManager;
let DisplayMetrics = android.util.DisplayMetrics;
let RootTool = org.autojs.autojs.tool.RootTool;
let ITelephony = com.android.internal.telephony.ITelephony;
let ITelecomService = com.android.internal.telephony.ITelecomService;

// noinspection JSUnusedGlobalSymbols
let ext = {
Expand Down Expand Up @@ -412,7 +412,7 @@ let ext = {
},
/**
* @param {number} [max_buffer_time=9e3]
* @return {boolean}
* @returns {boolean}
*/
wakeUpWithBuffer(max_buffer_time) {
let _isScreenOn = this.isScreenOn.bind(this);
Expand Down Expand Up @@ -490,10 +490,10 @@ let ext = {
* @param {Devicex$ScreenOff$Strategy$Options} [options.key_code]
* @param {
* Devicex$ScreenOff$Strategy$Options | {
* listener?: {function(function(string[]=):*):*},
* listener?: {function(function(...string|string[]):*):*},
* }
* } [options.provider]
* @return {boolean}
* @returns {boolean}
*/
screenOff(options) {
require('./ext-app').load();
Expand Down Expand Up @@ -794,27 +794,33 @@ let ext = {
}
},
/**
* Returns a state number which indicated phone calling state
* Returns a state number indicating phone calling state.
* @example
* // expected: {0: IDLE, 1: RINGING, 2: OFF-HOOK}
* // some device may behave abnormally: {2: IDLE, 1: OFF-HOOK}
* // furthermore, always returns 0
* console.log(devicex.getCallState() === android.telephony.TelephonyManager.CALL_STATE_IDLE);
* @see android.telephony.TelephonyManager.CALL_STATE_IDLE
* @see android.telephony.TelephonyManager.CALL_STATE_RINGING
* @see android.telephony.TelephonyManager.CALL_STATE_OFFHOOK
* @returns {number}
* <br>
* -- 0: IDLE; <br>
* -- 1: RINGING; <br>
* -- 2: OFF-HOOK; <br>
* // some device may behave abnormally <br>
* -- 2: IDLE; <br>
* -- 1: OFF-HOOK; <br>
* // even always returns 0
*/
getCallState() {
let _svr_mgr = ITelephony.Stub.asInterface(ServiceManager.checkService('phone'));
let _svc_ctx = context.getSystemService(Context.TELEPHONY_SERVICE);

return _svr_mgr.getCallState() | _svc_ctx.getCallState();
// TODO remove backed up code at Oct 18, 2021 (around)
// let ITelephony = com.android.internal.telephony.ITelephony;
// let _svr_mgr = ITelephony.Stub.asInterface(ServiceManager.checkService('phone'));
// let _svc_ctx = context.getSystemService(Context.TELEPHONY_SERVICE);
//
// return _svr_mgr.getCallState() | _svc_ctx.getCallState();

return ITelecomService.Stub
.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE))
.getCallState();
},
/**
* Returns display screen width and height data and
* converter functions with different aspect ratios <br>
* Scaling based on Sony Xperia XZ1 Compact - G8441 (720 × 1280)
* converter functions with different aspect ratios.
* Scaling based on Sony Xperia XZ1 Compact - G8441 (720 × 1280).
* @param {boolean} [is_global_assign=false] -- set true for global assignment
* @param {Object} [options]
* @param {boolean} [options.is_global_assign=false]
Expand Down Expand Up @@ -1436,7 +1442,6 @@ function StateManager(provider, key, data_type, state_set) {
// tool function(s) //

/**
* @private
* @this StateManager
* @param {*[]} states
* @param {boolean} is_clockwise
Expand All @@ -1448,7 +1453,6 @@ function StateManager(provider, key, data_type, state_set) {
}

/**
* @private
* @param {'clockwise'|'anticlockwise'|'+'|'-'} [direction] - other supported values: +0, -0
* @returns {boolean}
*/
Expand All @@ -1458,8 +1462,7 @@ function StateManager(provider, key, data_type, state_set) {
}

/**
* @returns {Function}
* @private
* @returns {function}
*/
function _parseProvider() {
switch (provider) {
Expand Down
Loading

0 comments on commit 642102c

Please sign in to comment.