diff options
author | Amith Yamasani <yamasani@google.com> | 2011-03-02 12:53:31 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-03-02 12:53:31 -0800 |
commit | 0c62c6449bf2c0954653b996a3bfb269a64c6562 (patch) | |
tree | 2e4d31f60828bd986ed3605ff320cc46ff53d300 /src/com/android | |
parent | 302b0572075e90ffe2004ca5999f3c3a3753189e (diff) | |
parent | 38d3353e37be450b1b95d2525acbd53e9b67130e (diff) | |
download | packages_apps_Settings-0c62c6449bf2c0954653b996a3bfb269a64c6562.tar.gz packages_apps_Settings-0c62c6449bf2c0954653b996a3bfb269a64c6562.tar.bz2 packages_apps_Settings-0c62c6449bf2c0954653b996a3bfb269a64c6562.zip |
am 38d3353e: am 03e90322: Merge "Remove more entries not relevant to wifi-only devices." into honeycomb
* commit '38d3353e37be450b1b95d2525acbd53e9b67130e':
Remove more entries not relevant to wifi-only devices.
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/settings/DateTimeSettings.java | 7 | ||||
-rw-r--r-- | src/com/android/settings/DeviceInfoSettings.java | 25 | ||||
-rw-r--r-- | src/com/android/settings/Utils.java | 26 | ||||
-rw-r--r-- | src/com/android/settings/deviceinfo/Status.java | 123 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/BatteryHistoryChart.java | 33 | ||||
-rw-r--r-- | src/com/android/settings/fuelgauge/PowerUsageSummary.java | 5 | ||||
-rw-r--r-- | src/com/android/settings/wifi/AdvancedSettings.java | 12 |
7 files changed, 158 insertions, 73 deletions
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java index f1edbb91e..64f42a0fc 100644 --- a/src/com/android/settings/DateTimeSettings.java +++ b/src/com/android/settings/DateTimeSettings.java @@ -87,6 +87,12 @@ public class DateTimeSettings extends SettingsPreferenceFragment mAutoTimePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME); mAutoTimePref.setChecked(autoTimeEnabled); mAutoTimeZonePref = (CheckBoxPreference) findPreference(KEY_AUTO_TIME_ZONE); + // Override auto-timezone if it's a wifi-only device. + // TODO: Remove this when auto-timezone is implemented based on wifi-location. + if (Utils.isWifiOnly()) { + getPreferenceScreen().removePreference(mAutoTimeZonePref); + autoTimeZoneEnabled = false; + } mAutoTimeZonePref.setChecked(autoTimeZoneEnabled); mTimePref = findPreference("time"); @@ -125,7 +131,6 @@ public class DateTimeSettings extends SettingsPreferenceFragment mTimeZone.setEnabled(!autoTimeZoneEnabled); } - @Override public void onResume() { super.onResume(); diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java index 2bd861029..c3fe955d3 100644 --- a/src/com/android/settings/DeviceInfoSettings.java +++ b/src/com/android/settings/DeviceInfoSettings.java @@ -39,6 +39,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class DeviceInfoSettings extends SettingsPreferenceFragment { + private static final String TAG = "DeviceInfoSettings"; private static final String KEY_CONTAINER = "container"; @@ -49,6 +50,11 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { private static final String KEY_COPYRIGHT = "copyright"; private static final String KEY_SYSTEM_UPDATE_SETTINGS = "system_update_settings"; private static final String PROPERTY_URL_SAFETYLEGAL = "ro.url.safetylegal"; + private static final String KEY_KERNEL_VERSION = "kernel_version"; + private static final String KEY_BUILD_NUMBER = "build_number"; + private static final String KEY_DEVICE_MODEL = "device_model"; + private static final String KEY_BASEBAND_VERSION = "baseband_version"; + private static final String KEY_FIRMWARE_VERSION = "firmware_version"; long[] mHits = new long[3]; @@ -69,17 +75,22 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { getPreferenceScreen().removePreference(findPreference("system_tutorial")); } - setStringSummary("firmware_version", Build.VERSION.RELEASE); - findPreference("firmware_version").setEnabled(true); - setValueSummary("baseband_version", "gsm.version.baseband"); - setStringSummary("device_model", Build.MODEL); - setStringSummary("build_number", Build.DISPLAY); - findPreference("kernel_version").setSummary(getFormattedKernelVersion()); + setStringSummary(KEY_FIRMWARE_VERSION, Build.VERSION.RELEASE); + findPreference(KEY_FIRMWARE_VERSION).setEnabled(true); + setValueSummary(KEY_BASEBAND_VERSION, "gsm.version.baseband"); + setStringSummary(KEY_DEVICE_MODEL, Build.MODEL); + setStringSummary(KEY_BUILD_NUMBER, Build.DISPLAY); + findPreference(KEY_KERNEL_VERSION).setSummary(getFormattedKernelVersion()); // Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set removePreferenceIfPropertyMissing(getPreferenceScreen(), "safetylegal", PROPERTY_URL_SAFETYLEGAL); + // Remove Baseband version if wifi-only device + if (Utils.isWifiOnly()) { + getPreferenceScreen().removePreference(findPreference(KEY_BASEBAND_VERSION)); + } + /* * Settings is a generic app and should not contain any device-specific * info. @@ -107,7 +118,7 @@ public class DeviceInfoSettings extends SettingsPreferenceFragment { @Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { - if (preference.getKey().equals("firmware_version")) { + if (preference.getKey().equals(KEY_FIRMWARE_VERSION)) { System.arraycopy(mHits, 1, mHits, 0, mHits.length-1); mHits[mHits.length-1] = SystemClock.uptimeMillis(); if (mHits[0] >= (SystemClock.uptimeMillis()-500)) { diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index dd80222ab..18c6159f2 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -25,6 +25,8 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.drawable.Drawable; +import android.net.ConnectivityManager; +import android.net.LinkProperties; import android.os.Bundle; import android.os.SystemProperties; import android.preference.Preference; @@ -33,6 +35,8 @@ import android.preference.PreferenceActivity.Header; import android.telephony.TelephonyManager; import android.text.TextUtils; +import java.net.InetAddress; +import java.util.Iterator; import java.util.List; public class Utils { @@ -282,4 +286,26 @@ public class Utils { public static boolean isWifiOnly() { return "wifi-only".equals(SystemProperties.get("ro.carrier")); } + + /** + * Returns the WIFI IP Addresses, if any, taking into account IPv4 and IPv6 style addresses. + * @param context the application context + * @return the formatted and comma-separated IP addresses, or null if none. + */ + public static String getWifiIpAddresses(Context context) { + ConnectivityManager cm = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); + LinkProperties prop = cm.getLinkProperties(ConnectivityManager.TYPE_WIFI); + if (prop == null) return null; + Iterator<InetAddress> iter = prop.getAddresses().iterator(); + // If there are no entries, return null + if (!iter.hasNext()) return null; + // Concatenate all available addresses, comma separated + String addresses = ""; + while (iter.hasNext()) { + addresses += iter.next().getHostAddress(); + if (iter.hasNext()) addresses += ", "; + } + return addresses; + } } diff --git a/src/com/android/settings/deviceinfo/Status.java b/src/com/android/settings/deviceinfo/Status.java index a8f7e4fa9..999c765f7 100644 --- a/src/com/android/settings/deviceinfo/Status.java +++ b/src/com/android/settings/deviceinfo/Status.java @@ -64,6 +64,7 @@ import java.lang.ref.WeakReference; */ public class Status extends PreferenceActivity { + private static final String KEY_DATA_STATE = "data_state"; private static final String KEY_SERVICE_STATE = "service_state"; private static final String KEY_OPERATOR_NAME = "operator_name"; private static final String KEY_ROAMING_STATE = "roaming_state"; @@ -77,10 +78,26 @@ public class Status extends PreferenceActivity { private static final String KEY_SIGNAL_STRENGTH = "signal_strength"; private static final String KEY_BATTERY_STATUS = "battery_status"; private static final String KEY_BATTERY_LEVEL = "battery_level"; + private static final String KEY_WIFI_IP_ADDRESS = "wifi_ip_address"; private static final String KEY_WIFI_MAC_ADDRESS = "wifi_mac_address"; private static final String KEY_BT_ADDRESS = "bt_address"; private static final String KEY_SERIAL_NUMBER = "serial_number"; + private static final String[] PHONE_RELATED_ENTRIES = { + KEY_DATA_STATE, + KEY_SERVICE_STATE, + KEY_OPERATOR_NAME, + KEY_ROAMING_STATE, + KEY_NETWORK_TYPE, + KEY_PHONE_NUMBER, + KEY_IMEI, + KEY_IMEI_SV, + KEY_PRL_VERSION, + KEY_MIN_NUMBER, + KEY_MEID_NUMBER, + KEY_SIGNAL_STRENGTH + }; + private static final int EVENT_SIGNAL_STRENGTH_CHANGED = 200; private static final int EVENT_SERVICE_STATE_CHANGED = 300; @@ -200,42 +217,49 @@ public class Status extends PreferenceActivity { mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH); mUptime = findPreference("up_time"); - //NOTE "imei" is the "Device ID" since it represents the IMEI in GSM and the MEID in CDMA - if (mPhone.getPhoneName().equals("CDMA")) { - setSummaryText(KEY_MEID_NUMBER, mPhone.getMeid()); - setSummaryText(KEY_MIN_NUMBER, mPhone.getCdmaMin()); - setSummaryText(KEY_PRL_VERSION, mPhone.getCdmaPrlVersion()); - - // device is not GSM/UMTS, do not display GSM/UMTS features - // check Null in case no specified preference in overlay xml - removePreferenceFromScreen(KEY_IMEI); - removePreferenceFromScreen(KEY_IMEI_SV); + if (Utils.isWifiOnly()) { + for (String key : PHONE_RELATED_ENTRIES) { + removePreferenceFromScreen(key); + } } else { - setSummaryText(KEY_IMEI, mPhone.getDeviceId()); - - setSummaryText(KEY_IMEI_SV, - ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)) - .getDeviceSoftwareVersion()); + // NOTE "imei" is the "Device ID" since it represents + // the IMEI in GSM and the MEID in CDMA + if (mPhone.getPhoneName().equals("CDMA")) { + setSummaryText(KEY_MEID_NUMBER, mPhone.getMeid()); + setSummaryText(KEY_MIN_NUMBER, mPhone.getCdmaMin()); + setSummaryText(KEY_PRL_VERSION, mPhone.getCdmaPrlVersion()); + + // device is not GSM/UMTS, do not display GSM/UMTS features + // check Null in case no specified preference in overlay xml + removePreferenceFromScreen(KEY_IMEI); + removePreferenceFromScreen(KEY_IMEI_SV); + } else { + setSummaryText(KEY_IMEI, mPhone.getDeviceId()); + + setSummaryText(KEY_IMEI_SV, + ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)) + .getDeviceSoftwareVersion()); + + // device is not CDMA, do not display CDMA features + // check Null in case no specified preference in overlay xml + removePreferenceFromScreen(KEY_PRL_VERSION); + removePreferenceFromScreen(KEY_MEID_NUMBER); + removePreferenceFromScreen(KEY_MIN_NUMBER); + } - // device is not CDMA, do not display CDMA features - // check Null in case no specified preference in overlay xml - removePreferenceFromScreen(KEY_PRL_VERSION); - removePreferenceFromScreen(KEY_MEID_NUMBER); - removePreferenceFromScreen(KEY_MIN_NUMBER); - } + String rawNumber = mPhone.getLine1Number(); // may be null or empty + String formattedNumber = null; + if (!TextUtils.isEmpty(rawNumber)) { + formattedNumber = PhoneNumberUtils.formatNumber(rawNumber); + } + // If formattedNumber is null or empty, it'll display as "Unknown". + setSummaryText(KEY_PHONE_NUMBER, formattedNumber); - String rawNumber = mPhone.getLine1Number(); // may be null or empty - String formattedNumber = null; - if (!TextUtils.isEmpty(rawNumber)) { - formattedNumber = PhoneNumberUtils.formatNumber(rawNumber); + mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler); + mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED); + mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED); } - // If formattedNumber is null or empty, it'll display as "Unknown". - setSummaryText(KEY_PHONE_NUMBER, formattedNumber); - mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler); - mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED); - mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED); - setWifiStatus(); setBtStatus(); @@ -251,16 +275,17 @@ public class Status extends PreferenceActivity { protected void onResume() { super.onResume(); - mPhoneStateReceiver.registerIntent(); - registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); - - updateSignalStrength(); - updateServiceState(mPhone.getServiceState()); - updateDataState(); - - mTelephonyManager.listen(mPhoneStateListener, - PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); + if (!Utils.isWifiOnly()) { + mPhoneStateReceiver.registerIntent(); + + updateSignalStrength(); + updateServiceState(mPhone.getServiceState()); + updateDataState(); + mTelephonyManager.listen(mPhoneStateListener, + PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); + } + registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); mHandler.sendEmptyMessage(EVENT_UPDATE_STATS); } @@ -268,8 +293,10 @@ public class Status extends PreferenceActivity { public void onPause() { super.onPause(); - mPhoneStateReceiver.unregisterIntent(); - mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); + if (!Utils.isWifiOnly()) { + mPhoneStateReceiver.unregisterIntent(); + mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); + } unregisterReceiver(mBatteryInfoReceiver); mHandler.removeMessages(EVENT_UPDATE_STATS); } @@ -333,7 +360,7 @@ public class Status extends PreferenceActivity { break; } - setSummaryText("data_state", display); + setSummaryText(KEY_DATA_STATE, display); } private void updateServiceState(ServiceState serviceState) { @@ -392,7 +419,7 @@ public class Status extends PreferenceActivity { + r.getString(R.string.radioInfo_display_asu)); } } - + private void setWifiStatus() { WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); @@ -401,6 +428,14 @@ public class Status extends PreferenceActivity { String macAddress = wifiInfo == null ? null : wifiInfo.getMacAddress(); wifiMacAddressPref.setSummary(!TextUtils.isEmpty(macAddress) ? macAddress : getString(R.string.status_unavailable)); + + Preference wifiIpAddressPref = findPreference(KEY_WIFI_IP_ADDRESS); + String ipAddress = Utils.getWifiIpAddresses(this); + if (ipAddress != null) { + wifiIpAddressPref.setSummary(ipAddress); + } else { + wifiIpAddressPref.setSummary(getString(R.string.status_unavailable)); + } } private void setBtStatus() { diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java index 23107da8f..97ebf43cc 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java @@ -173,6 +173,7 @@ public class BatteryHistoryChart extends View { int mBatHigh; boolean mHaveWifi; boolean mHaveGps; + boolean mHavePhoneSignal; public BatteryHistoryChart(Context context, AttributeSet attrs) { super(context, attrs); @@ -377,7 +378,9 @@ public class BatteryHistoryChart extends View { mNumHist = lastInteresting; mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0; mHaveWifi = (aggrStates&HistoryItem.STATE_WIFI_RUNNING_FLAG) != 0; - + if (!com.android.settings.Utils.isWifiOnly()) { + mHavePhoneSignal = true; + } if (mHistEnd <= mHistStart) mHistEnd = mHistStart+1; mTotalDurationString = Utils.formatElapsedTime(getContext(), mHistEnd - mHistStart); } @@ -421,7 +424,9 @@ public class BatteryHistoryChart extends View { if (lastWakeLock) { mWakeLockPath.lineTo(w, h-mWakeLockOffset); } - mPhoneSignalChart.finish(w); + if (mHavePhoneSignal) { + mPhoneSignalChart.finish(w); + } } @Override @@ -467,15 +472,19 @@ public class BatteryHistoryChart extends View { mWifiRunningOffset = mWakeLockOffset + barOffset; mGpsOnOffset = mWifiRunningOffset + (mHaveWifi ? barOffset : 0); mPhoneSignalOffset = mGpsOnOffset + (mHaveGps ? barOffset : 0); - mLevelOffset = mPhoneSignalOffset + barOffset + mLineWidth; - mPhoneSignalChart.init(w); + mLevelOffset = mPhoneSignalOffset + (mHavePhoneSignal ? barOffset : 0) + mLineWidth; + if (mHavePhoneSignal) { + mPhoneSignalChart.init(w); + } } else { mScreenOnOffset = mGpsOnOffset = mWifiRunningOffset = mWakeLockOffset = mLineWidth; mChargingOffset = mLineWidth*2; mPhoneSignalOffset = 0; mLevelOffset = mLineWidth*3; - mPhoneSignalChart.init(0); + if (mHavePhoneSignal) { + mPhoneSignalChart.init(0); + } } mBatLevelPath.reset(); @@ -597,7 +606,7 @@ public class BatteryHistoryChart extends View { lastWakeLock = wakeLock; } - if (mLargeMode) { + if (mLargeMode && mHavePhoneSignal) { int bin; if (((rec.states&HistoryItem.STATE_PHONE_STATE_MASK) >> HistoryItem.STATE_PHONE_STATE_SHIFT) @@ -661,8 +670,10 @@ public class BatteryHistoryChart extends View { if (!mBatCriticalPath.isEmpty()) { canvas.drawPath(mBatCriticalPath, mBatteryCriticalPaint); } - int top = height-mPhoneSignalOffset - (mLineWidth/2); - mPhoneSignalChart.draw(canvas, top, mLineWidth); + int top = height - (mHavePhoneSignal ? mPhoneSignalOffset - (mLineWidth/2) : 0); + if (mHavePhoneSignal) { + mPhoneSignalChart.draw(canvas, top, mLineWidth); + } if (!mScreenOnPath.isEmpty()) { canvas.drawPath(mScreenOnPath, mScreenOnPaint); } @@ -684,8 +695,10 @@ public class BatteryHistoryChart extends View { } if (mLargeMode) { - canvas.drawText(mPhoneSignalLabel, 0, - height - mPhoneSignalOffset - mTextDescent, mTextPaint); + if (mHavePhoneSignal) { + canvas.drawText(mPhoneSignalLabel, 0, + height - mPhoneSignalOffset - mTextDescent, mTextPaint); + } if (mHaveGps) { canvas.drawText(mGpsOnLabel, 0, height - mGpsOnOffset - mTextDescent, mTextPaint); diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index c5cba039c..fc903eb33 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -684,7 +684,10 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable { addWiFiUsage(uSecNow); addBluetoothUsage(uSecNow); addIdleUsage(uSecNow); // Not including cellular idle power - addRadioUsage(uSecNow); + // Don't compute radio usage if it's a wifi-only device + if (!com.android.settings.Utils.isWifiOnly()) { + addRadioUsage(uSecNow); + } } private BatterySipper addEntry(String label, DrainType drainType, long time, int iconId, diff --git a/src/com/android/settings/wifi/AdvancedSettings.java b/src/com/android/settings/wifi/AdvancedSettings.java index d5d55b1a7..faea9f25b 100644 --- a/src/com/android/settings/wifi/AdvancedSettings.java +++ b/src/com/android/settings/wifi/AdvancedSettings.java @@ -18,6 +18,7 @@ package com.android.settings.wifi; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.Utils; import android.app.Activity; import android.content.Context; @@ -103,16 +104,7 @@ public class AdvancedSettings extends SettingsPreferenceFragment : getActivity().getString(R.string.status_unavailable)); Preference wifiIpAddressPref = findPreference(KEY_CURRENT_IP_ADDRESS); - String ipAddress = null; - if (wifiInfo != null) { - long addr = wifiInfo.getIpAddress(); - if (addr != 0) { - // handle negative values whe first octet > 127 - if (addr < 0) addr += 0x100000000L; - ipAddress = String.format("%d.%d.%d.%d", - addr & 0xFF, (addr >> 8) & 0xFF, (addr >> 16) & 0xFF, (addr >> 24) & 0xFF); - } - } + String ipAddress = Utils.getWifiIpAddresses(getActivity()); wifiIpAddressPref.setSummary(ipAddress == null ? getActivity().getString(R.string.status_unavailable) : ipAddress); } |