update 扫一扫

This commit is contained in:
gallonyin
2023-05-26 22:34:15 +08:00
parent ac8b45002c
commit cd807632d1
6 changed files with 146 additions and 3 deletions

View File

@@ -1,6 +1,5 @@
package org.yameida.worktool.activity package org.yameida.worktool.activity
import android.Manifest
import android.os.Bundle import android.os.Bundle
import android.provider.Settings import android.provider.Settings
import android.view.WindowManager import android.view.WindowManager
@@ -13,6 +12,7 @@ import org.yameida.worktool.*
import android.content.* import android.content.*
import android.os.IBinder import android.os.IBinder
import android.text.InputType import android.text.InputType
import com.blankj.utilcode.constant.PermissionConstants
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.qmuiteam.qmui.widget.dialog.QMUIDialog import com.qmuiteam.qmui.widget.dialog.QMUIDialog
import org.yameida.worktool.service.PlayNotifyService import org.yameida.worktool.service.PlayNotifyService
@@ -51,7 +51,7 @@ class ListenActivity : AppCompatActivity() {
initOverlays() initOverlays()
initData() initData()
initNotification() initNotification()
PermissionUtils.permission(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE).request() PermissionUtils.permission(PermissionConstants.STORAGE).request()
registerReceiver(openWsReceiver, IntentFilter(Constant.WEWORK_NOTIFY)) registerReceiver(openWsReceiver, IntentFilter(Constant.WEWORK_NOTIFY))
} }

View File

@@ -93,6 +93,9 @@ public class WeworkMessageBean {
public static final int RELAY_MERGE_MESSAGE = 228; public static final int RELAY_MERGE_MESSAGE = 228;
public static final int SEND_MULTI_MESSAGE = 229; public static final int SEND_MULTI_MESSAGE = 229;
public static final int SEND_MERGE_MESSAGE = 230; public static final int SEND_MERGE_MESSAGE = 230;
public static final int VOICE_CALL = 231;
public static final int VIDEO_CALL = 232;
public static final int SCAN_QR_CODE = 233;
public static final int ROBOT_LOG = 301; public static final int ROBOT_LOG = 301;
public static final int ROBOT_ERROR_LOG = 302; public static final int ROBOT_ERROR_LOG = 302;

View File

@@ -189,6 +189,9 @@ object MyLooper {
WeworkMessageBean.SEND_MERGE_MESSAGE -> { WeworkMessageBean.SEND_MERGE_MESSAGE -> {
WeworkController.sendMergeMessage(message) WeworkController.sendMergeMessage(message)
} }
WeworkMessageBean.SCAN_QR_CODE -> {
WeworkController.scanQrCode(message)
}
WeworkMessageBean.DISMISS_GROUP -> { WeworkMessageBean.DISMISS_GROUP -> {
WeworkController.dismissGroup(message) WeworkController.dismissGroup(message)
} }

View File

@@ -513,6 +513,22 @@ object WeworkController {
) )
} }
/**
* 扫一扫
* @see WeworkMessageBean.SCAN_QR_CODE
* @param message#fileUrl 图片地址
* @param message#fileBase64 文件Base64
*/
@RequestMapping
fun scanQrCode(message: WeworkMessageBean): Boolean {
LogUtils.d("scanQrCode(): ${message.fileUrl} ${message.fileBase64?.substring(0, 100)}")
return WeworkOperationImpl.scanQrCode(
message,
message.fileUrl,
message.fileBase64
)
}
/** /**
* 获取群信息 * 获取群信息
* @see WeworkMessageBean.GET_GROUP_INFO * @see WeworkMessageBean.GET_GROUP_INFO

View File

@@ -1,5 +1,6 @@
package org.yameida.worktool.service package org.yameida.worktool.service
import android.graphics.Bitmap
import android.view.accessibility.AccessibilityNodeInfo import android.view.accessibility.AccessibilityNodeInfo
import org.yameida.worktool.Constant import org.yameida.worktool.Constant
import org.yameida.worktool.model.WeworkMessageBean import org.yameida.worktool.model.WeworkMessageBean
@@ -1644,6 +1645,85 @@ object WeworkOperationImpl {
} }
} }
/**
* 扫一扫
* @see WeworkMessageBean.SCAN_QR_CODE
* @param fileUrl 图片地址
* @param fileBase64 文件Base64
*/
fun scanQrCode(message: WeworkMessageBean, fileUrl: String?, fileBase64: String?): Boolean {
val startTime = System.currentTimeMillis()
goHome()
var filePath = ""
if (fileUrl != null) {
LogUtils.i("下载开始 $fileUrl")
val execute = OkGo.get<File>(fileUrl).execute()
LogUtils.i("下载完成 $fileUrl")
val body = execute.body()
if (body != null) {
val df = SimpleDateFormat("yyyy-MM-dd-HH:mm:ss")
filePath = "${Utils.getApp().getExternalFilesDir("scan")}/${df.format(Date())}_scan.jpg"
ImageUtils.save(ImageUtils.getBitmap(body.byteStream()), filePath, Bitmap.CompressFormat.JPEG, 100, true)
PropUtil.setProp(PropUtil.propVideo, filePath)
LogUtils.i("文件存储本地成功 $filePath")
} else {
LogUtils.e("文件下载失败")
uploadCommandResult(message, ExecCallbackBean.ERROR_FILE_DOWNLOAD, "文件下载失败 $fileUrl", startTime)
return false
}
} else {
//todo base64
}
val list = AccessibilityUtil.findOneByClazz(getRoot(), Views.RecyclerView, Views.ListView, Views.ViewGroup)
if (list != null) {
val frontNode = AccessibilityUtil.findFrontNode(list)
val textViewList = AccessibilityUtil.findAllOnceByClazz(frontNode, Views.TextView)
if (textViewList.size >= 2) {
val searchButton: AccessibilityNodeInfo = textViewList[textViewList.size - 2]
val multiButton: AccessibilityNodeInfo = textViewList[textViewList.size - 1]
AccessibilityUtil.performClick(multiButton)
sleep(Constant.POP_WINDOW_INTERVAL)
val list = AccessibilityUtil.findAllByClazz(getRoot(), Views.ListView).lastOrNull()
if (list != null) {
if (AccessibilityUtil.findTextAndClick(list, "扫一扫", exact = true)) {
AccessibilityExtraUtil.loadingPage("LoginScannerActivity")
if (AccessibilityExtraUtil.loadingPage("LoginPcActivity")) {
if (AccessibilityUtil.findTextAndClick(getRoot(), "登录", exact = true)) {
LogUtils.i("点击登录")
uploadCommandResult(message, ExecCallbackBean.SUCCESS, "点击登录", startTime)
return true
} else {
LogUtils.e("未找到登录按钮")
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到登录按钮", startTime)
return false
}
} else {
LogUtils.e("未找到确认登录页")
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到确认登录页", startTime)
return false
}
} else {
LogUtils.e("未找到扫一扫按钮")
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到扫一扫按钮", startTime)
return false
}
} else {
LogUtils.e("未找到扫一扫列表")
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到扫一扫列表", startTime)
return false
}
} else {
LogUtils.e("未找到搜索按钮")
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到搜索按钮", startTime)
return false
}
} else {
LogUtils.e("未找到聊天列表")
uploadCommandResult(message, ExecCallbackBean.ERROR_BUTTON, "未找到聊天列表", startTime)
return false
}
}
/** /**
* 展示群信息 * 展示群信息
* @see WeworkMessageBean.SHOW_GROUP_INFO * @see WeworkMessageBean.SHOW_GROUP_INFO
@@ -2500,7 +2580,7 @@ object WeworkOperationImpl {
/** /**
* 获取群二维码并上传后台 * 获取群二维码并上传后台
*/ */
fun getGroupQrcode(groupName: String, groupRemark: String?): Boolean { private fun getGroupQrcode(groupName: String, groupRemark: String?): Boolean {
if (!Constant.groupQrCode) return true if (!Constant.groupQrCode) return true
if (AccessibilityUtil.findOneByText(getRoot(), "全部群成员", "微信用户创建", timeout = Constant.CHANGE_PAGE_INTERVAL) != null || if (AccessibilityUtil.findOneByText(getRoot(), "全部群成员", "微信用户创建", timeout = Constant.CHANGE_PAGE_INTERVAL) != null ||
(WeworkRoomUtil.intoRoom(groupName) && WeworkRoomUtil.intoGroupManager())) { (WeworkRoomUtil.intoRoom(groupName) && WeworkRoomUtil.intoGroupManager())) {

View File

@@ -0,0 +1,41 @@
package org.yameida.worktool.utils
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.ShellUtils
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
/**
* 系统属性工具类
*/
object PropUtil {
const val propVideo = "persist.lg.sourc_video"
fun getProp(propName: String = propVideo) {
try {
val process = Runtime.getRuntime().exec("getprop $propName")
val ir = InputStreamReader(process.inputStream)
val input = BufferedReader(ir)
var str: String? = null
while (input.readLine().also { str = it } != null) {
LogUtils.i("$propName: $str")
}
} catch (e: IOException) {
e.printStackTrace()
}
}
fun setProp(propName: String = propVideo, propValue: String = "/storage/emulated/0/Download/1.mp4") {
try {
ShellUtils.execCmd("setprop $propName $propValue", true, false)
} catch (e: IOException) {
e.printStackTrace()
} catch (e: InterruptedException) {
e.printStackTrace()
}
getProp(propName)
}
}