Android-Auto-Api icon indicating copy to clipboard operation
Android-Auto-Api copied to clipboard

基于fragment切换后无法拿到新显示内容

Open helloworld10010 opened this issue 1 year ago • 3 comments

切换后找不到按钮,明明在。已经使用android:accessibilityEventTypes="typeAllMask"

helloworld10010 avatar Jun 26 '23 08:06 helloworld10010

清除后台目标应用,从act.startActivity(act.packageManager.getLaunchIntentForPackage(TARGET_PROCESS))进去执行查找的找不到,手动打开目标应用home到后台,再执行自动程序就正常了。已经使用waitforApp act.startActivity(act.packageManager.getLaunchIntentForPackage(TARGET_PROCESS)) if(waitForApp(TARGET_PROCESS,5000).also { toast( if(it) "success" else "fail") })

helloworld10010 avatar Jun 26 '23 14:06 helloworld10010

试来试去,应该跟rootNodesOfAllWindows方法有关,不知道什么原理,改代码让它走<=LOLLIPOP分支就好了 小米6 MIUI11.0.5 android版本9 api28 compileSdk33 targetSdk31

helloworld10010 avatar Jun 26 '23 14:06 helloworld10010

试来试去,应该跟rootNodesOfAllWindows方法有关,不知道什么原理,改代码让它走<=LOLLIPOP分支就好了 小米6 MIUI11.0.5 android版本9 api28 compileSdk33 targetSdk31

哥们,怎么操作的?直接把

fun rootNodesOfAllWindows(): ViewChildList =
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ViewChildList().also { list ->
                    AutoApi.windows()?.sortedByDescending {
                        if (it.isActive) Int.MAX_VALUE else it.layer
                    }?.forEach { win ->
                        list.add(
                            win.root?.let { r -> ViewNode(r.also(AccessibilityNodeInfo::refresh)) }
                        )
                    } ?: list.add(activeWinNode())
                }
            } else {
                ViewChildList().also { list ->
                    list.add(activeWinNode())
                }
            }

改成

fun rootNodesOfAllWindows(): ViewChildList =
            ViewChildList().also { list ->
                AutoApi.windows()?.sortedByDescending {
                    if (it.isActive) Int.MAX_VALUE else it.layer
                }?.forEach { win ->
                    list.add(
                        win.root?.let { r -> ViewNode(r.also(AccessibilityNodeInfo::refresh)) }
                    )
                } ?: list.add(activeWinNode())
            }

吗?其他的不用动?还是继续用SF去查找控件吗?

dujianchi avatar Nov 11 '23 13:11 dujianchi