update app外场景禁止自动跳回
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
||||
applicationId "org.yameida.worktool"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 26041
|
||||
versionName "2.6.4"
|
||||
versionCode 26042
|
||||
versionName "2.6.4.2"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -112,7 +112,7 @@ fun getRoot(): AccessibilityNodeInfo {
|
||||
* 获取前台窗口
|
||||
* @param ignoreCheck false 必须等待前台为企业微信 true 直接返回当前前台窗口
|
||||
*/
|
||||
fun getRoot(ignoreCheck: Boolean): AccessibilityNodeInfo {
|
||||
fun getRoot(ignoreCheck: Boolean, share: Boolean = false): AccessibilityNodeInfo {
|
||||
while (true) {
|
||||
val tempRoot = WeworkController.weworkService.rootInActiveWindow
|
||||
val root = WeworkController.weworkService.rootInActiveWindow
|
||||
@@ -139,6 +139,8 @@ fun getRoot(ignoreCheck: Boolean): AccessibilityNodeInfo {
|
||||
error("点击关闭应用ANR")
|
||||
}
|
||||
}
|
||||
//app外场景禁止自动跳回(分享文件)
|
||||
if (!share) {
|
||||
WeworkController.weworkService.currentPackage = root.packageName?.toString() ?: ""
|
||||
if (System.currentTimeMillis() % 30 == 0L) {
|
||||
error("当前不在企业微信: ${root.packageName}")
|
||||
@@ -151,6 +153,7 @@ fun getRoot(ignoreCheck: Boolean): AccessibilityNodeInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ignoreCheck) {
|
||||
return root
|
||||
}
|
||||
|
||||
@@ -434,11 +434,19 @@ object WeworkOperationImpl {
|
||||
AccessibilityUtil.performClick(imageViewList[1])
|
||||
val shareFileButton = AccessibilityUtil.findOneByDesc(getRoot(), "以原文件分享", "用其他应用打开")
|
||||
AccessibilityUtil.performClick(shareFileButton)
|
||||
var shareToWorkButton = AccessibilityUtil.findOneByText(getRoot(true), "发送给同事")
|
||||
var shareToWorkButton = AccessibilityUtil.findOneByText(getRoot(true, share = true), "发送给同事")
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
if (shareToWorkButton == null) {
|
||||
LogUtils.e("未找到发送给同事: $objectName")
|
||||
if (retryCount > 0) {
|
||||
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
|
||||
}
|
||||
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "未找到发送给同事: $objectName", startTime, listOf(), titleList)
|
||||
return false
|
||||
}
|
||||
AccessibilityUtil.performClick(shareToWorkButton)
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true, share = true), "发送给同事")
|
||||
LogUtils.v("尝试发送给同事", shareToWorkButton == null, WeworkController.weworkService.currentPackage)
|
||||
val time = System.currentTimeMillis()
|
||||
var currentTime = time
|
||||
@@ -448,7 +456,7 @@ object WeworkOperationImpl {
|
||||
LogUtils.e("尝试手势点击!!!!!")
|
||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true, share = true), "发送给同事")
|
||||
} else {
|
||||
break
|
||||
}
|
||||
@@ -682,11 +690,19 @@ object WeworkOperationImpl {
|
||||
newFile.writeBytes(body.bytes())
|
||||
LogUtils.i("文件存储本地成功 $filePath")
|
||||
ShareUtil.share("${if (fileType.isBlank()) "*" else fileType}/*", newFile)
|
||||
var shareToWorkButton = AccessibilityUtil.findOneByText(getRoot(true), "发送给同事")
|
||||
var shareToWorkButton = AccessibilityUtil.findOneByText(getRoot(true, share = true), "发送给同事")
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
if (shareToWorkButton == null) {
|
||||
LogUtils.e("未找到发送给同事: $objectName")
|
||||
if (retryCount > 0) {
|
||||
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
|
||||
}
|
||||
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "未找到发送给同事: $objectName", startTime, listOf(), titleList)
|
||||
return false
|
||||
}
|
||||
AccessibilityUtil.performClick(shareToWorkButton)
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true, share = true), "发送给同事")
|
||||
LogUtils.v("尝试发送给同事", shareToWorkButton == null, WeworkController.weworkService.currentPackage)
|
||||
val time = System.currentTimeMillis()
|
||||
var currentTime = time
|
||||
@@ -696,7 +712,7 @@ object WeworkOperationImpl {
|
||||
LogUtils.e("尝试手势点击!!!!!")
|
||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true, share = true), "发送给同事")
|
||||
} else {
|
||||
break
|
||||
}
|
||||
@@ -742,11 +758,19 @@ object WeworkOperationImpl {
|
||||
newFile.writeBytes(EncodeUtils.base64Decode(fileBase64))
|
||||
LogUtils.i("文件存储本地成功 $filePath")
|
||||
ShareUtil.share("${if (fileType.isBlank()) "*" else fileType}/*", newFile)
|
||||
var shareToWorkButton = AccessibilityUtil.findOneByText(getRoot(true), "发送给同事")
|
||||
var shareToWorkButton = AccessibilityUtil.findOneByText(getRoot(true, share = true), "发送给同事")
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
if (shareToWorkButton == null) {
|
||||
LogUtils.e("未找到发送给同事: $objectName")
|
||||
if (retryCount > 0) {
|
||||
return pushMicroDiskImage(message, titleList, objectName, extraText, retryCount - 1)
|
||||
}
|
||||
uploadCommandResult(message, ExecCallbackBean.ERROR_RELAY, "未找到发送给同事: $objectName", startTime, listOf(), titleList)
|
||||
return false
|
||||
}
|
||||
AccessibilityUtil.performClick(shareToWorkButton)
|
||||
sleep(Constant.POP_WINDOW_INTERVAL)
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true, share = true), "发送给同事")
|
||||
LogUtils.v("尝试发送给同事", shareToWorkButton == null, WeworkController.weworkService.currentPackage)
|
||||
val time = System.currentTimeMillis()
|
||||
var currentTime = time
|
||||
@@ -756,7 +780,7 @@ object WeworkOperationImpl {
|
||||
LogUtils.e("尝试手势点击!!!!!")
|
||||
AccessibilityUtil.clickByNode(WeworkController.weworkService, shareToWorkButton)
|
||||
sleep(Constant.CHANGE_PAGE_INTERVAL)
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true), "发送给同事")
|
||||
shareToWorkButton = AccessibilityUtil.findOnceByText(getRoot(true, share = true), "发送给同事")
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -640,7 +640,7 @@ object AccessibilityUtil {
|
||||
if (result != null) return result
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -693,7 +693,7 @@ object AccessibilityUtil {
|
||||
if (result != null) return result
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -765,7 +765,7 @@ object AccessibilityUtil {
|
||||
if (result.size >= minSize) return result
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -830,7 +830,7 @@ object AccessibilityUtil {
|
||||
if (result.size >= minSize) return result
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -891,7 +891,7 @@ object AccessibilityUtil {
|
||||
if (result != null) return result
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -961,7 +961,7 @@ object AccessibilityUtil {
|
||||
if (result.size >= minSize) return result
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -1287,7 +1287,7 @@ object AccessibilityUtil {
|
||||
findOnceByText(node, *textList, exact = exact, desc = desc) ?: return true
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
@@ -1313,7 +1313,7 @@ object AccessibilityUtil {
|
||||
findOnceByClazz(node, *clazzList) ?: return true
|
||||
sleep(SHORT_INTERVAL)
|
||||
if (root) {
|
||||
node = getRoot(true)
|
||||
node = getRoot(true, share = true)
|
||||
} else {
|
||||
node.refresh()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user