Merge "Don't show battery usage information if data is bogus."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5960572..c5e5eb7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -130,7 +130,8 @@
             </intent-filter>
         </activity-alias>
 
-        <activity android:name=".wifi.WifiInfo">
+        <activity android:name=".wifi.WifiInfo"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -138,7 +139,8 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".wifi.WifiConfigInfo">
+        <activity android:name=".wifi.WifiConfigInfo"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -146,7 +148,8 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".wifi.WifiAPITest">
+        <activity android:name=".wifi.WifiAPITest"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -154,7 +157,8 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".wifi.WifiStatusTest">
+        <activity android:name=".wifi.WifiStatusTest"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -163,7 +167,7 @@
         </activity>
 
         <activity-alias android:name=".wifi.WifiApSettings"
-            android:targetActivity="Settings">
+                android:targetActivity="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -311,7 +315,8 @@
         </activity>
 
         <activity android:name="PhysicalKeyboardSettings"
-                android:label="@string/builtin_keyboard_settings_title">
+                android:label="@string/builtin_keyboard_settings_title"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -391,7 +396,7 @@
         </activity>
 
         <activity android:name="Settings$DeviceInfoSettingsActivity"
-                android:theme="@android:style/Theme.Holo.Extended"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge"
                 android:label="@string/device_info_settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -407,7 +412,7 @@
 
         <activity android:name="SettingsLicenseActivity"
                 android:label="@string/settings_license_activity_title"
-                android:theme="@*android:style/Theme.Dialog.Alert">
+                android:theme="@*android:style/Theme.Holo.Dialog.Alert">
             <intent-filter>
                 <action android:name="android.settings.LICENSE" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -416,7 +421,7 @@
 
         <activity android:name="SettingsSafetyLegalActivity"
                 android:label="@string/settings_safetylegal_activity_title"
-                android:theme="@*android:style/Theme.Dialog.Alert">
+                android:theme="@*android:style/Theme.Holo.Dialog.Alert">
             <intent-filter>
                 <action android:name="android.settings.SAFETY" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -586,7 +591,9 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="IccLockSettings" android:label="@string/sim_lock_settings"
+        <activity android:name="IccLockSettings"
+                android:label="@string/sim_lock_settings"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge"
                 android:process="com.android.phone">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -667,7 +674,9 @@
         </activity>
 
         <!-- Runs in the phone process since it needs access to the Phone object -->
-        <activity android:name=".deviceinfo.Status" android:label="@string/device_status_activity_title"
+        <activity android:name=".deviceinfo.Status"
+                android:label="@string/device_status_activity_title"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge"
                 android:process="com.android.phone">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -692,7 +701,9 @@
                 android:resource="@id/storage_settings" />
         </activity>
 
-        <activity android:name="ApnEditor" android:label="@string/apn_edit">
+        <activity android:name="ApnEditor"
+                android:label="@string/apn_edit"
+                android:theme="@android:style/Theme.Holo.DialogWhenLarge">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <action android:name="android.intent.action.EDIT" />
diff --git a/res/values/styles.xml b/res/values/styles.xml
index c24359b..991637b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -79,7 +79,7 @@
         <item name="android:windowContentOverlay">@null</item>
     </style>
     
-    <style name="Theme.CreateShortCut" parent="android:Theme.Holo">
+    <style name="Theme.CreateShortCut" parent="android:Theme.Holo.DialogWhenLarge">
     </style>
     
 </resources>
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index 860c2ea..492c9d1 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -35,11 +35,9 @@
         
         <PreferenceScreen
                 android:key="power_usage"
+                android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
                 android:title="@string/power_usage_summary_title"
                 android:summary="@string/power_usage_summary">
-            <intent android:action="android.intent.action.MAIN"
-                    android:targetPackage="com.android.settings"
-                    android:targetClass="com.android.settings.fuelgauge.PowerUsageSummary" />
         </PreferenceScreen>
 
         <!-- Legal Information -->
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index 25ab6da..a13a292 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -52,8 +52,6 @@
 
     final TextUtils.SimpleStringSplitter mStringColonSplitter
             = new TextUtils.SimpleStringSplitter(':');
-    
-    private String mLastTickedInputMethodId;
 
     private AlertDialog mDialog = null;
     
@@ -145,7 +143,6 @@
 
         InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
                 this, getContentResolver(), mInputMethodProperties);
-        mLastTickedInputMethodId = null;
 
         if (mLanguagePref != null) {
             Configuration conf = getResources().getConfiguration();
@@ -161,7 +158,7 @@
     public void onPause() {
         super.onPause();
         InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
-                mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId);
+                mInputMethodProperties, mHaveHardKeyboard);
     }
 
     @Override
@@ -184,7 +181,6 @@
                         selImi = imi;
                         if (isSystemIme(imi)) {
                             // This is a built-in IME, so no need to warn.
-                            mLastTickedInputMethodId = id;
                             return super.onPreferenceTreeClick(preferenceScreen, preference);
                         }
                     }
@@ -203,7 +199,6 @@
                                     new DialogInterface.OnClickListener() {
                                         public void onClick(DialogInterface dialog, int which) {
                                             chkPref.setChecked(true);
-                                            mLastTickedInputMethodId = id;
                                         }
 
                             })
@@ -223,8 +218,6 @@
                         R.string.ime_security_warning,
                         selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
                 mDialog.show();
-            } else if (id.equals(mLastTickedInputMethodId)) {
-                mLastTickedInputMethodId = null;
             }
         } else if (preference instanceof PreferenceScreen) {
             if (preference.getFragment() != null) {
diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
index 3659dbb..cb90514 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java
@@ -42,8 +42,6 @@
 
     private List<InputMethodInfo> mInputMethodProperties;
 
-    private String mLastTickedInputMethodId;
-
     private AlertDialog mDialog = null;
 
     @Override
@@ -60,14 +58,13 @@
         super.onResume();
         InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
                 this, getContentResolver(), mInputMethodProperties);
-        mLastTickedInputMethodId = null;
     }
 
     @Override
     public void onPause() {
         super.onPause();
         InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
-                mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId);
+                mInputMethodProperties, mHaveHardKeyboard);
     }
 
     @Override
@@ -89,7 +86,6 @@
                             InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
                                     this, mInputMethodProperties, id, true);
                             // This is a built-in IME, so no need to warn.
-                            mLastTickedInputMethodId = id;
                             return super.onPreferenceTreeClick(preferenceScreen, preference);
                         }
                         break;
@@ -111,7 +107,6 @@
                                             InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
                                                     InputMethodAndSubtypeEnabler.this,
                                                     mInputMethodProperties, id, true);
-                                            mLastTickedInputMethodId = id;
                                         }
 
                             })
@@ -132,9 +127,6 @@
                         selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
                 mDialog.show();
             } else {
-                if (id.equals(mLastTickedInputMethodId)) {
-                    mLastTickedInputMethodId = null;
-                }
                 InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
                         this, mInputMethodProperties, id, false);
             }
diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java
index 709dace..288e6c2 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java
@@ -98,15 +98,13 @@
 
     public static void saveInputMethodSubtypeList(
             SettingsPreferenceFragment context, ContentResolver resolver,
-            List<InputMethodInfo> inputMethodProperties,
-            boolean hasHardKeyboard, String lastTickedInputMethodId) {
+            List<InputMethodInfo> inputMethodProperties, boolean hasHardKeyboard) {
         String currentInputMethodId = Settings.Secure.getString(resolver,
                 Settings.Secure.DEFAULT_INPUT_METHOD);
         final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
 
         StringBuilder builder = new StringBuilder();
         StringBuilder disabledSysImes = new StringBuilder();
-        InputMethodInfo firstEnabledIMI = null;
         int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
 
         final boolean onlyOneIME = inputMethodProperties.size() == 1;
@@ -121,9 +119,6 @@
                     || (pref != null && pref.isChecked())) {
                 if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER);
                 builder.append(id);
-                if (firstEnabledIMI == null) {
-                    firstEnabledIMI = property;
-                }
                 for (InputMethodSubtype subtype : property.getSubtypes()) {
                     CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
                             id + subtype.hashCode());
@@ -141,8 +136,11 @@
             } else if (isCurrentInputMethod) {
                 // We are processing the current input method, but found that it's not enabled.
                 // This means that the current input method has been uninstalled.
-                // If currentInputMethod is already uninstalled, selects last ticked IME
-                currentInputMethodId = lastTickedInputMethodId;
+                // If currentInputMethod is already uninstalled, InputMethodManagerService will
+                // find the applicable IME from the history and the system locale.
+                if (DEBUG) {
+                    Log.d(TAG, "Current IME was uninstalled or disabled.");
+                }
             }
             // If it's a disabled system ime, add it to the disabled list so that it
             // doesn't get enabled automatically on any changes to the package list
@@ -152,15 +150,6 @@
             }
         }
 
-        // If the last input method is unset, set it as the first enabled one.
-        if (TextUtils.isEmpty(currentInputMethodId)) {
-            if (firstEnabledIMI != null) {
-                currentInputMethodId = firstEnabledIMI.getId();
-            } else {
-                currentInputMethodId = null;
-            }
-        }
-
         if (DEBUG) {
             Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
             Log.d(TAG, "--- Save disable system inputmethod settings. :"
@@ -183,6 +172,8 @@
                 Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
         Settings.Secure.putString(resolver,
                 Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
+        // If the current input method is unset, InputMethodManagerService will find the applicable
+        // IME from the history and the system locale.
         Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
                 currentInputMethodId != null ? currentInputMethodId : "");
     }
diff --git a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
index c49f5ac..4de7ef5 100644
--- a/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiConfigUiForSetupWizardXL.java
@@ -67,20 +67,29 @@
         mEdit = edit;
         mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
-        mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, false);
+        mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, true);
         mController = new WifiConfigController(this, mView, mAccessPoint, edit);
 
-        // Set Focus to password View.
-        final View viewToBeFocused = mView.findViewById(R.id.password);
-        if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE &&
-                viewToBeFocused instanceof EditText) {
-            // After acquiring the focus, we show software keyboard.
-            viewToBeFocused.setOnFocusChangeListener(this);
-            final boolean requestFocusResult = viewToBeFocused.requestFocus();
-            Log.i(TAG, String.format("Focus request  %s.",
-                    (requestFocusResult ? "successful" : "failed")));
-            if (!requestFocusResult) {
-                viewToBeFocused.setOnFocusChangeListener(null);
+        // Assumes R.id.password is inside security_fields.
+        // TODO: confirm it is ok to assume R.id.password is the only EditText to be focused, and
+        // R.id.security_fields is the only parent for possible EditTexts. Possibly we need to
+        // check parentand detect visibility manually.
+        if (mView.findViewById(R.id.security_fields).getVisibility() == View.VISIBLE) {
+            // Set Focus to password View.
+            final View viewToBeFocused = mView.findViewById(R.id.password);
+            if (viewToBeFocused == null) {
+                Log.w(TAG, "password field to be focused not found.");
+            } else if (!(viewToBeFocused instanceof EditText)) {
+                Log.w(TAG, "password field is not EditText");
+            } else {
+                // After acquiring the focus, we show software keyboard.
+                viewToBeFocused.setOnFocusChangeListener(this);
+                final boolean requestFocusResult = viewToBeFocused.requestFocus();
+                Log.i(TAG, String.format("Focus request  %s.",
+                        (requestFocusResult ? "successful" : "failed")));
+                if (!requestFocusResult) {
+                    viewToBeFocused.setOnFocusChangeListener(null);
+                }
             }
         }
     }
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
index f59816e..468e5c2 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizardXL.java
@@ -163,6 +163,7 @@
 
     @Override
     public void onClick(View view) {
+        hideSoftwareKeyboard();
         if (view == mAddNetworkButton) {
             onAddNetworkButtonPressed();
         } else if (view == mRefreshButton) {
@@ -184,7 +185,6 @@
         } else if (view == mDetailButton) {
             mWifiSettings.showDialogForSelectedPreference();
         }
-        hideSoftwareKeyboard();
     }
 
     private void hideSoftwareKeyboard() {
@@ -334,7 +334,7 @@
         } else {
             view.findViewById(R.id.wifi_general_info).setVisibility(View.GONE);
         }
-        parent.addView(view);
+        // parent.addView(view);
 
         mStatusText.setText(R.string.wifi_setup_status_edit_network);
         mAddNetworkButton.setVisibility(View.GONE);