File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff 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
2325Array . 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
140166module . exports = Robot ;
Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments