解决CTS测试项testIsUserAMonkey
来源:互联网 发布:好听的翻唱知乎 编辑:程序博客网 时间:2024/06/06 16:48
Android cts 测试中有一项测试testIsUserAMonkey
host_log如下:
02-16 09:57:53 I/00003c591ec7205b: android.app.cts.ActivityManagerTest#testIsUserAMonkey FAIL
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:48)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertFalse(Assert.java:34)
at junit.framework.Assert.assertFalse(Assert.java:41)
at android.app.cts.ActivityManagerTest.testIsUserAMonkey(ActivityManagerTest.java:367)
at java.lang.reflect.Method.invoke(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:115)
at android.support.test.internal.runner.junit3.AndroidTestResult.runProtected(AndroidTestResult.java:77)
at junit.framework.TestResult.run(TestResult.java:118)
at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:55)
at junit.framework.TestCase.run(TestCase.java:124)
at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
at android.support.test.internal.runner.junit3.AndroidTestSuite$1.run(AndroidTestSuite.java:98)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
查cts源码ests/tests/app/src/android/app/cts/ActivityManagerTest.java找到测试项
361 /**
362 * Simple test for {@link ActivityManager.isUserAMonkey()} - verifies its false.
363 *
364 * TODO: test positive case
365 */
366 public void testIsUserAMonkey() {
367 assertFalse(ActivityManager.isUserAMonkey());
368 }
根据isUserAMonkey函数在framework下grep -nr isUserAMonkey找到该函数的最终实现
base/services/core/java/com/android/server/am/ActivityManagerService.java:10797
10797 public boolean isUserAMonkey() {
10798 synchronized (this) {
10799 // If there is a controller also implies the user is a monkey.
10800 return (mUserIsMonkey || mController != null);
10801 }
10802 }
可以知道判断isUserAMonkey是mUserIsMonkey 和mController 决定。
在isUserAMonkey函数中加打印发现mUserIsMonkey 值不论fail或者pass都是false.而mController 会是!=null。
进而找到设置mController 函数setActivityController。
在framework层使用命令grep -nr setActivityController
会找到base/core/java/android/app/ActivityManagerNative.java中有这个函数
public void setActivityController(IActivityController watcher) throws RemoteException{}
在这个函数中添加Log.i("xxx", "native setActivityController----",new RuntimeException("here").fillInStackTrace());
打印调用此函数的堆栈信息。
测试后可以在logcat中找到堆栈信息。
最后发现是我们的一个系统应用在开机调用android.app.ActivityManagerProxy.setActivityController
埋了一周的坑被填了。
- 解决CTS测试项testIsUserAMonkey
- android CTS测试FAIL项解决集锦
- android CTS和GTS测试FAIL项解决集锦
- cts 测试
- cts 测试
- CTS测试
- CTS 测试
- CTS测试
- cts测试
- android CTS和GTS测试FAIL项解决集锦 (转)
- android.hardware.cts.SensorTest测试项出现的Timed out问题如何解决?
- Adroid 4.2 CTS测试 fail项汇总
- CTS中的camera相关测试项
- android cts测试失败项以及原因
- Android CTS 测试研究
- Android的CTS测试
- Android的CTS测试
- Android CTS 测试 过程
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this a
- 使用Eclipse的Working Set,界面清爽多了
- Spring注解@Component、@Repository、@Service、@Controller区别
- 一维数组、二维数组、字符数组的&、sizeof等操作
- maven环境变量的配置及+eclipse的配置使用
- 解决CTS测试项testIsUserAMonkey
- 在iOS 8中使用UIAlertController
- iOS-iOS内购流程(手把手图文教程)
- 什么是抽象类
- 2 find命令之xargs
- poj3233Matrix Power Series (等比矩阵求和)
- 459. Repeated Substring Pattern
- Android 使用DialogFragment创建对话框
- Hive总结(零)Hive的基础知识