在新鲜的Android模拟器上禁用首次运行问候 [英] Disabling first-run greeter on fresh android emulator

查看:1077
本文介绍了在新鲜的Android模拟器上禁用首次运行问候的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个要求直接从启动器启动应用程序的测试.因为我无法通过意图启动来正确模拟它.

I am writing a test that requires launching application directly from launcher. Because I can't emulate it correctly by launching through intent.

问题是,当我在一个新的模拟器上运行测试时(我正在使用Travis CI,但可以在我的家用PC上轻松复制),该模拟器以首次运行"迎宾器覆盖层开始.这会阻止我的uiautomator代码正确启动该应用程序.

The problem is that when I am running the test on a fresh emulator (I am using Travis CI, but it can be easily reproduced on my home PC) the emulator starts with the "first run" greeter overlay. Which blocks my uiautomator code from correctly launching the application.

我试图添加一些代码以关闭该问候器,但是不幸的是,当我的问候器检测和关闭"代码已经停止工作并认为海岸很清楚时,它可能会延迟出现.

I have tried to add some code to close that greeter but unfortunately it can appear with some delay, when my "greeter detecting and closing" code has already stopped working thinking that the coast is clear.

有没有保证禁用该迎宾员的方法?某些偏爱也许只是一个可以可靠地杀死迎宾员的代码示例.

Is there any guaranteed way to disable that greeter? Some preference maybe or just an example of code that will reliably kill the greeter.

推荐答案

显然,迎宾员被称为保鲜".通过搜索(相当旧的)代码,我发现了以下内容:

Apparently the greeter is called "cling". Searching though (rather old) code I found the following:

下一站是位于isRunningInTestHarness()/4.0.2_r1/android/app/ActivityManager.java#ActivityManager.isRunningInTestHarness%28%29"rel =" nofollow> http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.2_r1/android/app/ActivityManager.java#ActivityManager.isRunningInTestHarness%28%29

And next stop is isRunningInTestHarness() at http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.2_r1/android/app/ActivityManager.java#ActivityManager.isRunningInTestHarness%28%29

public static boolean isRunningInTestHarness() {
    return SystemProperties.getBoolean("ro.test_harness", false);
}

反过来导致 adb shell setprop ro.test_harness true .哪个才行.

Which in turn leads to adb shell setprop ro.test_harness true. Which just works.

这篇关于在新鲜的Android模拟器上禁用首次运行问候的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆