1、测试android.webkit.cts.GeolocationTest Fail
提示:
cts-tf > run cts --class android.webkit.cts.GeolocationTest
12-13 16:55:23 I/TestInvocation: Starting invocation for 'cts' on build '4.4_r3' on device 385b4e4a
12-13 16:55:23 I/385b4e4a: Created result dir 2014.12.13_16.55.23
12-13 16:55:34 I/385b4e4a: Collecting device info
12-13 16:55:35 I/385b4e4a: -----------------------------------------
12-13 16:55:35 I/385b4e4a: Test package android.webkit started
12-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 setting
at 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 := true
tags_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=0
else # !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_DE