Merge "Fixing the build" into jb-mr1-dev
diff --git a/api/current.txt b/api/current.txt
index f8329f2..c732c3e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -18907,7 +18907,7 @@
     field public static final deprecated java.lang.String USB_MASS_STORAGE_ENABLED = "usb_mass_storage_enabled";
     field public static final deprecated java.lang.String USE_GOOGLE_MAIL = "use_google_mail";
     field public static final deprecated java.lang.String WIFI_MAX_DHCP_RETRY_COUNT = "wifi_max_dhcp_retry_count";
-    field public static final java.lang.String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = "wifi_mobile_data_transition_wakelock_timeout_ms";
+    field public static final deprecated java.lang.String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS = "wifi_mobile_data_transition_wakelock_timeout_ms";
     field public static final deprecated java.lang.String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON = "wifi_networks_available_notification_on";
     field public static final deprecated java.lang.String WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY = "wifi_networks_available_repeat_delay";
     field public static final deprecated java.lang.String WIFI_NUM_OPEN_NETWORKS_KEPT = "wifi_num_open_networks_kept";
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 0b1c524..6cf4dd0 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -1098,8 +1098,8 @@
      */
     public static Long getMaxBytesOverMobile(Context context) {
         try {
-            return Settings.Secure.getLong(context.getContentResolver(),
-                    Settings.Secure.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
+            return Settings.Global.getLong(context.getContentResolver(),
+                    Settings.Global.DOWNLOAD_MAX_BYTES_OVER_MOBILE);
         } catch (SettingNotFoundException exc) {
             return null;
         }
@@ -1116,8 +1116,8 @@
      */
     public static Long getRecommendedMaxBytesOverMobile(Context context) {
         try {
-            return Settings.Secure.getLong(context.getContentResolver(),
-                    Settings.Secure.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
+            return Settings.Global.getLong(context.getContentResolver(),
+                    Settings.Global.DOWNLOAD_RECOMMENDED_MAX_BYTES_OVER_MOBILE);
         } catch (SettingNotFoundException exc) {
             return null;
         }
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 9aae1ec..965e488 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3563,7 +3563,8 @@
         public static final String WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON =
                 Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON;
         /**
-         * @deprecated Moved to Global namespace
+         * @deprecated Use {@link android.provider.Settings.Global#WIMAX_NETWORKS_AVAILABLE_NOTIFICATION_ON}
+         * instead.
          * {@hide}
          */
         @Deprecated
@@ -3608,7 +3609,8 @@
          * the user turns off tethering.
          *
          * @hide
-         * @deprecated moved to Global
+         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SAVED_STATE}
+         * instead.
          */
         @Deprecated
         public static final String WIFI_SAVED_STATE = Global.WIFI_SAVED_STATE;
@@ -3637,6 +3639,7 @@
         /**
          * The acceptable packet loss percentage (range 0 - 100) before trying
          * another AP on the same network.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_ACCEPTABLE_PACKET_LOSS_PERCENTAGE =
@@ -3645,12 +3648,14 @@
         /**
          * The number of access points required for a network in order for the
          * watchdog to monitor it.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_AP_COUNT = "wifi_watchdog_ap_count";
 
         /**
          * The delay between background checks.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_DELAY_MS =
@@ -3659,6 +3664,7 @@
         /**
          * Whether the Wi-Fi watchdog is enabled for background checking even
          * after it thinks the user has connected to a good access point.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_ENABLED =
@@ -3666,6 +3672,7 @@
 
         /**
          * The timeout for a background ping
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_BACKGROUND_CHECK_TIMEOUT_MS =
@@ -3676,6 +3683,7 @@
          * fail. Again, if these fail, they will *not* be used in packet loss
          * calculation. For example, one network always seemed to time out for
          * the first couple pings, so this is set to 3 by default.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_INITIAL_IGNORED_PING_COUNT =
@@ -3686,6 +3694,7 @@
          * If this number is reached, the watchdog will no longer monitor the
          * initial connection state for the network. This is a safeguard for
          * networks containing multiple APs whose DNS does not respond to pings.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_MAX_AP_CHECKS = "wifi_watchdog_max_ap_checks";
@@ -3697,60 +3706,73 @@
 
         /**
          * A comma-separated list of SSIDs for which the Wi-Fi watchdog should be enabled.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_WATCH_LIST = "wifi_watchdog_watch_list";
 
         /**
          * The number of pings to test if an access point is a good connection.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_PING_COUNT = "wifi_watchdog_ping_count";
 
         /**
          * The delay between pings.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_PING_DELAY_MS = "wifi_watchdog_ping_delay_ms";
 
         /**
          * The timeout per ping.
+         * @deprecated This setting is not used.
          */
         @Deprecated
         public static final String WIFI_WATCHDOG_PING_TIMEOUT_MS = "wifi_watchdog_ping_timeout_ms";
 
         /**
          * ms delay before rechecking an 'online' wifi connection when it is thought to be unstable.
+         * @deprecated This setting is not used.
          * @hide
          */
+        @Deprecated
         public static final String WIFI_WATCHDOG_ARP_CHECK_INTERVAL_MS =
                 "wifi_watchdog_arp_interval_ms";
 
         /**
          * ms delay interval between rssi polling when the signal is known to be weak
+         * @deprecated This setting is not used.
          * @hide
          */
+        @Deprecated
         public static final String WIFI_WATCHDOG_RSSI_FETCH_INTERVAL_MS =
                 "wifi_watchdog_rssi_fetch_interval_ms";
 
-
         /**
          * Number of ARP pings per check.
+         * @deprecated This setting is not used.
          * @hide
          */
+        @Deprecated
         public static final String WIFI_WATCHDOG_NUM_ARP_PINGS = "wifi_watchdog_num_arp_pings";
 
         /**
          * Minimum number of responses to the arp pings to consider the test 'successful'.
+         * @deprecated This setting is not used.
          * @hide
          */
+        @Deprecated
         public static final String WIFI_WATCHDOG_MIN_ARP_RESPONSES =
                 "wifi_watchdog_min_arp_responses";
 
         /**
          * Timeout on ARP pings
+         * @deprecated This setting is not used.
          * @hide
          */
+        @Deprecated
         public static final String WIFI_WATCHDOG_ARP_PING_TIMEOUT_MS =
                 "wifi_watchdog_arp_ping_timeout_ms";
 
@@ -3809,11 +3831,11 @@
         public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";
 
         /**
-         * Maximum amount of time in milliseconds to hold a wakelock while waiting for mobile
-         * data connectivity to be established after a disconnect from Wi-Fi.
+         * @deprecated Use
+         * {@link android.provider.Settings.Global#WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS} instead
          */
         public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
-            "wifi_mobile_data_transition_wakelock_timeout_ms";
+                Global.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS;
 
         /**
          * Whether network service discovery is enabled.
@@ -4158,16 +4180,6 @@
         public static final String ERROR_LOGCAT_PREFIX =
                 "logcat_for_";
 
-
-        /**
-         * Screen timeout in milliseconds corresponding to the
-         * PowerManager's POKE_LOCK_SHORT_TIMEOUT flag (i.e. the fastest
-         * possible screen timeout behavior.)
-         * @hide
-         */
-        public static final String SHORT_KEYLIGHT_DELAY_MS =
-                "short_keylight_delay_ms";
-
         /**
          * The interval in minutes after which the amount of free storage left on the
          * device is logged to the event log
@@ -4220,7 +4232,8 @@
          * When idle, it is possible for the device to be switched from Wi-Fi to
          * the mobile data network.
          * @hide
-         * @deprecated Moved to Global
+         * @deprecated Use {@link android.provider.Settings.Global#WIFI_IDLE_MS}
+         * instead.
          */
         @Deprecated
         public static final String WIFI_IDLE_MS = Global.WIFI_IDLE_MS;
@@ -4230,7 +4243,8 @@
          * to connect. This is necessary to connect to an access point when
          * device is on the move and the screen is off.
          * @hide
-         * @deprecated Moved to Global
+         * @deprecated Use {@link android.provider.Settings.Global#WIFI_FRAMEWORK_SCAN_INTERVAL_MS}
+         * instead.
          */
         @Deprecated
         public static final String WIFI_FRAMEWORK_SCAN_INTERVAL_MS =
@@ -4239,14 +4253,16 @@
         /**
          * The interval in milliseconds to scan as used by the wifi supplicant
          * @hide
-         * @deprecated Moved to Global
+         * @deprecated Use {@link android.provider.Settings.Global#WIFI_SUPPLICANT_SCAN_INTERVAL_MS}
+         * instead.
          */
         @Deprecated
         public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
                 Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_POLL_INTERVAL_MS}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4254,7 +4270,8 @@
                 Global.PDP_WATCHDOG_POLL_INTERVAL_MS;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_LONG_POLL_INTERVAL_MS}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4262,7 +4279,8 @@
                 Global.PDP_WATCHDOG_LONG_POLL_INTERVAL_MS;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4270,7 +4288,8 @@
                 Global.PDP_WATCHDOG_ERROR_POLL_INTERVAL_MS;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_TRIGGER_PACKET_COUNT}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4278,7 +4297,8 @@
                 Global.PDP_WATCHDOG_TRIGGER_PACKET_COUNT;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_ERROR_POLL_COUNT}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4286,7 +4306,8 @@
                 Global.PDP_WATCHDOG_ERROR_POLL_COUNT;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4294,7 +4315,8 @@
                 Global.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4302,7 +4324,8 @@
                 Global.DATA_STALL_ALARM_NON_AGGRESSIVE_DELAY_IN_MS;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4310,7 +4333,8 @@
                 Global.DATA_STALL_ALARM_AGGRESSIVE_DELAY_IN_MS;
 
         /**
-         * @deprecated Moved to Settings.Global
+         * @deprecated Use {@link android.provider.Settings.Global#GPRS_REGISTER_CHECK_PERIOD_MS}
+         * instead.
          * @hide
          */
         @Deprecated
@@ -4851,25 +4875,6 @@
                 "contacts_preauth_uri_expiration";
 
         /**
-         * Overlay display devices setting.
-         * The associated value is a specially formatted string that describes the
-         * size and density of simulated secondary display devices.
-         * <p>
-         * Format: {width}x{height}/{dpi};...
-         * </p><p>
-         * Example:
-         * <ul>
-         * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
-         * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
-         * at 1080p and the second at 720p.</li>
-         * <li>If the value is empty, then no overlay display devices are created.</li>
-         * </ul></p>
-         *
-         * @hide
-         */
-        public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
-
-        /**
          * This are the settings to be backed up.
          *
          * NOTE: Settings are backed up and restored in the order they appear
@@ -5741,6 +5746,24 @@
         */
        public static final String MODE_RINGER = "mode_ringer";
 
+       /**
+        * Overlay display devices setting.
+        * The associated value is a specially formatted string that describes the
+        * size and density of simulated secondary display devices.
+        * <p>
+        * Format: {width}x{height}/{dpi};...
+        * </p><p>
+        * Example:
+        * <ul>
+        * <li><code>1280x720/213</code>: make one overlay that is 1280x720 at 213dpi.</li>
+        * <li><code>1920x1080/320;1280x720/213</code>: make two overlays, the first
+        * at 1080p and the second at 720p.</li>
+        * <li>If the value is empty, then no overlay display devices are created.</li>
+        * </ul></p>
+        *
+        * @hide
+        */
+       public static final String OVERLAY_DISPLAY_DEVICES = "overlay_display_devices";
 
         // Populated lazily, guarded by class object:
         private static NameValueCache sNameValueCache = new NameValueCache(
diff --git a/core/java/android/webkit/JniUtil.java b/core/java/android/webkit/JniUtil.java
index e3e6092..01a81c4 100644
--- a/core/java/android/webkit/JniUtil.java
+++ b/core/java/android/webkit/JniUtil.java
@@ -173,8 +173,8 @@
         checkInitialized();
         // If the device has not checked in it won't have pulled down the system setting for the
         // Autofill Url. In that case we will not make autofill server requests.
-        return Settings.Secure.getString(sContext.getContentResolver(),
-                Settings.Secure.WEB_AUTOFILL_QUERY_URL);
+        return Settings.Global.getString(sContext.getContentResolver(),
+                Settings.Global.WEB_AUTOFILL_QUERY_URL);
     }
 
     private static boolean canSatisfyMemoryAllocation(long bytesRequested) {
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_circle.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_circle.png
new file mode 100644
index 0000000..f724ea5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_circle.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png
new file mode 100644
index 0000000..979ca08
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_hour.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_minute.png b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_minute.png
new file mode 100644
index 0000000..eef78c1
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/ic_qs_clock_minute.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_circle.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_circle.png
new file mode 100644
index 0000000..27904f2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_circle.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png
new file mode 100644
index 0000000..4dca96a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_hour.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_minute.png b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_minute.png
new file mode 100644
index 0000000..12e7818
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_qs_clock_minute.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_circle.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_circle.png
new file mode 100644
index 0000000..c7864ba
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_circle.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png
new file mode 100644
index 0000000..a293c0b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_hour.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_minute.png b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_minute.png
new file mode 100644
index 0000000..bb0c17c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_qs_clock_minute.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/qs_tile_background.xml b/packages/SystemUI/res/drawable/qs_tile_background.xml
index 83dadd8..96891c1 100644
--- a/packages/SystemUI/res/drawable/qs_tile_background.xml
+++ b/packages/SystemUI/res/drawable/qs_tile_background.xml
@@ -18,9 +18,9 @@
 -->
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_pressed="true">
-	<color android:color="#252725" />
+	<color android:color="#212121" />
     </item>
     <item>
-        <color android:color="#1B1D1B" />
+        <color android:color="#161616" />
     </item>
 </selector>
diff --git a/packages/SystemUI/res/layout/quick_settings_tile_alarm.xml b/packages/SystemUI/res/layout/quick_settings_tile_alarm.xml
new file mode 100644
index 0000000..0327bee
--- /dev/null
+++ b/packages/SystemUI/res/layout/quick_settings_tile_alarm.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<TextView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    style="@style/TextAppearance.QuickSettings.TileView"
+    android:id="@+id/alarm_textview"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_gravity="center"
+    android:gravity="center"
+    android:drawableTop="@drawable/ic_qs_alarm_on"
+    />
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/quick_settings_tile_time.xml b/packages/SystemUI/res/layout/quick_settings_tile_time.xml
index f09e0cb..4ffbf52 100644
--- a/packages/SystemUI/res/layout/quick_settings_tile_time.xml
+++ b/packages/SystemUI/res/layout/quick_settings_tile_time.xml
@@ -19,30 +19,20 @@
     android:layout_height="wrap_content"
     android:layout_gravity="center"
     android:orientation="vertical">
-    <com.android.systemui.statusbar.policy.Clock
-        android:textAppearance="@style/TextAppearance.QuickSettings.Clock"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_horizontal"
-        android:paddingTop="3dp"
-        android:paddingBottom="3dp"
-        android:singleLine="true"
+    <AnalogClock
+        android:id="@+id/analog_clock"
+        android:layout_width="32dp"
+        android:layout_height="32dp"
+        android:layout_gravity="center"
+        android:layout_marginBottom="10dp"
+        android:dial="@drawable/ic_qs_clock_circle"
+        android:hand_hour="@drawable/ic_qs_clock_hour"
+        android:hand_minute="@drawable/ic_qs_clock_minute"
         />
     <com.android.systemui.statusbar.policy.QuickSettingsDateView
-        android:textAppearance="@style/TextAppearance.QuickSettings.Date"
+        android:textAppearance="@style/TextAppearance.QuickSettings.TileView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
         />
-    <TextView
-        android:textAppearance="@style/TextAppearance.QuickSettings.Alarm"
-        android:id="@+id/alarm_textview"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_horizontal"
-        android:paddingTop="2dp"
-        android:paddingBottom="4dp"
-        android:drawableLeft="@drawable/ic_qs_alarm_on"
-        android:drawablePadding="4dp"
-        />
 </LinearLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 90fe558..46c3903 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -187,6 +187,6 @@
     <dimen name="quick_settings_cell_height">110dp</dimen>
 
     <!-- The padding between each tile within the QuickSettings layout -->
-    <dimen name="quick_settings_cell_gap">5dp</dimen>
+    <dimen name="quick_settings_cell_gap">4dp</dimen>
 
 </resources>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index f6fe8d0..d666fc3 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -80,7 +80,7 @@
         <item name="android:drawablePadding">12dp</item>
         <item name="android:textSize">12dp</item>
         <item name="android:textStyle">normal</item>
-        <item name="android:textColor">#ff8d908c</item>
+        <item name="android:textColor">#CCCCCC</item>
         <item name="android:textAllCaps">true</item>
         <item name="android:singleLine">true</item>
         <item name="android:ellipsize">marquee</item>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index c1104d4..d8bbee9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -150,8 +150,8 @@
     private ContentObserver mProvisioningObserver = new ContentObserver(new Handler()) {
         @Override
         public void onChange(boolean selfChange) {
-            final boolean provisioned = 0 != Settings.Secure.getInt(
-                    mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0);
+            final boolean provisioned = 0 != Settings.Global.getInt(
+                    mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
             if (provisioned != mDeviceProvisioned) {
                 mDeviceProvisioned = provisioned;
                 updateNotificationIcons();
@@ -198,7 +198,7 @@
 
         mProvisioningObserver.onChange(false); // set up
         mContext.getContentResolver().registerContentObserver(
-                Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED), true,
+                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), true,
                 mProvisioningObserver);
 
         mBarService = IStatusBarService.Stub.asInterface(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
index bb03fd3..7077018 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -265,21 +265,17 @@
         timeTile.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                // TODO: Jump into the alarm application
+                // TODO: Jump into the clock application
                 Intent intent = new Intent();
                 intent.setComponent(new ComponentName(
                         "com.google.android.deskclock",
-                        "com.android.deskclock.AlarmClock"));
+                        "com.android.deskclock.DeskClock"));
                 startSettingsActivity(intent);
             }
         });
         mModel.addTimeTile(timeTile, new QuickSettingsModel.RefreshCallback() {
             @Override
-            public void refreshView(QuickSettingsTileView view, State alarmState) {
-                TextView tv = (TextView) view.findViewById(R.id.alarm_textview);
-                tv.setText(alarmState.label);
-                tv.setVisibility(alarmState.enabled ? View.VISIBLE : View.GONE);
-            }
+            public void refreshView(QuickSettingsTileView view, State alarmState) {}
         });
         parent.addView(timeTile);
         mDynamicSpannedTiles.add(timeTile);
@@ -487,6 +483,31 @@
     }
 
     private void addTemporaryTiles(final ViewGroup parent, final LayoutInflater inflater) {
+        // Alarm tile
+        QuickSettingsTileView alarmTile = (QuickSettingsTileView)
+                inflater.inflate(R.layout.quick_settings_tile, parent, false);
+        alarmTile.setContent(R.layout.quick_settings_tile_alarm, inflater);
+        alarmTile.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                // TODO: Jump into the alarm application
+                Intent intent = new Intent();
+                intent.setComponent(new ComponentName(
+                        "com.google.android.deskclock",
+                        "com.android.deskclock.AlarmClock"));
+                startSettingsActivity(intent);
+            }
+        });
+        mModel.addAlarmTile(alarmTile, new QuickSettingsModel.RefreshCallback() {
+            @Override
+            public void refreshView(QuickSettingsTileView view, State alarmState) {
+                TextView tv = (TextView) view.findViewById(R.id.alarm_textview);
+                tv.setText(alarmState.label);
+                view.setVisibility(alarmState.enabled ? View.VISIBLE : View.GONE);
+            }
+        });
+        parent.addView(alarmTile);
+
         // Location
         QuickSettingsTileView locationTile = (QuickSettingsTileView)
                 inflater.inflate(R.layout.quick_settings_tile, parent, false);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
index e2190fe..4e8339e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsContainerView.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.util.AttributeSet;
+import android.view.View;
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
 
@@ -73,20 +74,22 @@
         for (int i = 0; i < N; ++i) {
             // Update the child's width
             QuickSettingsTileView v = (QuickSettingsTileView) getChildAt(i);
-            ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
-            int colSpan = v.getColumnSpan();
-            lp.width = (int) ((colSpan * cellWidth) + (colSpan - 1) * mCellGap);
+            if (v.getVisibility() != View.GONE) {
+                ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
+                int colSpan = v.getColumnSpan();
+                lp.width = (int) ((colSpan * cellWidth) + (colSpan - 1) * mCellGap);
 
-            // Measure the child
-            int newWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
-            int newHeightSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
-            v.measure(newWidthSpec, newHeightSpec);
+                // Measure the child
+                int newWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
+                int newHeightSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
+                v.measure(newWidthSpec, newHeightSpec);
 
-            // Save the cell height
-            if (cellHeight <= 0) {
-                cellHeight = v.getMeasuredHeight();
+                // Save the cell height
+                if (cellHeight <= 0) {
+                    cellHeight = v.getMeasuredHeight();
+                }
+                cursor += colSpan;
             }
-            cursor += colSpan;
         }
 
         // Set the measured dimensions.  We always fill the tray width, but wrap to the height of
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
index 3f74388..04633bf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java
@@ -137,8 +137,12 @@
     private UserState mUserState = new UserState();
 
     private QuickSettingsTileView mTimeTile;
-    private RefreshCallback mTimeAlarmCallback;
-    private State mTimeAlarmState = new State();
+    private RefreshCallback mTimeCallback;
+    private State mTimeState = new State();
+
+    private QuickSettingsTileView mAlarmTile;
+    private RefreshCallback mAlarmCallback;
+    private State mAlarmState = new State();
 
     private QuickSettingsTileView mAirplaneModeTile;
     private RefreshCallback mAirplaneModeCallback;
@@ -212,17 +216,24 @@
     // Time
     void addTimeTile(QuickSettingsTileView view, RefreshCallback cb) {
         mTimeTile = view;
-        mTimeAlarmCallback = cb;
-        mTimeAlarmCallback.refreshView(view, mTimeAlarmState);
+        mTimeCallback = cb;
+        mTimeCallback.refreshView(view, mTimeState);
+    }
+
+    // Alarm
+    void addAlarmTile(QuickSettingsTileView view, RefreshCallback cb) {
+        mAlarmTile = view;
+        mAlarmCallback = cb;
+        mAlarmCallback.refreshView(view, mAlarmState);
     }
     void onAlarmChanged(Intent intent) {
-        mTimeAlarmState.enabled = intent.getBooleanExtra("alarmSet", false);
-        mTimeAlarmCallback.refreshView(mTimeTile, mTimeAlarmState);
+        mAlarmState.enabled = intent.getBooleanExtra("alarmSet", false);
+        mAlarmCallback.refreshView(mAlarmTile, mAlarmState);
     }
     void onNextAlarmChanged() {
-        mTimeAlarmState.label = Settings.System.getString(mContext.getContentResolver(),
+        mAlarmState.label = Settings.System.getString(mContext.getContentResolver(),
                 Settings.System.NEXT_ALARM_FORMATTED);
-        mTimeAlarmCallback.refreshView(mTimeTile, mTimeAlarmState);
+        mAlarmCallback.refreshView(mAlarmTile, mAlarmState);
     }
 
     // Airplane Mode
@@ -330,7 +341,7 @@
             mRSSIState.signalIconId = enabled && (mobileSignalIconId > 0)
                     ? mobileSignalIconId
                     : R.drawable.ic_qs_signal_no_signal;
-            mRSSIState.dataTypeIconId = enabled && (dataTypeIconId > 0)
+            mRSSIState.dataTypeIconId = enabled && (dataTypeIconId > 0) && !mWifiState.enabled
                     ? dataTypeIconId
                     : 0;
             mRSSIState.label = enabled
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index c55b5bc..91fc67a 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -317,9 +317,9 @@
             }
 
             mUsbStorageNotification.setLatestEventInfo(mContext, title, message, pi);
-            final boolean adbOn = 1 == Settings.Secure.getInt(
+            final boolean adbOn = 1 == Settings.Global.getInt(
                 mContext.getContentResolver(),
-                Settings.Secure.ADB_ENABLED,
+                Settings.Global.ADB_ENABLED,
                 0);
 
             if (POP_UMS_ACTIVITY_ON_CONNECT && !adbOn) {
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index fe8e45b..01b53e2 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -773,8 +773,8 @@
     }
 
     boolean isDeviceProvisioned() {
-        return Settings.Secure.getInt(
-                mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+        return Settings.Global.getInt(
+                mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0;
     }
 
     private void handleLongPressOnHome() {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
index 6fca826..15a6f9f 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
@@ -306,8 +306,8 @@
     private KeyguardUpdateMonitor(Context context) {
         mContext = context;
 
-        mDeviceProvisioned = Settings.Secure.getInt(
-                mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+        mDeviceProvisioned = Settings.Global.getInt(
+                mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0;
 
         // Since device can't be un-provisioned, we only need to register a content observer
         // to update mDeviceProvisioned when we are...
@@ -357,8 +357,8 @@
             @Override
             public void onChange(boolean selfChange) {
                 super.onChange(selfChange);
-                mDeviceProvisioned = Settings.Secure.getInt(mContext.getContentResolver(),
-                    Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+                mDeviceProvisioned = Settings.Global.getInt(mContext.getContentResolver(),
+                    Settings.Global.DEVICE_PROVISIONED, 0) != 0;
                 if (mDeviceProvisioned) {
                     mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
                 }
@@ -367,13 +367,13 @@
         };
 
         mContext.getContentResolver().registerContentObserver(
-                Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED),
+                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED),
                 false, mContentObserver);
 
         // prevent a race condition between where we check the flag and where we register the
         // observer by grabbing the value once again...
-        boolean provisioned = Settings.Secure.getInt(mContext.getContentResolver(),
-            Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+        boolean provisioned = Settings.Global.getInt(mContext.getContentResolver(),
+            Settings.Global.DEVICE_PROVISIONED, 0) != 0;
         if (provisioned != mDeviceProvisioned) {
             mDeviceProvisioned = provisioned;
             if (mDeviceProvisioned) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard_obsolete/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/keyguard_obsolete/KeyguardUpdateMonitor.java
index d990f5f..67dc8a7 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard_obsolete/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard_obsolete/KeyguardUpdateMonitor.java
@@ -286,8 +286,8 @@
     public KeyguardUpdateMonitor(Context context) {
         mContext = context;
 
-        mDeviceProvisioned = Settings.Secure.getInt(
-                mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+        mDeviceProvisioned = Settings.Global.getInt(
+                mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0;
 
         // Since device can't be un-provisioned, we only need to register a content observer
         // to update mDeviceProvisioned when we are...
@@ -321,8 +321,8 @@
             @Override
             public void onChange(boolean selfChange) {
                 super.onChange(selfChange);
-                mDeviceProvisioned = Settings.Secure.getInt(mContext.getContentResolver(),
-                    Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+                mDeviceProvisioned = Settings.Global.getInt(mContext.getContentResolver(),
+                    Settings.Global.DEVICE_PROVISIONED, 0) != 0;
                 if (mDeviceProvisioned) {
                     mHandler.sendMessage(mHandler.obtainMessage(MSG_DEVICE_PROVISIONED));
                 }
@@ -331,13 +331,13 @@
         };
 
         mContext.getContentResolver().registerContentObserver(
-                Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED),
+                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED),
                 false, mContentObserver);
 
         // prevent a race condition between where we check the flag and where we register the
         // observer by grabbing the value once again...
-        boolean provisioned = Settings.Secure.getInt(mContext.getContentResolver(),
-            Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+        boolean provisioned = Settings.Global.getInt(mContext.getContentResolver(),
+            Settings.Global.DEVICE_PROVISIONED, 0) != 0;
         if (provisioned != mDeviceProvisioned) {
             mDeviceProvisioned = provisioned;
             if (mDeviceProvisioned) {
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 5e2b425..15fc479 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -729,14 +729,14 @@
         final ContentResolver resolver = context.getContentResolver();
         boolean areEnabled = Settings.Secure.getInt(resolver,
                 Settings.Secure.BACKUP_ENABLED, 0) != 0;
-        mProvisioned = Settings.Secure.getInt(resolver,
-                Settings.Secure.DEVICE_PROVISIONED, 0) != 0;
+        mProvisioned = Settings.Global.getInt(resolver,
+                Settings.Global.DEVICE_PROVISIONED, 0) != 0;
         mAutoRestore = Settings.Secure.getInt(resolver,
                 Settings.Secure.BACKUP_AUTO_RESTORE, 1) != 0;
 
         mProvisionedObserver = new ProvisionedObserver(mBackupHandler);
         resolver.registerContentObserver(
-                Settings.Secure.getUriFor(Settings.Secure.DEVICE_PROVISIONED),
+                Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED),
                 false, mProvisionedObserver);
 
         // If Encrypted file systems is enabled or disabled, this call will return the
@@ -4956,7 +4956,7 @@
 
     boolean deviceIsProvisioned() {
         final ContentResolver resolver = mContext.getContentResolver();
-        return (Settings.Secure.getInt(resolver, Settings.Secure.DEVICE_PROVISIONED, 0) != 0);
+        return (Settings.Global.getInt(resolver, Settings.Global.DEVICE_PROVISIONED, 0) != 0);
     }
 
     // Run a *full* backup pass for the given package, writing the resulting data stream
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java
index e68686d..aa5ae3d 100755
--- a/services/java/com/android/server/BluetoothManagerService.java
+++ b/services/java/com/android/server/BluetoothManagerService.java
@@ -159,8 +159,8 @@
      *  Returns true if the Bluetooth saved state is "on"
      */
     private final boolean isBluetoothPersistedStateOn() {
-        return Settings.Secure.getInt(mContentResolver,
-                Settings.Secure.BLUETOOTH_ON, 0) ==1;
+        return Settings.Global.getInt(mContentResolver,
+                Settings.Global.BLUETOOTH_ON, 0) ==1;
     }
 
     /**
@@ -168,8 +168,8 @@
      *
      */
     private void persistBluetoothSetting(boolean setOn) {
-        Settings.Secure.putInt(mContext.getContentResolver(),
-                               Settings.Secure.BLUETOOTH_ON,
+        Settings.Global.putInt(mContext.getContentResolver(),
+                               Settings.Global.BLUETOOTH_ON,
                                setOn ? 1 : 0);
     }
 
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 9676eb9..ceb17c7 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -701,7 +701,7 @@
                 mNetConfigs[preference].isDefault()) {
             if (mNetworkPreference != preference) {
                 final ContentResolver cr = mContext.getContentResolver();
-                Settings.Secure.putInt(cr, Settings.Secure.NETWORK_PREFERENCE, preference);
+                Settings.Global.putInt(cr, Settings.Global.NETWORK_PREFERENCE, preference);
                 synchronized(this) {
                     mNetworkPreference = preference;
                 }
@@ -724,8 +724,8 @@
     private int getPersistedNetworkPreference() {
         final ContentResolver cr = mContext.getContentResolver();
 
-        final int networkPrefSetting = Settings.Secure
-                .getInt(cr, Settings.Secure.NETWORK_PREFERENCE, -1);
+        final int networkPrefSetting = Settings.Global
+                .getInt(cr, Settings.Global.NETWORK_PREFERENCE, -1);
         if (networkPrefSetting != -1) {
             return networkPrefSetting;
         }
@@ -2108,14 +2108,14 @@
         final int timeout;
 
         if (ConnectivityManager.isNetworkTypeMobile(type)) {
-            timeout = Settings.Secure.getInt(mContext.getContentResolver(),
-                                             Settings.Secure.DATA_ACTIVITY_TIMEOUT_MOBILE,
+            timeout = Settings.Global.getInt(mContext.getContentResolver(),
+                                             Settings.Global.DATA_ACTIVITY_TIMEOUT_MOBILE,
                                              0);
             // Canonicalize mobile network type
             type = ConnectivityManager.TYPE_MOBILE;
         } else if (ConnectivityManager.TYPE_WIFI == type) {
-            timeout = Settings.Secure.getInt(mContext.getContentResolver(),
-                                             Settings.Secure.DATA_ACTIVITY_TIMEOUT_WIFI,
+            timeout = Settings.Global.getInt(mContext.getContentResolver(),
+                                             Settings.Global.DATA_ACTIVITY_TIMEOUT_WIFI,
                                              0);
         } else {
             // do not track any other networks
@@ -2930,8 +2930,8 @@
     public boolean isTetheringSupported() {
         enforceTetherAccessPermission();
         int defaultVal = (SystemProperties.get("ro.tether.denied").equals("true") ? 0 : 1);
-        boolean tetherEnabledInSettings = (Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.TETHER_SUPPORTED, defaultVal) != 0);
+        boolean tetherEnabledInSettings = (Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.TETHER_SUPPORTED, defaultVal) != 0);
         return tetherEnabledInSettings && mTetheringConfigValid;
     }
 
diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java
index 65c39f2..8ad5a91 100644
--- a/services/java/com/android/server/DockObserver.java
+++ b/services/java/com/android/server/DockObserver.java
@@ -147,8 +147,8 @@
 
             final ContentResolver cr = mContext.getContentResolver();
 
-            if (Settings.Secure.getInt(cr,
-                    Settings.Secure.DEVICE_PROVISIONED, 0) == 0) {
+            if (Settings.Global.getInt(cr,
+                    Settings.Global.DEVICE_PROVISIONED, 0) == 0) {
                 Slog.i(TAG, "Device not provisioned, skipping dock broadcast");
                 return;
             }
@@ -168,29 +168,29 @@
 
             // User feedback to confirm dock connection. Particularly
             // useful for flaky contact pins...
-            if (Settings.System.getInt(cr,
-                    Settings.System.DOCK_SOUNDS_ENABLED, 1) == 1) {
+            if (Settings.Global.getInt(cr,
+                    Settings.Global.DOCK_SOUNDS_ENABLED, 1) == 1) {
                 String whichSound = null;
                 if (mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
                     if ((mPreviousDockState == Intent.EXTRA_DOCK_STATE_DESK) ||
                         (mPreviousDockState == Intent.EXTRA_DOCK_STATE_LE_DESK) ||
                         (mPreviousDockState == Intent.EXTRA_DOCK_STATE_HE_DESK)) {
-                        whichSound = Settings.System.DESK_UNDOCK_SOUND;
+                        whichSound = Settings.Global.DESK_UNDOCK_SOUND;
                     } else if (mPreviousDockState == Intent.EXTRA_DOCK_STATE_CAR) {
-                        whichSound = Settings.System.CAR_UNDOCK_SOUND;
+                        whichSound = Settings.Global.CAR_UNDOCK_SOUND;
                     }
                 } else {
                     if ((mDockState == Intent.EXTRA_DOCK_STATE_DESK) ||
                         (mDockState == Intent.EXTRA_DOCK_STATE_LE_DESK) ||
                         (mDockState == Intent.EXTRA_DOCK_STATE_HE_DESK)) {
-                        whichSound = Settings.System.DESK_DOCK_SOUND;
+                        whichSound = Settings.Global.DESK_DOCK_SOUND;
                     } else if (mDockState == Intent.EXTRA_DOCK_STATE_CAR) {
-                        whichSound = Settings.System.CAR_DOCK_SOUND;
+                        whichSound = Settings.Global.CAR_DOCK_SOUND;
                     }
                 }
 
                 if (whichSound != null) {
-                    final String soundPath = Settings.System.getString(cr, whichSound);
+                    final String soundPath = Settings.Global.getString(cr, whichSound);
                     if (soundPath != null) {
                         final Uri soundUri = Uri.parse("file://" + soundPath);
                         if (soundUri != null) {
diff --git a/services/java/com/android/server/NetworkTimeUpdateService.java b/services/java/com/android/server/NetworkTimeUpdateService.java
index 76972bc..790be55 100644
--- a/services/java/com/android/server/NetworkTimeUpdateService.java
+++ b/services/java/com/android/server/NetworkTimeUpdateService.java
@@ -215,8 +215,8 @@
      * Checks if the user prefers to automatically set the time.
      */
     private boolean isAutomaticTimeRequested() {
-        return Settings.System.getInt(mContext.getContentResolver(), Settings.System.AUTO_TIME, 0)
-                != 0;
+        return Settings.Global.getInt(
+                mContext.getContentResolver(), Settings.Global.AUTO_TIME, 0) != 0;
     }
 
     /** Receiver for Nitz time events */
@@ -289,7 +289,7 @@
 
         void observe(Context context) {
             ContentResolver resolver = context.getContentResolver();
-            resolver.registerContentObserver(Settings.System.getUriFor(Settings.System.AUTO_TIME),
+            resolver.registerContentObserver(Settings.Global.getUriFor(Settings.Global.AUTO_TIME),
                     false, this);
         }
 
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index bab4f7a..76194ae 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -626,8 +626,8 @@
         // After that, including subsequent boots, init with notifications turned on.
         // This works on the first boot because the setup wizard will toggle this
         // flag at least once and we'll go back to 0 after that.
-        if (0 == Settings.Secure.getInt(mContext.getContentResolver(),
-                    Settings.Secure.DEVICE_PROVISIONED, 0)) {
+        if (0 == Settings.Global.getInt(mContext.getContentResolver(),
+                    Settings.Global.DEVICE_PROVISIONED, 0)) {
             mDisabledNotifications = StatusBarManager.DISABLE_NOTIFICATION_ALERTS;
         }
 
diff --git a/services/java/com/android/server/SamplingProfilerService.java b/services/java/com/android/server/SamplingProfilerService.java
index 0034d2c..fbf1aa4 100644
--- a/services/java/com/android/server/SamplingProfilerService.java
+++ b/services/java/com/android/server/SamplingProfilerService.java
@@ -90,7 +90,7 @@
     private void registerSettingObserver(Context context) {
         ContentResolver contentResolver = context.getContentResolver();
         contentResolver.registerContentObserver(
-                Settings.Secure.getUriFor(Settings.Secure.SAMPLING_PROFILER_MS),
+                Settings.Global.getUriFor(Settings.Global.SAMPLING_PROFILER_MS),
                 false, new SamplingProfilerSettingsObserver(contentResolver));
     }
 
@@ -111,8 +111,8 @@
         }
         @Override
         public void onChange(boolean selfChange) {
-            Integer samplingProfilerMs = Settings.Secure.getInt(
-                    mContentResolver, Settings.Secure.SAMPLING_PROFILER_MS, 0);
+            Integer samplingProfilerMs = Settings.Global.getInt(
+                    mContentResolver, Settings.Global.SAMPLING_PROFILER_MS, 0);
             // setting this secure property will start or stop sampling profiler,
             // as well as adjust the the time between taking snapshots.
             SystemProperties.set("persist.sys.profiler_ms", samplingProfilerMs.toString());
diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java
index 72fde11..df91dec 100755
--- a/services/java/com/android/server/VibratorService.java
+++ b/services/java/com/android/server/VibratorService.java
@@ -31,6 +31,7 @@
 import android.os.IBinder;
 import android.os.Binder;
 import android.os.SystemClock;
+import android.os.UserHandle;
 import android.os.Vibrator;
 import android.os.WorkSource;
 import android.provider.Settings;
@@ -139,6 +140,7 @@
 
     public void systemReady() {
         mIm = (InputManager)mContext.getSystemService(Context.INPUT_SERVICE);
+
         mContext.getContentResolver().registerContentObserver(
                 Settings.System.getUriFor(Settings.System.VIBRATE_INPUT_DEVICES), true,
                 new ContentObserver(mH) {
@@ -146,7 +148,15 @@
                     public void onChange(boolean selfChange) {
                         updateInputDeviceVibrators();
                     }
-                });
+                }, UserHandle.USER_ALL);
+
+        mContext.registerReceiver(new BroadcastReceiver() {
+            @Override
+            public void onReceive(Context context, Intent intent) {
+                updateInputDeviceVibrators();
+            }
+        }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mH);
+
         updateInputDeviceVibrators();
     }
 
@@ -341,8 +351,9 @@
             synchronized (mInputDeviceVibrators) {
                 mVibrateInputDevicesSetting = false;
                 try {
-                    mVibrateInputDevicesSetting = Settings.System.getInt(mContext.getContentResolver(),
-                            Settings.System.VIBRATE_INPUT_DEVICES) > 0;
+                    mVibrateInputDevicesSetting = Settings.System.getIntForUser(
+                            mContext.getContentResolver(),
+                            Settings.System.VIBRATE_INPUT_DEVICES, UserHandle.USER_CURRENT) > 0;
                 } catch (SettingNotFoundException snfe) {
                 }
 
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 3427699..b266bd4 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2266,8 +2266,8 @@
         // low-level factory test mode.
         final ContentResolver resolver = mContext.getContentResolver();
         if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL &&
-                Settings.Secure.getInt(resolver,
-                        Settings.Secure.DEVICE_PROVISIONED, 0) != 0) {
+                Settings.Global.getInt(resolver,
+                        Settings.Global.DEVICE_PROVISIONED, 0) != 0) {
             mCheckedForSetup = true;
             
             // See if we should be showing the platform update setup UI.
@@ -8312,8 +8312,8 @@
         addErrorToDropBox("wtf", r, processName, null, null, tag, null, null, crashInfo);
 
         if (r != null && r.pid != Process.myPid() &&
-                Settings.Secure.getInt(mContext.getContentResolver(),
-                        Settings.Secure.WTF_IS_FATAL, 0) != 0) {
+                Settings.Global.getInt(mContext.getContentResolver(),
+                        Settings.Global.WTF_IS_FATAL, 0) != 0) {
             crashApplication(r, crashInfo);
             return true;
         } else {
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index d8f3546..b38d617 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -627,8 +627,8 @@
     }
 
     public void checkDunRequired() {
-        int secureSetting = Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.TETHER_DUN_REQUIRED, 2);
+        int secureSetting = Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.TETHER_DUN_REQUIRED, 2);
         synchronized (mPublicSync) {
             // 2 = not set, 0 = DUN not required, 1 = DUN required
             if (secureSetting != 2) {
diff --git a/services/java/com/android/server/display/OverlayDisplayAdapter.java b/services/java/com/android/server/display/OverlayDisplayAdapter.java
index 75ddd24..0767fc0 100644
--- a/services/java/com/android/server/display/OverlayDisplayAdapter.java
+++ b/services/java/com/android/server/display/OverlayDisplayAdapter.java
@@ -19,10 +19,14 @@
 import com.android.internal.util.DumpUtils;
 import com.android.internal.util.IndentingPrintWriter;
 
+import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.database.ContentObserver;
 import android.os.Handler;
 import android.os.IBinder;
+import android.os.UserHandle;
 import android.provider.Settings;
 import android.util.DisplayMetrics;
 import android.util.Slog;
@@ -88,19 +92,28 @@
             @Override
             public void run() {
                 getContext().getContentResolver().registerContentObserver(
-                        Settings.System.getUriFor(Settings.Secure.OVERLAY_DISPLAY_DEVICES),
-                        true, new SettingsObserver(getHandler()));
+                        Settings.Global.getUriFor(Settings.Global.OVERLAY_DISPLAY_DEVICES),
+                        true, new ContentObserver(getHandler()) {
+                            @Override
+                            public void onChange(boolean selfChange) {
+                                updateOverlayDisplayDevices();
+                            }
+                        });
 
-                synchronized (getSyncRoot()) {
-                    updateOverlayDisplayDevicesLocked();
-                }
+                updateOverlayDisplayDevices();
             }
         });
     }
 
+    private void updateOverlayDisplayDevices() {
+        synchronized (getSyncRoot()) {
+            updateOverlayDisplayDevicesLocked();
+        }
+    }
+
     private void updateOverlayDisplayDevicesLocked() {
-        String value = Settings.System.getString(getContext().getContentResolver(),
-                Settings.Secure.OVERLAY_DISPLAY_DEVICES);
+        String value = Settings.Global.getString(getContext().getContentResolver(),
+                Settings.Global.OVERLAY_DISPLAY_DEVICES);
         if (value == null) {
             value = "";
         }
@@ -171,19 +184,6 @@
         }
     }
 
-    private final class SettingsObserver extends ContentObserver {
-        public SettingsObserver(Handler handler) {
-            super(handler);
-        }
-
-        @Override
-        public void onChange(boolean selfChange) {
-            synchronized (getSyncRoot()) {
-                updateOverlayDisplayDevicesLocked();
-            }
-        }
-    }
-
     private final class OverlayDisplayDevice extends DisplayDevice {
         private final String mName;
         private final int mWidth;
diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java
index 948c0e0..0b4a721 100644
--- a/services/java/com/android/server/input/InputManagerService.java
+++ b/services/java/com/android/server/input/InputManagerService.java
@@ -241,6 +241,14 @@
         registerPointerSpeedSettingObserver();
         registerShowTouchesSettingObserver();
 
+        mContext.registerReceiver(new BroadcastReceiver() {
+            @Override
+            public void onReceive(Context context, Intent intent) {
+                updatePointerSpeedFromSettings();
+                updateShowTouchesFromSettings();
+            }
+        }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
+
         updatePointerSpeedFromSettings();
         updateShowTouchesFromSettings();
     }
@@ -1073,14 +1081,14 @@
                     public void onChange(boolean selfChange) {
                         updatePointerSpeedFromSettings();
                     }
-                });
+                }, UserHandle.USER_ALL);
     }
 
     private int getPointerSpeedSetting() {
         int speed = InputManager.DEFAULT_POINTER_SPEED;
         try {
-            speed = Settings.System.getInt(mContext.getContentResolver(),
-                    Settings.System.POINTER_SPEED);
+            speed = Settings.System.getIntForUser(mContext.getContentResolver(),
+                    Settings.System.POINTER_SPEED, UserHandle.USER_CURRENT);
         } catch (SettingNotFoundException snfe) {
         }
         return speed;
@@ -1099,14 +1107,14 @@
                     public void onChange(boolean selfChange) {
                         updateShowTouchesFromSettings();
                     }
-                });
+                }, UserHandle.USER_ALL);
     }
 
     private int getShowTouchesSetting(int defaultValue) {
         int result = defaultValue;
         try {
-            result = Settings.System.getInt(mContext.getContentResolver(),
-                    Settings.System.SHOW_TOUCHES);
+            result = Settings.System.getIntForUser(mContext.getContentResolver(),
+                    Settings.System.SHOW_TOUCHES, UserHandle.USER_CURRENT);
         } catch (SettingNotFoundException snfe) {
         }
         return result;
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index bb11fe7..28870a2 100755
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -535,8 +535,8 @@
         }
 
         if (info != null) {
-            boolean dataEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
-                                                         Settings.Secure.MOBILE_DATA, 1) == 1;
+            boolean dataEnabled = Settings.Global.getInt(mContext.getContentResolver(),
+                                                         Settings.Global.MOBILE_DATA, 1) == 1;
             boolean networkAvailable = info.isAvailable() && dataEnabled;
             String defaultApn = getSelectedApn();
             if (defaultApn == null) {
@@ -952,8 +952,8 @@
             mStarted = true;
             mPositionMode = GPS_POSITION_MODE_STANDALONE;
 
-             if (Settings.Secure.getInt(mContext.getContentResolver(),
-                    Settings.Secure.ASSISTED_GPS_ENABLED, 1) != 0) {
+             if (Settings.Global.getInt(mContext.getContentResolver(),
+                    Settings.Global.ASSISTED_GPS_ENABLED, 1) != 0) {
                 if (hasCapability(GPS_CAPABILITY_MSB)) {
                     mPositionMode = GPS_POSITION_MODE_MS_BASED;
                 }
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 4800e7db..c4cdd07 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -5907,8 +5907,8 @@
      * @return the current "allow unknown sources" setting
      */
     private int getUnknownSourcesSettings() {
-        return android.provider.Settings.Secure.getInt(mContext.getContentResolver(),
-                android.provider.Settings.Secure.INSTALL_NON_MARKET_APPS,
+        return android.provider.Settings.Global.getInt(mContext.getContentResolver(),
+                android.provider.Settings.Global.INSTALL_NON_MARKET_APPS,
                 -1);
     }
 
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index 7052ed5..030eb5e 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -48,6 +48,7 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemClock;
+import android.os.UserHandle;
 import android.os.WorkSource;
 import android.provider.Settings;
 import android.service.dreams.Dream;
@@ -357,34 +358,44 @@
             // Register for broadcasts from other components of the system.
             IntentFilter filter = new IntentFilter();
             filter.addAction(Intent.ACTION_BATTERY_CHANGED);
-            mContext.registerReceiver(new BatteryReceiver(), filter);
+            mContext.registerReceiver(new BatteryReceiver(), filter, null, mHandler);
 
             filter = new IntentFilter();
             filter.addAction(Intent.ACTION_BOOT_COMPLETED);
-            mContext.registerReceiver(new BootCompletedReceiver(), filter);
+            mContext.registerReceiver(new BootCompletedReceiver(), filter, null, mHandler);
 
             filter = new IntentFilter();
             filter.addAction(Intent.ACTION_DOCK_EVENT);
-            mContext.registerReceiver(new DockReceiver(), filter);
+            mContext.registerReceiver(new DockReceiver(), filter, null, mHandler);
 
             filter = new IntentFilter();
             filter.addAction(Dream.ACTION_DREAMING_STOPPED);
-            mContext.registerReceiver(new DreamReceiver(), filter);
+            mContext.registerReceiver(new DreamReceiver(), filter, null, mHandler);
+
+            filter = new IntentFilter();
+            filter.addAction(Intent.ACTION_USER_SWITCHED);
+            mContext.registerReceiver(new UserSwitchedReceiver(), filter, null, mHandler);
 
             // Register for settings changes.
             final ContentResolver resolver = mContext.getContentResolver();
             resolver.registerContentObserver(Settings.Secure.getUriFor(
-                    Settings.Secure.SCREENSAVER_ENABLED), false, mSettingsObserver);
+                    Settings.Secure.SCREENSAVER_ENABLED),
+                    false, mSettingsObserver, UserHandle.USER_ALL);
             resolver.registerContentObserver(Settings.Secure.getUriFor(
-                    Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP), false, mSettingsObserver);
+                    Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP),
+                    false, mSettingsObserver, UserHandle.USER_ALL);
             resolver.registerContentObserver(Settings.System.getUriFor(
-                    Settings.System.SCREEN_OFF_TIMEOUT), false, mSettingsObserver);
+                    Settings.System.SCREEN_OFF_TIMEOUT),
+                    false, mSettingsObserver, UserHandle.USER_ALL);
             resolver.registerContentObserver(Settings.Global.getUriFor(
-                    Settings.Global.STAY_ON_WHILE_PLUGGED_IN), false, mSettingsObserver);
+                    Settings.Global.STAY_ON_WHILE_PLUGGED_IN),
+                    false, mSettingsObserver, UserHandle.USER_ALL);
             resolver.registerContentObserver(Settings.System.getUriFor(
-                    Settings.System.SCREEN_BRIGHTNESS), false, mSettingsObserver);
+                    Settings.System.SCREEN_BRIGHTNESS),
+                    false, mSettingsObserver, UserHandle.USER_ALL);
             resolver.registerContentObserver(Settings.System.getUriFor(
-                    Settings.System.SCREEN_BRIGHTNESS_MODE), false, mSettingsObserver);
+                    Settings.System.SCREEN_BRIGHTNESS_MODE),
+                    false, mSettingsObserver, UserHandle.USER_ALL);
 
             // Go.
             readConfigurationLocked();
@@ -406,34 +417,38 @@
     private void updateSettingsLocked() {
         final ContentResolver resolver = mContext.getContentResolver();
 
-        mDreamsEnabledSetting = (Settings.Secure.getInt(resolver,
-                Settings.Secure.SCREENSAVER_ENABLED, 0) != 0);
-        mDreamsActivateOnSleepSetting = (Settings.Secure.getInt(resolver,
-                Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 0) != 0);
-        mScreenOffTimeoutSetting = Settings.System.getInt(resolver,
-                Settings.System.SCREEN_OFF_TIMEOUT, DEFAULT_SCREEN_OFF_TIMEOUT);
+        mDreamsEnabledSetting = (Settings.Secure.getIntForUser(resolver,
+                Settings.Secure.SCREENSAVER_ENABLED, 0,
+                UserHandle.USER_CURRENT) != 0);
+        mDreamsActivateOnSleepSetting = (Settings.Secure.getIntForUser(resolver,
+                Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 0,
+                UserHandle.USER_CURRENT) != 0);
+        mScreenOffTimeoutSetting = Settings.System.getIntForUser(resolver,
+                Settings.System.SCREEN_OFF_TIMEOUT, DEFAULT_SCREEN_OFF_TIMEOUT,
+                UserHandle.USER_CURRENT);
         mStayOnWhilePluggedInSetting = Settings.Global.getInt(resolver,
-                Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
-                BatteryManager.BATTERY_PLUGGED_AC);
+                Settings.Global.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC);
 
         final int oldScreenBrightnessSetting = mScreenBrightnessSetting;
-        mScreenBrightnessSetting = Settings.System.getInt(resolver,
-                Settings.System.SCREEN_BRIGHTNESS, mScreenBrightnessSettingDefault);
+        mScreenBrightnessSetting = Settings.System.getIntForUser(resolver,
+                Settings.System.SCREEN_BRIGHTNESS, mScreenBrightnessSettingDefault,
+                UserHandle.USER_CURRENT);
         if (oldScreenBrightnessSetting != mScreenBrightnessSetting) {
             mTemporaryScreenBrightnessSettingOverride = -1;
         }
 
         final float oldScreenAutoBrightnessAdjustmentSetting =
                 mScreenAutoBrightnessAdjustmentSetting;
-        mScreenAutoBrightnessAdjustmentSetting = Settings.System.getFloat(resolver,
-                Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f);
+        mScreenAutoBrightnessAdjustmentSetting = Settings.System.getFloatForUser(resolver,
+                Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f,
+                UserHandle.USER_CURRENT);
         if (oldScreenAutoBrightnessAdjustmentSetting != mScreenAutoBrightnessAdjustmentSetting) {
             mTemporaryScreenAutoBrightnessAdjustmentSettingOverride = Float.NaN;
         }
 
-        mScreenBrightnessModeSetting = Settings.System.getInt(resolver,
+        mScreenBrightnessModeSetting = Settings.System.getIntForUser(resolver,
                 Settings.System.SCREEN_BRIGHTNESS_MODE,
-                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT);
 
         mDirty |= DIRTY_SETTINGS;
     }
@@ -1962,6 +1977,15 @@
         }
     }
 
+    private final class UserSwitchedReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            synchronized (mLock) {
+                handleSettingsChangedLocked();
+            }
+        }
+    }
+
     private final class SettingsObserver extends ContentObserver {
         public SettingsObserver(Handler handler) {
             super(handler);
diff --git a/services/java/com/android/server/usb/UsbDeviceManager.java b/services/java/com/android/server/usb/UsbDeviceManager.java
index 8f13501..10011aa 100644
--- a/services/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/java/com/android/server/usb/UsbDeviceManager.java
@@ -124,8 +124,8 @@
         }
         @Override
         public void onChange(boolean selfChange) {
-            boolean enable = (Settings.Secure.getInt(mContentResolver,
-                    Settings.Secure.ADB_ENABLED, 0) > 0);
+            boolean enable = (Settings.Global.getInt(mContentResolver,
+                    Settings.Global.ADB_ENABLED, 0) > 0);
             mHandler.sendMessage(MSG_ENABLE_ADB, enable);
         }
     }
@@ -190,7 +190,7 @@
         mUseUsbNotification = !massStorageSupported;
 
         // make sure the ADB_ENABLED setting value matches the current state
-        Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED, mAdbEnabled ? 1 : 0);
+        Settings.Global.putInt(mContentResolver, Settings.Global.ADB_ENABLED, mAdbEnabled ? 1 : 0);
 
         mHandler.sendEmptyMessage(MSG_SYSTEM_READY);
     }
@@ -351,7 +351,7 @@
 
                 // register observer to listen for settings changes
                 mContentResolver.registerContentObserver(
-                        Settings.Secure.getUriFor(Settings.Secure.ADB_ENABLED),
+                        Settings.Global.getUriFor(Settings.Global.ADB_ENABLED),
                                 false, new AdbSettingsObserver());
 
                 // Watch for USB configuration changes
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index c09c261..efedbd8 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -7946,8 +7946,8 @@
         synchronized(mWindowMap) {
             final DisplayContent displayContent = getDisplayContentLocked(displayId);
             setForcedDisplayDensityLocked(displayContent, displayContent.mInitialDisplayDensity);
-            Settings.Secure.putString(mContext.getContentResolver(),
-                    Settings.Secure.DISPLAY_DENSITY_FORCED, "");
+            Settings.Global.putString(mContext.getContentResolver(),
+                    Settings.Global.DISPLAY_DENSITY_FORCED, "");
         }
     }
 
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index b71e38e..acf452f 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -1055,11 +1055,12 @@
             // just keep the crop rect the same as the source surface.
             w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight);
         } else if (!w.isDefaultDisplay()) {
-            // On a different display is easy, just use the entire display.
+            // On a different display there is no system decor.  Crop the window
+            // by the screen boundaries.
             w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(), w.mCompatFrame.height());
-            w.mSystemDecorRect.intersect(-w.mFrame.left, -w.mFrame.top,
-                    displayInfo.logicalWidth - w.mFrame.left,
-                    displayInfo.logicalHeight - w.mFrame.top);
+            w.mSystemDecorRect.intersect(-w.mCompatFrame.left, -w.mCompatFrame.top,
+                    displayInfo.logicalWidth - w.mCompatFrame.left,
+                    displayInfo.logicalHeight - w.mCompatFrame.top);
         } else if (w.mLayer >= mService.mSystemDecorLayer) {
             // Above the decor layer is easy, just use the entire window.
             // Unless we have a universe background...  in which case all the
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 4aa092b..e7927ae 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1060,8 +1060,8 @@
      */
     public void setCountryCode(String countryCode, boolean persist) {
         if (persist) {
-            Settings.Secure.putString(mContext.getContentResolver(),
-                    Settings.Secure.WIFI_COUNTRY_CODE,
+            Settings.Global.putString(mContext.getContentResolver(),
+                    Settings.Global.WIFI_COUNTRY_CODE,
                     countryCode);
         }
         sendMessage(obtainMessage(CMD_SET_COUNTRY_CODE, countryCode));
@@ -1318,8 +1318,8 @@
      * Set the country code from the system setting value, if any.
      */
     private void setCountryCode() {
-        String countryCode = Settings.Secure.getString(mContext.getContentResolver(),
-                Settings.Secure.WIFI_COUNTRY_CODE);
+        String countryCode = Settings.Global.getString(mContext.getContentResolver(),
+                Settings.Global.WIFI_COUNTRY_CODE);
         if (countryCode != null && !countryCode.isEmpty()) {
             setCountryCode(countryCode, false);
         } else {
@@ -1609,8 +1609,8 @@
     }
 
     private int getMaxDhcpRetries() {
-        return Settings.Secure.getInt(mContext.getContentResolver(),
-                                      Settings.Secure.WIFI_MAX_DHCP_RETRY_COUNT,
+        return Settings.Global.getInt(mContext.getContentResolver(),
+                                      Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT,
                                       DEFAULT_MAX_DHCP_RETRIES);
     }