简体   繁体   English

使用shell或/和uiautomator检查主屏幕是否处于前台

[英]Check that homescreen is in foreground using shell or/and uiautomator

Maybe some value in dumpsys (had no success to find such)? 也许dumpsys有一些价值(找不到这样的成功)?

Or as kind of partial workaround check default launcher and then check that it's in foreground? 还是作为部分解决方法,请检查默认启动器,然后检查其是否在前台? But how to check what app is default launcher then? 但是,如何检查默认启动器是哪个应用程序呢?

Thanks 谢谢

dumpsys activity activities or dumpsys activity recents will give you the recent activities, and if the home screen is in the foreground, then its associated launcher would show up under the entries in Recent #0 . dumpsys activity activitiesdumpsys activity recents最近活动将为您提供最近的活动,如果主屏幕位于前台,则其关联的启动器将显示在“ Recent #0的条目下。

As for finding out the default launcher, you would need root access since the default app information is stored under /data/system/users/0/package-restrictions.xml ( source ), and the command would be: 至于找出默认的启动程序,您将需要root访问权限,因为默认的应用程序信息被存储在/data/system/users/0/package-restrictions.xml ),并命令将是:

cat package-restrictions.xml | grep -B6 "android.intent.category.HOME"

You have to look for the value: 您必须寻找值:

<item name="ginlemon.flowerpro/ginlemon.flower.HomeScreen" match="100000" set="3">

Change B6 to a bigger value if you don't see <item name= . 如果您没有看到<item name=请将B6更改为更大的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM