am e71a8772: Import translations. DO NOT MERGE

* commit 'e71a8772bbc92a72e68484bb6c0aa2e3c0baa64d':
  Import translations. DO NOT MERGE
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f2e51a1..71cc520 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -61,6 +61,7 @@
     <uses-permission android:name="android.permission.MANAGE_USERS" />
     <uses-permission android:name="android.permission.READ_PROFILE" />
     <uses-permission android:name="android.permission.CONFIGURE_WIFI_DISPLAY" />
+    <uses-permission android:name="android.permission.SET_TIME" />
 
     <application android:label="@string/settings_label"
             android:icon="@mipmap/ic_launcher_settings"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d6abe94..97f2af3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2828,8 +2828,6 @@
     <string name="auto_punctuate_summary">Press Space key twice to insert \u0022.\u0022</string>
     <!-- On Security & location settings screen, setting check box name. Title of the checkbox to set whether password edit fields will show the most recent character typed and then hide it, or just hide it right away.  By hide, I mean mask it out. -->
     <string name="show_password">Make passwords visible</string>
-    <!-- On Security & location settings screen, setting check box summary. Summary for the visible passwords setting. -->
-    <string name="show_password_summary"></string>
     <!-- Warning message about security implications of enabling an input method, displayed as a dialog
          message when the user selects to enable an IME. -->
     <string name="ime_security_warning">This input method may be able to collect
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index b0313eb..ee87e51 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -33,7 +33,6 @@
 
         <CheckBoxPreference android:key="show_password"
                 android:title="@string/show_password"
-                android:summary="@string/show_password_summary"
                 android:persistent="false"/>
     </PreferenceCategory>
 
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index f07d6fa..94c793d 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -55,6 +55,7 @@
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
+import com.android.internal.statusbar.StatusBarIcon;
 import com.android.internal.telephony.ITelephony;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
@@ -229,6 +230,16 @@
     };
 
     private AudioManager mAudioManager;
+    /** The status bar where back/home/recent buttons are shown. */
+    private StatusBarManager mStatusBar;
+
+    /** All the widgets to disable in the status bar */
+    final private static int sWidgetsToDisable = StatusBarManager.DISABLE_EXPAND
+            | StatusBarManager.DISABLE_NOTIFICATION_ICONS
+            | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
+            | StatusBarManager.DISABLE_SYSTEM_INFO
+            | StatusBarManager.DISABLE_HOME
+            | StatusBarManager.DISABLE_RECENT;
 
     /** @return whether or not this Activity was started for debugging the UI only. */
     private boolean isDebugView() {
@@ -269,6 +280,7 @@
      */
     @Override
     public void onBackPressed() {
+        // In the rare case that something pressed back even though we were disabled.
         if (mIgnoreBack)
             return;
         super.onBackPressed();
@@ -299,13 +311,8 @@
 
         // Disable the status bar, but do NOT disable back because the user needs a way to go
         // from keyboard settings and back to the password screen.
-        StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
-        sbm.disable(StatusBarManager.DISABLE_EXPAND
-                | StatusBarManager.DISABLE_NOTIFICATION_ICONS
-                | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
-                | StatusBarManager.DISABLE_SYSTEM_INFO
-                | StatusBarManager.DISABLE_HOME
-                | StatusBarManager.DISABLE_RECENT);
+        mStatusBar = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
+        mStatusBar.disable(sWidgetsToDisable);
 
         setAirplaneModeIfNecessary();
         mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
@@ -403,7 +410,7 @@
 
         ((ProgressBar) findViewById(R.id.progress_bar)).setIndeterminate(true);
         // Ignore all back presses from now, both hard and soft keys.
-        mIgnoreBack = true;
+        setBackFunctionality(false);
         // Start the first run of progress manually. This method sets up messages to occur at
         // repeated intervals.
         updateProgress();
@@ -469,7 +476,7 @@
         if (mCooldown <= 0) {
             // Re-enable the password entry and back presses.
             mPasswordEntry.setEnabled(true);
-            mIgnoreBack = false;
+            setBackFunctionality(true);
             status.setText(R.string.enter_password);
         } else {
             CharSequence template = getText(R.string.crypt_keeper_cooldown);
@@ -481,6 +488,19 @@
         }
     }
 
+    /**
+     * Sets the back status: enabled or disabled according to the parameter.
+     * @param isEnabled true if back is enabled, false otherwise.
+     */
+    private final void setBackFunctionality(boolean isEnabled) {
+        mIgnoreBack = !isEnabled;
+        if (isEnabled) {
+            mStatusBar.disable(sWidgetsToDisable);
+        } else {
+            mStatusBar.disable(sWidgetsToDisable | StatusBarManager.DISABLE_BACK);
+        }
+    }
+
     private void passwordEntryInit() {
         mPasswordEntry = (EditText) findViewById(R.id.passwordEntry);
         mPasswordEntry.setOnEditorActionListener(this);
@@ -610,7 +630,7 @@
             // Disable the password entry and back keypress while checking the password. These
             // we either be re-enabled if the password was wrong or after the cooldown period.
             mPasswordEntry.setEnabled(false);
-            mIgnoreBack = true;
+            setBackFunctionality(false);
 
             Log.d(TAG, "Attempting to send command to decrypt");
             new DecryptTask().execute(password);
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java
index 53f25a2..65a34f4 100644
--- a/src/com/android/settings/DateTimeSettings.java
+++ b/src/com/android/settings/DateTimeSettings.java
@@ -17,6 +17,7 @@
 package com.android.settings;
 
 import android.app.Activity;
+import android.app.AlarmManager;
 import android.app.DatePickerDialog;
 import android.app.Dialog;
 import android.app.TimePickerDialog;
@@ -184,18 +185,18 @@
 
     @Override
     public void onDateSet(DatePicker view, int year, int month, int day) {
-        setDate(year, month, day);
         final Activity activity = getActivity();
         if (activity != null) {
+            setDate(activity, year, month, day);
             updateTimeAndDateDisplay(activity);
         }
     }
 
     @Override
     public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
-        setTime(hourOfDay, minute);
         final Activity activity = getActivity();
         if (activity != null) {
+            setTime(activity, hourOfDay, minute);
             updateTimeAndDateDisplay(activity);
         }
 
@@ -337,7 +338,7 @@
         }
     }
 
-    /* package */ static void setDate(int year, int month, int day) {
+    /* package */ static void setDate(Context context, int year, int month, int day) {
         Calendar c = Calendar.getInstance();
 
         c.set(Calendar.YEAR, year);
@@ -346,11 +347,11 @@
         long when = c.getTimeInMillis();
 
         if (when / 1000 < Integer.MAX_VALUE) {
-            SystemClock.setCurrentTimeMillis(when);
+            ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
         }
     }
 
-    /* package */ static void setTime(int hourOfDay, int minute) {
+    /* package */ static void setTime(Context context, int hourOfDay, int minute) {
         Calendar c = Calendar.getInstance();
 
         c.set(Calendar.HOUR_OF_DAY, hourOfDay);
@@ -360,7 +361,7 @@
         long when = c.getTimeInMillis();
 
         if (when / 1000 < Integer.MAX_VALUE) {
-            SystemClock.setCurrentTimeMillis(when);
+            ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
         }
     }
 
diff --git a/src/com/android/settings/DateTimeSettingsSetupWizard.java b/src/com/android/settings/DateTimeSettingsSetupWizard.java
index 87b1cae..05e0d4e 100644
--- a/src/com/android/settings/DateTimeSettingsSetupWizard.java
+++ b/src/com/android/settings/DateTimeSettingsSetupWizard.java
@@ -188,9 +188,9 @@
                 Settings.Global.putInt(getContentResolver(), Settings.Global.AUTO_TIME,
                       mAutoDateTimeButton.isChecked() ? 1 : 0);
                 if (!mAutoDateTimeButton.isChecked()) {
-                    DateTimeSettings.setDate(mDatePicker.getYear(), mDatePicker.getMonth(),
+                    DateTimeSettings.setDate(this, mDatePicker.getYear(), mDatePicker.getMonth(),
                             mDatePicker.getDayOfMonth());
-                    DateTimeSettings.setTime(
+                    DateTimeSettings.setTime(this,
                             mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
                 }
             }
diff --git a/src/com/android/settings/bluetooth/DockService.java b/src/com/android/settings/bluetooth/DockService.java
index ab0e7c7..c9a18a3 100644
--- a/src/com/android/settings/bluetooth/DockService.java
+++ b/src/com/android/settings/bluetooth/DockService.java
@@ -120,6 +120,8 @@
     private int mPendingTurnOnStartId = INVALID_STARTID;
     private int mPendingTurnOffStartId = INVALID_STARTID;
 
+    private CheckBox mAudioMediaCheckbox;
+
     @Override
     public void onCreate() {
         if (DEBUG) Log.d(TAG, "onCreate");
@@ -499,6 +501,8 @@
         View view;
         LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
 
+        mAudioMediaCheckbox = null;
+
         if (device != null) {
             // Device in a new dock.
             boolean firstTime =
@@ -528,14 +532,14 @@
             ab.setTitle(getString(R.string.bluetooth_dock_settings_title));
 
             view = inflater.inflate(R.layout.dock_audio_media_enable_dialog, null);
-            CheckBox audioMediaCheckbox =
+            mAudioMediaCheckbox =
                     (CheckBox) view.findViewById(R.id.dock_audio_media_enable_cb);
 
             boolean checked = Settings.Global.getInt(getContentResolver(),
                                     Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, 0) == 1;
 
-            audioMediaCheckbox.setChecked(checked);
-            audioMediaCheckbox.setOnCheckedChangeListener(mCheckedChangeListener);
+            mAudioMediaCheckbox.setChecked(checked);
+            mAudioMediaCheckbox.setOnCheckedChangeListener(mCheckedChangeListener);
         }
 
         float pixelScaleFactor = getResources().getDisplayMetrics().density;
@@ -601,19 +605,24 @@
     private final DialogInterface.OnClickListener mClickListener =
             new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int which) {
-                    if (which == DialogInterface.BUTTON_POSITIVE
-                            && mDevice != null) {
-                        if (!LocalBluetoothPreferences
-                                .hasDockAutoConnectSetting(
-                                        DockService.this,
-                                        mDevice.getAddress())) {
-                            LocalBluetoothPreferences
-                                    .saveDockAutoConnectSetting(
+                    if (which == DialogInterface.BUTTON_POSITIVE) {
+                        if (mDevice != null) {
+                            if (!LocalBluetoothPreferences
+                                    .hasDockAutoConnectSetting(
                                             DockService.this,
-                                            mDevice.getAddress(), true);
-                        }
+                                            mDevice.getAddress())) {
+                                LocalBluetoothPreferences
+                                        .saveDockAutoConnectSetting(
+                                                DockService.this,
+                                                mDevice.getAddress(), true);
+                            }
 
-                        applyBtSettings(mDevice, mStartIdAssociatedWithDialog);
+                            applyBtSettings(mDevice, mStartIdAssociatedWithDialog);
+                        } else if (mAudioMediaCheckbox != null) {
+                            Settings.Global.putInt(getContentResolver(),
+                                    Settings.Global.DOCK_AUDIO_MEDIA_ENABLED,
+                                    mAudioMediaCheckbox.isChecked() ? 1 : 0);
+                        }
                     }
                 }
             };
diff --git a/src/com/android/settings/fuelgauge/PowerUsageDetail.java b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
index 4f98163..753bf82 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageDetail.java
@@ -34,10 +34,10 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Process;
-import android.os.UserHandle;
 import android.preference.PreferenceActivity;
 import android.provider.Settings;
 import android.text.TextUtils;
+import android.text.format.Formatter;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -310,10 +310,12 @@
                 switch (mTypes[i]) {
                     case R.string.usage_type_data_recv:
                     case R.string.usage_type_data_send:
-                        value = Utils.formatBytes(getActivity(), mValues[i]);
+                        final long bytes = (long) (mValues[i]);
+                        value = Formatter.formatFileSize(getActivity(), bytes);
                         break;
                     case R.string.usage_type_no_coverage:
-                        value = String.format("%d%%", (int) Math.floor(mValues[i]));
+                        final int percentage = (int) Math.floor(mValues[i]);
+                        value = getActivity().getString(R.string.percentage, percentage);
                         break;
                     case R.string.usage_type_gps:
                         mUsesGps = true;
diff --git a/src/com/android/settings/fuelgauge/Utils.java b/src/com/android/settings/fuelgauge/Utils.java
index 2ffc9de..5c99a86 100644
--- a/src/com/android/settings/fuelgauge/Utils.java
+++ b/src/com/android/settings/fuelgauge/Utils.java
@@ -64,21 +64,4 @@
         }
         return sb.toString();
     }
-
-    /**
-     * Formats data size in KB, MB, from the given bytes.
-     * @param context the application context
-     * @param bytes data size in bytes
-     * @return the formatted size such as 4.52 MB or 245 KB or 332 bytes
-     */
-    public static String formatBytes(Context context, double bytes) {
-        // TODO: I18N
-        if (bytes > 1000 * 1000) {
-            return String.format("%.2f MB", ((int) (bytes / 1000)) / 1000f);
-        } else if (bytes > 1024) {
-            return String.format("%.2f KB", ((int) (bytes / 10)) / 100f);
-        } else {
-            return String.format("%d bytes", (int) bytes);
-        }
-    }
 }
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 632dfe5..dbaaf37 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -26,6 +26,7 @@
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
 import android.content.pm.UserInfo;
+import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.drawable.BitmapDrawable;
@@ -477,6 +478,7 @@
     }
 
     private void loadIconsAsync(List<Integer> missingIcons) {
+        final Resources resources = getResources();
         new AsyncTask<List<Integer>, Void, Void>() {
             @Override
             protected void onPostExecute(Void result) {
@@ -485,17 +487,16 @@
 
             @Override
             protected Void doInBackground(List<Integer>... values) {
-                if (getActivity() == null) return null;
                 for (int userId : values[0]) {
                     Bitmap bitmap = mUserManager.getUserIcon(userId);
-                    Drawable d = new BitmapDrawable(getResources(), bitmap);
+                    Drawable d = new BitmapDrawable(resources, bitmap);
                     mUserIcons.append(userId, d);
                 }
                 return null;
             }
         }.execute(missingIcons);
-
     }
+
     private void assignProfilePhoto(final UserInfo user) {
         if (!Utils.copyMeProfilePhoto(getActivity(), user)) {
             assignDefaultPhoto(user);