Merge "Remove "Screen lock" category header as the title is sufficient."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f793d79..e0e0819 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3357,11 +3357,11 @@
     <string name="sync_automatically">Auto-sync app data</string>
 
     <!-- Sync status messages on Accounts & Synchronization settings --><skip />
-    <!-- Sync status shown when sync is enabled [CHAR LIMIT=20] -->
+    <!-- Sync status shown when sync is enabled [CHAR LIMIT=25] -->
     <string name="sync_enabled">Sync is ON</string>
-    <!-- Sync status shown when sync is disabled [CHAR LIMIT=20] -->
+    <!-- Sync status shown when sync is disabled [CHAR LIMIT=25] -->
     <string name="sync_disabled">Sync is OFF</string>
-    <!-- Sync status shown when last sync resulted in an error [CHAR LIMIT=20] -->
+    <!-- Sync status shown when last sync resulted in an error [CHAR LIMIT=25] -->
     <string name="sync_error">Sync error</string>
 
     <!-- Data synchronization settings screen, setting option name -->
@@ -3474,6 +3474,11 @@
     <!-- UI debug setting: show cpu usage summary [CHAR LIMIT=50] -->
     <string name="show_cpu_usage_summary">Screen overlay showing current CPU usage</string>
 
+    <!-- UI debug setting: force hardware acceleration to render apps [CHAR LIMIT=25] -->
+    <string name="force_hw_ui">Force hardware acceleration</string>
+    <!-- UI debug setting: force hardware acceleration summary [CHAR LIMIT=50] -->
+    <string name="force_hw_ui_summary">Render applications using the GPU</string>
+
     <!-- UI debug setting: scaling factor for window animations [CHAR LIMIT=25] -->
     <string name="window_animation_scale_title">Window animation scale</string>
 
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 76e50aa..68e24c4 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -85,6 +85,11 @@
             android:title="@string/show_cpu_usage"
             android:summary="@string/show_cpu_usage_summary"/>
 
+        <CheckBoxPreference
+            android:key="force_hw_ui"
+            android:title="@string/force_hw_ui"
+            android:summary="@string/force_hw_ui_summary"/>
+
         <ListPreference
             android:key="window_animation_scale"
             android:title="@string/window_animation_scale_title"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index c3725e4..2ffae19 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -60,12 +60,14 @@
     private static final String HDCP_CHECKING_KEY = "hdcp_checking";
     private static final String HDCP_CHECKING_PROPERTY = "persist.sys.hdcp_checking";
     private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";
+    private static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw";
 
     private static final String STRICT_MODE_KEY = "strict_mode";
     private static final String POINTER_LOCATION_KEY = "pointer_location";
     private static final String SHOW_TOUCHES_KEY = "show_touches";
     private static final String SHOW_SCREEN_UPDATES_KEY = "show_screen_updates";
     private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
+    private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
     private static final String WINDOW_ANIMATION_SCALE_KEY = "window_animation_scale";
     private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
 
@@ -88,6 +90,7 @@
     private CheckBoxPreference mShowTouches;
     private CheckBoxPreference mShowScreenUpdates;
     private CheckBoxPreference mShowCpuUsage;
+    private CheckBoxPreference mForceHardwareUi;
     private ListPreference mWindowAnimationScale;
     private ListPreference mTransitionAnimationScale;
 
@@ -121,6 +124,7 @@
         mShowTouches = (CheckBoxPreference) findPreference(SHOW_TOUCHES_KEY);
         mShowScreenUpdates = (CheckBoxPreference) findPreference(SHOW_SCREEN_UPDATES_KEY);
         mShowCpuUsage = (CheckBoxPreference) findPreference(SHOW_CPU_USAGE_KEY);
+        mForceHardwareUi = (CheckBoxPreference) findPreference(FORCE_HARDWARE_UI_KEY);
         mWindowAnimationScale = (ListPreference) findPreference(WINDOW_ANIMATION_SCALE_KEY);
         mWindowAnimationScale.setOnPreferenceChangeListener(this);
         mTransitionAnimationScale = (ListPreference) findPreference(TRANSITION_ANIMATION_SCALE_KEY);
@@ -172,6 +176,7 @@
         updateShowTouchesOptions();
         updateFlingerOptions();
         updateCpuUsageOptions();
+        updateHardwareUiOptions();
         updateAnimationScaleOptions();
         updateImmediatelyDestroyActivitiesOptions();
         updateAppProcessLimitOptions();
@@ -294,11 +299,19 @@
         }
     }
 
+    private void updateHardwareUiOptions() {
+        mForceHardwareUi.setChecked(SystemProperties.getBoolean(HARDWARE_UI_PROPERTY, false));
+    }
+    
+    private void writeHardwareUiOptions() {
+        SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
+    }
+
     private void updateCpuUsageOptions() {
         mShowCpuUsage.setChecked(Settings.System.getInt(getActivity().getContentResolver(),
                 Settings.System.SHOW_PROCESSES, 0) != 0);
     }
-
+    
     private void writeCpuUsageOptions() {
         boolean value = mShowCpuUsage.isChecked();
         Settings.System.putInt(getActivity().getContentResolver(),
@@ -441,6 +454,8 @@
             writeImmediatelyDestroyActivitiesOptions();
         } else if (preference == mShowAllANRs) {
             writeShowAllANRsOptions();
+        } else if (preference == mForceHardwareUi) {
+            writeHardwareUiOptions();
         }
 
         return false;
diff --git a/src/com/android/settings/accounts/ManageAccountsSettings.java b/src/com/android/settings/accounts/ManageAccountsSettings.java
index 0f52fe5..1396e03 100644
--- a/src/com/android/settings/accounts/ManageAccountsSettings.java
+++ b/src/com/android/settings/accounts/ManageAccountsSettings.java
@@ -19,6 +19,7 @@
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.OnAccountsUpdateListener;
+import android.app.ActionBar;
 import android.app.Activity;
 import android.content.ContentResolver;
 import android.content.Intent;
@@ -31,12 +32,15 @@
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.Switch;
 import android.widget.TextView;
 
 import com.android.settings.AccountPreference;
@@ -50,15 +54,14 @@
         implements OnAccountsUpdateListener, DialogCreatable {
 
     private static final int MENU_ADD_ACCOUNT = Menu.FIRST;
-    private static final int MENU_SYNC_APP = MENU_ADD_ACCOUNT + 1;
 
     private static final int REQUEST_SHOW_SYNC_SETTINGS = 1;
 
     private String[] mAuthorities;
     private TextView mErrorInfoView;
-    private MenuItem mSyncAppMenuItem;
 
     private SettingsDialogFragment mDialogFragment;
+    private Switch mAutoSyncSwitch;
 
     @Override
     public void onCreate(Bundle icicle) {
@@ -91,6 +94,27 @@
         mErrorInfoView = (TextView)view.findViewById(R.id.sync_settings_error_info);
         mErrorInfoView.setVisibility(View.GONE);
 
+        mAutoSyncSwitch = new Switch(activity);
+
+        // TODO Where to put the switch in tablet multipane layout?
+        final int padding = activity.getResources().getDimensionPixelSize(
+                R.dimen.action_bar_switch_padding);
+        mAutoSyncSwitch.setPadding(0, 0, padding, 0);
+        activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+                ActionBar.DISPLAY_SHOW_CUSTOM);
+        activity.getActionBar().setCustomView(mAutoSyncSwitch, new ActionBar.LayoutParams(
+                ActionBar.LayoutParams.WRAP_CONTENT,
+                ActionBar.LayoutParams.WRAP_CONTENT,
+                Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+        mAutoSyncSwitch.setChecked(ContentResolver.getMasterSyncAutomatically());
+        mAutoSyncSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                ContentResolver.setMasterSyncAutomatically(isChecked);
+                onSyncStateUpdated();
+            }
+        });
+
         mAuthorities = activity.getIntent().getStringArrayExtra(AUTHORITIES_FILTER_KEY);
 
         updateAuthDescriptions();
@@ -135,9 +159,6 @@
         MenuItem addAccountItem = menu.add(0, MENU_ADD_ACCOUNT, 0, R.string.add_account_label);
         addAccountItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
                 | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
-        mSyncAppMenuItem = menu.add(0, MENU_SYNC_APP, 0, R.string.sync_automatically).
-                setCheckable(true).setChecked(ContentResolver.getMasterSyncAutomatically());
-        mSyncAppMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
     }
 
     @Override
@@ -146,11 +167,6 @@
         if (itemId == MENU_ADD_ACCOUNT) {
             onAddAccountClicked();
             return true;
-        } else if (itemId == MENU_SYNC_APP) {
-            // Use the opposite, the checked state has not yet been changed
-            ContentResolver.setMasterSyncAutomatically(!item.isChecked());
-            onSyncStateUpdated();            
-            return true;
         } else {
             return super.onOptionsItemSelected(item);
         }
@@ -161,8 +177,8 @@
         // Catch any delayed delivery of update messages
         if (getActivity() == null) return;
         // Set background connection state
-        if (mSyncAppMenuItem != null) {
-            mSyncAppMenuItem.setChecked(ContentResolver.getMasterSyncAutomatically());
+        if (mAutoSyncSwitch != null) {
+            mAutoSyncSwitch.setChecked(ContentResolver.getMasterSyncAutomatically());
         }
 
         // iterate over all the preferences, setting the state properly for each