Skip to content

Commit 1d9279b

Browse files
committed
add method, bug fixes
1 parent 45f537c commit 1d9279b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/Robot.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function LollipopRobot(max_retry_times) {
1818
this.waitForAvailable = function () {
1919
shell("su");
2020
};
21+
22+
this.enableWorkProfile = function (flag) {};
2123
}
2224

2325
Array.prototype.chunk = function (size) {
@@ -71,6 +73,26 @@ function GeneralRobot(max_retry_times) {
7173
log("无障碍服务故障");
7274
exit();
7375
};
76+
77+
this.enableWorkProfile = function (flag) {
78+
quickSettings();
79+
sleep(1000);
80+
let btn = desc("工作应用").findOnce();
81+
if (!btn) {
82+
log("未找到工作应用按钮");
83+
exit();
84+
}
85+
let checked = btn.checked();
86+
let turn = flag ^ checked; // 异或
87+
if (turn) {
88+
btn.click();
89+
sleep(4000);
90+
}
91+
back();
92+
sleep(500);
93+
back();
94+
sleep(500);
95+
};
7496
}
7597

7698
/**
@@ -135,6 +157,10 @@ function Robot(max_retry_times) {
135157
this.waitForAvailable = function () {
136158
this.robot.waitForAvailable();
137159
};
160+
161+
this.enableWorkProfile = function (flag) {
162+
this.robot.enableWorkProfile(flag);
163+
};
138164
}
139165

140166
module.exports = Robot;

lib/Secure.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function Secure(robot, max_retry_times) {
3333
};
3434

3535
this.isAmbient = function() {
36-
return device.isScreenOn() && id("com.android.systemui:id/scrim_notifications").clickable(false).exists(); // 是否熄屏显示
36+
return device.isScreenOn()
37+
&& (currentPackage() == "com.android.systemui")
38+
&& id("com.android.systemui:id/scrim_notifications").clickable(false).exists(); // 是否熄屏显示
3739
};
3840

3941
this.wakeUp = function(times) {

0 commit comments

Comments
 (0)