[GTS] GtsPackageManagerHostTestCases
com.google.android.pm.gts.PackageManagerHostTest#testSoundPool failed
套件版本:6.0_R1
问题描述:
com.google.android.pm.gts.PackageManagerHostTest#testSoundPool fail
junit.framework.AssertionFailedError: Instant App should be able to access Media / DrmManager.
logcat:
07-23 23:38:37.483 296 296 E SELinux : avc: denied { find } for service=drm.drmManager pid=6532 uid=10185 scontext=u:r:ephemeral_app:s0:c512,c768 tcontext=u:object_r:drmserver_service:s0 tclass=service_manager permissive=0
07-23 23:38:37.484 6532 6550 I ServiceManager: Waiting for service drm.drmManager...
07-23 23:38:37.622 332 352 I powerd : [powerd_req] POWER_MSG_QUERY_INFO: cmd:6, param:0
07-23 23:38:37.695 818 901 D MtkDataShapingUtils: openLteGateByDataShaping datashaping instance is null
07-23 23:38:38.486 296 296 E SELinux : avc: denied { find } for service=drm.drmManager pid=6532 uid=10185 scontext=u:r:ephemeral_app:s0:c512,c768 tcontext=u:object_r:drmserver_service:s0 tclass=service_manager permissive=0
07-23 23:38:38.487 6532 6550 I ServiceManager: Waiting for service drm.drmManager...
07-23 23:38:38.905 818 923 D WifiStateMachine: MtkL2ConnectedState { when=-3ms what=131155 arg1=1 target=com.android.internal.util.StateMachine$SmHandler } 1 0, mShouldDeferDisableWifi = false, mWaitForWfcNotify = false
07-23 23:38:39.437 5911 5911 W MessengerIpcClient: Received response for unknown request: 1
07-23 23:38:39.488 296 296 E SELinux : avc: denied { find } for service=drm.drmManager pid=6532 uid=10185 scontext=u:r:ephemeral_app:s0:c512,c768 tcontext=u:object_r:drmserver_service:s0 tclass=service_manager permissive=0
07-23 23:38:39.489 6532 6550 W DrmManagerClientImpl(Native): DrmManagerService not published, waiting...
07-23 23:38:39.493 3323 6395 I System.out: [OkHttp] sendRequest<<
07-23 23:38:39.646 332 352 I powerd : [powerd_req] POWER_MSG_QUERY_INFO: cmd:6, param:0
07-23 23:38:39.991 296 296 E SELinux : avc: denied { find } for service=drm.drmManager pid=6532 uid=10185 scontext=u:r:ephemeral_app:s0:c512,c768 tcontext=u:object_r:drmserver_service:s0 tclass=service_manager permissive=0
07-23 23:38:39.992 6532 6550 I ServiceManager: Waiting for service drm.drmManager...
07-23 23:38:40.480 6532 6546 I TestRunner: failed: testSoundPool(com.google.android.gts.packagemanager.InstantAppTestCases)
07-23 23:38:40.480 6532 6546 I TestRunner: ----- begin exception -----
07-23 23:38:40.481 6532 6546 I TestRunner: java.lang.AssertionError: Instant App should be able to access Media / DrmManager.
07-23 23:38:40.481 6532 6546 I TestRunner: Please apply patches r.android.com/502604, SHA d2b3a45, and SHA b93f049
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.Assert.fail(Assert.java:88)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.Assert.assertTrue(Assert.java:41)
07-23 23:38:40.481 6532 6546 I TestRunner: at com.google.android.gts.packagemanager.InstantAppTestCases.testSoundPool(InstantAppTestCases.java:199)
07-23 23:38:40.481 6532 6546 I TestRunner: at java.lang.reflect.Method.invoke(Native Method)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:52)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:148)
07-23 23:38:40.481 6532 6546 I TestRunner: at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:142)
07-23 23:38:40.481 6532 6546 I TestRunner: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
07-23 23:38:40.481 6532 6546 I TestRunner: at java.lang.Thread.run(Thread.java:764)
07-23 23:38:40.482 6532 6546 I TestRunner: ----- end exception -----
07-23 23:38:40.485 6532 6546 I TestRunner: finished: testSoundPool(com.google.android.gts.packagemanager.InstantAppTestCases)
07-23 23:38:40.507 6532 6532 I MonitoringInstr: Activities that are still in CREATED to STOPPED: 0
07-23 23:38:40.509 6532 6546 I TestRunner: run finished: 1 tests, 1 failed, 0 ignored
从test result以及logcat看测试失败的原因是:没有 access Media / DrmManager的权限
发现log中的avc信息:
07-23 23:38:37.483 296 296 E SELinux : avc: denied { find } for service=drm.drmManager pid=6532 uid=10185 scontext=u:r:ephemeral_app:s0:c512,c768 tcontext=u:object_r:drmserver_service:s0 tclass=service_manager permissive=0
那我们测试此项gts前执行 adb shell setenforce 0
, 然后执行gts命令:run gts -m GtsPackageManagerHostTestCases -t com.google.android.pm.gts.PackageManagerHostTest#testSoundPool
,结果是pass.可以确定原因,需要添加权限,根据avc log,需添加如下信息到ephemeral_app.te中:
allow ephemeral_app drmserver_service:service_manager { find };
完成添加编译版本测试OK