Merge "Settings for the screen magnification feature." into jb-mr1-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index decfe92..fd00184 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1965,6 +1965,9 @@
     <!-- Storage setting.  Summary for PTP checkbox [CHAR LIMIT=NONE]-->
     <string name="usb_label_installer_cd">"Install file-transfer tools"</string>
 
+    <!-- Section header above list of other users storage [CHAR LIMIT=32] -->
+    <string name="storage_other_users">Other users</string>
+
     <!-- Phone info screen, section titles: -->
     <string name="battery_status_title">Battery status</string>
     <!-- Phone info screen, section titles: -->
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index d0ec1e7..9837193 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -869,14 +869,14 @@
 
     private boolean getDataRoaming() {
         final ContentResolver resolver = getActivity().getContentResolver();
-        return Settings.Secure.getInt(resolver, Settings.Secure.DATA_ROAMING, 0) != 0;
+        return Settings.Global.getInt(resolver, Settings.Global.DATA_ROAMING, 0) != 0;
     }
 
     private void setDataRoaming(boolean enabled) {
         // TODO: teach telephony DataConnectionTracker to watch and apply
         // updates when changed.
         final ContentResolver resolver = getActivity().getContentResolver();
-        Settings.Secure.putInt(resolver, Settings.Secure.DATA_ROAMING, enabled ? 1 : 0);
+        Settings.Global.putInt(resolver, Settings.Global.DATA_ROAMING, enabled ? 1 : 0);
         mMenuDataRoaming.setChecked(enabled);
     }
 
@@ -1899,7 +1899,7 @@
 
     /**
      * Dialog to request user confirmation before setting
-     * {@link android.provider.Settings.Secure#DATA_ROAMING}.
+     * {@link android.provider.Settings.Global#DATA_ROAMING}.
      */
     public static class ConfirmDataRoamingFragment extends DialogFragment {
         public static void show(DataUsageSummary parent) {
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 8ebcd1c..f590ea6 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -322,8 +322,8 @@
         }
 
         final ContentResolver cr = getActivity().getContentResolver();
-        mLastEnabledState = Settings.Secure.getInt(cr,
-                Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
+        mLastEnabledState = Settings.Global.getInt(cr,
+                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
         mEnabledSwitch.setChecked(mLastEnabledState);
         setPrefsEnabledState(mLastEnabledState);
 
@@ -332,8 +332,8 @@
             // settings that are enabled.  This is an invalid state.  Switch
             // to debug settings being enabled, so the user knows there is
             // stuff enabled and can turn it all off if they want.
-            Settings.Secure.putInt(getActivity().getContentResolver(),
-                    Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 1);
+            Settings.Global.putInt(getActivity().getContentResolver(),
+                    Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
             mLastEnabledState = true;
             setPrefsEnabledState(mLastEnabledState);
         }
@@ -348,12 +348,12 @@
         final Context context = getActivity();
         final ContentResolver cr = context.getContentResolver();
         mHaveDebugSettings = false;
-        updateCheckBox(mEnableAdb, Settings.Secure.getInt(cr,
-                Settings.Secure.ADB_ENABLED, 0) != 0);
+        updateCheckBox(mEnableAdb, Settings.Global.getInt(cr,
+                Settings.Global.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(mKeepScreenOn, Settings.Global.getInt(cr,
+                Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
         updateCheckBox(mEnforceReadExternal, isPermissionEnforced(READ_EXTERNAL_STORAGE));
         updateCheckBox(mAllowMockLocation, Settings.Secure.getInt(cr,
                 Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
@@ -834,8 +834,8 @@
                     mEnableDialog.setOnDismissListener(this);
                 } else {
                     resetDangerousOptions();
-                    Settings.Secure.putInt(getActivity().getContentResolver(),
-                            Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0);
+                    Settings.Global.putInt(getActivity().getContentResolver(),
+                            Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
                     mLastEnabledState = isChecked;
                     setPrefsEnabledState(mLastEnabledState);
                 }
@@ -876,16 +876,16 @@
                         .show();
                 mAdbDialog.setOnDismissListener(this);
             } else {
-                Settings.Secure.putInt(getActivity().getContentResolver(),
-                        Settings.Secure.ADB_ENABLED, 0);
+                Settings.Global.putInt(getActivity().getContentResolver(),
+                        Settings.Global.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, 
+            Settings.Global.putInt(getActivity().getContentResolver(),
+                    Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
                     mKeepScreenOn.isChecked() ? 
                     (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB) : 0);
         } else if (preference == mEnforceReadExternal) {
@@ -979,8 +979,8 @@
         if (dialog == mAdbDialog) {
             if (which == DialogInterface.BUTTON_POSITIVE) {
                 mDialogClicked = true;
-                Settings.Secure.putInt(getActivity().getContentResolver(),
-                        Settings.Secure.ADB_ENABLED, 1);
+                Settings.Global.putInt(getActivity().getContentResolver(),
+                        Settings.Global.ADB_ENABLED, 1);
             } else {
                 // Reset the toggle
                 mEnableAdb.setChecked(false);
@@ -988,8 +988,8 @@
         } else if (dialog == mEnableDialog) {
             if (which == DialogInterface.BUTTON_POSITIVE) {
                 mDialogClicked = true;
-                Settings.Secure.putInt(getActivity().getContentResolver(),
-                        Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 1);
+                Settings.Global.putInt(getActivity().getContentResolver(),
+                        Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
                 mLastEnabledState = true;
                 setPrefsEnabledState(mLastEnabledState);
             } else {
diff --git a/src/com/android/settings/LocationSettings.java b/src/com/android/settings/LocationSettings.java
index d5c4d9f..4153485 100644
--- a/src/com/android/settings/LocationSettings.java
+++ b/src/com/android/settings/LocationSettings.java
@@ -129,7 +129,7 @@
                 mAssistedGps.setEnabled(enabled);
             }
         } else if (preference == mAssistedGps) {
-            Settings.Secure.putInt(cr, Settings.Secure.ASSISTED_GPS_ENABLED,
+            Settings.Global.putInt(cr, Settings.Global.ASSISTED_GPS_ENABLED,
                     mAssistedGps.isChecked() ? 1 : 0);
         } else {
             // If we didn't handle it, let preferences handle it.
@@ -152,8 +152,8 @@
         mNetwork.setChecked(networkEnabled);
         mLocationAccess.setChecked(gpsEnabled || networkEnabled);
         if (mAssistedGps != null) {
-            mAssistedGps.setChecked(Settings.Secure.getInt(res,
-                    Settings.Secure.ASSISTED_GPS_ENABLED, 2) == 1);
+            mAssistedGps.setChecked(Settings.Global.getInt(res,
+                    Settings.Global.ASSISTED_GPS_ENABLED, 2) == 1);
             mAssistedGps.setEnabled(gpsEnabled);
         }
     }
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 8f33b9b..e1e4a09 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -229,13 +229,13 @@
     }
 
     private boolean isNonMarketAppsAllowed() {
-        return Settings.Secure.getInt(getContentResolver(),
-                                      Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
+        return Settings.Global.getInt(getContentResolver(),
+                                      Settings.Global.INSTALL_NON_MARKET_APPS, 0) > 0;
     }
 
     private void setNonMarketAppsAllowed(boolean enabled) {
         // Change the system setting
-        Settings.Secure.putInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS,
+        Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS,
                                 enabled ? 1 : 0);
     }
 
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index 2f477ea..794c478 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -101,8 +101,7 @@
 
     private void addCategoryForVolume(StorageVolume volume) {
         final StorageVolumePreferenceCategory category = new StorageVolumePreferenceCategory(
-                getActivity(), volume, mStorageManager);
-        // TODO: if primary emulated storage, then insert split items
+                getActivity(), volume);
         mCategories.add(category);
         getPreferenceScreen().addPreference(category);
         category.init();
diff --git a/src/com/android/settings/deviceinfo/PercentageBarChart.java b/src/com/android/settings/deviceinfo/PercentageBarChart.java
index b45eb69..cb25b81 100644
--- a/src/com/android/settings/deviceinfo/PercentageBarChart.java
+++ b/src/com/android/settings/deviceinfo/PercentageBarChart.java
@@ -16,8 +16,6 @@
 
 package com.android.settings.deviceinfo;
 
-import com.android.settings.R;
-
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
@@ -26,10 +24,13 @@
 import android.util.AttributeSet;
 import android.view.View;
 
+import com.android.settings.R;
+
 import java.util.Collection;
 
 /**
- * 
+ * Draws a horizontal bar chart with colored slices, each represented by
+ * {@link Entry}.
  */
 public class PercentageBarChart extends View {
     private final Paint mEmptyPaint = new Paint();
@@ -38,14 +39,21 @@
 
     private int mMinTickWidth = 1;
 
-    public static class Entry {
+    public static class Entry implements Comparable<Entry> {
+        public final int order;
         public final float percentage;
         public final Paint paint;
 
-        protected Entry(float percentage, Paint paint) {
+        protected Entry(int order, float percentage, Paint paint) {
+            this.order = order;
             this.percentage = percentage;
             this.paint = paint;
         }
+
+        @Override
+        public int compareTo(Entry another) {
+            return order - another.order;
+        }
     }
 
     public PercentageBarChart(Context context, AttributeSet attrs) {
@@ -139,12 +147,11 @@
      * @param percentage the total width that
      * @param color the color to draw the entry
      */
-    public static Entry createEntry(float percentage, int color) {
+    public static Entry createEntry(int order, float percentage, int color) {
         final Paint p = new Paint();
         p.setColor(color);
         p.setStyle(Paint.Style.FILL);
-
-        return new Entry(percentage, p);
+        return new Entry(order, percentage, p);
     }
 
     public void setEntries(Collection<Entry> entries) {
diff --git a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
index 063f68d..4c7c3e6 100644
--- a/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
+++ b/src/com/android/settings/deviceinfo/StorageVolumePreferenceCategory.java
@@ -43,6 +43,7 @@
 import com.google.android.collect.Lists;
 
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -65,10 +66,14 @@
     private Preference mFormatPreference;
     private Preference mStorageLow;
 
-    private final Resources mResources;
+    private final StorageVolume mVolume;
 
-    private final StorageVolume mStorageVolume;
+    private final boolean mIsEmulated;
+    private final boolean mIsPrimary;
+
+    private final Resources mResources;
     private final StorageManager mStorageManager;
+    private final UserManager mUserManager;
 
     /** Measurement for local user. */
     private StorageMeasurement mLocalMeasure;
@@ -76,7 +81,6 @@
     private List<StorageMeasurement> mAllMeasures = Lists.newArrayList();
 
     private boolean mAllowFormat;
-    private final boolean mMeasureUsers;
 
     private boolean mUsbConnected;
     private String mUsbFunction;
@@ -166,15 +170,17 @@
         }
     };
 
-    public StorageVolumePreferenceCategory(
-            Context context, StorageVolume volume, StorageManager storageManager) {
+    public StorageVolumePreferenceCategory(Context context, StorageVolume volume) {
         super(context);
+
+        mVolume = volume;
+
+        mIsPrimary = volume != null ? volume.isPrimary() : false;
+        mIsEmulated = volume != null ? volume.isEmulated() : false;
+
         mResources = context.getResources();
-
-        mStorageVolume = volume;
-        mStorageManager = storageManager;
-
-        final boolean isPrimary = volume != null ? volume.isPrimary() : false;
+        mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
 
         setTitle(volume != null ? volume.getDescription(context)
                 : context.getText(R.string.internal_storage));
@@ -183,13 +189,11 @@
         mAllMeasures.add(mLocalMeasure);
 
         // Cannot format emulated storage
-        mAllowFormat = mStorageVolume != null && !mStorageVolume.isEmulated();
+        mAllowFormat = mVolume != null && !mVolume.isEmulated();
+
         // For now we are disabling reformatting secondary external storage
         // until some interoperability problems with MTP are fixed
-        if (!isPrimary) mAllowFormat = false;
-
-        // Measure other users when showing primary emulated storage
-        mMeasureUsers = (mStorageVolume != null && mStorageVolume.isEmulated()) && isPrimary;
+        if (!mIsPrimary) mAllowFormat = false;
     }
 
     private void addStorageItem(String key, int titleRes, int colorRes) {
@@ -203,41 +207,43 @@
     public void init() {
         final Context context = getContext();
 
+        final UserInfo currentUser;
+        try {
+            currentUser = ActivityManagerNative.getDefault().getCurrentUser();
+        } catch (RemoteException e) {
+            throw new RuntimeException("Failed to get current user");
+        }
+
+        final List<UserInfo> otherUsers = getUsersExcluding(currentUser);
+        final boolean measureUsers = mIsEmulated && mIsPrimary && otherUsers.size() > 0;
+
         mUsageBarPreference = new UsageBarPreference(context);
         mUsageBarPreference.setOrder(ORDER_USAGE_BAR);
         addPreference(mUsageBarPreference);
 
         addStorageItem(KEY_TOTAL_SIZE, R.string.memory_size, 0);
+        addStorageItem(KEY_AVAILABLE, R.string.memory_available, R.color.memory_avail);
+
+        if (measureUsers) {
+            addPreference(new PreferenceHeader(context, currentUser.name));
+        }
+
         addStorageItem(KEY_APPLICATIONS, R.string.memory_apps_usage, R.color.memory_apps_usage);
         addStorageItem(KEY_DCIM, R.string.memory_dcim_usage, R.color.memory_dcim);
         addStorageItem(KEY_MUSIC, R.string.memory_music_usage, R.color.memory_music);
         addStorageItem(KEY_DOWNLOADS, R.string.memory_downloads_usage, R.color.memory_downloads);
         addStorageItem(KEY_MISC, R.string.memory_media_misc_usage, R.color.memory_misc);
-        addStorageItem(KEY_AVAILABLE, R.string.memory_available, R.color.memory_avail);
 
-        if (mMeasureUsers) {
-            final UserManager userManager = (UserManager) context.getSystemService(
-                    Context.USER_SERVICE);
-
-            final UserInfo currentUser;
-            try {
-                currentUser = ActivityManagerNative.getDefault().getCurrentUser();
-            } catch (RemoteException e) {
-                throw new RuntimeException("Failed to get current user");
-            }
+        if (measureUsers) {
+            addPreference(new PreferenceHeader(context, R.string.storage_other_users));
 
             int count = 0;
-            for (UserInfo info : userManager.getUsers()) {
-                // Only measure other users
-                if (info.id == currentUser.id) {
-                    continue;
-                }
-
+            for (UserInfo info : otherUsers) {
                 final UserHandle user = new UserHandle(info.id);
                 final String key = buildUserKey(user);
 
                 final StorageMeasurement measure = StorageMeasurement.getInstance(
-                        context, mStorageVolume, user);
+                        context, mVolume, user);
                 measure.setIncludeAppCodeSize(false);
                 mAllMeasures.add(measure);
 
@@ -276,14 +282,14 @@
     }
 
     public StorageVolume getStorageVolume() {
-        return mStorageVolume;
+        return mVolume;
     }
 
     private void updatePreferencesFromState() {
         mMountTogglePreference.setEnabled(true);
 
-        String state = mStorageVolume != null
-                ? mStorageManager.getVolumeState(mStorageVolume.getPath())
+        String state = mVolume != null
+                ? mStorageManager.getVolumeState(mVolume.getPath())
                 : Environment.MEDIA_MOUNTED;
 
         String readOnly = "";
@@ -295,7 +301,7 @@
             }
         }
 
-        if ((mStorageVolume == null || !mStorageVolume.isRemovable())
+        if ((mVolume == null || !mVolume.isRemovable())
                 && !Environment.MEDIA_UNMOUNTED.equals(state)) {
             // This device has built-in storage that is not removable.
             // There is no reason for the user to unmount it.
@@ -354,7 +360,7 @@
         final long usedSize = totalSize - availSize;
 
         mUsageBarPreference.clear();
-        mUsageBarPreference.addEntry(usedSize / (float) totalSize, android.graphics.Color.GRAY);
+        mUsageBarPreference.addEntry(0, usedSize / (float) totalSize, android.graphics.Color.GRAY);
         mUsageBarPreference.commit();
         mShowingApprox = true;
 
@@ -373,7 +379,8 @@
         if (mLocalMeasure.isExternalSDCard()) {
             // TODO FIXME: external SD card will not report any size. Show used space in bar graph
             final long usedSize = totalSize - availSize;
-            mUsageBarPreference.addEntry(usedSize / (float) totalSize, android.graphics.Color.GRAY);
+            mUsageBarPreference.addEntry(
+                    0, usedSize / (float) totalSize, android.graphics.Color.GRAY);
         }
 
         updatePreference(appsSize, totalSize, KEY_APPLICATIONS);
@@ -415,13 +422,15 @@
         updatePreference(size, totalSize, category, true);
     }
 
-    private void updatePreference(long size, long totalSize, String category, boolean showBar) {
+    private void updatePreference(long size, long totalSize, String category, boolean addBar) {
         final StorageItemPreference pref = (StorageItemPreference) findPreference(category);
+
         if (pref != null) {
             if (size > 0) {
                 pref.setSummary(formatSize(size));
-                if (showBar) {
-                    mUsageBarPreference.addEntry(size / (float) totalSize, pref.getColor());
+                if (addBar) {
+                    final int order = pref.getOrder();
+                    mUsageBarPreference.addEntry(order, size / (float) totalSize, pref.getColor());
                 }
             } else {
                 removePreference(pref);
@@ -497,7 +506,7 @@
         if (pref == mFormatPreference) {
             intent = new Intent(Intent.ACTION_VIEW);
             intent.setClass(getContext(), com.android.settings.MediaFormat.class);
-            intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, mStorageVolume);
+            intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, mVolume);
         } else if (KEY_APPLICATIONS.equals(key)) {
             intent = new Intent(Intent.ACTION_MANAGE_PACKAGE_STORAGE);
             intent.setClass(getContext(),
@@ -517,10 +526,42 @@
             Context context = getContext().getApplicationContext();
             if (mLocalMeasure.getMiscSize() > 0) {
                 intent = new Intent(context, MiscFilesHandler.class);
-                intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, mStorageVolume);
+                intent.putExtra(StorageVolume.EXTRA_STORAGE_VOLUME, mVolume);
             }
         }
 
         return intent;
     }
+
+    public static class PreferenceHeader extends Preference {
+        public PreferenceHeader(Context context, int titleRes) {
+            super(context, null, com.android.internal.R.attr.preferenceCategoryStyle);
+            setTitle(titleRes);
+        }
+
+        public PreferenceHeader(Context context, CharSequence title) {
+            super(context, null, com.android.internal.R.attr.preferenceCategoryStyle);
+            setTitle(title);
+        }
+
+        @Override
+        public boolean isEnabled() {
+            return false;
+        }
+    }
+
+
+    /**
+     * Return list of other users, excluding the current user.
+     */
+    private List<UserInfo> getUsersExcluding(UserInfo excluding) {
+        final List<UserInfo> users = mUserManager.getUsers();
+        final Iterator<UserInfo> i = users.iterator();
+        while (i.hasNext()) {
+            if (i.next().id == excluding.id) {
+                i.remove();
+            }
+        }
+        return users;
+    }
 }
diff --git a/src/com/android/settings/deviceinfo/UsageBarPreference.java b/src/com/android/settings/deviceinfo/UsageBarPreference.java
index 5aeaef5..2f3fd03 100644
--- a/src/com/android/settings/deviceinfo/UsageBarPreference.java
+++ b/src/com/android/settings/deviceinfo/UsageBarPreference.java
@@ -17,6 +17,7 @@
 package com.android.settings.deviceinfo;
 
 import com.android.settings.R;
+import com.google.common.collect.Lists;
 
 import android.content.Context;
 import android.preference.Preference;
@@ -25,6 +26,8 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * Creates a percentage bar chart inside a preference.
@@ -32,7 +35,7 @@
 public class UsageBarPreference extends Preference {
     private PercentageBarChart mChart = null;
 
-    private final Collection<PercentageBarChart.Entry> mEntries = new ArrayList<PercentageBarChart.Entry>();
+    private final List<PercentageBarChart.Entry> mEntries = Lists.newArrayList();
 
     public UsageBarPreference(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
@@ -49,8 +52,9 @@
         setLayoutResource(R.layout.preference_memoryusage);
     }
 
-    public void addEntry(float percentage, int color) {
-        mEntries.add(PercentageBarChart.createEntry(percentage, color));
+    public void addEntry(int order, float percentage, int color) {
+        mEntries.add(PercentageBarChart.createEntry(order, percentage, color));
+        Collections.sort(mEntries);
     }
 
     @Override
@@ -58,7 +62,6 @@
         super.onBindView(view);
 
         mChart = (PercentageBarChart) view.findViewById(R.id.percentage_bar_chart);
-
         mChart.setEntries(mEntries);
     }
 
diff --git a/src/com/android/settings/wifi/WifiApEnabler.java b/src/com/android/settings/wifi/WifiApEnabler.java
index 86a7cb4..f3fd566 100644
--- a/src/com/android/settings/wifi/WifiApEnabler.java
+++ b/src/com/android/settings/wifi/WifiApEnabler.java
@@ -117,7 +117,7 @@
         if (enable && ((wifiState == WifiManager.WIFI_STATE_ENABLING) ||
                     (wifiState == WifiManager.WIFI_STATE_ENABLED))) {
             mWifiManager.setWifiEnabled(false);
-            Settings.Secure.putInt(cr, Settings.Secure.WIFI_SAVED_STATE, 1);
+            Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 1);
         }
 
         if (mWifiManager.setWifiApEnabled(null, enable)) {
@@ -133,13 +133,13 @@
         if (!enable) {
             int wifiSavedState = 0;
             try {
-                wifiSavedState = Settings.Secure.getInt(cr, Settings.Secure.WIFI_SAVED_STATE);
+                wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
             } catch (Settings.SettingNotFoundException e) {
                 ;
             }
             if (wifiSavedState == 1) {
                 mWifiManager.setWifiEnabled(true);
-                Settings.Secure.putInt(cr, Settings.Secure.WIFI_SAVED_STATE, 0);
+                Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);
             }
         }
     }