Loading packages/SettingsProvider/res/values/defaults.xml +2 −5 Original line number Diff line number Diff line Loading @@ -40,11 +40,8 @@ <bool name="def_wifi_display_on">false</bool> <bool name="def_install_non_market_apps">false</bool> <bool name="def_package_verifier_enable">true</bool> <!-- Comma-separated list of location providers. Network location is off by default because it requires user opt-in via Setup Wizard or Settings. --> <string name="def_location_providers_allowed" translatable="false">gps</string> <!-- Comma-separated list of location providers --> <string name="def_location_providers_allowed" translatable="false">gps,network</string> <bool name="assisted_gps_enabled">true</bool> <bool name="def_netstats_enabled">true</bool> <bool name="def_usb_mass_storage_enabled">true</bool> Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +36 −1 Original line number Diff line number Diff line Loading @@ -3232,7 +3232,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 172; private static final int SETTINGS_VERSION = 173; private final int mUserId; Loading Loading @@ -4217,6 +4217,41 @@ public class SettingsProvider extends ContentProvider { currentVersion = 172; } if (currentVersion == 172) { // Version 172: Set the default value for Secure Settings: LOCATION_MODE final SettingsState secureSettings = getSecureSettingsLocked(userId); final Setting locationMode = secureSettings.getSettingLocked( Secure.LOCATION_MODE); if (locationMode.isNull()) { final Setting locationProvidersAllowed = secureSettings.getSettingLocked( Secure.LOCATION_PROVIDERS_ALLOWED); String defLocationMode = Integer.toString( !TextUtils.isEmpty(locationProvidersAllowed.getValue()) ? Secure.LOCATION_MODE_HIGH_ACCURACY : Secure.LOCATION_MODE_OFF); secureSettings.insertSettingLocked( Secure.LOCATION_MODE, defLocationMode, null, true, SettingsState.SYSTEM_PACKAGE_NAME); // also reset LOCATION_PROVIDERS_ALLOWED back to the default value - this // setting is now only for debug/test purposes, and will likely be removed // in a later release. LocationManagerService is responsible for adjusting // these settings to the proper state. String defLocationProvidersAllowed = getContext().getResources().getString( R.string.def_location_providers_allowed); secureSettings.insertSettingLocked( Secure.LOCATION_PROVIDERS_ALLOWED, defLocationProvidersAllowed, null, true, SettingsState.SYSTEM_PACKAGE_NAME); } currentVersion = 173; } // vXXX: Add new settings above this point. if (currentVersion != newVersion) { Loading services/core/java/com/android/server/LocationManagerService.java +11 −24 Original line number Diff line number Diff line Loading @@ -849,6 +849,15 @@ public class LocationManagerService extends ILocationManager.Stub { mAllowed = !mIsManagedBySettings; mEnabled = false; mProperties = null; if (mIsManagedBySettings) { // since we assume providers are disabled by default Settings.Secure.putStringForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-" + mName, mCurrentUserId); } } @GuardedBy("mLock") Loading Loading @@ -2900,33 +2909,11 @@ public class LocationManagerService extends ILocationManager.Stub { long identity = Binder.clearCallingIdentity(); try { boolean enabled; try { enabled = Settings.Secure.getIntForUser( return Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, userId) != Settings.Secure.LOCATION_MODE_OFF; } catch (Settings.SettingNotFoundException e) { // OS upgrade case where mode isn't set yet enabled = !TextUtils.isEmpty(Settings.Secure.getStringForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, userId)); try { Settings.Secure.putIntForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, enabled ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY : Settings.Secure.LOCATION_MODE_OFF, userId); } catch (RuntimeException ex) { // any problem with writing should not be propagated Slog.e(TAG, "error updating location mode", ex); } } return enabled; } finally { Binder.restoreCallingIdentity(identity); } Loading Loading
packages/SettingsProvider/res/values/defaults.xml +2 −5 Original line number Diff line number Diff line Loading @@ -40,11 +40,8 @@ <bool name="def_wifi_display_on">false</bool> <bool name="def_install_non_market_apps">false</bool> <bool name="def_package_verifier_enable">true</bool> <!-- Comma-separated list of location providers. Network location is off by default because it requires user opt-in via Setup Wizard or Settings. --> <string name="def_location_providers_allowed" translatable="false">gps</string> <!-- Comma-separated list of location providers --> <string name="def_location_providers_allowed" translatable="false">gps,network</string> <bool name="assisted_gps_enabled">true</bool> <bool name="def_netstats_enabled">true</bool> <bool name="def_usb_mass_storage_enabled">true</bool> Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +36 −1 Original line number Diff line number Diff line Loading @@ -3232,7 +3232,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 172; private static final int SETTINGS_VERSION = 173; private final int mUserId; Loading Loading @@ -4217,6 +4217,41 @@ public class SettingsProvider extends ContentProvider { currentVersion = 172; } if (currentVersion == 172) { // Version 172: Set the default value for Secure Settings: LOCATION_MODE final SettingsState secureSettings = getSecureSettingsLocked(userId); final Setting locationMode = secureSettings.getSettingLocked( Secure.LOCATION_MODE); if (locationMode.isNull()) { final Setting locationProvidersAllowed = secureSettings.getSettingLocked( Secure.LOCATION_PROVIDERS_ALLOWED); String defLocationMode = Integer.toString( !TextUtils.isEmpty(locationProvidersAllowed.getValue()) ? Secure.LOCATION_MODE_HIGH_ACCURACY : Secure.LOCATION_MODE_OFF); secureSettings.insertSettingLocked( Secure.LOCATION_MODE, defLocationMode, null, true, SettingsState.SYSTEM_PACKAGE_NAME); // also reset LOCATION_PROVIDERS_ALLOWED back to the default value - this // setting is now only for debug/test purposes, and will likely be removed // in a later release. LocationManagerService is responsible for adjusting // these settings to the proper state. String defLocationProvidersAllowed = getContext().getResources().getString( R.string.def_location_providers_allowed); secureSettings.insertSettingLocked( Secure.LOCATION_PROVIDERS_ALLOWED, defLocationProvidersAllowed, null, true, SettingsState.SYSTEM_PACKAGE_NAME); } currentVersion = 173; } // vXXX: Add new settings above this point. if (currentVersion != newVersion) { Loading
services/core/java/com/android/server/LocationManagerService.java +11 −24 Original line number Diff line number Diff line Loading @@ -849,6 +849,15 @@ public class LocationManagerService extends ILocationManager.Stub { mAllowed = !mIsManagedBySettings; mEnabled = false; mProperties = null; if (mIsManagedBySettings) { // since we assume providers are disabled by default Settings.Secure.putStringForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "-" + mName, mCurrentUserId); } } @GuardedBy("mLock") Loading Loading @@ -2900,33 +2909,11 @@ public class LocationManagerService extends ILocationManager.Stub { long identity = Binder.clearCallingIdentity(); try { boolean enabled; try { enabled = Settings.Secure.getIntForUser( return Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, userId) != Settings.Secure.LOCATION_MODE_OFF; } catch (Settings.SettingNotFoundException e) { // OS upgrade case where mode isn't set yet enabled = !TextUtils.isEmpty(Settings.Secure.getStringForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, userId)); try { Settings.Secure.putIntForUser( mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, enabled ? Settings.Secure.LOCATION_MODE_HIGH_ACCURACY : Settings.Secure.LOCATION_MODE_OFF, userId); } catch (RuntimeException ex) { // any problem with writing should not be propagated Slog.e(TAG, "error updating location mode", ex); } } return enabled; } finally { Binder.restoreCallingIdentity(identity); } Loading