From 75360a9fa2fcead8b516467d982c5cdf82c63263 Mon Sep 17 00:00:00 2001 From: Runt <qingingrunt2010@qq.com> Date: Sun, 15 May 2022 06:44:38 +0000 Subject: [PATCH] 歌词解析 修复及优化 handler 阻塞问题优化 --- app/src/main/java/com/auto/lyric/service/AutoInputService.java | 32 ++++++++++++++++++-------------- 1 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/auto/lyric/service/AutoInputService.java b/app/src/main/java/com/auto/lyric/service/AutoInputService.java index c68f2c6..9e90755 100644 --- a/app/src/main/java/com/auto/lyric/service/AutoInputService.java +++ b/app/src/main/java/com/auto/lyric/service/AutoInputService.java @@ -129,19 +129,21 @@ * 点击弹出 edit弹框 */ private void clickEdit(){ - List<AccessibilityNodeInfo> list = getRootInActiveWindow().findAccessibilityNodeInfosByText("说点什么..."); - Log.e(TAG,"获取到控件 "+list.size()); - if (list != null && list.size() > 0 && flag) { - //模拟第三方点击事件 - //找到你的节点以后 就直接点击他就行了 - //AccessibilityNodeInfo node = list.get(0); - list.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - Log.e(TAG,"执行点击 "+list.get(0).getPaneTitle()); + try{ + List<AccessibilityNodeInfo> list = getRootInActiveWindow().findAccessibilityNodeInfosByText("说点什么..."); + Log.e(TAG,"获取到控件 "+list.size()); + if (list != null && list.size() > 0 && flag) { + //模拟第三方点击事件 + //找到你的节点以后 就直接点击他就行了 + //AccessibilityNodeInfo node = list.get(0); + list.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + Log.e(TAG,"执行点击 "+list.get(0).getPaneTitle()); + } + }else if(flag){ + //Toast.makeText(getBaseContext(),"未找到控件",Toast.LENGTH_SHORT).show(); } - }else if(flag){ - //Toast.makeText(getBaseContext(),"未找到控件",Toast.LENGTH_SHORT).show(); - } + }catch ( Exception e){} } @SuppressLint("NewApi") @@ -176,8 +178,8 @@ @SuppressLint("NewApi") private AccessibilityNodeInfo getViewByDesc(AccessibilityNodeInfo node, String desc){ try{ - Log.e(TAG,desc +" getViewByDesc id:"+node.getViewIdResourceName() +" class:"+node.getClassName()+" text:"+node.getText()+" "+node.getContentDescription()); - Log.e(TAG,"getViewByDesc node:"+node); + //Log.e(TAG,desc +" getViewByDesc id:"+node.getViewIdResourceName() +" class:"+node.getClassName()+" text:"+node.getText()+" "+node.getContentDescription()); + //Log.e(TAG,"getViewByDesc node:"+node); if(node.getChildCount() > 0){ for(int i = 0 ; i < node.getChildCount() ; i ++){ if(node.getChild(i) != null) { @@ -209,7 +211,9 @@ @Override public void onInterrupt() { + Log.e(TAG,"onInterrupt 服务停止"); unregisterReceiver(receiver); + Toast.makeText(getBaseContext(),"服务停止",Toast.LENGTH_SHORT).show(); } @Override protected void onServiceConnected() { -- Gitblit v1.9.1