summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/AccessibilitySettings.java2
-rw-r--r--src/com/android/settings/BatteryInfo.java3
-rw-r--r--src/com/android/settings/BrightnessPreference.java25
-rw-r--r--src/com/android/settings/BugreportPreference.java4
-rw-r--r--src/com/android/settings/DataUsageSummary.java8
-rw-r--r--src/com/android/settings/DevelopmentSettings.java40
-rw-r--r--src/com/android/settings/DisplaySettings.java9
-rw-r--r--src/com/android/settings/DreamComponentPreference.java4
-rw-r--r--src/com/android/settings/DreamSettings.java142
-rw-r--r--src/com/android/settings/DreamTesterPreference.java59
-rw-r--r--src/com/android/settings/RadioInfo.java35
-rw-r--r--src/com/android/settings/SecuritySettings.java10
-rw-r--r--src/com/android/settings/Settings.java11
-rw-r--r--src/com/android/settings/TetherSettings.java10
-rw-r--r--src/com/android/settings/Utils.java14
-rw-r--r--src/com/android/settings/applications/ApplicationsState.java5
-rw-r--r--src/com/android/settings/applications/InstalledAppDetails.java43
-rw-r--r--src/com/android/settings/applications/ManageApplications.java3
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/A2dpProfile.java58
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java15
-rw-r--r--src/com/android/settings/bluetooth/BluetoothDiscoverableTimeoutReceiver.java87
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/BluetoothEventManager.java5
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothSettings.java2
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/CachedBluetoothDevice.java33
-rw-r--r--src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java14
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/HeadsetProfile.java72
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/HidProfile.java47
-rw-r--r--src/com/android/settings/bluetooth/LocalBluetoothPreferences.java7
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/LocalBluetoothProfile.java0
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java27
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/OppProfile.java0
-rwxr-xr-xsrc/com/android/settings/bluetooth/PBAPServerProfile.java142
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/PanProfile.java37
-rw-r--r--src/com/android/settings/bluetooth/RequestPermissionActivity.java6
-rw-r--r--src/com/android/settings/deviceinfo/PercentageBarChart.java63
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageSummary.java42
-rw-r--r--src/com/android/settings/nfc/AndroidBeam.java2
-rw-r--r--src/com/android/settings/tts/TextToSpeechSettings.java11
-rw-r--r--src/com/android/settings/tts/TtsEnginePreference.java8
-rw-r--r--src/com/android/settings/tts/TtsEngineSettingsFragment.java76
-rw-r--r--src/com/android/settings/users/UserDetailsSettings.java130
-rw-r--r--src/com/android/settings/users/UserSettings.java16
-rw-r--r--src/com/android/settings/vpn2/VpnDialog.java1
-rw-r--r--src/com/android/settings/vpn2/VpnProfile.java121
-rw-r--r--src/com/android/settings/vpn2/VpnSettings.java1
-rw-r--r--src/com/android/settings/widget/ChartView.java2
-rw-r--r--src/com/android/settings/widget/SettingsAppWidgetProvider.java58
-rw-r--r--src/com/android/settings/wifi/AdvancedWifiSettings.java10
-rw-r--r--src/com/android/settings/wifi/WifiSettings.java24
-rw-r--r--src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java7
-rw-r--r--src/com/android/settings/wifi/WpsDialog.java6
51 files changed, 1030 insertions, 527 deletions
diff --git a/src/com/android/settings/AccessibilitySettings.java b/src/com/android/settings/AccessibilitySettings.java
index 8cb04cc..4047555 100644
--- a/src/com/android/settings/AccessibilitySettings.java
+++ b/src/com/android/settings/AccessibilitySettings.java
@@ -586,7 +586,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
activity.getActionBar().setCustomView(toggleSwitch,
new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+ Gravity.CENTER_VERTICAL | Gravity.END));
return toggleSwitch;
}
diff --git a/src/com/android/settings/BatteryInfo.java b/src/com/android/settings/BatteryInfo.java
index d8046cf..ccad236 100644
--- a/src/com/android/settings/BatteryInfo.java
+++ b/src/com/android/settings/BatteryInfo.java
@@ -102,6 +102,9 @@ public class BatteryInfo extends Activity {
case BatteryManager.BATTERY_PLUGGED_USB:
mPower.setText(getString(R.string.battery_info_power_usb));
break;
+ case BatteryManager.BATTERY_PLUGGED_WIRELESS:
+ mPower.setText(getString(R.string.battery_info_power_wireless));
+ break;
case (BatteryManager.BATTERY_PLUGGED_AC|BatteryManager.BATTERY_PLUGGED_USB):
mPower.setText(getString(R.string.battery_info_power_ac_usb));
break;
diff --git a/src/com/android/settings/BrightnessPreference.java b/src/com/android/settings/BrightnessPreference.java
index eff5c50..a80ceb9 100644
--- a/src/com/android/settings/BrightnessPreference.java
+++ b/src/com/android/settings/BrightnessPreference.java
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.IPowerManager;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.preference.SeekBarDialogPreference;
@@ -37,6 +38,8 @@ import android.widget.SeekBar;
public class BrightnessPreference extends SeekBarDialogPreference implements
SeekBar.OnSeekBarChangeListener, CheckBox.OnCheckedChangeListener {
+ private final int mScreenBrightnessMinimum;
+ private final int mScreenBrightnessMaximum;
private SeekBar mSeekBar;
private CheckBox mCheckBox;
@@ -51,12 +54,6 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
private boolean mRestoredOldState;
- // Backlight range is from 0 - 255. Need to make sure that user
- // doesn't set the backlight to 0 and get stuck
- private int mScreenBrightnessDim =
- getContext().getResources().getInteger(com.android.internal.R.integer.config_screenBrightnessDim);
- private static final int MAXIMUM_BACKLIGHT = android.os.PowerManager.BRIGHTNESS_ON;
-
private static final int SEEK_BAR_RANGE = 10000;
private ContentObserver mBrightnessObserver = new ContentObserver(new Handler()) {
@@ -77,6 +74,10 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
public BrightnessPreference(Context context, AttributeSet attrs) {
super(context, attrs);
+ PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
+ mScreenBrightnessMinimum = pm.getMinimumScreenBrightnessSetting();
+ mScreenBrightnessMaximum = pm.getMaximumScreenBrightnessSetting();
+
mAutomaticAvailable = context.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
@@ -155,8 +156,8 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
} else {
brightness = mCurBrightness;
}
- brightness = (brightness - mScreenBrightnessDim)
- / (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
+ brightness = (brightness - mScreenBrightnessMinimum)
+ / (mScreenBrightnessMaximum - mScreenBrightnessMinimum);
}
return (int)(brightness*SEEK_BAR_RANGE);
}
@@ -218,7 +219,7 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
IPowerManager power = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
if (power != null) {
- power.setAutoBrightnessAdjustment(valf);
+ power.setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(valf);
}
if (write) {
final ContentResolver resolver = getContext().getContentResolver();
@@ -229,13 +230,13 @@ public class BrightnessPreference extends SeekBarDialogPreference implements
}
}
} else {
- int range = (MAXIMUM_BACKLIGHT - mScreenBrightnessDim);
- brightness = (brightness*range)/SEEK_BAR_RANGE + mScreenBrightnessDim;
+ int range = (mScreenBrightnessMaximum - mScreenBrightnessMinimum);
+ brightness = (brightness * range)/SEEK_BAR_RANGE + mScreenBrightnessMinimum;
try {
IPowerManager power = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
if (power != null) {
- power.setBacklightBrightness(brightness);
+ power.setTemporaryScreenBrightnessSettingOverride(brightness);
}
if (write) {
mCurBrightness = -1;
diff --git a/src/com/android/settings/BugreportPreference.java b/src/com/android/settings/BugreportPreference.java
index e003d61..ba58ef4 100644
--- a/src/com/android/settings/BugreportPreference.java
+++ b/src/com/android/settings/BugreportPreference.java
@@ -33,8 +33,8 @@ public class BugreportPreference extends DialogPreference {
@Override
protected void onPrepareDialogBuilder(Builder builder) {
super.onPrepareDialogBuilder(builder);
- builder.setPositiveButton(R.string.report, this);
- builder.setMessage(R.string.bugreport_message);
+ builder.setPositiveButton(com.android.internal.R.string.report, this);
+ builder.setMessage(com.android.internal.R.string.bugreport_message);
}
@Override
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 5e20a6e..d0ec1e7 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -85,7 +85,7 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
-import android.os.UserId;
+import android.os.UserHandle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.provider.Settings;
@@ -806,7 +806,7 @@ public class DataUsageSummary extends Fragment {
updateDetailData();
- if (UserId.isApp(appId) && !mPolicyManager.getRestrictBackground()
+ if (UserHandle.isApp(appId) && !mPolicyManager.getRestrictBackground()
&& isBandwidthControlEnabled() && hasReadyMobileRadio(context)) {
setPreferenceTitle(mAppRestrictView, R.string.data_usage_app_restrict_background);
setPreferenceSummary(mAppRestrictView,
@@ -1486,8 +1486,8 @@ public class DataUsageSummary extends Fragment {
for (int i = 0; i < size; i++) {
entry = stats.getValues(i, entry);
- final boolean isApp = UserId.isApp(entry.uid);
- final int appId = isApp ? UserId.getAppId(entry.uid) : entry.uid;
+ final boolean isApp = UserHandle.isApp(entry.uid);
+ final int appId = isApp ? UserHandle.getAppId(entry.uid) : entry.uid;
if (isApp || appId == UID_REMOVED || appId == UID_TETHERING) {
AppItem item = knownUids.get(appId);
if (item == null) {
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 46ffe83..97a6165 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -79,6 +79,7 @@ public class DevelopmentSettings extends PreferenceFragment
private static final String ENFORCE_READ_EXTERNAL = "enforce_read_external";
private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";
private static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw";
+ private static final String BUGREPORT_IN_POWER_KEY = "bugreport_in_power";
private static final String DEBUG_APP_KEY = "debug_app";
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
@@ -91,6 +92,7 @@ public class DevelopmentSettings extends PreferenceFragment
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
private static final String SHOW_HW_SCREEN_UPDATES_KEY = "show_hw_screen_udpates";
+ private static final String SHOW_HW_LAYERS_UPDATES_KEY = "show_hw_layers_udpates";
private static final String DEBUG_LAYOUT_KEY = "debug_layout";
private static final String WINDOW_ANIMATION_SCALE_KEY = "window_animation_scale";
private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
@@ -118,6 +120,7 @@ public class DevelopmentSettings extends PreferenceFragment
private boolean mDontPokeProperties;
private CheckBoxPreference mEnableAdb;
+ private CheckBoxPreference mBugreportInPower;
private CheckBoxPreference mKeepScreenOn;
private CheckBoxPreference mEnforceReadExternal;
private CheckBoxPreference mAllowMockLocation;
@@ -136,6 +139,7 @@ public class DevelopmentSettings extends PreferenceFragment
private CheckBoxPreference mForceHardwareUi;
private CheckBoxPreference mTrackFrameTime;
private CheckBoxPreference mShowHwScreenUpdates;
+ private CheckBoxPreference mShowHwLayersUpdates;
private CheckBoxPreference mDebugLayout;
private ListPreference mWindowAnimationScale;
private ListPreference mTransitionAnimationScale;
@@ -170,6 +174,7 @@ public class DevelopmentSettings extends PreferenceFragment
addPreferencesFromResource(R.xml.development_prefs);
mEnableAdb = findAndInitCheckboxPref(ENABLE_ADB);
+ mBugreportInPower = findAndInitCheckboxPref(BUGREPORT_IN_POWER_KEY);
mKeepScreenOn = findAndInitCheckboxPref(KEEP_SCREEN_ON);
mEnforceReadExternal = findAndInitCheckboxPref(ENFORCE_READ_EXTERNAL);
mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
@@ -188,6 +193,7 @@ public class DevelopmentSettings extends PreferenceFragment
mForceHardwareUi = findAndInitCheckboxPref(FORCE_HARDWARE_UI_KEY);
mTrackFrameTime = findAndInitCheckboxPref(TRACK_FRAME_TIME_KEY);
mShowHwScreenUpdates = findAndInitCheckboxPref(SHOW_HW_SCREEN_UPDATES_KEY);
+ mShowHwLayersUpdates = findAndInitCheckboxPref(SHOW_HW_LAYERS_UPDATES_KEY);
mDebugLayout = findAndInitCheckboxPref(DEBUG_LAYOUT_KEY);
mWindowAnimationScale = (ListPreference) findPreference(WINDOW_ANIMATION_SCALE_KEY);
mAllPrefs.add(mWindowAnimationScale);
@@ -260,7 +266,7 @@ public class DevelopmentSettings extends PreferenceFragment
activity.getActionBar().setCustomView(mEnabledSwitch, new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+ Gravity.CENTER_VERTICAL | Gravity.END));
}
@Override
@@ -333,9 +339,11 @@ public class DevelopmentSettings extends PreferenceFragment
mHaveDebugSettings = false;
updateCheckBox(mEnableAdb, Settings.Secure.getInt(cr,
Settings.Secure.ADB_ENABLED, 0) != 0);
+ updateCheckBox(mBugreportInPower, Settings.Secure.getInt(cr,
+ Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0);
updateCheckBox(mKeepScreenOn, Settings.System.getInt(cr,
Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
- updateCheckBox(mEnforceReadExternal, isPermissionEnforced(context, READ_EXTERNAL_STORAGE));
+ updateCheckBox(mEnforceReadExternal, isPermissionEnforced(READ_EXTERNAL_STORAGE));
updateCheckBox(mAllowMockLocation, Settings.Secure.getInt(cr,
Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
updateHdcpValues();
@@ -349,6 +357,7 @@ public class DevelopmentSettings extends PreferenceFragment
updateHardwareUiOptions();
updateTrackFrameTimeOptions();
updateShowHwScreenUpdatesOptions();
+ updateShowHwLayersUpdatesOptions();
updateDebugLayoutOptions();
updateAnimationScaleOptions();
updateEnableTracesOptions();
@@ -581,7 +590,18 @@ public class DevelopmentSettings extends PreferenceFragment
private void writeShowHwScreenUpdatesOptions() {
SystemProperties.set(HardwareRenderer.DEBUG_DIRTY_REGIONS_PROPERTY,
- mShowHwScreenUpdates.isChecked() ? "true" : "false");
+ mShowHwScreenUpdates.isChecked() ? "true" : null);
+ pokeSystemProperties();
+ }
+
+ private void updateShowHwLayersUpdatesOptions() {
+ updateCheckBox(mShowHwLayersUpdates, SystemProperties.getBoolean(
+ HardwareRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, false));
+ }
+
+ private void writeShowHwLayersUpdatesOptions() {
+ SystemProperties.set(HardwareRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY,
+ mShowHwLayersUpdates.isChecked() ? "true" : null);
pokeSystemProperties();
}
@@ -705,7 +725,6 @@ public class DevelopmentSettings extends PreferenceFragment
}
private void updateEnableTracesOptions() {
- String strValue = SystemProperties.get(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS);
long flags = SystemProperties.getLong(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS, 0);
String[] values = mEnableTracesPref.getEntryValues();
int numSet = 0;
@@ -809,6 +828,10 @@ public class DevelopmentSettings extends PreferenceFragment
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.ADB_ENABLED, 0);
}
+ } else if (preference == mBugreportInPower) {
+ Settings.Secure.putInt(getActivity().getContentResolver(),
+ Settings.Secure.BUGREPORT_IN_POWER_MENU,
+ mBugreportInPower.isChecked() ? 1 : 0);
} else if (preference == mKeepScreenOn) {
Settings.System.putInt(getActivity().getContentResolver(),
Settings.System.STAY_ON_WHILE_PLUGGED_IN,
@@ -850,6 +873,8 @@ public class DevelopmentSettings extends PreferenceFragment
writeTrackFrameTimeOptions();
} else if (preference == mShowHwScreenUpdates) {
writeShowHwScreenUpdatesOptions();
+ } else if (preference == mShowHwLayersUpdates) {
+ writeShowHwLayersUpdatesOptions();
} else if (preference == mDebugLayout) {
writeDebugLayoutOptions();
}
@@ -941,6 +966,7 @@ public class DevelopmentSettings extends PreferenceFragment
void pokeSystemProperties() {
if (!mDontPokeProperties) {
+ //noinspection unchecked
(new SystemPropPoker()).execute();
}
}
@@ -970,7 +996,7 @@ public class DevelopmentSettings extends PreferenceFragment
}
/**
- * Dialog to confirm enforcement of {@link #READ_EXTERNAL_STORAGE}.
+ * Dialog to confirm enforcement of {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}.
*/
public static class ConfirmEnforceFragment extends DialogFragment {
public static void show(DevelopmentSettings parent) {
@@ -1005,9 +1031,9 @@ public class DevelopmentSettings extends PreferenceFragment
}
}
- private static boolean isPermissionEnforced(Context context, String permission) {
+ private static boolean isPermissionEnforced(String permission) {
try {
- return ActivityThread.getPackageManager().isPermissionEnforced(READ_EXTERNAL_STORAGE);
+ return ActivityThread.getPackageManager().isPermissionEnforced(permission);
} catch (RemoteException e) {
throw new RuntimeException("Problem talking with PackageManager", e);
}
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index fc162e2..c71f886 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -232,10 +232,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
}
private void updateScreenSaverSummary() {
+ boolean activatedOnSleep = DreamSettings.isScreenSaverActivatedOnSleep(getActivity());
+ boolean activatedOnDock = DreamSettings.isScreenSaverActivatedOnDock(getActivity());
mScreenSaverPreference.setSummary(
- DreamSettings.isScreenSaverEnabled(mScreenSaverPreference.getContext())
- ? R.string.screensaver_settings_summary_on
- : R.string.screensaver_settings_summary_off);
+ activatedOnSleep && activatedOnDock ? R.string.screensaver_settings_summary_both :
+ activatedOnSleep ? R.string.screensaver_settings_summary_sleep :
+ activatedOnDock ? R.string.screensaver_settings_summary_dock :
+ R.string.screensaver_settings_summary_off);
}
private void updateAccelerometerRotationCheckbox() {
diff --git a/src/com/android/settings/DreamComponentPreference.java b/src/com/android/settings/DreamComponentPreference.java
index 2114dd1..1b70db1 100644
--- a/src/com/android/settings/DreamComponentPreference.java
+++ b/src/com/android/settings/DreamComponentPreference.java
@@ -80,7 +80,9 @@ public class DreamComponentPreference extends Preference {
ServiceManager.getService("dreams"));
try {
cn = dm.getDreamComponent();
- } catch (RemoteException ex) {
+ } catch (RemoteException ex) { }
+
+ if (cn == null) {
setSummary("(unknown)");
return;
}
diff --git a/src/com/android/settings/DreamSettings.java b/src/com/android/settings/DreamSettings.java
index d9953aa..80b6a84 100644
--- a/src/com/android/settings/DreamSettings.java
+++ b/src/com/android/settings/DreamSettings.java
@@ -48,12 +48,19 @@ import java.util.ArrayList;
public class DreamSettings extends SettingsPreferenceFragment {
private static final String TAG = "DreamSettings";
+ private static final String KEY_ACTIVATE_ON_SLEEP = "activate_on_sleep";
private static final String KEY_ACTIVATE_ON_DOCK = "activate_on_dock";
+ private static final String KEY_COMPONENT = "screensaver_component";
+ private static final String KEY_TEST = "test";
- private CheckBoxPreference mActivateOnDockPreference;
+ private static final int DEFAULT_SLEEP = 0;
+ private static final int DEFAULT_DOCK = 1;
- private Switch mEnableSwitch;
- private Enabler mEnabler;
+ private ActivationSetting mActivateOnSleep;
+ private ActivationSetting mActivateOnDock;
+
+ private Preference mComponentPref;
+ private Preference mTestPref;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -61,99 +68,76 @@ public class DreamSettings extends SettingsPreferenceFragment {
addPreferencesFromResource(R.xml.dream_settings);
- mActivateOnDockPreference = (CheckBoxPreference) findPreference(KEY_ACTIVATE_ON_DOCK);
-
- final Activity activity = getActivity();
-
- mEnableSwitch = new Switch(activity);
-
- if (activity instanceof PreferenceActivity) {
- PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
- // note: we do not check onIsHidingHeaders() or onIsMultiPane() because there's no
- // switch in the left-hand pane to control this; we need to show the ON/OFF in our
- // fragment every time
- final int padding = activity.getResources().getDimensionPixelSize(
- R.dimen.action_bar_switch_padding);
- mEnableSwitch.setPadding(0, 0, padding, 0);
- activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
- ActionBar.DISPLAY_SHOW_CUSTOM);
- activity.getActionBar().setCustomView(mEnableSwitch, new ActionBar.LayoutParams(
- ActionBar.LayoutParams.WRAP_CONTENT,
- ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.RIGHT));
- activity.getActionBar().setTitle(R.string.screensaver_settings_title);
- }
+ mComponentPref = findPreference(KEY_COMPONENT);
+ mTestPref = findPreference(KEY_TEST);
- mEnabler = new Enabler(activity, mEnableSwitch);
+ mActivateOnSleep = new ActivationSetting(getActivity(),
+ SCREENSAVER_ENABLED, DEFAULT_SLEEP,
+ (CheckBoxPreference) findPreference(KEY_ACTIVATE_ON_SLEEP));
+ mActivateOnDock = new ActivationSetting(getActivity(),
+ SCREENSAVER_ACTIVATE_ON_DOCK, DEFAULT_DOCK,
+ (CheckBoxPreference) findPreference(KEY_ACTIVATE_ON_DOCK));
}
- public static boolean isScreenSaverEnabled(Context context) {
+ public static boolean isScreenSaverActivatedOnSleep(Context context) {
return 0 != Settings.Secure.getInt(
- context.getContentResolver(), SCREENSAVER_ENABLED, 1);
- }
-
- public static void setScreenSaverEnabled(Context context, boolean enabled) {
- Settings.Secure.putInt(
- context.getContentResolver(), SCREENSAVER_ENABLED, enabled ? 1 : 0);
+ context.getContentResolver(), SCREENSAVER_ENABLED, DEFAULT_SLEEP);
}
- public static class Enabler implements CompoundButton.OnCheckedChangeListener {
- private final Context mContext;
- private Switch mSwitch;
-
- public Enabler(Context context, Switch switch_) {
- mContext = context;
- setSwitch(switch_);
- }
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- setScreenSaverEnabled(mContext, isChecked);
- }
- public void setSwitch(Switch switch_) {
- if (mSwitch == switch_) return;
- if (mSwitch != null) mSwitch.setOnCheckedChangeListener(null);
- mSwitch = switch_;
- mSwitch.setOnCheckedChangeListener(this);
-
- final boolean enabled = isScreenSaverEnabled(mContext);
- mSwitch.setChecked(enabled);
- }
- public void pause() {
- mSwitch.setOnCheckedChangeListener(null);
- }
- public void resume() {
- mSwitch.setOnCheckedChangeListener(this);
- }
+ public static boolean isScreenSaverActivatedOnDock(Context context) {
+ return 0 != Settings.Secure.getInt(
+ context.getContentResolver(), SCREENSAVER_ACTIVATE_ON_DOCK, DEFAULT_DOCK);
}
@Override
public void onResume() {
- if (mEnabler != null) {
- mEnabler.resume();
- }
-
- final boolean currentActivateOnDock = 0 != Settings.Secure.getInt(getContentResolver(),
- SCREENSAVER_ACTIVATE_ON_DOCK, 1);
- mActivateOnDockPreference.setChecked(currentActivateOnDock);
+ mActivateOnSleep.onResume();
+ mActivateOnDock.onResume();
+ refreshDependents();
super.onResume();
}
@Override
- public void onPause() {
- if (mEnabler != null) {
- mEnabler.pause();
- }
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+ mActivateOnSleep.onClick(preference);
+ mActivateOnDock.onClick(preference);
+ refreshDependents();
+ return super.onPreferenceTreeClick(preferenceScreen, preference);
+ }
- super.onPause();
+ private void refreshDependents() {
+ boolean enabled = mActivateOnSleep.isSelected() || mActivateOnDock.isSelected();
+ mComponentPref.setEnabled(enabled);
+ mTestPref.setEnabled(enabled);
}
- @Override
- public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- if (preference == mActivateOnDockPreference) {
- Settings.Secure.putInt(getContentResolver(),
- SCREENSAVER_ACTIVATE_ON_DOCK,
- mActivateOnDockPreference.isChecked() ? 1 : 0);
+ private static class ActivationSetting {
+ private final Context mContext;
+ private final String mName;
+ private final int mDefaultValue;
+ private final CheckBoxPreference mPref;
+
+ ActivationSetting(Context context, String name, int defaultValue, CheckBoxPreference pref) {
+ mContext = context;
+ mName = name;
+ mDefaultValue = defaultValue;
+ mPref = pref;
+ }
+ public boolean isSelected() {
+ return mPref.isChecked();
+ }
+ void onClick(Preference preference) {
+ if (preference == mPref) {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ mName,
+ mPref.isChecked() ? 1 : 0);
+ }
+ }
+ void onResume() {
+ boolean currentActivated = 0 != Settings.Secure.getInt(mContext.getContentResolver(),
+ mName, mDefaultValue);
+ mPref.setChecked(currentActivated);
}
- return super.onPreferenceTreeClick(preferenceScreen, preference);
}
+
}
diff --git a/src/com/android/settings/DreamTesterPreference.java b/src/com/android/settings/DreamTesterPreference.java
index 87a142c..fa1d708 100644
--- a/src/com/android/settings/DreamTesterPreference.java
+++ b/src/com/android/settings/DreamTesterPreference.java
@@ -16,72 +16,33 @@
package com.android.settings;
-import static android.provider.Settings.Secure.SCREENSAVER_COMPONENT;
-
-import android.app.AlertDialog;
-import android.content.Context;
import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.res.Resources;
+import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.preference.Preference;
-import android.provider.Settings;
import android.service.dreams.IDreamManager;
import android.util.AttributeSet;
import android.util.Log;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.ListAdapter;
-import android.widget.TextView;
-
-import java.util.ArrayList;
-import java.util.List;
public class DreamTesterPreference extends Preference {
private static final String TAG = "DreamTesterPreference";
-
- private final PackageManager pm;
- private final ContentResolver resolver;
public DreamTesterPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- pm = getContext().getPackageManager();
- resolver = getContext().getContentResolver();
}
@Override
protected void onClick() {
- String component = Settings.Secure.getString(resolver, SCREENSAVER_COMPONENT);
- Log.v(TAG, "component=" + component);
- if (component != null) {
- ComponentName cn = ComponentName.unflattenFromString(component);
- Log.v(TAG, "cn=" + cn);
-// Intent intent = new Intent(Intent.ACTION_MAIN)
-// .setComponent(cn)
-// .addFlags(
-// Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
-// )
-// .putExtra("android.dreams.TEST", true);
-// getContext().startService(intent);
- IDreamManager dm = IDreamManager.Stub.asInterface(
- ServiceManager.getService("dreams"));
- try {
- dm.testDream(cn);
- } catch (RemoteException ex) {
- // too bad, so sad, oh mom, oh dad
- }
+ IDreamManager dm = IDreamManager.Stub.asInterface(ServiceManager.getService("dreams"));
+ try {
+ ComponentName cn = dm.getDreamComponent();
+ Log.v(TAG, "DreamComponent cn=" + cn);
+ dm.testDream(cn);
+ } catch (RemoteException ex) {
+ Log.w(TAG, "error testing dream", ex);
+ // too bad, so sad, oh mom, oh dad
}
}
+
}
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index 5ba3837..d72508a 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -33,6 +33,7 @@ import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
@@ -111,6 +112,7 @@ public class RadioInfo extends Activity {
private TextView mCfi;
private TextView mLocation;
private TextView mNeighboringCids;
+ private TextView mCellInfo;
private TextView resets;
private TextView attempts;
private TextView successes;
@@ -140,6 +142,7 @@ public class RadioInfo extends Activity {
private String mHttpClientTestResult;
private boolean mMwiValue = false;
private boolean mCfiValue = false;
+ private List<CellInfo> mCellInfoValue;
private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
@@ -171,6 +174,13 @@ public class RadioInfo extends Activity {
mCfiValue = cfi;
updateCallRedirect();
}
+
+ @Override
+ public void onCellInfoChanged(List<CellInfo> arrayCi) {
+ Log.d(TAG, "[RadioInfo] onCellInfoChanged: arrayCi=" + arrayCi);
+ mCellInfoValue = arrayCi;
+ updateCellInfoTv();
+ }
};
private Handler mHandler = new Handler() {
@@ -263,6 +273,7 @@ public class RadioInfo extends Activity {
mCfi = (TextView) findViewById(R.id.cfi);
mLocation = (TextView) findViewById(R.id.location);
mNeighboringCids = (TextView) findViewById(R.id.neighboring);
+ mCellInfo = (TextView) findViewById(R.id.cellinfo);
resets = (TextView) findViewById(R.id.resets);
attempts = (TextView) findViewById(R.id.attempts);
@@ -326,6 +337,10 @@ public class RadioInfo extends Activity {
mHandler.obtainMessage(EVENT_QUERY_NEIGHBORING_CIDS_DONE));
CellLocation.requestLocationUpdate();
+
+ // Get current cell info
+ mCellInfoValue = mTelephonyManager.getAllCellInfo();
+ Log.d(TAG, "[RadioInfo] onCreate: mCellInfoValue=" + mCellInfoValue);
}
@Override
@@ -356,7 +371,8 @@ public class RadioInfo extends Activity {
| PhoneStateListener.LISTEN_DATA_ACTIVITY
| PhoneStateListener.LISTEN_CELL_LOCATION
| PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
- | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR);
+ | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
+ | PhoneStateListener.LISTEN_CELL_INFO);
}
@Override
@@ -508,6 +524,23 @@ public class RadioInfo extends Activity {
mNeighboringCids.setText(sb.toString());
}
+ private final void updateCellInfoTv() {
+ StringBuilder value = new StringBuilder();
+ if (mCellInfoValue != null) {
+ int index = 0;
+ for (CellInfo ci : mCellInfoValue) {
+ value.append('[');
+ value.append(index);
+ value.append("]=");
+ value.append(ci.toString());
+ if (++index < mCellInfoValue.size()) {
+ value.append("\n");
+ }
+ }
+ }
+ mCellInfo.setText(value.toString());
+ }
+
private final void
updateMessageWaiting() {
mMwi.setText(String.valueOf(mMwiValue));
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index a12da3e..8f33b9b 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -26,7 +26,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
-import android.os.UserId;
+import android.os.UserHandle;
import android.os.Vibrator;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
@@ -141,7 +141,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
DevicePolicyManager dpm =
(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
- if (UserId.myUserId() == 0) {
+ if (UserHandle.myUserId() == 0) {
switch (dpm.getStorageEncryptionStatus()) {
case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
// The device is currently encrypted.
@@ -193,7 +193,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
- if (UserId.myUserId() > 0) {
+ if (UserHandle.myUserId() > 0) {
return root;
}
// Rest are for primary user...
@@ -446,7 +446,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
resultCode == Activity.RESULT_OK) {
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
lockPatternUtils.setBiometricWeakLivelinessEnabled(false);
- mBiometricWeakLiveliness.setChecked(false);
+ // Setting the mBiometricWeakLiveliness checked value to false is handled when onResume
+ // is called by grabbing the value from lockPatternUtils. We can't set it here
+ // because mBiometricWeakLiveliness could be null
return;
}
createPreferenceHierarchy();
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index ebbec5d..364f96a 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -40,7 +40,7 @@ import android.os.Bundle;
import android.os.INetworkManagementService;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.UserId;
+import android.os.UserHandle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceActivity.Header;
@@ -96,12 +96,17 @@ public class Settings extends PreferenceActivity
// Show only these settings for restricted users
private int[] SETTINGS_FOR_RESTRICTED = {
+ R.id.wireless_section,
R.id.wifi_settings,
R.id.bluetooth_settings,
+ R.id.device_section,
R.id.sound_settings,
R.id.display_settings,
+ R.id.personal_section,
R.id.security_settings,
R.id.account_settings,
+ R.id.account_add,
+ R.id.system_section,
R.id.about_settings
};
@@ -410,13 +415,13 @@ public class Settings extends PreferenceActivity
i = insertAccountsHeaders(target, headerIndex);
} else if (id == R.id.user_settings) {
if (!mEnableUserManagement
- || !UserId.MU_ENABLED || UserId.myUserId() != 0
+ || !UserHandle.MU_ENABLED || UserHandle.myUserId() != 0
|| !getResources().getBoolean(R.bool.enable_user_management)
|| Utils.isMonkeyRunning()) {
target.remove(header);
}
}
- if (UserId.MU_ENABLED && UserId.myUserId() != 0
+ if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
&& !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
target.remove(header);
}
diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java
index 4a79eca..ce53550 100644
--- a/src/com/android/settings/TetherSettings.java
+++ b/src/com/android/settings/TetherSettings.java
@@ -55,6 +55,7 @@ import java.util.Locale;
*/
public class TetherSettings extends SettingsPreferenceFragment
implements DialogInterface.OnClickListener, Preference.OnPreferenceChangeListener {
+ private static final String TAG = "TetherSettings";
private static final String USB_TETHER_SETTINGS = "usb_tether_settings";
private static final String ENABLE_WIFI_AP = "enable_wifi_ap";
@@ -234,8 +235,10 @@ public class TetherSettings extends SettingsPreferenceFragment
switch (intent
.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR)) {
case BluetoothAdapter.STATE_ON:
- mBluetoothPan.setBluetoothTethering(true);
- mBluetoothEnableForTether = false;
+ if(mBluetoothPan != null) {
+ mBluetoothPan.setBluetoothTethering(true);
+ mBluetoothEnableForTether = false;
+ }
break;
case BluetoothAdapter.STATE_OFF:
@@ -392,7 +395,8 @@ public class TetherSettings extends SettingsPreferenceFragment
} else if (btState == BluetoothAdapter.STATE_TURNING_ON) {
mBluetoothTether.setEnabled(false);
mBluetoothTether.setSummary(R.string.bluetooth_turning_on);
- } else if (btState == BluetoothAdapter.STATE_ON && mBluetoothPan.isTetheringOn()) {
+ } else if (btState == BluetoothAdapter.STATE_ON &&
+ mBluetoothPan != null && mBluetoothPan.isTetheringOn()) {
mBluetoothTether.setChecked(true);
mBluetoothTether.setEnabled(true);
if (bluetoothTethered > 1) {
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index a029342..777a712 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -371,11 +371,15 @@ public class Utils {
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
statusString = res.getString(R.string.battery_info_status_charging);
if (plugType > 0) {
- statusString = statusString
- + " "
- + res.getString((plugType == BatteryManager.BATTERY_PLUGGED_AC)
- ? R.string.battery_info_status_charging_ac
- : R.string.battery_info_status_charging_usb);
+ int resId;
+ if (plugType == BatteryManager.BATTERY_PLUGGED_AC) {
+ resId = R.string.battery_info_status_charging_ac;
+ } else if (plugType == BatteryManager.BATTERY_PLUGGED_USB) {
+ resId = R.string.battery_info_status_charging_usb;
+ } else {
+ resId = R.string.battery_info_status_charging_wireless;
+ }
+ statusString = statusString + " " + res.getString(resId);
}
} else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) {
statusString = res.getString(R.string.battery_info_status_discharging);
diff --git a/src/com/android/settings/applications/ApplicationsState.java b/src/com/android/settings/applications/ApplicationsState.java
index 3256fb2..cca9086 100644
--- a/src/com/android/settings/applications/ApplicationsState.java
+++ b/src/com/android/settings/applications/ApplicationsState.java
@@ -786,7 +786,10 @@ public class ApplicationsState {
private long getTotalExternalSize(PackageStats ps) {
if (ps != null) {
+ // We also include the cache size here because for non-emulated
+ // we don't automtically clean cache files.
return ps.externalCodeSize + ps.externalDataSize
+ + ps.externalCacheSize
+ ps.externalMediaSize + ps.externalObbSize;
}
return SIZE_INVALID;
@@ -822,7 +825,7 @@ public class ApplicationsState {
long externalCodeSize = stats.externalCodeSize
+ stats.externalObbSize;
long externalDataSize = stats.externalDataSize
- + stats.externalMediaSize + stats.externalCacheSize;
+ + stats.externalMediaSize;
long newSize = externalCodeSize + externalDataSize
+ getTotalInternalSize(stats);
if (entry.size != newSize ||
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 7fe3711..101764d 100644
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -384,7 +384,12 @@ public class InstalledAppDetails extends Fragment
mDataSize = (TextView)view.findViewById(R.id.data_size_text);
mExternalCodeSize = (TextView)view.findViewById(R.id.external_code_size_text);
mExternalDataSize = (TextView)view.findViewById(R.id.external_data_size_text);
-
+
+ if (Environment.isExternalStorageEmulated()) {
+ ((View)mExternalCodeSize.getParent()).setVisibility(View.GONE);
+ ((View)mExternalDataSize.getParent()).setVisibility(View.GONE);
+ }
+
// Get Control button panel
View btnPanel = view.findViewById(R.id.control_buttons_panel);
mForceStopButton = (Button) btnPanel.findViewById(R.id.left_button);
@@ -675,22 +680,28 @@ public class InstalledAppDetails extends Fragment
} else {
mHaveSizes = true;
- if (mLastCodeSize != mAppEntry.codeSize) {
- mLastCodeSize = mAppEntry.codeSize;
- mAppSize.setText(getSizeStr(mAppEntry.codeSize));
- }
- if (mLastDataSize != mAppEntry.dataSize) {
- mLastDataSize = mAppEntry.dataSize;
- mDataSize.setText(getSizeStr(mAppEntry.dataSize));
+ long codeSize = mAppEntry.codeSize;
+ long dataSize = mAppEntry.dataSize;
+ if (Environment.isExternalStorageEmulated()) {
+ codeSize += mAppEntry.externalCodeSize;
+ dataSize += mAppEntry.externalDataSize;
+ } else {
+ if (mLastExternalCodeSize != mAppEntry.externalCodeSize) {
+ mLastExternalCodeSize = mAppEntry.externalCodeSize;
+ mExternalCodeSize.setText(getSizeStr(mAppEntry.externalCodeSize));
+ }
+ if (mLastExternalDataSize != mAppEntry.externalDataSize) {
+ mLastExternalDataSize = mAppEntry.externalDataSize;
+ mExternalDataSize.setText(getSizeStr( mAppEntry.externalDataSize));
+ }
}
- if (mLastExternalCodeSize != mAppEntry.externalCodeSize) {
- mLastExternalCodeSize = mAppEntry.externalCodeSize;
- mExternalCodeSize.setText(getSizeStr(mAppEntry.externalCodeSize));
+ if (mLastCodeSize != codeSize) {
+ mLastCodeSize = codeSize;
+ mAppSize.setText(getSizeStr(codeSize));
}
- long nonCacheExtDataSize = mAppEntry.externalDataSize - mAppEntry.externalCacheSize;
- if (mLastExternalDataSize != nonCacheExtDataSize) {
- mLastExternalDataSize = nonCacheExtDataSize;
- mExternalDataSize.setText(getSizeStr(nonCacheExtDataSize));
+ if (mLastDataSize != dataSize) {
+ mLastDataSize = dataSize;
+ mDataSize.setText(getSizeStr(dataSize));
}
long cacheSize = mAppEntry.cacheSize + mAppEntry.externalCacheSize;
if (mLastCacheSize != cacheSize) {
@@ -702,7 +713,7 @@ public class InstalledAppDetails extends Fragment
mTotalSize.setText(getSizeStr(mAppEntry.size));
}
- if ((mAppEntry.dataSize+nonCacheExtDataSize) <= 0 || !mCanClearData) {
+ if ((mAppEntry.dataSize+ mAppEntry.externalDataSize) <= 0 || !mCanClearData) {
mClearDataButton.setEnabled(false);
} else {
mClearDataButton.setEnabled(true);
diff --git a/src/com/android/settings/applications/ManageApplications.java b/src/com/android/settings/applications/ManageApplications.java
index 1cc9dcc..1240d43 100644
--- a/src/com/android/settings/applications/ManageApplications.java
+++ b/src/com/android/settings/applications/ManageApplications.java
@@ -341,7 +341,8 @@ public class ManageApplications extends Fragment implements
final int N = mApplications.getCount();
for (int i=0; i<N; i++) {
ApplicationsState.AppEntry ae = mApplications.getAppEntry(i);
- mAppStorage += ae.externalCodeSize + ae.externalDataSize;
+ mAppStorage += ae.externalCodeSize + ae.externalDataSize
+ + ae.externalCacheSize;
}
}
} else {
diff --git a/src/com/android/settings/bluetooth/A2dpProfile.java b/src/com/android/settings/bluetooth/A2dpProfile.java
index b7ba44d..fbf24c9 100644..100755
--- a/src/com/android/settings/bluetooth/A2dpProfile.java
+++ b/src/com/android/settings/bluetooth/A2dpProfile.java
@@ -24,17 +24,19 @@ import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.os.ParcelUuid;
+import android.util.Log;
import com.android.settings.R;
+import java.util.ArrayList;
import java.util.List;
-/**
- * A2dpProfile handles Bluetooth A2DP.
- * TODO: add null checks around calls to mService object.
- */
final class A2dpProfile implements LocalBluetoothProfile {
+ private static final String TAG = "A2dpProfile";
+ private static boolean V = true;
+
private BluetoothA2dp mService;
+ private boolean mIsProfileReady;
static final ParcelUuid[] SINK_UUIDS = {
BluetoothUuid.AudioSink,
@@ -42,6 +44,7 @@ final class A2dpProfile implements LocalBluetoothProfile {
};
static final String NAME = "A2DP";
+ private final LocalBluetoothProfileManager mProfileManager;
// Order of this profile in device profiles list
private static final int ORDINAL = 1;
@@ -51,15 +54,22 @@ final class A2dpProfile implements LocalBluetoothProfile {
implements BluetoothProfile.ServiceListener {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ if (V) Log.d(TAG,"Bluetooth service connected");
mService = (BluetoothA2dp) proxy;
+ mIsProfileReady=true;
}
public void onServiceDisconnected(int profile) {
- mService = null;
+ if (V) Log.d(TAG,"Bluetooth service disconnected");
+ mIsProfileReady=false;
}
}
- A2dpProfile(Context context) {
+ public boolean isProfileReady() {
+ return mIsProfileReady;
+ }
+ A2dpProfile(Context context, LocalBluetoothProfileManager profileManager) {
+ mProfileManager = profileManager;
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
adapter.getProfileProxy(context, new A2dpServiceListener(),
BluetoothProfile.A2DP);
@@ -73,7 +83,8 @@ final class A2dpProfile implements LocalBluetoothProfile {
return true;
}
- private List<BluetoothDevice> getConnectedDevices() {
+ public List<BluetoothDevice> getConnectedDevices() {
+ if (mService == null) return new ArrayList<BluetoothDevice>(0);
return mService.getDevicesMatchingConnectionStates(
new int[] {BluetoothProfile.STATE_CONNECTED,
BluetoothProfile.STATE_CONNECTING,
@@ -81,6 +92,7 @@ final class A2dpProfile implements LocalBluetoothProfile {
}
public boolean connect(BluetoothDevice device) {
+ if (mService == null) return false;
List<BluetoothDevice> sinks = getConnectedDevices();
if (sinks != null) {
for (BluetoothDevice sink : sinks) {
@@ -91,22 +103,33 @@ final class A2dpProfile implements LocalBluetoothProfile {
}
public boolean disconnect(BluetoothDevice device) {
+ if (mService == null) return false;
+ // Downgrade priority as user is disconnecting the headset.
+ if (mService.getPriority(device) > BluetoothProfile.PRIORITY_ON){
+ mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
+ }
return mService.disconnect(device);
}
public int getConnectionStatus(BluetoothDevice device) {
+ if (mService == null) {
+ return BluetoothProfile.STATE_DISCONNECTED;
+ }
return mService.getConnectionState(device);
}
public boolean isPreferred(BluetoothDevice device) {
+ if (mService == null) return false;
return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
}
public int getPreferred(BluetoothDevice device) {
+ if (mService == null) return BluetoothProfile.PRIORITY_OFF;
return mService.getPriority(device);
}
public void setPreferred(BluetoothDevice device, boolean preferred) {
+ if (mService == null) return;
if (preferred) {
if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) {
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
@@ -115,8 +138,8 @@ final class A2dpProfile implements LocalBluetoothProfile {
mService.setPriority(device, BluetoothProfile.PRIORITY_OFF);
}
}
-
boolean isA2dpPlaying() {
+ if (mService == null) return false;
List<BluetoothDevice> sinks = mService.getConnectedDevices();
if (!sinks.isEmpty()) {
if (mService.isA2dpPlaying(sinks.get(0))) {
@@ -126,10 +149,6 @@ final class A2dpProfile implements LocalBluetoothProfile {
return false;
}
- public boolean isProfileReady() {
- return mService != null;
- }
-
public String toString() {
return NAME;
}
@@ -143,7 +162,7 @@ final class A2dpProfile implements LocalBluetoothProfile {
}
public int getSummaryResourceForDevice(BluetoothDevice device) {
- int state = mService.getConnectionState(device);
+ int state = getConnectionStatus(device);
switch (state) {
case BluetoothProfile.STATE_DISCONNECTED:
return R.string.bluetooth_a2dp_profile_summary_use_for;
@@ -159,4 +178,17 @@ final class A2dpProfile implements LocalBluetoothProfile {
public int getDrawableResource(BluetoothClass btClass) {
return R.drawable.ic_bt_headphones_a2dp;
}
+
+ protected void finalize() {
+ if (V) Log.d(TAG, "finalize()");
+ if (mService != null) {
+ try {
+ BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.A2DP,
+ mService);
+ mService = null;
+ }catch (Throwable t) {
+ Log.w(TAG, "Error cleaning up A2DP proxy", t);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
index babf1e2..d687136 100755
--- a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
@@ -29,6 +29,9 @@ import android.text.format.DateUtils;
import com.android.settings.R;
+import android.text.format.Time;
+import android.util.Log;
+
/**
* BluetoothDiscoverableEnabler is a helper to manage the "Discoverable"
* checkbox. It sets/unsets discoverability and keeps track of how much time
@@ -36,6 +39,8 @@ import com.android.settings.R;
*/
final class BluetoothDiscoverableEnabler implements Preference.OnPreferenceClickListener {
+ private static final String TAG = "BluetoothDiscoverableEnabler";
+
private static final String SYSTEM_PROPERTY_DISCOVERABLE_TIMEOUT =
"debug.bt.discoverable_time";
@@ -128,15 +133,20 @@ final class BluetoothDiscoverableEnabler implements Preference.OnPreferenceClick
private void setEnabled(boolean enable) {
if (enable) {
int timeout = getDiscoverableTimeout();
- mLocalAdapter.setDiscoverableTimeout(timeout);
-
long endTimestamp = System.currentTimeMillis() + timeout * 1000L;
LocalBluetoothPreferences.persistDiscoverableEndTimestamp(mContext, endTimestamp);
mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, timeout);
updateCountdownSummary();
+
+ Log.d(TAG, "setEnabled(): enabled = " + enable + "timeout = " + timeout);
+
+ if (timeout > 0) {
+ BluetoothDiscoverableTimeoutReceiver.setDiscoverableAlarm(mContext, endTimestamp);
+ }
} else {
mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
+ BluetoothDiscoverableTimeoutReceiver.cancelDiscoverableAlarm(mContext);
}
}
@@ -238,6 +248,7 @@ final class BluetoothDiscoverableEnabler implements Preference.OnPreferenceClick
}
void handleModeChanged(int mode) {
+ Log.d(TAG, "handleModeChanged(): mode = " + mode);
if (mode == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
mDiscoverable = true;
updateCountdownSummary();
diff --git a/src/com/android/settings/bluetooth/BluetoothDiscoverableTimeoutReceiver.java b/src/com/android/settings/bluetooth/BluetoothDiscoverableTimeoutReceiver.java
new file mode 100644
index 0000000..14f7b22
--- /dev/null
+++ b/src/com/android/settings/bluetooth/BluetoothDiscoverableTimeoutReceiver.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 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.bluetooth;
+
+/* Required to handle timeout notification when phone is suspended */
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+
+import android.bluetooth.BluetoothAdapter;
+import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+
+public class BluetoothDiscoverableTimeoutReceiver extends BroadcastReceiver {
+ private static final String TAG = "BluetoothDiscoverableTimeoutReceiver";
+
+ private static final String INTENT_DISCOVERABLE_TIMEOUT =
+ "android.bluetooth.intent.DISCOVERABLE_TIMEOUT";
+
+ static void setDiscoverableAlarm(Context context, long alarmTime) {
+ Log.d(TAG, "setDiscoverableAlarm(): alarmTime = " + alarmTime);
+
+ Intent intent = new Intent(INTENT_DISCOVERABLE_TIMEOUT);
+ intent.setClass(context, BluetoothDiscoverableTimeoutReceiver.class);
+ PendingIntent pending = PendingIntent.getBroadcast(
+ context, 0, intent, 0);
+ AlarmManager alarmManager =
+ (AlarmManager) context.getSystemService (Context.ALARM_SERVICE);
+
+ if (pending != null) {
+ // Cancel any previous alarms that do the same thing.
+ alarmManager.cancel(pending);
+ Log.d(TAG, "setDiscoverableAlarm(): cancel prev alarm");
+ }
+ pending = PendingIntent.getBroadcast(
+ context, 0, intent, 0);
+
+ alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pending);
+ }
+
+ static void cancelDiscoverableAlarm(Context context) {
+ Log.d(TAG, "cancelDiscoverableAlarm(): Enter");
+
+ Intent intent = new Intent(INTENT_DISCOVERABLE_TIMEOUT);
+ intent.setClass(context, BluetoothDiscoverableTimeoutReceiver.class);
+ PendingIntent pending = PendingIntent.getBroadcast(
+ context, 0, intent, PendingIntent.FLAG_NO_CREATE);
+ if (pending != null) {
+ // Cancel any previous alarms that do the same thing.
+ AlarmManager alarmManager =
+ (AlarmManager) context.getSystemService (Context.ALARM_SERVICE);
+
+ alarmManager.cancel(pending);
+ }
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ LocalBluetoothAdapter localBluetoothAdapter = LocalBluetoothAdapter.getInstance();
+
+ if(localBluetoothAdapter != null &&
+ localBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
+ Log.d(TAG, "Disable discoverable...");
+
+ localBluetoothAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE);
+ } else {
+ Log.e(TAG, "localBluetoothAdapter is NULL!!");
+ }
+ }
+};
diff --git a/src/com/android/settings/bluetooth/BluetoothEventManager.java b/src/com/android/settings/bluetooth/BluetoothEventManager.java
index a6d9bcf..0eead85 100644..100755
--- a/src/com/android/settings/bluetooth/BluetoothEventManager.java
+++ b/src/com/android/settings/bluetooth/BluetoothEventManager.java
@@ -21,6 +21,7 @@ import com.android.settings.R;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -99,6 +100,7 @@ final class BluetoothEventManager {
// Dock event broadcasts
addHandler(Intent.ACTION_DOCK_EVENT, new DockEventHandler());
+
mContext.registerReceiver(mBroadcastReceiver, mAdapterIntentFilter);
}
@@ -163,6 +165,8 @@ final class BluetoothEventManager {
callback.onBluetoothStateChanged(state);
}
}
+ // Inform CachedDeviceManager that the adapter state has changed
+ mDeviceManager.onBluetoothStateChanged(state);
}
}
@@ -365,7 +369,6 @@ final class BluetoothEventManager {
}
}
}
-
boolean readPairedDevices() {
Set<BluetoothDevice> bondedDevices = mLocalAdapter.getBondedDevices();
if (bondedDevices == null) {
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index d30e428..f44efc4 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -125,7 +125,7 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+ Gravity.CENTER_VERTICAL | Gravity.END));
}
}
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
index 01fd1b2..ef223d5 100644..100755
--- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
@@ -25,6 +25,7 @@ import android.os.ParcelUuid;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;
+import android.bluetooth.BluetoothAdapter;
import java.util.ArrayList;
import java.util.Collection;
@@ -118,7 +119,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
Log.d(TAG, "onProfileStateChanged: profile " + profile +
" newProfileState " + newProfileState);
}
-
mProfileConnectionState.put(profile, newProfileState);
if (newProfileState == BluetoothProfile.STATE_CONNECTED) {
if (!mProfiles.contains(profile)) {
@@ -156,6 +156,14 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
for (LocalBluetoothProfile profile : mProfiles) {
disconnect(profile);
}
+ // Disconnect PBAP server in case its connected
+ // This is to ensure all the profiles are disconnected as some CK/Hs do not
+ // disconnect PBAP connection when HF connection is brought down
+ PbapServerProfile PbapProfile = mProfileManager.getPbapProfile();
+ if (PbapProfile.getConnectionStatus(mDevice) == BluetoothProfile.STATE_CONNECTED)
+ {
+ PbapProfile.disconnect(mDevice);
+ }
}
void disconnect(LocalBluetoothProfile profile) {
@@ -184,12 +192,15 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
private void connectWithoutResettingTimer(boolean connectAllProfiles) {
// Try to initialize the profiles if they were not.
if (mProfiles.isEmpty()) {
- if (!updateProfiles()) {
- // If UUIDs are not available yet, connect will be happen
- // upon arrival of the ACTION_UUID intent.
- if (DEBUG) Log.d(TAG, "No profiles. Maybe we will connect later");
- return;
- }
+ // if mProfiles is empty, then do not invoke updateProfiles. This causes a race
+ // condition with carkits during pairing, wherein RemoteDevice.UUIDs have been updated
+ // from bluetooth stack but ACTION.uuid is not sent yet.
+ // Eventually ACTION.uuid will be received which shall trigger the connection of the
+ // various profiles
+ // If UUIDs are not available yet, connect will be happen
+ // upon arrival of the ACTION_UUID intent.
+ Log.d(TAG, "No profiles. Maybe we will connect later");
+ return;
}
// Reset the only-show-one-error-dialog tracking variable
@@ -236,9 +247,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
// Reset the only-show-one-error-dialog tracking variable
mIsConnectingErrorPossible = true;
connectInt(profile);
+ // Refresh the UI based on profile.connect() call
+ refresh();
}
- private void connectInt(LocalBluetoothProfile profile) {
+ synchronized void connectInt(LocalBluetoothProfile profile) {
if (!ensurePaired()) {
return;
}
@@ -283,8 +296,6 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
}
void unpair() {
- disconnect();
-
int state = getBondState();
if (state == BluetoothDevice.BOND_BONDING) {
@@ -436,7 +447,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
ParcelUuid[] localUuids = mLocalAdapter.getUuids();
if (localUuids == null) return false;
- mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles);
+ mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles, mLocalNapRoleConnected);
if (DEBUG) {
Log.e(TAG, "updating profiles for " + mDevice.getAliasName());
diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
index 77f6b2c..06be3c4 100644
--- a/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
+++ b/src/com/android/settings/bluetooth/CachedBluetoothDeviceManager.java
@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;
@@ -134,6 +135,19 @@ final class CachedBluetoothDeviceManager {
}
}
+ public synchronized void onBluetoothStateChanged(int bluetoothState) {
+ // When Bluetooth is turning off, we need to clear the non-bonded devices
+ // Otherwise, they end up showing up on the next BT enable
+ if (bluetoothState == BluetoothAdapter.STATE_TURNING_OFF) {
+ for (int i = mCachedDevices.size() - 1; i >= 0; i--) {
+ CachedBluetoothDevice cachedDevice = mCachedDevices.get(i);
+ if (cachedDevice.getBondState() != BluetoothDevice.BOND_BONDED) {
+ cachedDevice.setVisible(false);
+ mCachedDevices.remove(i);
+ }
+ }
+ }
+ }
private void log(String msg) {
if (DEBUG) {
Log.d(TAG, msg);
diff --git a/src/com/android/settings/bluetooth/HeadsetProfile.java b/src/com/android/settings/bluetooth/HeadsetProfile.java
index 99d070b..83c8e8e 100644..100755
--- a/src/com/android/settings/bluetooth/HeadsetProfile.java
+++ b/src/com/android/settings/bluetooth/HeadsetProfile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2012 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.
@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
@@ -27,6 +28,7 @@ import android.util.Log;
import com.android.settings.R;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -34,9 +36,10 @@ import java.util.List;
*/
final class HeadsetProfile implements LocalBluetoothProfile {
private static final String TAG = "HeadsetProfile";
+ private static boolean V = true;
private BluetoothHeadset mService;
- private boolean mProfileReady;
+ private boolean mIsProfileReady;
private final LocalBluetoothAdapter mLocalAdapter;
private final CachedBluetoothDeviceManager mDeviceManager;
@@ -57,38 +60,38 @@ final class HeadsetProfile implements LocalBluetoothProfile {
implements BluetoothProfile.ServiceListener {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ if (V) Log.d(TAG,"Bluetooth service connected");
mService = (BluetoothHeadset) proxy;
- mProfileReady = true;
// We just bound to the service, so refresh the UI of the
// headset device.
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
- if (deviceList.isEmpty()) {
- return;
+ if (!deviceList.isEmpty()) {
+ BluetoothDevice firstDevice = deviceList.get(0);
+ CachedBluetoothDevice device = mDeviceManager.findDevice(firstDevice);
+ // we may add a new device here, but generally this should not happen
+ if (device == null) {
+ Log.w(TAG, "HeadsetProfile found new device: " + firstDevice);
+ device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, firstDevice);
+ }
+ device.onProfileStateChanged(HeadsetProfile.this,
+ BluetoothProfile.STATE_CONNECTED);
}
- BluetoothDevice firstDevice = deviceList.get(0);
- CachedBluetoothDevice device = mDeviceManager.findDevice(firstDevice);
- // we may add a new device here, but generally this should not happen
- if (device == null) {
- Log.w(TAG, "HeadsetProfile found new device: " + firstDevice);
- device = mDeviceManager.addDevice(mLocalAdapter, mProfileManager, firstDevice);
- }
- device.onProfileStateChanged(HeadsetProfile.this,
- BluetoothProfile.STATE_CONNECTED);
mProfileManager.callServiceConnectedListeners();
+ mIsProfileReady=true;
}
public void onServiceDisconnected(int profile) {
- mProfileReady = false;
- mService = null;
+ if (V) Log.d(TAG,"Bluetooth service disconnected");
mProfileManager.callServiceDisconnectedListeners();
+ mIsProfileReady=false;
}
}
- // TODO(): The calls must get queued if mService becomes null.
- // It can happen when the phone app crashes for some reason.
- // All callers should have service listeners. Dock Service is the only
- // one right now.
+ public boolean isProfileReady() {
+ return mIsProfileReady;
+ }
+
HeadsetProfile(Context context, LocalBluetoothAdapter adapter,
CachedBluetoothDeviceManager deviceManager,
LocalBluetoothProfileManager profileManager) {
@@ -108,6 +111,7 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
public boolean connect(BluetoothDevice device) {
+ if (mService == null) return false;
List<BluetoothDevice> sinks = mService.getConnectedDevices();
if (sinks != null) {
for (BluetoothDevice sink : sinks) {
@@ -118,6 +122,7 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
public boolean disconnect(BluetoothDevice device) {
+ if (mService == null) return false;
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
if (!deviceList.isEmpty() && deviceList.get(0).equals(device)) {
// Downgrade priority as user is disconnecting the headset.
@@ -132,7 +137,6 @@ final class HeadsetProfile implements LocalBluetoothProfile {
public int getConnectionStatus(BluetoothDevice device) {
if (mService == null) return BluetoothProfile.STATE_DISCONNECTED;
-
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
return !deviceList.isEmpty() && deviceList.get(0).equals(device)
@@ -141,14 +145,17 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
public boolean isPreferred(BluetoothDevice device) {
+ if (mService == null) return false;
return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
}
public int getPreferred(BluetoothDevice device) {
+ if (mService == null) return BluetoothProfile.PRIORITY_OFF;
return mService.getPriority(device);
}
public void setPreferred(BluetoothDevice device, boolean preferred) {
+ if (mService == null) return;
if (preferred) {
if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) {
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
@@ -158,8 +165,12 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
}
- public synchronized boolean isProfileReady() {
- return mProfileReady;
+ public List<BluetoothDevice> getConnectedDevices() {
+ if (mService == null) return new ArrayList<BluetoothDevice>(0);
+ return mService.getDevicesMatchingConnectionStates(
+ new int[] {BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.STATE_CONNECTING,
+ BluetoothProfile.STATE_DISCONNECTING});
}
public String toString() {
@@ -175,7 +186,7 @@ final class HeadsetProfile implements LocalBluetoothProfile {
}
public int getSummaryResourceForDevice(BluetoothDevice device) {
- int state = mService.getConnectionState(device);
+ int state = getConnectionStatus(device);
switch (state) {
case BluetoothProfile.STATE_DISCONNECTED:
return R.string.bluetooth_headset_profile_summary_use_for;
@@ -191,4 +202,17 @@ final class HeadsetProfile implements LocalBluetoothProfile {
public int getDrawableResource(BluetoothClass btClass) {
return R.drawable.ic_bt_headset_hfp;
}
+
+ protected void finalize() {
+ if (V) Log.d(TAG, "finalize()");
+ if (mService != null) {
+ try {
+ BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.HEADSET,
+ mService);
+ mService = null;
+ }catch (Throwable t) {
+ Log.w(TAG, "Error cleaning up HID proxy", t);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/HidProfile.java b/src/com/android/settings/bluetooth/HidProfile.java
index 920f4bb..c502850 100644..100755
--- a/src/com/android/settings/bluetooth/HidProfile.java
+++ b/src/com/android/settings/bluetooth/HidProfile.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2012 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.
@@ -16,11 +16,13 @@
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothInputDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
+import android.util.Log;
import com.android.settings.R;
@@ -30,8 +32,11 @@ import java.util.List;
* HidProfile handles Bluetooth HID profile.
*/
final class HidProfile implements LocalBluetoothProfile {
+ private static final String TAG = "HidProfile";
+ private static boolean V = true;
+
private BluetoothInputDevice mService;
- private boolean mProfileReady;
+ private boolean mIsProfileReady;
static final String NAME = "HID";
@@ -43,16 +48,21 @@ final class HidProfile implements LocalBluetoothProfile {
implements BluetoothProfile.ServiceListener {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ if (V) Log.d(TAG,"Bluetooth service connected");
mService = (BluetoothInputDevice) proxy;
- mProfileReady = true;
+ mIsProfileReady=true;
}
public void onServiceDisconnected(int profile) {
- mProfileReady = false;
- mService = null;
+ if (V) Log.d(TAG,"Bluetooth service disconnected");
+ mIsProfileReady=false;
}
}
+ public boolean isProfileReady() {
+ return mIsProfileReady;
+ }
+
HidProfile(Context context, LocalBluetoothAdapter adapter) {
adapter.getProfileProxy(context, new InputDeviceServiceListener(),
BluetoothProfile.INPUT_DEVICE);
@@ -67,14 +77,19 @@ final class HidProfile implements LocalBluetoothProfile {
}
public boolean connect(BluetoothDevice device) {
+ if (mService == null) return false;
return mService.connect(device);
}
public boolean disconnect(BluetoothDevice device) {
+ if (mService == null) return false;
return mService.disconnect(device);
}
public int getConnectionStatus(BluetoothDevice device) {
+ if (mService == null) {
+ return BluetoothProfile.STATE_DISCONNECTED;
+ }
List<BluetoothDevice> deviceList = mService.getConnectedDevices();
return !deviceList.isEmpty() && deviceList.get(0).equals(device)
@@ -83,14 +98,17 @@ final class HidProfile implements LocalBluetoothProfile {
}
public boolean isPreferred(BluetoothDevice device) {
+ if (mService == null) return false;
return mService.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
}
public int getPreferred(BluetoothDevice device) {
+ if (mService == null) return BluetoothProfile.PRIORITY_OFF;
return mService.getPriority(device);
}
public void setPreferred(BluetoothDevice device, boolean preferred) {
+ if (mService == null) return;
if (preferred) {
if (mService.getPriority(device) < BluetoothProfile.PRIORITY_ON) {
mService.setPriority(device, BluetoothProfile.PRIORITY_ON);
@@ -100,10 +118,6 @@ final class HidProfile implements LocalBluetoothProfile {
}
}
- public boolean isProfileReady() {
- return mProfileReady;
- }
-
public String toString() {
return NAME;
}
@@ -118,7 +132,7 @@ final class HidProfile implements LocalBluetoothProfile {
}
public int getSummaryResourceForDevice(BluetoothDevice device) {
- int state = mService.getConnectionState(device);
+ int state = getConnectionStatus(device);
switch (state) {
case BluetoothProfile.STATE_DISCONNECTED:
return R.string.bluetooth_hid_profile_summary_use_for;
@@ -149,4 +163,17 @@ final class HidProfile implements LocalBluetoothProfile {
return R.drawable.ic_bt_misc_hid;
}
}
+
+ protected void finalize() {
+ if (V) Log.d(TAG, "finalize()");
+ if (mService != null) {
+ try {
+ BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.INPUT_DEVICE,
+ mService);
+ mService = null;
+ }catch (Throwable t) {
+ Log.w(TAG, "Error cleaning up HID proxy", t);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
index 7e62b0e..36bc7c8 100644
--- a/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothPreferences.java
@@ -19,6 +19,7 @@ package com.android.settings.bluetooth;
import android.app.QueuedWork;
import android.content.Context;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
/**
* LocalBluetoothPreferences provides an interface to the preferences
@@ -63,6 +64,12 @@ final class LocalBluetoothPreferences {
return false;
}
+ // If in appliance mode, do not show dialog in foreground.
+ if ((context.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_TYPE_APPLIANCE) == Configuration.UI_MODE_TYPE_APPLIANCE) {
+ return false;
+ }
+
// If Bluetooth Settings is visible
if (manager.isForegroundActivity()) {
return true;
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfile.java b/src/com/android/settings/bluetooth/LocalBluetoothProfile.java
index 8c0de95..8c0de95 100644..100755
--- a/src/com/android/settings/bluetooth/LocalBluetoothProfile.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothProfile.java
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
index f3143f0..916ef9e 100644..100755
--- a/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothProfileManager.java
@@ -21,17 +21,22 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.bluetooth.BluetoothInputDevice;
import android.bluetooth.BluetoothPan;
+import android.bluetooth.BluetoothPbap;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
import android.content.Context;
import android.content.Intent;
import android.os.ParcelUuid;
import android.util.Log;
+import android.os.Handler;
+import android.os.Message;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+import java.util.List;
/**
* LocalBluetoothProfileManager provides access to the LocalBluetoothProfile
@@ -77,6 +82,7 @@ final class LocalBluetoothProfileManager {
private final HidProfile mHidProfile;
private OppProfile mOppProfile;
private final PanProfile mPanProfile;
+ private final PbapServerProfile mPbapProfile;
/**
* Mapping from profile name, e.g. "HEADSET" to profile object.
@@ -113,6 +119,10 @@ final class LocalBluetoothProfileManager {
addPanProfile(mPanProfile, PanProfile.NAME,
BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);
+ //Create PBAP server profile, but do not add it to list of profiles
+ // as we do not need to monitor the profile as part of profile list
+ mPbapProfile = new PbapServerProfile(context);
+
Log.d(TAG, "LocalBluetoothProfileManager construction complete");
}
@@ -128,7 +138,7 @@ final class LocalBluetoothProfileManager {
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.AudioSource)) {
if (mA2dpProfile == null) {
Log.d(TAG, "Adding local A2DP profile");
- mA2dpProfile = new A2dpProfile(mContext);
+ mA2dpProfile = new A2dpProfile(mContext, this);
addProfile(mA2dpProfile, A2dpProfile.NAME,
BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
}
@@ -287,6 +297,11 @@ final class LocalBluetoothProfileManager {
return mHeadsetProfile;
}
+ PbapServerProfile getPbapProfile(){
+ return mPbapProfile;
+ }
+
+
/**
* Fill in a list of LocalBluetoothProfile objects that are supported by
* the local device and the remote device.
@@ -298,7 +313,8 @@ final class LocalBluetoothProfileManager {
*/
synchronized void updateProfiles(ParcelUuid[] uuids, ParcelUuid[] localUuids,
Collection<LocalBluetoothProfile> profiles,
- Collection<LocalBluetoothProfile> removedProfiles) {
+ Collection<LocalBluetoothProfile> removedProfiles,
+ boolean isPanNapConnected) {
// Copy previous profile list into removedProfiles
removedProfiles.clear();
removedProfiles.addAll(profiles);
@@ -336,10 +352,13 @@ final class LocalBluetoothProfileManager {
removedProfiles.remove(mHidProfile);
}
- if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.NAP) &&
- mPanProfile != null) {
+ if(isPanNapConnected)
+ Log.d(TAG, "Valid PAN-NAP connection exists.");
+ if ((BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.NAP) &&
+ mPanProfile != null) || isPanNapConnected) {
profiles.add(mPanProfile);
removedProfiles.remove(mPanProfile);
}
}
+
}
diff --git a/src/com/android/settings/bluetooth/OppProfile.java b/src/com/android/settings/bluetooth/OppProfile.java
index 7ee2ad1..7ee2ad1 100644..100755
--- a/src/com/android/settings/bluetooth/OppProfile.java
+++ b/src/com/android/settings/bluetooth/OppProfile.java
diff --git a/src/com/android/settings/bluetooth/PBAPServerProfile.java b/src/com/android/settings/bluetooth/PBAPServerProfile.java
new file mode 100755
index 0000000..7217574
--- /dev/null
+++ b/src/com/android/settings/bluetooth/PBAPServerProfile.java
@@ -0,0 +1,142 @@
+/*
+ * 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.bluetooth;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothClass;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothPbap;
+import android.bluetooth.BluetoothProfile;
+import android.content.Context;
+import android.util.Log;
+
+import com.android.settings.R;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ *PBAPServer Profile
+ */
+final class PbapServerProfile implements LocalBluetoothProfile {
+ private static final String TAG = "PbapServerProfile";
+ private static boolean V = true;
+
+ private BluetoothPbap mService;
+ private boolean mIsProfileReady;
+
+ static final String NAME = "PBAP Server";
+
+ // Order of this profile in device profiles list
+ private static final int ORDINAL = 6;
+
+ // These callbacks run on the main thread.
+ private final class PbapServiceListener
+ implements BluetoothPbap.ServiceListener {
+
+ public void onServiceConnected(BluetoothPbap proxy) {
+ if (V) Log.d(TAG,"Bluetooth service connected");
+ mService = (BluetoothPbap) proxy;
+ mIsProfileReady=true;
+ }
+
+ public void onServiceDisconnected() {
+ if (V) Log.d(TAG,"Bluetooth service disconnected");
+ mIsProfileReady=false;
+ }
+ }
+
+ public boolean isProfileReady() {
+ return mIsProfileReady;
+ }
+
+ PbapServerProfile(Context context) {
+ BluetoothPbap pbap = new BluetoothPbap(context, new PbapServiceListener());
+ }
+
+ public boolean isConnectable() {
+ return true;
+ }
+
+ public boolean isAutoConnectable() {
+ return false;
+ }
+
+ public boolean connect(BluetoothDevice device) {
+ /*Can't connect from server */
+ return false;
+
+ }
+
+ public boolean disconnect(BluetoothDevice device) {
+ if (mService == null) return false;
+ return mService.disconnect();
+ }
+
+ public int getConnectionStatus(BluetoothDevice device) {
+ if (mService == null) {
+ return BluetoothProfile.STATE_DISCONNECTED;
+ }
+ if (mService.isConnected(device))
+ return BluetoothProfile.STATE_CONNECTED;
+ else
+ return BluetoothProfile.STATE_DISCONNECTED;
+ }
+
+ public boolean isPreferred(BluetoothDevice device) {
+ return false;
+ }
+
+ public int getPreferred(BluetoothDevice device) {
+ return -1;
+ }
+
+ public void setPreferred(BluetoothDevice device, boolean preferred) {
+ // ignore: isPreferred is always true for PBAP
+ }
+
+ public String toString() {
+ return NAME;
+ }
+
+ public int getOrdinal() {
+ return ORDINAL;
+ }
+
+ public int getNameResource(BluetoothDevice device) {
+ return 0;
+ }
+
+ public int getSummaryResourceForDevice(BluetoothDevice device) {
+ return 0;
+ }
+
+ public int getDrawableResource(BluetoothClass btClass) {
+ return 0;
+ }
+ protected void finalize() {
+ if (V) Log.d(TAG, "finalize()");
+ if (mService != null) {
+ try {
+ mService.close();
+ mService = null;
+ }catch (Throwable t) {
+ Log.w(TAG, "Error cleaning up PBAP proxy", t);
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/bluetooth/PanProfile.java b/src/com/android/settings/bluetooth/PanProfile.java
index 3db4a2b..b9db77b 100644..100755
--- a/src/com/android/settings/bluetooth/PanProfile.java
+++ b/src/com/android/settings/bluetooth/PanProfile.java
@@ -22,6 +22,7 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothPan;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
+import android.util.Log;
import com.android.settings.R;
@@ -32,7 +33,11 @@ import java.util.List;
* PanProfile handles Bluetooth PAN profile (NAP and PANU).
*/
final class PanProfile implements LocalBluetoothProfile {
+ private static final String TAG = "PanProfile";
+ private static boolean V = true;
+
private BluetoothPan mService;
+ private boolean mIsProfileReady;
// Tethering direction for each device
private final HashMap<BluetoothDevice, Integer> mDeviceRoleMap =
@@ -48,14 +53,21 @@ final class PanProfile implements LocalBluetoothProfile {
implements BluetoothProfile.ServiceListener {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ if (V) Log.d(TAG,"Bluetooth service connected");
mService = (BluetoothPan) proxy;
+ mIsProfileReady=true;
}
public void onServiceDisconnected(int profile) {
- mService = null;
+ if (V) Log.d(TAG,"Bluetooth service disconnected");
+ mIsProfileReady=false;
}
}
+ public boolean isProfileReady() {
+ return mIsProfileReady;
+ }
+
PanProfile(Context context) {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
adapter.getProfileProxy(context, new PanServiceListener(),
@@ -71,6 +83,7 @@ final class PanProfile implements LocalBluetoothProfile {
}
public boolean connect(BluetoothDevice device) {
+ if (mService == null) return false;
List<BluetoothDevice> sinks = mService.getConnectedDevices();
if (sinks != null) {
for (BluetoothDevice sink : sinks) {
@@ -81,10 +94,14 @@ final class PanProfile implements LocalBluetoothProfile {
}
public boolean disconnect(BluetoothDevice device) {
+ if (mService == null) return false;
return mService.disconnect(device);
}
public int getConnectionStatus(BluetoothDevice device) {
+ if (mService == null) {
+ return BluetoothProfile.STATE_DISCONNECTED;
+ }
return mService.getConnectionState(device);
}
@@ -100,10 +117,6 @@ final class PanProfile implements LocalBluetoothProfile {
// ignore: isPreferred is always true for PAN
}
- public boolean isProfileReady() {
- return true;
- }
-
public String toString() {
return NAME;
}
@@ -121,7 +134,7 @@ final class PanProfile implements LocalBluetoothProfile {
}
public int getSummaryResourceForDevice(BluetoothDevice device) {
- int state = mService.getConnectionState(device);
+ int state = getConnectionStatus(device);
switch (state) {
case BluetoothProfile.STATE_DISCONNECTED:
return R.string.bluetooth_pan_profile_summary_use_for;
@@ -154,4 +167,16 @@ final class PanProfile implements LocalBluetoothProfile {
return false;
}
}
+
+ protected void finalize() {
+ if (V) Log.d(TAG, "finalize()");
+ if (mService != null) {
+ try {
+ BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.PAN, mService);
+ mService = null;
+ }catch (Throwable t) {
+ Log.w(TAG, "Error cleaning up PAN proxy", t);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/RequestPermissionActivity.java b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
index 529312d..08c10fb 100644
--- a/src/com/android/settings/bluetooth/RequestPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/RequestPermissionActivity.java
@@ -228,8 +228,12 @@ public class RequestPermissionActivity extends Activity implements
} else if (mLocalAdapter.setScanMode(
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, mTimeout)) {
// If already in discoverable mode, this will extend the timeout.
+ long endTime = System.currentTimeMillis() + (long) mTimeout * 1000;
LocalBluetoothPreferences.persistDiscoverableEndTimestamp(
- this, System.currentTimeMillis() + (long) mTimeout * 1000);
+ this, endTime);
+ if (0 < mTimeout) {
+ BluetoothDiscoverableTimeoutReceiver.setDiscoverableAlarm(this, endTime);
+ }
returnCode = mTimeout;
// Activity.RESULT_FIRST_USER should be 1
if (returnCode < RESULT_FIRST_USER) {
diff --git a/src/com/android/settings/deviceinfo/PercentageBarChart.java b/src/com/android/settings/deviceinfo/PercentageBarChart.java
index 95973c4..b45eb69 100644
--- a/src/com/android/settings/deviceinfo/PercentageBarChart.java
+++ b/src/com/android/settings/deviceinfo/PercentageBarChart.java
@@ -71,29 +71,56 @@ public class PercentageBarChart extends View {
final int width = right - left;
- float lastX = left;
-
- if (mEntries != null) {
- for (final Entry e : mEntries) {
- final float entryWidth;
- if (e.percentage == 0.0f) {
- entryWidth = 0.0f;
- } else {
- entryWidth = Math.max(mMinTickWidth, width * e.percentage);
+ final boolean isLayoutRtl = isLayoutRtl();
+ if (isLayoutRtl) {
+ float nextX = right;
+
+ if (mEntries != null) {
+ for (final Entry e : mEntries) {
+ final float entryWidth;
+ if (e.percentage == 0.0f) {
+ entryWidth = 0.0f;
+ } else {
+ entryWidth = Math.max(mMinTickWidth, width * e.percentage);
+ }
+
+ final float lastX = nextX - entryWidth;
+ if (lastX < left) {
+ canvas.drawRect(left, top, nextX, bottom, e.paint);
+ return;
+ }
+
+ canvas.drawRect(lastX, top, nextX, bottom, e.paint);
+ nextX = lastX;
}
+ }
- final float nextX = lastX + entryWidth;
- if (nextX > right) {
- canvas.drawRect(lastX, top, right, bottom, e.paint);
- return;
+ canvas.drawRect(left, top, nextX, bottom, mEmptyPaint);
+ } else {
+ float lastX = left;
+
+ if (mEntries != null) {
+ for (final Entry e : mEntries) {
+ final float entryWidth;
+ if (e.percentage == 0.0f) {
+ entryWidth = 0.0f;
+ } else {
+ entryWidth = Math.max(mMinTickWidth, width * e.percentage);
+ }
+
+ final float nextX = lastX + entryWidth;
+ if (nextX > right) {
+ canvas.drawRect(lastX, top, right, bottom, e.paint);
+ return;
+ }
+
+ canvas.drawRect(lastX, top, nextX, bottom, e.paint);
+ lastX = nextX;
}
-
- canvas.drawRect(lastX, top, nextX, bottom, e.paint);
- lastX = nextX;
}
- }
- canvas.drawRect(lastX, top, right, bottom, mEmptyPaint);
+ canvas.drawRect(lastX, top, right, bottom, mEmptyPaint);
+ }
}
/**
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index fa2b02d..ab2c891 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -436,6 +436,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
final int NU = uidStats.size();
for (int iu = 0; iu < NU; iu++) {
Uid u = uidStats.valueAt(iu);
+ double p;
double power = 0;
double highestDrain = 0;
String packageWithHighestDrain = null;
@@ -445,11 +446,11 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
long cpuFgTime = 0;
long wakelockTime = 0;
long gpsTime = 0;
+ if (DEBUG) Log.i(TAG, "UID " + u.getUid());
if (processStats.size() > 0) {
// Process CPU time
for (Map.Entry<String, ? extends BatteryStats.Uid.Proc> ent
: processStats.entrySet()) {
- if (DEBUG) Log.i(TAG, "Process name = " + ent.getKey());
Uid.Proc ps = ent.getValue();
final long userTime = ps.getUserTime(which);
final long systemTime = ps.getSystemTime(which);
@@ -470,6 +471,10 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
processPower += ratio * tmpCpuTime * powerCpuNormal[step];
}
cpuTime += tmpCpuTime;
+ if (DEBUG && processPower != 0) {
+ Log.i(TAG, String.format("process %s, cpu power=%.2f",
+ ent.getKey(), processPower / 1000));
+ }
power += processPower;
if (packageWithHighestDrain == null
|| packageWithHighestDrain.startsWith("*")) {
@@ -481,8 +486,6 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
packageWithHighestDrain = ent.getKey();
}
}
- if (DEBUG) Log.i(TAG, "Max drain of " + highestDrain
- + " by " + packageWithHighestDrain);
}
if (cpuFgTime > cpuTime) {
if (DEBUG && cpuFgTime > cpuTime + 10000) {
@@ -491,6 +494,7 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
cpuTime = cpuFgTime; // Statistics may not have been gathered yet.
}
power /= 1000;
+ if (DEBUG && power != 0) Log.i(TAG, String.format("total cpu power=%.2f", power));
// Process wake lock usage
Map<String, ? extends BatteryStats.Uid.Wakelock> wakelockStats = u.getWakelockStats();
@@ -508,19 +512,32 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
appWakelockTime += wakelockTime;
// Add cost of holding a wake lock
- power += (wakelockTime
+ p = (wakelockTime
* mPowerProfile.getAveragePower(PowerProfile.POWER_CPU_AWAKE)) / 1000;
+ power += p;
+ if (DEBUG && p != 0) Log.i(TAG, String.format("wakelock power=%.2f", p));
// Add cost of data traffic
long tcpBytesReceived = u.getTcpBytesReceived(mStatsType);
long tcpBytesSent = u.getTcpBytesSent(mStatsType);
- power += (tcpBytesReceived+tcpBytesSent) * averageCostPerByte;
+ p = (tcpBytesReceived+tcpBytesSent) * averageCostPerByte;
+ power += p;
+ if (DEBUG && p != 0) Log.i(TAG, String.format("tcp power=%.2f", p));
// Add cost of keeping WIFI running.
long wifiRunningTimeMs = u.getWifiRunningTime(uSecTime, which) / 1000;
mAppWifiRunning += wifiRunningTimeMs;
- power += (wifiRunningTimeMs
+ p = (wifiRunningTimeMs
* mPowerProfile.getAveragePower(PowerProfile.POWER_WIFI_ON)) / 1000;
+ power += p;
+ if (DEBUG && p != 0) Log.i(TAG, String.format("wifi running power=%.2f", p));
+
+ // Add cost of WIFI scans
+ long wifiScanTimeMs = u.getWifiScanTime(uSecTime, which) / 1000;
+ p = (wifiScanTimeMs
+ * mPowerProfile.getAveragePower(PowerProfile.POWER_WIFI_SCAN)) / 1000;
+ power += p;
+ if (DEBUG && p != 0) Log.i(TAG, String.format("wifi scanning power=%.2f", p));
// Process Sensor usage
Map<Integer, ? extends BatteryStats.Uid.Sensor> sensorStats = u.getSensorStats();
@@ -541,16 +558,16 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
sensorManager.getDefaultSensor(sensorType);
if (sensorData != null) {
multiplier = sensorData.getPower();
- if (DEBUG) {
- Log.i(TAG, "Got sensor " + sensorData.getName() + " with power = "
- + multiplier);
- }
}
}
- power += (multiplier * sensorTime) / 1000;
+ p = (multiplier * sensorTime) / 1000;
+ power += p;
+ if (DEBUG && p != 0) {
+ Log.i(TAG, String.format("sensor %s power=%.2f", sensor.toString(), p));
+ }
}
- if (DEBUG) Log.i(TAG, "UID " + u.getUid() + ": power=" + power);
+ if (DEBUG) Log.i(TAG, String.format("UID %d total power=%.2f", u.getUid(), power));
// Add the app to the list if it is consuming power
if (power != 0 || u.getUid() == 0) {
@@ -583,7 +600,6 @@ public class PowerUsageSummary extends PreferenceFragment implements Runnable {
if (power > mMaxPower) mMaxPower = power;
mTotalPower += power;
}
- if (DEBUG) Log.i(TAG, "Added power = " + power);
}
// The device has probably been awake for longer than the screen on
diff --git a/src/com/android/settings/nfc/AndroidBeam.java b/src/com/android/settings/nfc/AndroidBeam.java
index a6bd037..bf02c13 100644
--- a/src/com/android/settings/nfc/AndroidBeam.java
+++ b/src/com/android/settings/nfc/AndroidBeam.java
@@ -58,7 +58,7 @@ public class AndroidBeam extends Fragment
activity.getActionBar().setCustomView(mActionBarSwitch, new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+ Gravity.CENTER_VERTICAL | Gravity.END));
activity.getActionBar().setTitle(R.string.android_beam_settings_title);
}
}
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 603d028..6718ab0 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -149,14 +149,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
}
}
- @Override
- public void onPause() {
- super.onPause();
- if ((mDefaultRatePref != null) && (mDefaultRatePref.getDialog() != null)) {
- mDefaultRatePref.getDialog().dismiss();
- }
- }
-
private void initSettings() {
final ContentResolver resolver = getContentResolver();
@@ -288,6 +280,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
}
}
+ @Override
public boolean onPreferenceChange(Preference preference, Object objValue) {
if (KEY_DEFAULT_RATE.equals(preference.getKey())) {
// Default rate
@@ -309,6 +302,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
/**
* Called when mPlayExample is clicked
*/
+ @Override
public boolean onPreferenceClick(Preference preference) {
if (preference == mPlayExample) {
// Get the sample text from the TTS engine; onActivityResult will do
@@ -335,6 +329,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
builder.setCancelable(true);
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
+ @Override
public void onClick(DialogInterface dialog, int which) {
updateDefaultEngine(key);
}
diff --git a/src/com/android/settings/tts/TtsEnginePreference.java b/src/com/android/settings/tts/TtsEnginePreference.java
index 196882f..3d612f0 100644
--- a/src/com/android/settings/tts/TtsEnginePreference.java
+++ b/src/com/android/settings/tts/TtsEnginePreference.java
@@ -16,8 +16,6 @@
package com.android.settings.tts;
-import com.android.settings.R;
-
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -31,6 +29,9 @@ import android.widget.CompoundButton;
import android.widget.RadioButton;
+import com.android.settings.R;
+
+
public class TtsEnginePreference extends Preference {
/**
@@ -173,7 +174,8 @@ public class TtsEnginePreference extends Preference {
}
private void onRadioButtonClicked(CompoundButton buttonView, boolean isChecked) {
- if (mPreventRadioButtonCallbacks) {
+ if (mPreventRadioButtonCallbacks ||
+ (mSharedState.getCurrentChecked() == buttonView)) {
return;
}
diff --git a/src/com/android/settings/tts/TtsEngineSettingsFragment.java b/src/com/android/settings/tts/TtsEngineSettingsFragment.java
index fcc2f2e..d8e32aa 100644
--- a/src/com/android/settings/tts/TtsEngineSettingsFragment.java
+++ b/src/com/android/settings/tts/TtsEngineSettingsFragment.java
@@ -16,11 +16,11 @@
package com.android.settings.tts;
-import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
-
import android.content.ActivityNotFoundException;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -32,6 +32,9 @@ import android.speech.tts.TtsEngines;
import android.text.TextUtils;
import android.util.Log;
+import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
+
import java.util.ArrayList;
import java.util.Locale;
@@ -45,11 +48,14 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
private static final String KEY_ENGINE_SETTINGS = "tts_engine_settings";
private static final String KEY_INSTALL_DATA = "tts_install_data";
+ private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
+
private TtsEngines mEnginesHelper;
private ListPreference mLocalePreference;
private Preference mEngineSettingsPreference;
private Preference mInstallVoicesPreference;
private Intent mEngineSettingsIntent;
+ private Intent mVoiceDataDetails;
private TextToSpeech mTts;
@@ -63,13 +69,22 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
@Override
public void run() {
mLocalePreference.setEnabled(true);
- updateVoiceDetails();
}
});
}
}
};
+ private final BroadcastReceiver mLanguagesChangedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // Installed or uninstalled some data packs
+ if (TextToSpeech.Engine.ACTION_TTS_DATA_INSTALLED.equals(intent.getAction())) {
+ checkTtsData();
+ }
+ }
+ };
+
public TtsEngineSettingsFragment() {
super();
}
@@ -89,7 +104,8 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
mInstallVoicesPreference.setOnPreferenceClickListener(this);
// Remove this preference unless voices are indeed available to install.
root.removePreference(mInstallVoicesPreference);
-
+ // Remove this preference unless locales are indeed available.
+ root.removePreference(mLocalePreference);
root.setTitle(getEngineLabel());
root.setKey(getEngineName());
@@ -103,30 +119,57 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
mInstallVoicesPreference.setEnabled(false);
mLocalePreference.setEnabled(false);
+
+ mVoiceDataDetails = getArguments().getParcelable(TtsEnginePreference.FRAGMENT_ARGS_VOICES);
+
mTts = new TextToSpeech(getActivity().getApplicationContext(), mTtsInitListener,
getEngineName());
+
+ // Check if data packs changed
+ checkTtsData();
+
+ getActivity().registerReceiver(mLanguagesChangedReceiver,
+ new IntentFilter(TextToSpeech.Engine.ACTION_TTS_DATA_INSTALLED));
}
@Override
public void onDestroy() {
+ getActivity().unregisterReceiver(mLanguagesChangedReceiver);
mTts.shutdown();
super.onDestroy();
}
+ private final void checkTtsData() {
+ Intent intent = new Intent(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
+ intent.setPackage(getEngineName());
+ try {
+ if (DBG) Log.d(TAG, "Updating engine: Checking voice data: " + intent.toUri(0));
+ startActivityForResult(intent, VOICE_DATA_INTEGRITY_CHECK);
+ } catch (ActivityNotFoundException ex) {
+ Log.e(TAG, "Failed to check TTS data, no activity found for " + intent + ")");
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == VOICE_DATA_INTEGRITY_CHECK) {
+ mVoiceDataDetails = data;
+ updateVoiceDetails();
+ }
+ }
+
private void updateVoiceDetails() {
- final Intent voiceDataDetails = getArguments().getParcelable(
- TtsEnginePreference.FRAGMENT_ARGS_VOICES);
- if (DBG) Log.d(TAG, "Parsing voice data details, data: " + voiceDataDetails.toUri(0));
- ArrayList<String> available = voiceDataDetails.getStringArrayListExtra(
+ if (DBG) Log.d(TAG, "Parsing voice data details, data: " + mVoiceDataDetails.toUri(0));
+
+ final ArrayList<String> available = mVoiceDataDetails.getStringArrayListExtra(
TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES);
- ArrayList<String> unavailable = voiceDataDetails.getStringArrayListExtra(
+ final ArrayList<String> unavailable = mVoiceDataDetails.getStringArrayListExtra(
TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES);
if (available == null){
Log.e(TAG, "TTS data check failed (available == null).");
- final CharSequence[] empty = new CharSequence[0];
- mLocalePreference.setEntries(empty);
- mLocalePreference.setEntryValues(empty);
+ mLocalePreference.setEnabled(false);
+ getPreferenceScreen().removePreference(mLocalePreference);
return;
}
@@ -138,11 +181,12 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
}
if (available.size() > 0) {
+ mLocalePreference.setEnabled(true);
+ getPreferenceScreen().addPreference(mLocalePreference);
updateDefaultLocalePref(available);
} else {
- final CharSequence[] empty = new CharSequence[0];
- mLocalePreference.setEntries(empty);
- mLocalePreference.setEntryValues(empty);
+ mLocalePreference.setEnabled(false);
+ getPreferenceScreen().removePreference(mLocalePreference);
}
}
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index 84cabe9..1f4f39b 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -16,8 +16,10 @@
package com.android.settings.users;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -26,12 +28,15 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.CompressFormat;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.SystemProperties;
+import android.os.UserManager;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
@@ -50,7 +55,8 @@ import java.util.HashMap;
import java.util.List;
public class UserDetailsSettings extends SettingsPreferenceFragment
- implements Preference.OnPreferenceChangeListener, DialogCreatable {
+ implements Preference.OnPreferenceChangeListener, DialogCreatable,
+ Preference.OnPreferenceClickListener {
private static final String TAG = "UserDetailsSettings";
@@ -58,15 +64,16 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
private static final int DIALOG_CONFIRM_REMOVE = 1;
private static final String KEY_USER_NAME = "user_name";
+ private static final String KEY_USER_PICTURE = "user_picture";
private static final String KEY_INSTALLED_APPS = "market_apps_category";
private static final String KEY_SYSTEM_APPS = "system_apps_category";
+ private static final String KEY_ACCOUNT = "associated_account";
+ private static final String KEY_RESTRICTIONS = "restrictions_category";
+
public static final String EXTRA_USER_ID = "user_id";
- private static final String[] SYSTEM_APPS = {
- "com.google.android.browser",
- "com.google.android.gm",
- "com.google.android.youtube"
- };
+ private static final int RESULT_PICK_IMAGE = 1;
+ private static final int RESULT_CROP_IMAGE = 2;
static class AppState {
boolean dirty;
@@ -81,9 +88,12 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
private PreferenceGroup mSystemAppGroup;
private PreferenceGroup mInstalledAppGroup;
private EditTextPreference mNamePref;
+ private Preference mPicturePref;
+ private Preference mAccountPref;
private IPackageManager mIPm;
private PackageManager mPm;
+ private UserManager mUm;
private int mUserId;
private boolean mNewUser;
@@ -95,18 +105,25 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
mNewUser = args == null || args.getInt(EXTRA_USER_ID, -1) == -1;
mUserId = mNewUser ? -1 : args.getInt(EXTRA_USER_ID, -1);
mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+ mUm = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
if (mUserId == -1) {
- try {
- mUserId = mIPm.createUser(getString(R.string.user_new_user_name), 0).id;
- } catch (RemoteException re) {
- }
+ mUserId = mUm.createUser(getString(R.string.user_new_user_name), 0).id;
}
mSystemAppGroup = (PreferenceGroup) findPreference(KEY_SYSTEM_APPS);
mInstalledAppGroup = (PreferenceGroup) findPreference(KEY_INSTALLED_APPS);
mNamePref = (EditTextPreference) findPreference(KEY_USER_NAME);
mNamePref.setOnPreferenceChangeListener(this);
+ mPicturePref = findPreference(KEY_USER_PICTURE);
+ mPicturePref.setOnPreferenceClickListener(this);
+ mAccountPref = findPreference(KEY_ACCOUNT);
+ mAccountPref.setOnPreferenceClickListener(this);
+ if (mUserId == 0) {
+ getPreferenceScreen().removePreference(mSystemAppGroup);
+ getPreferenceScreen().removePreference(mInstalledAppGroup);
+ getPreferenceScreen().removePreference(findPreference(KEY_RESTRICTIONS));
+ }
setHasOptionsMenu(true);
}
@@ -114,7 +131,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
public void onResume() {
super.onResume();
mPm = getActivity().getPackageManager();
- if (mUserId > 0) {
+ if (mUserId >= 0) {
initExistingUser();
} else {
initNewUser();
@@ -124,6 +141,9 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ if (mUserId == 0) {
+ return;
+ }
MenuItem addAccountItem = menu.add(0, MENU_REMOVE_USER, 0,
mNewUser ? R.string.user_discard_user_menu : R.string.user_remove_user_menu);
addAccountItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
@@ -142,7 +162,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
}
private void initExistingUser() {
- List<UserInfo> users = mPm.getUsers();
+ List<UserInfo> users = mUm.getUsers();
UserInfo foundUser = null;
for (UserInfo user : users) {
if (user.id == mUserId) {
@@ -153,6 +173,9 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
if (foundUser != null) {
mNamePref.setSummary(foundUser.name);
mNamePref.setText(foundUser.name);
+ if (foundUser.iconPath != null) {
+ setPhotoId(foundUser.iconPath);
+ }
}
}
@@ -171,12 +194,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
}
private void removeUserNow() {
- try {
- mIPm.removeUser(mUserId);
- } catch (RemoteException re) {
- // Couldn't remove user. Shouldn't happen
- Log.e(TAG, "Couldn't remove user " + mUserId + "\n" + re);
- }
+ mUm.removeUser(mUserId);
finish();
}
@@ -200,6 +218,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
}
private void refreshApps() {
+ if (mUserId == 0) return;
mSystemAppGroup.removeAll();
mInstalledAppGroup.removeAll();
@@ -253,12 +272,8 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
if (TextUtils.isEmpty(name)) {
return false;
}
- try {
- mIPm.updateUserName(mUserId, (String) newValue);
- mNamePref.setSummary((String) newValue);
- } catch (RemoteException re) {
- return false;
- }
+ mUm.setUserName(mUserId, (String) newValue);
+ mNamePref.setSummary((String) newValue);
}
return true;
}
@@ -282,4 +297,69 @@ public class UserDetailsSettings extends SettingsPreferenceFragment
return null;
}
}
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (preference == mAccountPref) {
+// Intent launch = AccountManager.newChooseAccountsIntent(null, null, new String[]{"com.google"}, false, null,
+// null, null, null);
+ } else if (preference == mPicturePref) {
+ Intent intent = new Intent();
+ intent.setType("image/*");
+ intent.setAction(Intent.ACTION_GET_CONTENT);
+
+ startActivityForResult(intent, RESULT_PICK_IMAGE);
+ }
+ return false;
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (resultCode != Activity.RESULT_OK) {
+ return;
+ }
+ switch (requestCode) {
+ case RESULT_PICK_IMAGE:
+ if (data.getData() != null) {
+ Uri imageUri = data.getData();
+ System.err.println("imageUri = " + imageUri);
+ cropImage(imageUri);
+ }
+ break;
+ case RESULT_CROP_IMAGE:
+ saveCroppedImage(data);
+ break;
+ }
+ }
+
+ private void cropImage(Uri imageUri) {
+ final Uri inputPhotoUri = imageUri;
+ Intent intent = new Intent("com.android.camera.action.CROP");
+ intent.setDataAndType(inputPhotoUri, "image/*");
+ intent.putExtra("crop", "true");
+ intent.putExtra("aspectX", 1);
+ intent.putExtra("aspectY", 1);
+ intent.putExtra("outputX", 96);
+ intent.putExtra("outputY", 96);
+ intent.putExtra("return-data", true);
+ startActivityForResult(intent, RESULT_CROP_IMAGE);
+ }
+
+ private void saveCroppedImage(Intent data) {
+ if (data.hasExtra("data")) {
+ Bitmap bitmap = (Bitmap) data.getParcelableExtra("data");
+ ParcelFileDescriptor fd = mUm.setUserIcon(mUserId);
+ if (fd != null) {
+ bitmap.compress(CompressFormat.PNG, 100,
+ new ParcelFileDescriptor.AutoCloseOutputStream(fd));
+ setPhotoId(mUm.getUserInfo(mUserId).iconPath);
+ }
+ }
+ }
+
+ private void setPhotoId(String realPath) {
+ Drawable d = Drawable.createFromPath(realPath);
+ if (d == null) return;
+ mPicturePref.setIcon(d);
+ }
}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 9380586..e530493 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -16,8 +16,11 @@
package com.android.settings.users;
+import android.content.Context;
import android.content.pm.UserInfo;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.UserManager;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
@@ -79,19 +82,28 @@ public class UserSettings extends SettingsPreferenceFragment
}
private void updateUserList() {
- List<UserInfo> users = getActivity().getPackageManager().getUsers();
+ List<UserInfo> users = ((UserManager) getActivity().getSystemService(Context.USER_SERVICE))
+ .getUsers();
mUserListCategory.removeAll();
for (UserInfo user : users) {
- if (user.id == 0) continue;
Preference pref = new Preference(getActivity());
pref.setTitle(user.name);
pref.setOnPreferenceClickListener(this);
pref.setKey("id=" + user.id);
+ if (user.iconPath != null) {
+ setPhotoId(pref, user.iconPath);
+ }
mUserListCategory.addPreference(pref);
}
}
+ private void setPhotoId(Preference pref, String realPath) {
+ Drawable d = Drawable.createFromPath(realPath);
+ if (d == null) return;
+ pref.setIcon(d);
+ }
+
@Override
public boolean onPreferenceClick(Preference pref) {
String sid = pref.getKey();
diff --git a/src/com/android/settings/vpn2/VpnDialog.java b/src/com/android/settings/vpn2/VpnDialog.java
index ca85d99..9ef269b 100644
--- a/src/com/android/settings/vpn2/VpnDialog.java
+++ b/src/com/android/settings/vpn2/VpnDialog.java
@@ -16,6 +16,7 @@
package com.android.settings.vpn2;
+import com.android.internal.net.VpnProfile;
import com.android.settings.R;
import android.app.AlertDialog;
diff --git a/src/com/android/settings/vpn2/VpnProfile.java b/src/com/android/settings/vpn2/VpnProfile.java
deleted file mode 100644
index d4d0e79..0000000
--- a/src/com/android/settings/vpn2/VpnProfile.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.vpn2;
-
-import java.nio.charset.Charsets;
-
-/**
- * Parcel-like entity class for VPN profiles. To keep things simple, all
- * fields are package private. Methods are provided for serialization, so
- * storage can be implemented easily. Two rules are set for this class.
- * First, all fields must be kept non-null. Second, always make a copy
- * using clone() before modifying.
- */
-class VpnProfile implements Cloneable {
- // Match these constants with R.array.vpn_types.
- static final int TYPE_PPTP = 0;
- static final int TYPE_L2TP_IPSEC_PSK = 1;
- static final int TYPE_L2TP_IPSEC_RSA = 2;
- static final int TYPE_IPSEC_XAUTH_PSK = 3;
- static final int TYPE_IPSEC_XAUTH_RSA = 4;
- static final int TYPE_IPSEC_HYBRID_RSA = 5;
- static final int TYPE_MAX = 5;
-
- // Entity fields.
- final String key; // -1
- String name = ""; // 0
- int type = TYPE_PPTP; // 1
- String server = ""; // 2
- String username = ""; // 3
- String password = ""; // 4
- String dnsServers = ""; // 5
- String searchDomains = ""; // 6
- String routes = ""; // 7
- boolean mppe = true; // 8
- String l2tpSecret = ""; // 9
- String ipsecIdentifier = "";// 10
- String ipsecSecret = ""; // 11
- String ipsecUserCert = ""; // 12
- String ipsecCaCert = ""; // 13
- String ipsecServerCert = "";// 14
-
- // Helper fields.
- boolean saveLogin = false;
-
- VpnProfile(String key) {
- this.key = key;
- }
-
- static VpnProfile decode(String key, byte[] value) {
- try {
- if (key == null) {
- return null;
- }
-
- String[] values = new String(value, Charsets.UTF_8).split("\0", -1);
- // There can be 14 or 15 values in ICS MR1.
- if (values.length < 14 || values.length > 15) {
- return null;
- }
-
- VpnProfile profile = new VpnProfile(key);
- profile.name = values[0];
- profile.type = Integer.valueOf(values[1]);
- if (profile.type < 0 || profile.type > TYPE_MAX) {
- return null;
- }
- profile.server = values[2];
- profile.username = values[3];
- profile.password = values[4];
- profile.dnsServers = values[5];
- profile.searchDomains = values[6];
- profile.routes = values[7];
- profile.mppe = Boolean.valueOf(values[8]);
- profile.l2tpSecret = values[9];
- profile.ipsecIdentifier = values[10];
- profile.ipsecSecret = values[11];
- profile.ipsecUserCert = values[12];
- profile.ipsecCaCert = values[13];
- profile.ipsecServerCert = (values.length > 14) ? values[14] : "";
-
- profile.saveLogin = !profile.username.isEmpty() || !profile.password.isEmpty();
- return profile;
- } catch (Exception e) {
- // ignore
- }
- return null;
- }
-
- byte[] encode() {
- StringBuilder builder = new StringBuilder(name);
- builder.append('\0').append(type);
- builder.append('\0').append(server);
- builder.append('\0').append(saveLogin ? username : "");
- builder.append('\0').append(saveLogin ? password : "");
- builder.append('\0').append(dnsServers);
- builder.append('\0').append(searchDomains);
- builder.append('\0').append(routes);
- builder.append('\0').append(mppe);
- builder.append('\0').append(l2tpSecret);
- builder.append('\0').append(ipsecIdentifier);
- builder.append('\0').append(ipsecSecret);
- builder.append('\0').append(ipsecUserCert);
- builder.append('\0').append(ipsecCaCert);
- builder.append('\0').append(ipsecServerCert);
- return builder.toString().getBytes(Charsets.UTF_8);
- }
-}
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index a26623b..a8cb35d 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -42,6 +42,7 @@ import android.widget.Toast;
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
+import com.android.internal.net.VpnProfile;
import com.android.settings.SettingsPreferenceFragment;
import java.net.Inet4Address;
diff --git a/src/com/android/settings/widget/ChartView.java b/src/com/android/settings/widget/ChartView.java
index f410d57..6441612 100644
--- a/src/com/android/settings/widget/ChartView.java
+++ b/src/com/android/settings/widget/ChartView.java
@@ -38,7 +38,7 @@ import com.android.settings.R;
public class ChartView extends FrameLayout {
// TODO: extend something that supports two-dimensional scrolling
- private static final int SWEEP_GRAVITY = Gravity.TOP | Gravity.LEFT;
+ private static final int SWEEP_GRAVITY = Gravity.TOP | Gravity.START;
ChartAxis mHoriz;
ChartAxis mVert;
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index 1d411f7..3fe5b39 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -34,6 +34,7 @@ import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.IPowerManager;
+import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
@@ -94,16 +95,10 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
R.drawable.appwidget_settings_ind_on_r_holo
};
- /**
- * Minimum and maximum brightnesses. Don't go to 0 since that makes the display unusable
- */
- private static final int MINIMUM_BACKLIGHT = android.os.PowerManager.BRIGHTNESS_DIM + 10;
- private static final int MAXIMUM_BACKLIGHT = android.os.PowerManager.BRIGHTNESS_ON;
- private static final int DEFAULT_BACKLIGHT = (int) (android.os.PowerManager.BRIGHTNESS_ON * 0.4f);
/** Minimum brightness at which the indicator is shown at half-full and ON */
- private static final int HALF_BRIGHTNESS_THRESHOLD = (int) (0.3 * MAXIMUM_BACKLIGHT);
+ private static final float HALF_BRIGHTNESS_THRESHOLD = 0.3f;
/** Minimum brightness at which the indicator is shown at full */
- private static final int FULL_BRIGHTNESS_THRESHOLD = (int) (0.8 * MAXIMUM_BACKLIGHT);
+ private static final float FULL_BRIGHTNESS_THRESHOLD = 0.8f;
private static final StateTracker sWifiState = new WifiStateTracker();
private static final StateTracker sBluetoothState = new BluetoothStateTracker();
@@ -684,11 +679,16 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
R.drawable.appwidget_settings_ind_on_r_holo);
} else {
final int brightness = getBrightness(context);
+ final PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
// Set the icon
- if (brightness > FULL_BRIGHTNESS_THRESHOLD) {
+ final int full = (int)(pm.getMaximumScreenBrightnessSetting()
+ * FULL_BRIGHTNESS_THRESHOLD);
+ final int half = (int)(pm.getMaximumScreenBrightnessSetting()
+ * HALF_BRIGHTNESS_THRESHOLD);
+ if (brightness > full) {
views.setImageViewResource(R.id.img_brightness,
R.drawable.ic_appwidget_settings_brightness_full_holo);
- } else if (brightness > HALF_BRIGHTNESS_THRESHOLD) {
+ } else if (brightness > half) {
views.setImageViewResource(R.id.img_brightness,
R.drawable.ic_appwidget_settings_brightness_half_holo);
} else {
@@ -696,7 +696,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
R.drawable.ic_appwidget_settings_brightness_off_holo);
}
// Set the ON state
- if (brightness > HALF_BRIGHTNESS_THRESHOLD) {
+ if (brightness > half) {
views.setImageViewResource(R.id.ind_brightness,
R.drawable.appwidget_settings_ind_on_r_holo);
} else {
@@ -775,13 +775,9 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
*/
private static int getBrightness(Context context) {
try {
- IPowerManager power = IPowerManager.Stub.asInterface(
- ServiceManager.getService("power"));
- if (power != null) {
- int brightness = Settings.System.getInt(context.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS);
- return brightness;
- }
+ int brightness = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS);
+ return brightness;
} catch (Exception e) {
}
return 0;
@@ -795,13 +791,9 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
*/
private static boolean getBrightnessMode(Context context) {
try {
- IPowerManager power = IPowerManager.Stub.asInterface(
- ServiceManager.getService("power"));
- if (power != null) {
- int brightnessMode = Settings.System.getInt(context.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS_MODE);
- return brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
- }
+ int brightnessMode = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS_MODE);
+ return brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
} catch (Exception e) {
Log.d(TAG, "getBrightnessMode: " + e);
}
@@ -818,6 +810,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
IPowerManager power = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
if (power != null) {
+ PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
+
ContentResolver cr = context.getContentResolver();
int brightness = Settings.System.getInt(cr,
Settings.System.SCREEN_BRIGHTNESS);
@@ -832,15 +826,15 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
// Rotate AUTO -> MINIMUM -> DEFAULT -> MAXIMUM
// Technically, not a toggle...
if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
- brightness = MINIMUM_BACKLIGHT;
+ brightness = pm.getMinimumScreenBrightnessSetting();
brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
- } else if (brightness < DEFAULT_BACKLIGHT) {
- brightness = DEFAULT_BACKLIGHT;
- } else if (brightness < MAXIMUM_BACKLIGHT) {
- brightness = MAXIMUM_BACKLIGHT;
+ } else if (brightness < pm.getDefaultScreenBrightnessSetting()) {
+ brightness = pm.getDefaultScreenBrightnessSetting();
+ } else if (brightness < pm.getMaximumScreenBrightnessSetting()) {
+ brightness = pm.getMaximumScreenBrightnessSetting();
} else {
brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
- brightness = MINIMUM_BACKLIGHT;
+ brightness = pm.getMinimumScreenBrightnessSetting();
}
if (context.getResources().getBoolean(
@@ -854,7 +848,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
}
if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) {
- power.setBacklightBrightness(brightness);
+ power.setTemporaryScreenBrightnessSettingOverride(brightness);
Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness);
}
}
diff --git a/src/com/android/settings/wifi/AdvancedWifiSettings.java b/src/com/android/settings/wifi/AdvancedWifiSettings.java
index bb50d2a..c9bf3bc 100644
--- a/src/com/android/settings/wifi/AdvancedWifiSettings.java
+++ b/src/com/android/settings/wifi/AdvancedWifiSettings.java
@@ -44,6 +44,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
private static final String KEY_NOTIFY_OPEN_NETWORKS = "notify_open_networks";
private static final String KEY_SLEEP_POLICY = "sleep_policy";
private static final String KEY_POOR_NETWORK_DETECTION = "wifi_poor_network_detection";
+ private static final String KEY_SUSPEND_OPTIMIZATIONS = "suspend_optimizations";
private WifiManager mWifiManager;
@@ -84,6 +85,11 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
}
}
+ CheckBoxPreference suspendOptimizations =
+ (CheckBoxPreference) findPreference(KEY_SUSPEND_OPTIMIZATIONS);
+ suspendOptimizations.setChecked(Secure.getInt(getContentResolver(),
+ Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1);
+
ListPreference frequencyPref = (ListPreference) findPreference(KEY_FREQUENCY_BAND);
if (mWifiManager.isDualBandSupported()) {
@@ -148,6 +154,10 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
Secure.putInt(getContentResolver(),
Secure.WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED,
((CheckBoxPreference) preference).isChecked() ? 1 : 0);
+ } else if (KEY_SUSPEND_OPTIMIZATIONS.equals(key)) {
+ Secure.putInt(getContentResolver(),
+ Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED,
+ ((CheckBoxPreference) preference).isChecked() ? 1 : 0);
} else {
return super.onPreferenceTreeClick(screen, preference);
}
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index de42f2a..a4ee589 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -114,7 +114,6 @@ public class WifiSettings extends SettingsPreferenceFragment
private final Scanner mScanner;
private WifiManager mWifiManager;
- private WifiManager.Channel mChannel;
private WifiManager.ActionListener mConnectListener;
private WifiManager.ActionListener mSaveListener;
private WifiManager.ActionListener mForgetListener;
@@ -243,7 +242,6 @@ public class WifiSettings extends SettingsPreferenceFragment
mP2pSupported = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT);
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
- mChannel = mWifiManager.initialize(getActivity(), getActivity().getMainLooper(), null);
mConnectListener = new WifiManager.ActionListener() {
public void onSuccess() {
@@ -344,7 +342,7 @@ public class WifiSettings extends SettingsPreferenceFragment
activity.getActionBar().setCustomView(actionBarSwitch, new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT,
- Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+ Gravity.CENTER_VERTICAL | Gravity.END));
}
}
@@ -373,7 +371,7 @@ public class WifiSettings extends SettingsPreferenceFragment
getActivity().registerReceiver(mReceiver, mFilter);
if (mKeyStoreNetworkId != INVALID_NETWORK_ID &&
KeyStore.getInstance().state() == KeyStore.State.UNLOCKED) {
- mWifiManager.connect(mChannel, mKeyStoreNetworkId, mConnectListener);
+ mWifiManager.connect(mKeyStoreNetworkId, mConnectListener);
}
mKeyStoreNetworkId = INVALID_NETWORK_ID;
@@ -520,13 +518,13 @@ public class WifiSettings extends SettingsPreferenceFragment
case MENU_ID_CONNECT: {
if (mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
if (!requireKeyStore(mSelectedAccessPoint.getConfig())) {
- mWifiManager.connect(mChannel, mSelectedAccessPoint.networkId,
+ mWifiManager.connect(mSelectedAccessPoint.networkId,
mConnectListener);
}
} else if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE) {
/** Bypass dialog for unsecured networks */
mSelectedAccessPoint.generateOpenNetworkConfig();
- mWifiManager.connect(mChannel, mSelectedAccessPoint.getConfig(),
+ mWifiManager.connect(mSelectedAccessPoint.getConfig(),
mConnectListener);
} else {
showDialog(mSelectedAccessPoint, true);
@@ -534,7 +532,7 @@ public class WifiSettings extends SettingsPreferenceFragment
return true;
}
case MENU_ID_FORGET: {
- mWifiManager.forget(mChannel, mSelectedAccessPoint.networkId, mForgetListener);
+ mWifiManager.forget(mSelectedAccessPoint.networkId, mForgetListener);
return true;
}
case MENU_ID_MODIFY: {
@@ -553,7 +551,7 @@ public class WifiSettings extends SettingsPreferenceFragment
if (mSelectedAccessPoint.security == AccessPoint.SECURITY_NONE &&
mSelectedAccessPoint.networkId == INVALID_NETWORK_ID) {
mSelectedAccessPoint.generateOpenNetworkConfig();
- mWifiManager.connect(mChannel, mSelectedAccessPoint.getConfig(), mConnectListener);
+ mWifiManager.connect(mSelectedAccessPoint.getConfig(), mConnectListener);
} else {
showDialog(mSelectedAccessPoint, false);
}
@@ -863,18 +861,18 @@ public class WifiSettings extends SettingsPreferenceFragment
if (mSelectedAccessPoint != null
&& !requireKeyStore(mSelectedAccessPoint.getConfig())
&& mSelectedAccessPoint.networkId != INVALID_NETWORK_ID) {
- mWifiManager.connect(mChannel, mSelectedAccessPoint.networkId,
+ mWifiManager.connect(mSelectedAccessPoint.networkId,
mConnectListener);
}
} else if (config.networkId != INVALID_NETWORK_ID) {
if (mSelectedAccessPoint != null) {
- mWifiManager.save(mChannel, config, mSaveListener);
+ mWifiManager.save(config, mSaveListener);
}
} else {
if (configController.isEdit() || requireKeyStore(config)) {
- mWifiManager.save(mChannel, config, mSaveListener);
+ mWifiManager.save(config, mSaveListener);
} else {
- mWifiManager.connect(mChannel, config, mConnectListener);
+ mWifiManager.connect(config, mConnectListener);
}
}
@@ -891,7 +889,7 @@ public class WifiSettings extends SettingsPreferenceFragment
return;
}
- mWifiManager.forget(mChannel, mSelectedAccessPoint.networkId, mForgetListener);
+ mWifiManager.forget(mSelectedAccessPoint.networkId, mForgetListener);
if (mWifiManager.isWifiEnabled()) {
mScanner.resume();
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index 8258b55..bc387cb 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -38,7 +38,6 @@ import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
-import com.android.internal.util.AsyncChannel;
import com.android.settings.R;
import java.util.Collection;
@@ -74,7 +73,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
private WifiSettings mWifiSettings;
private WifiManager mWifiManager;
- private WifiManager.Channel mChannel;
/** Used for resizing a padding above title. Hiden when software keyboard is shown. */
private View mTopPadding;
@@ -143,7 +141,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
setContentView(R.layout.wifi_settings_for_setup_wizard_xl);
mWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
- mChannel = mWifiManager.initialize(this, getMainLooper(), null);
// There's no button here enabling wifi network, so we need to enable it without
// users' request.
mWifiManager.setWifiEnabled(true);
@@ -596,7 +593,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
Log.d(TAG, String.format("forgeting Wi-Fi network \"%s\" (id: %d)",
config.SSID, config.networkId));
}
- mWifiManager.forget(mChannel, config.networkId, new WifiManager.ActionListener() {
+ mWifiManager.forget(config.networkId, new WifiManager.ActionListener() {
public void onSuccess() {
}
public void onFailure(int reason) {
@@ -761,7 +758,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
*/
/* package */ void onSaveNetwork(WifiConfiguration config) {
// We want to both save and connect a network. connectNetwork() does both.
- mWifiManager.connect(mChannel, config, new WifiManager.ActionListener() {
+ mWifiManager.connect(config, new WifiManager.ActionListener() {
public void onSuccess() {
}
public void onFailure(int reason) {
diff --git a/src/com/android/settings/wifi/WpsDialog.java b/src/com/android/settings/wifi/WpsDialog.java
index 40b2a35..b5b48ba 100644
--- a/src/com/android/settings/wifi/WpsDialog.java
+++ b/src/com/android/settings/wifi/WpsDialog.java
@@ -56,7 +56,6 @@ public class WpsDialog extends AlertDialog {
private static final int WPS_TIMEOUT_S = 120;
private WifiManager mWifiManager;
- private WifiManager.Channel mChannel;
private WifiManager.WpsListener mWpsListener;
private int mWpsSetup;
@@ -155,7 +154,6 @@ public class WpsDialog extends AlertDialog {
});
mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
- mChannel = mWifiManager.initialize(mContext, mContext.getMainLooper(), null);
setView(mView);
super.onCreate(savedInstanceState);
@@ -184,13 +182,13 @@ public class WpsDialog extends AlertDialog {
WpsInfo wpsConfig = new WpsInfo();
wpsConfig.setup = mWpsSetup;
- mWifiManager.startWps(mChannel, wpsConfig, mWpsListener);
+ mWifiManager.startWps(wpsConfig, mWpsListener);
}
@Override
protected void onStop() {
if (mDialogState != DialogState.WPS_COMPLETE) {
- mWifiManager.cancelWps(mChannel, null);
+ mWifiManager.cancelWps(null);
}
if (mReceiver != null) {