標籤:cts gms fail android
1、測試android.webkit.cts.GeolocationTest Fail
提示:
cts-tf > run cts --class android.webkit.cts.GeolocationTest12-13 16:55:23 I/TestInvocation: Starting invocation for 'cts' on build '4.4_r3' on device 385b4e4a12-13 16:55:23 I/385b4e4a: Created result dir 2014.12.13_16.55.2312-13 16:55:34 I/385b4e4a: Collecting device info12-13 16:55:35 I/385b4e4a: -----------------------------------------12-13 16:55:35 I/385b4e4a: Test package android.webkit started12-13 16:55:35 I/385b4e4a: -----------------------------------------12-13 16:55:38 I/385b4e4a: android.webkit.cts.GeolocationTest#testGeolocationPermissions FAIL java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure settingat android.os.Parcel.readException(Parcel.java:1480)at android.os.Parcel.readException(Parcel.java:1429)at android.location.ILocationManager$Stub$Proxy.addTestProvider(ILocationManager.java:944)at android.location.LocationManager.addTestProvider(LocationManager.java:1205)at android.webkit.cts.GeolocationTest.addTestProviders(GeolocationTest.java:188)at android.webkit.cts.GeolocationTest.setUp(GeolocationTest.java:166)at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
提示沒有相關的許可權
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
如果在《開發人員選項》中《允許類比位置》的開關沒有開啟,即使加上也是會報錯,這個開關的預設值是在/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java中進行設定
// Allow mock locations default, based on build loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);而ro.allow.mock.location的值是以下設定檔中設定的
檔案位於:/build/core.main.mk
## user/userdebug ##user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))enable_target_debugging := truetags_to_install :=ifneq (,$(user_variant)) # Target is secure in user builds. ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1 ifeq ($(user_variant),userdebug) # Pick up some extra useful tools tags_to_install += debug # Enable Dalvik lock contention logging for userdebug builds. ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500 else # Disable debugging in plain user builds. enable_target_debugging := endif # Turn on Dalvik preoptimization for libdvm.so user builds, but only if not # explicitly disabled and the build is running on Linux (since host # Dalvik isn't built for non-Linux hosts). ifeq (,$(WITH_DEXPREOPT)) ifeq ($(DALVIK_VM_LIB),libdvm.so) ifeq ($(user_variant),user) ifeq ($(HOST_OS),linux) WITH_DEXPREOPT := true endif endif endif endif # Disallow mock locations by default for user builds ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0else # !user_variant # Turn on checkjni for non-user builds. ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1 # Set device insecure for non-user builds. ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0 # Allow mock locations by default for non user builds ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1endif # !user_variant
當然修改這個CTS Fail有兩種方法
1、修改DatabaseHelper.java檔案
loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION, 1);
2、修改main.mk檔案
# Disallow mock locations by default for user builds ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
如果需要驗證可以手動開啟
Android4.4 CTS測試Fail項修改總結(一)