Skip to content

Commit

Permalink
add method, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
e1399579 committed Jun 3, 2024
1 parent 45f537c commit 1d9279b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions lib/Robot.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function LollipopRobot(max_retry_times) {
this.waitForAvailable = function () {
shell("su");
};

this.enableWorkProfile = function (flag) {};
}

Array.prototype.chunk = function (size) {
Expand Down Expand Up @@ -71,6 +73,26 @@ function GeneralRobot(max_retry_times) {
log("无障碍服务故障");
exit();
};

this.enableWorkProfile = function (flag) {
quickSettings();
sleep(1000);
let btn = desc("工作应用").findOnce();
if (!btn) {
log("未找到工作应用按钮");
exit();
}
let checked = btn.checked();
let turn = flag ^ checked; // 异或
if (turn) {
btn.click();
sleep(4000);
}
back();
sleep(500);
back();
sleep(500);
};
}

/**
Expand Down Expand Up @@ -135,6 +157,10 @@ function Robot(max_retry_times) {
this.waitForAvailable = function () {
this.robot.waitForAvailable();
};

this.enableWorkProfile = function (flag) {
this.robot.enableWorkProfile(flag);
};
}

module.exports = Robot;
4 changes: 3 additions & 1 deletion lib/Secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function Secure(robot, max_retry_times) {
};

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

this.wakeUp = function(times) {
Expand Down

0 comments on commit 1d9279b

Please sign in to comment.