Krosxx / Android-Auto-Api

安卓无障碍服务Api, 为了简化无障碍服务使用,并使用 Kotlin 以提供简洁的Api。
Apache License 2.0
418 stars 72 forks source link

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

Open helloworld10010 opened 1 year ago

helloworld10010 commented 1 year ago

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

helloworld10010 commented 1 year ago

清除后台目标应用,从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 commented 1 year ago

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

dujianchi commented 7 months ago

试来试去,应该跟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去查找控件吗?