Skip to content

Commit

Permalink
添加自定义锁屏扩展
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyJiangWJ committed Apr 27, 2020
1 parent f5d3d6a commit 6196401
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
*.zip
*.log
*.ign.js
*.ign.js
LockScreen.js
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- 支持自动判断Root和无障碍的自动化执行操作 `Automator`
- 封装了一个文本悬浮窗工具 `FloatyUtil`
- 支持自动解锁设备,也支持扩展自定义解锁
- 支持模拟手势自动锁定屏幕,同时支持扩展自定义锁屏代码
- 支持支付宝手势解锁
- 支持通过代码添加定时任务 `Timers` 来自作者 [SuperMonster003](https://github.com/SuperMonster003)
- 支持自动点击授权截图权限 `TryRequestScreenCapture` 来自作者 [SuperMonster003](https://github.com/SuperMonster003)
Expand Down
16 changes: 16 additions & 0 deletions extends/LockScreen-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* @Author: TonyJiangWJ
* @Date: 2020-04-27 23:46:00
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2020-04-27 23:50:55
* @Description:
*/
let { config: _config } = require('../config.js')(runtime, this)

module.exports = function () {
// MIUI 12 新控制中心
swipe(800, 10, 800, 1000, 500)
sleep(500)
// 点击锁屏按钮
click(parseInt(_config.lock_x), parseInt(_config.lock_y))
}
18 changes: 13 additions & 5 deletions lib/prototype/Automator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
* @Author: TonyJiangWJ
* @Date: 2020-04-25 20:37:31
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2020-04-26 17:11:42
* @Last Modified time: 2020-04-27 23:59:28
* @Description:
*/
let { config: _config } = require('../../config.js')(runtime, this)
let singletoneRequire = require('../SingletonRequirer.js')(runtime, this)
let _logUtils = singletoneRequire('LogUtils')
let customLockScreen = files.exists(FileUtils.getCurrentWorkPath() + '/extends/LockScreen.js') ? require('../../extends/LockScreen.js') : null


const hasRootPermission = function () {
return files.exists("/sbin/su") || files.exists("/system/xbin/su") || files.exists("/system/bin/su")
}

const _automator = (device.sdkInt < 24 || hasRootPermission()) ? new Automation_root() : new Automation()



module.exports = {
click: function (x, y) {
return _automator.click(x, y)
Expand Down Expand Up @@ -216,10 +220,14 @@ function Automation () {
* 下拉状态栏,点击锁屏按钮
*/
this.lockScreen = function () {
swipe(500, 10, 500, 1000, 500)
swipe(500, 10, 500, 1000, 500)
// 点击锁屏按钮
click(parseInt(_config.lock_x), parseInt(_config.lock_y))
if (customLockScreen) {
customLockScreen()
} else {
swipe(500, 10, 500, 1000, 500)
swipe(500, 10, 500, 1000, 500)
// 点击锁屏按钮
click(parseInt(_config.lock_x), parseInt(_config.lock_y))
}
}

}
8 changes: 6 additions & 2 deletions sync_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: TonyJiangWJ
# @Date: 2020-04-27 09:15:51
# @Last Modified by: TonyJiangWJ
# @Last Modified time: 2020-04-27 15:09:10
# @Last Modified time: 2020-04-27 23:57:32
# @Description:
###
#!/bin/bash
Expand Down Expand Up @@ -42,6 +42,10 @@ target_files=(
"lib/prototype/LockableStorage.js"
"lib/prototype/LogUtils.js"
"lib/prototype/TryRequestScreenCapture.js"
"lib/prototype/Automator.js"
"extends/LockScreen-demo.js"
"extends/LockScreen.js"
"test/TestLockScreen.js"
)
# 定义target_files下标,mac下的bash无法使用dict 暂时这么写
running_queue_dispatcher=0
Expand Down Expand Up @@ -73,4 +77,4 @@ sync_all_target_files() {

# sync_target_with_idx $running_queue_dispatcher

sync_all_target_files
sync_all_target_files
11 changes: 11 additions & 0 deletions test/TestLockScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* @Author: TonyJiangWJ
* @Date: 2020-04-27 23:41:15
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2020-04-27 23:51:48
* @Description: 测试锁屏功能
*/

let singletoneRequire = require('../lib/SingletonRequirer.js')(runtime, this)
let automator = singletoneRequire('Automator')
automator.lockScreen()

0 comments on commit 6196401

Please sign in to comment.