auto import from //branches/cupcake/...@125939
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index 0bd950b..f105712 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -63,7 +63,7 @@
         
         // This is the widget enabled state, not the preference toggled state
         mCheckBoxPref.setEnabled(true);
-        mCheckBoxPref.setChecked(isAirplaneModeOn());
+        mCheckBoxPref.setChecked(isAirplaneModeOn(mContext));
 
         mPhoneStateReceiver.registerIntent();
         mCheckBoxPref.setOnPreferenceChangeListener(this);
@@ -74,8 +74,8 @@
         mCheckBoxPref.setOnPreferenceChangeListener(null);
     }
     
-    private boolean isAirplaneModeOn() {
-        return Settings.System.getInt(mContext.getContentResolver(),
+    static boolean isAirplaneModeOn(Context context) {
+        return Settings.System.getInt(context.getContentResolver(),
                 Settings.System.AIRPLANE_MODE_ON, 0) != 0;
     }
 
diff --git a/src/com/android/settings/BatteryHistory.java b/src/com/android/settings/BatteryHistory.java
new file mode 100644
index 0000000..7e077d5
--- /dev/null
+++ b/src/com/android/settings/BatteryHistory.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import com.android.internal.app.IBatteryStats;
+
+import android.app.Activity;
+import android.os.BatteryStats;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import android.widget.TextView;
+
+public class BatteryHistory extends Activity {
+    private static final String TAG = "BatteryHistory";
+    TextView mTextView;
+    IBatteryStats mBatteryInfo;
+
+    private String getDump(BatteryStats stats) {
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            PrintWriter pw = new PrintWriter(out, true);
+            stats.dumpLocked(null, pw, null);
+            pw.flush();
+            pw.close();
+            out.close();
+            return new String(out.toByteArray(), 0);
+        } catch (IOException e) {
+            return "IOException";
+        }
+    }
+    
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        Log.i(TAG, "onCreate");
+        setContentView(R.layout.battery_history);
+        mTextView = (TextView) findViewById(R.id.text);
+        mBatteryInfo = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
+        try {
+            BatteryStats stats = mBatteryInfo.getStatistics();
+            String s = getDump(stats);
+            mTextView.setText(s);
+        } catch (RemoteException e) {
+            mTextView.setText("Got RemoteException");
+            Log.e(TAG, "RemoteException:", e);
+        }
+    }
+}
diff --git a/src/com/android/settings/BatteryInfo.java b/src/com/android/settings/BatteryInfo.java
index ed3e3e3..f9962fa 100644
--- a/src/com/android/settings/BatteryInfo.java
+++ b/src/com/android/settings/BatteryInfo.java
@@ -184,8 +184,8 @@
         
         if (mBatteryStats != null) {
             try {
-                long awakeTimeBattery = mBatteryStats.getAwakeTimeBattery();
-                long awakeTimePluggedIn = mBatteryStats.getAwakeTimePlugged();
+                long awakeTimeBattery = mBatteryStats.getAwakeTimeBattery() / 1000;
+                long awakeTimePluggedIn = mBatteryStats.getAwakeTimePlugged() / 1000;
                 mAwakeBattery.setText(DateUtils.formatElapsedTime(awakeTimeBattery / 1000) 
                         + " (" + (100 * awakeTimeBattery / uptime) + "%)");
                 mAwakePlugged.setText(DateUtils.formatElapsedTime(awakeTimePluggedIn / 1000)
diff --git a/src/com/android/settings/InputMethodsSettings.java b/src/com/android/settings/InputMethodsSettings.java
index d38779d..51b770d 100644
--- a/src/com/android/settings/InputMethodsSettings.java
+++ b/src/com/android/settings/InputMethodsSettings.java
@@ -80,8 +80,8 @@
             if (null != property.getSettingsActivity()) {
                 PreferenceScreen prefScreen = new PreferenceScreen(this, null);
                 prefScreen.setKey(property.getSettingsActivity());
-                // XXX TODO: handle localization properly.
-                prefScreen.setTitle(label + " settings");
+                prefScreen.setTitle(getResources().getString(
+                        R.string.input_methods_settings_label_format, label));
                 getPreferenceScreen().addPreference(prefScreen);
             }
         }
diff --git a/src/com/android/settings/InstalledAppDetails.java b/src/com/android/settings/InstalledAppDetails.java
index d3e7344..04121bb 100644
--- a/src/com/android/settings/InstalledAppDetails.java
+++ b/src/com/android/settings/InstalledAppDetails.java
@@ -291,7 +291,7 @@
         //display confirmation dialog
         new AlertDialog.Builder(this)
         .setTitle(getString(R.string.app_not_found_dlg_title))
-        .setIcon(R.drawable.ic_dialog_alert)
+        .setIcon(android.R.drawable.ic_dialog_alert)
         .setMessage(getString(msgId))
         .setNeutralButton(getString(R.string.dlg_ok), 
                 new DialogInterface.OnClickListener() {
@@ -421,7 +421,7 @@
                 //display confirmation dialog
                 new AlertDialog.Builder(this)
                 .setTitle(getString(R.string.clear_data_dlg_title))
-                .setIcon(R.drawable.ic_dialog_alert)
+                .setIcon(android.R.drawable.ic_dialog_alert)
                 .setMessage(getString(R.string.clear_data_dlg_text))
                 .setPositiveButton(R.string.dlg_ok, this)
                 .setNegativeButton(R.string.dlg_cancel, this)
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 9f98ab2..0c4545e 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -39,13 +39,8 @@
     
     @Override
     protected void onResume() {
-        findPreference(KEY_CALL_SETTINGS).setEnabled(!isAirplaneMode());
         super.onResume();
+        findPreference(KEY_CALL_SETTINGS).setEnabled(!AirplaneModeEnabler.isAirplaneModeOn(this));
     }
 
-    private boolean isAirplaneMode() {
-        return System.getInt(getContentResolver(), 
-                              System.AIRPLANE_MODE_ON, 0) > 0;
-    }   
-
 }
diff --git a/src/com/android/settings/ZoneList.java b/src/com/android/settings/ZoneList.java
index a2ec1ef..2877f00 100644
--- a/src/com/android/settings/ZoneList.java
+++ b/src/com/android/settings/ZoneList.java
@@ -111,7 +111,7 @@
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         menu.add(0, MENU_ALPHABETICAL, 0, R.string.zone_list_menu_sort_alphabetically)
-            .setIcon(R.drawable.ic_menu_sort_alphabetically);
+            .setIcon(android.R.drawable.ic_menu_sort_alphabetically);
         menu.add(0, MENU_TIMEZONE, 0, R.string.zone_list_menu_sort_by_timezone)
             .setIcon(R.drawable.ic_menu_3d_globe);
         
diff --git a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
index f895696..facb763 100644
--- a/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothDiscoverableEnabler.java
@@ -56,8 +56,14 @@
     private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
-            handleModeChanged(intent.getIntExtra(BluetoothIntent.MODE, 
-                    BluetoothDevice.MODE_UNKNOWN));
+            /*
+             * TODO: remove this once the BT framework broadcasts the
+             * MODE_CHANGED action when going into MODE_OFF.
+             */
+            int mode = BluetoothIntent.DISABLED_ACTION.equals(intent.getAction())
+                    ? BluetoothDevice.MODE_OFF                    
+                    : intent.getIntExtra(BluetoothIntent.MODE, BluetoothDevice.MODE_UNKNOWN);
+            handleModeChanged(mode);
         }
     };
 
@@ -85,9 +91,10 @@
         if (mLocalManager == null) {
             return;
         }
-        
-        mContext.registerReceiver(mReceiver, 
-                new IntentFilter(BluetoothIntent.MODE_CHANGED_ACTION));
+
+        IntentFilter filter = new IntentFilter(BluetoothIntent.MODE_CHANGED_ACTION);
+        filter.addAction(BluetoothIntent.DISABLED_ACTION);
+        mContext.registerReceiver(mReceiver, filter);
         mCheckBoxPreference.setOnPreferenceChangeListener(this);
         
         handleModeChanged(mLocalManager.getBluetoothManager().getMode());
@@ -164,7 +171,9 @@
     
     private void updateCountdownSummary() {
         int mode = mLocalManager.getBluetoothManager().getMode();
-        if (mode != BluetoothDevice.MODE_DISCOVERABLE) return;
+        if (mode != BluetoothDevice.MODE_DISCOVERABLE) {
+            return;
+        }
             
         long currentTimestamp = System.currentTimeMillis();
         long endTimestamp = mLocalManager.getSharedPreferences().getLong(
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 316e831..76248b4 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -147,7 +147,7 @@
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         menu.add(0, MENU_SCAN, 0, R.string.bluetooth_scan_for_devices)
-                .setIcon(R.drawable.ic_menu_refresh)
+                .setIcon(android.R.drawable.ic_menu_refresh)
                 .setAlphabeticShortcut('r');
         return true;
     }
diff --git a/src/com/android/settings/quicklaunch/QuickLaunchSettings.java b/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
index df15c0b..c023d4d 100644
--- a/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
+++ b/src/com/android/settings/quicklaunch/QuickLaunchSettings.java
@@ -140,7 +140,7 @@
                 // Create the dialog for clearing a shortcut
                 return new AlertDialog.Builder(this)
                         .setTitle(getString(R.string.quick_launch_clear_dialog_title))
-                        .setIcon(R.drawable.ic_dialog_alert)
+                        .setIcon(android.R.drawable.ic_dialog_alert)
                         .setMessage(getString(R.string.quick_launch_clear_dialog_message,
                                 mClearDialogShortcut, mClearDialogBookmarkTitle))
                         .setPositiveButton(R.string.quick_launch_clear_ok_button, this)
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index c92ed7c..3d7ac0a 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -176,7 +176,7 @@
             .setIcon(R.drawable.ic_menu_scan_network);
         
         menu.add(0, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
-            .setIcon(R.drawable.ic_menu_manage);
+            .setIcon(android.R.drawable.ic_menu_manage);
         
         return true;
     }