diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/AllowBindAppWidgetActivity.java | 4 | ||||
-rw-r--r-- | src/com/android/settings/BugreportPreference.java | 61 | ||||
-rw-r--r-- | src/com/android/settings/DeviceInfoSettings.java | 8 | ||||
-rw-r--r-- | src/com/android/settings/GoogleLocationSettingHelper.java | 129 | ||||
-rw-r--r-- | src/com/android/settings/LocationSettings.java | 110 |
5 files changed, 148 insertions, 164 deletions
diff --git a/src/com/android/settings/AllowBindAppWidgetActivity.java b/src/com/android/settings/AllowBindAppWidgetActivity.java index 2f54f8e..f05c1c2 100644 --- a/src/com/android/settings/AllowBindAppWidgetActivity.java +++ b/src/com/android/settings/AllowBindAppWidgetActivity.java @@ -57,8 +57,8 @@ public class AllowBindAppWidgetActivity extends AlertActivity implements try { mAppWidgetManager.bindAppWidgetId(mAppWidgetId, mComponentName); Intent result = new Intent(); - result.putExtra("EXTRA_APPWIDGET_ID", mAppWidgetId); - setResult(RESULT_OK); + result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); + setResult(RESULT_OK, result); } catch (Exception e) { Log.v("BIND_APPWIDGET", "Error binding widget with id " + mAppWidgetId + " and component " + mComponentName); diff --git a/src/com/android/settings/BugreportPreference.java b/src/com/android/settings/BugreportPreference.java new file mode 100644 index 0000000..e003d61 --- /dev/null +++ b/src/com/android/settings/BugreportPreference.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings; + +import android.app.AlertDialog.Builder; +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.os.SystemProperties; +import android.preference.DialogPreference; +import android.util.AttributeSet; +import android.view.View; + +public class BugreportPreference extends DialogPreference { + public BugreportPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onPrepareDialogBuilder(Builder builder) { + super.onPrepareDialogBuilder(builder); + builder.setPositiveButton(R.string.report, this); + builder.setMessage(R.string.bugreport_message); + } + + @Override + protected void showDialog(Bundle state) { + super.showDialog(state); + } + + @Override + protected void onBindDialogView(View view) { + super.onBindDialogView(view); + } + + @Override + protected void onDialogClosed(boolean positiveResult) { + super.onDialogClosed(positiveResult); + } + + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_POSITIVE) { + SystemProperties.set("ctl.start", "bugreport"); + } + } +} diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 152b8e2..3847862 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -62,6 +62,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { private static final String KEY_BASEBAND_VERSION = "baseband_version"; private static final String KEY_FIRMWARE_VERSION = "firmware_version"; private static final String KEY_UPDATE_SETTING = "additional_system_update_settings"; + private static final String KEY_EQUIPMENT_ID = "fcc_equipment_id"; + private static final String PROPERTY_EQUIPMENT_ID = "ro.ril.fccid"; long[] mHits = new long[3]; @@ -75,6 +77,8 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { findPreference(KEY_FIRMWARE_VERSION).setEnabled(true); setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband"); setStringSummary(KEY_DEVICE_MODEL, Build.MODEL + getMsvSuffix()); + setValueSummary(KEY_EQUIPMENT_ID, PROPERTY_EQUIPMENT_ID); + setStringSummary(KEY_DEVICE_MODEL, Build.MODEL); setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY); findPreference(KEY_KERNEL_VERSION).setSummary(getFormattedKernelVersion()); @@ -94,6 +98,10 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal", PROPERTY_URL_SAFETYLEGAL); + // Remove Equipment id preference if FCC ID is not set by RIL + removePreferenceIfPropertyMissing(getPreferenceScreen(), KEY_EQUIPMENT_ID, + PROPERTY_EQUIPMENT_ID); + // Remove Baseband version if wifi-only device if (Utils.isWifiOnly(getActivity())) { getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION)); diff --git a/src/com/android/settings/GoogleLocationSettingHelper.java b/src/com/android/settings/GoogleLocationSettingHelper.java deleted file mode 100644 index be4a02c..0000000 --- a/src/com/android/settings/GoogleLocationSettingHelper.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.settings; - -import android.content.ActivityNotFoundException; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.database.Cursor; -import android.net.Uri; -import android.util.Log; - -/** - * Helper class to read and write the 'Use My Location' setting used by Google Apps (e.g. GoogleQSB, - * VoiceSearch). - * - * This class duplicates a small amount of functionality from GSF (Google Services Framework) to - * allow the open source Settings app to interface to the 'Use My Location' setting owned by GSF. - */ -public class GoogleLocationSettingHelper { - - private static final String TAG = "GoogleLocationSettingHelper"; - - /** - * User has disagreed to use location for Google services. - */ - public static final int USE_LOCATION_FOR_SERVICES_OFF = 0; - - /** - * User has agreed to use location for Google services. - */ - public static final int USE_LOCATION_FOR_SERVICES_ON = 1; - - /** - * The user has neither agreed nor disagreed to use location for Google services yet. - */ - public static final int USE_LOCATION_FOR_SERVICES_NOT_SET = 2; - - private static final String GOOGLE_SETTINGS_AUTHORITY = "com.google.settings"; - private static final Uri GOOGLE_SETTINGS_CONTENT_URI = - Uri.parse("content://" + GOOGLE_SETTINGS_AUTHORITY + "/partner"); - private static final String NAME = "name"; - private static final String VALUE = "value"; - private static final String USE_LOCATION_FOR_SERVICES = "use_location_for_services"; - - private static final String ACTION_SET_USE_LOCATION_FOR_SERVICES = - "com.google.android.gsf.action.SET_USE_LOCATION_FOR_SERVICES"; - public static final String EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES = "disable"; - - /** - * Determine if the 'Use My Location' setting is applicable on this device, i.e. if the - * activity used to enabled/disable it is present. - */ - public static boolean isAvailable(Context context) { - ResolveInfo ri = context.getPackageManager().resolveActivity(getSetUseLocationIntent(), - PackageManager.MATCH_DEFAULT_ONLY); - return ri != null; - } - - private static Intent getSetUseLocationIntent() { - Intent i = new Intent(ACTION_SET_USE_LOCATION_FOR_SERVICES); - return i; - } - - /** - * Get the current value for the 'Use value for location' setting. - * @return One of {@link #USE_LOCATION_FOR_SERVICES_NOT_SET}, - * {@link #USE_LOCATION_FOR_SERVICES_OFF} or {@link #USE_LOCATION_FOR_SERVICES_ON}. - */ - public static int getUseLocationForServices(Context context) { - ContentResolver resolver = context.getContentResolver(); - Cursor c = null; - String stringValue = null; - try { - c = resolver.query(GOOGLE_SETTINGS_CONTENT_URI, new String[] { VALUE }, NAME + "=?", - new String[] { USE_LOCATION_FOR_SERVICES }, null); - if (c != null && c.moveToNext()) { - stringValue = c.getString(0); - } - } catch (RuntimeException e) { - Log.w(TAG, "Failed to get 'Use My Location' setting", e); - } finally { - if (c != null) { - c.close(); - } - } - if (stringValue == null) { - return USE_LOCATION_FOR_SERVICES_NOT_SET; - } - int value; - try { - value = Integer.parseInt(stringValue); - } catch (NumberFormatException nfe) { - value = USE_LOCATION_FOR_SERVICES_NOT_SET; - } - return value; - } - - /** - * Change the value of the 'Use My Location' setting. This launches a GSF activity which has - * the permissions to actually make the change, prompting the user if necessary. - */ - public static void setUseLocationForServices(Context context, boolean use) { - Intent i = getSetUseLocationIntent(); - i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - i.putExtra(EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES, !use); - try { - context.startActivity(i); - } catch (ActivityNotFoundException e) { - Log.e("GoogleLocationSettingHelper", "Problem while starting GSF location activity"); - } - } - -} diff --git a/src/com/android/settings/LocationSettings.java b/src/com/android/settings/LocationSettings.java index 5301db1..d5c4d9f 100644 --- a/src/com/android/settings/LocationSettings.java +++ b/src/com/android/settings/LocationSettings.java @@ -19,14 +19,18 @@ package com.android.settings; import android.content.ContentQueryMap; import android.content.ContentResolver; +import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.location.LocationManager; import android.preference.CheckBoxPreference; import android.preference.Preference; -import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceScreen; +import android.preference.SwitchPreference; import android.provider.Settings; +import android.util.AttributeSet; +import android.view.View; +import android.widget.TextView; import java.util.Observable; import java.util.Observer; @@ -35,18 +39,18 @@ import java.util.Observer; * Gesture lock pattern settings. */ public class LocationSettings extends SettingsPreferenceFragment - implements OnPreferenceChangeListener { + implements Preference.OnPreferenceChangeListener { // Location Settings + private static final String KEY_LOCATION_TOGGLE = "location_toggle"; private static final String KEY_LOCATION_NETWORK = "location_network"; private static final String KEY_LOCATION_GPS = "location_gps"; private static final String KEY_ASSISTED_GPS = "assisted_gps"; - private static final String KEY_USE_LOCATION = "location_use_for_services"; private CheckBoxPreference mNetwork; private CheckBoxPreference mGps; private CheckBoxPreference mAssistedGps; - private CheckBoxPreference mUseLocation; + private SwitchPreference mLocationAccess; // These provide support for receiving notification when Location Manager settings change. // This is necessary because the Network Location Provider can change settings @@ -82,24 +86,12 @@ public class LocationSettings extends SettingsPreferenceFragment addPreferencesFromResource(R.xml.location_settings); root = getPreferenceScreen(); + mLocationAccess = (SwitchPreference) root.findPreference(KEY_LOCATION_TOGGLE); mNetwork = (CheckBoxPreference) root.findPreference(KEY_LOCATION_NETWORK); mGps = (CheckBoxPreference) root.findPreference(KEY_LOCATION_GPS); mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS); - if (GoogleLocationSettingHelper.isAvailable(getActivity())) { - // GSF present, Add setting for 'Use My Location' - CheckBoxPreference useLocation = new CheckBoxPreference(getActivity()); - useLocation.setKey(KEY_USE_LOCATION); - useLocation.setTitle(R.string.use_location_title); - useLocation.setSummary(R.string.use_location_summary); - useLocation.setChecked( - GoogleLocationSettingHelper.getUseLocationForServices(getActivity()) - == GoogleLocationSettingHelper.USE_LOCATION_FOR_SERVICES_ON); - useLocation.setPersistent(false); - useLocation.setOnPreferenceChangeListener(this); - getPreferenceScreen().addPreference(useLocation); - mUseLocation = useLocation; - } + mLocationAccess.setOnPreferenceChangeListener(this); return root; } @@ -125,19 +117,19 @@ public class LocationSettings extends SettingsPreferenceFragment @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { - + final ContentResolver cr = getContentResolver(); if (preference == mNetwork) { - Settings.Secure.setLocationProviderEnabled(getContentResolver(), + Settings.Secure.setLocationProviderEnabled(cr, LocationManager.NETWORK_PROVIDER, mNetwork.isChecked()); } else if (preference == mGps) { boolean enabled = mGps.isChecked(); - Settings.Secure.setLocationProviderEnabled(getContentResolver(), + Settings.Secure.setLocationProviderEnabled(cr, LocationManager.GPS_PROVIDER, enabled); if (mAssistedGps != null) { mAssistedGps.setEnabled(enabled); } } else if (preference == mAssistedGps) { - Settings.Secure.putInt(getContentResolver(), Settings.Secure.ASSISTED_GPS_ENABLED, + Settings.Secure.putInt(cr, Settings.Secure.ASSISTED_GPS_ENABLED, mAssistedGps.isChecked() ? 1 : 0); } else { // If we didn't handle it, let preferences handle it. @@ -154,9 +146,11 @@ public class LocationSettings extends SettingsPreferenceFragment ContentResolver res = getContentResolver(); boolean gpsEnabled = Settings.Secure.isLocationProviderEnabled( res, LocationManager.GPS_PROVIDER); - mNetwork.setChecked(Settings.Secure.isLocationProviderEnabled( - res, LocationManager.NETWORK_PROVIDER)); + boolean networkEnabled = Settings.Secure.isLocationProviderEnabled( + res, LocationManager.NETWORK_PROVIDER); mGps.setChecked(gpsEnabled); + mNetwork.setChecked(networkEnabled); + mLocationAccess.setChecked(gpsEnabled || networkEnabled); if (mAssistedGps != null) { mAssistedGps.setChecked(Settings.Secure.getInt(res, Settings.Secure.ASSISTED_GPS_ENABLED, 2) == 1); @@ -173,16 +167,66 @@ public class LocationSettings extends SettingsPreferenceFragment createPreferenceHierarchy(); } - public boolean onPreferenceChange(Preference preference, Object value) { - if (preference == mUseLocation) { - boolean newValue = (value == null ? false : (Boolean) value); - GoogleLocationSettingHelper.setUseLocationForServices(getActivity(), newValue); - // We don't want to change the value immediately here, since the user may click - // disagree in the dialog that pops up. When the activity we just launched exits, this - // activity will be restated and the new value re-read, so the checkbox will get its - // new value then. - return false; + /** Enable or disable all providers when the master toggle is changed. */ + private void onToggleLocationAccess(boolean checked) { + final ContentResolver cr = getContentResolver(); + Settings.Secure.setLocationProviderEnabled(cr, + LocationManager.GPS_PROVIDER, checked); + Settings.Secure.setLocationProviderEnabled(cr, + LocationManager.NETWORK_PROVIDER, checked); + updateLocationToggles(); + } + + @Override + public boolean onPreferenceChange(Preference pref, Object newValue) { + if (pref.getKey().equals(KEY_LOCATION_TOGGLE)) { + onToggleLocationAccess((Boolean) newValue); } return true; } + +} + +class WrappingSwitchPreference extends SwitchPreference { + + public WrappingSwitchPreference(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public WrappingSwitchPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + + TextView title = (TextView) view.findViewById(android.R.id.title); + if (title != null) { + title.setSingleLine(false); + title.setMaxLines(3); + } + } +} + +class WrappingCheckBoxPreference extends CheckBoxPreference { + + public WrappingCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public WrappingCheckBoxPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onBindView(View view) { + super.onBindView(view); + + TextView title = (TextView) view.findViewById(android.R.id.title); + if (title != null) { + title.setSingleLine(false); + title.setMaxLines(3); + } + } } |