设置GPS需要系统权限:
GPS设置在settingprovider数据库的字段是 不是LOCATION_MODE而是 LOCATION_PROVIDERS_ALLOWED,
但用户在设置的时候是使用
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY);
系统内部会将数值转换成字符串
/** @hide */
public static boolean putStringForUser(ContentResolver resolver, String name, String value,
int userHandle) {
if (LOCATION_MODE.equals(name)) {
// HACK ALERT: temporary hack to work around b/10491283.
// TODO: once b/10491283 fixed, remove this hack
return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle);
}
if (MOVED_TO_GLOBAL.contains(name)) {
Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System"
+ " to android.provider.Settings.Global");
return Global.putStringForUser(resolver, name, value, userHandle);
}
return sNameValueCache.putStringForUser(resolver, name, value, userHandle);
}
如果用户直接调用
Settings.Secure.setLocationProviderEnabledForUser(
cr, LocationManager.NETWORK_PROVIDER, network, userId)
这语句是不会起作用的。
总结:
系统默认关闭GPS,在settingsprovder apk当中的 LOCATION_PROVIDERS_ALLOWED字符处理