am 07e28d1e: am 0100625b: Merge "Fix bug #6522190 MountService should respond to configuration changes ("INTERNAL STORAGE" string should be translated dynamically)" into jb-dev

* commit '07e28d1e9bd7373c83cb66d5d9e93ae9af1f090d':
  Fix bug #6522190 MountService should respond to configuration changes ("INTERNAL STORAGE" string should be translated dynamically)
diff --git a/core/java/android/os/storage/StorageVolume.java b/core/java/android/os/storage/StorageVolume.java
index 2c4b8631..79c8f3b 100644
--- a/core/java/android/os/storage/StorageVolume.java
+++ b/core/java/android/os/storage/StorageVolume.java
@@ -16,6 +16,7 @@
 
 package android.os.storage;
 
+import android.content.Context;
 import android.os.Parcel;
 import android.os.Parcelable;
 
@@ -28,7 +29,7 @@
     //private static final String TAG = "StorageVolume";
 
     private final String mPath;
-    private final String mDescription;
+    private final int mDescriptionId;
     private final boolean mRemovable;
     private final boolean mEmulated;
     private final int mMtpReserveSpace;
@@ -42,10 +43,10 @@
     // ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts.
     public static final String EXTRA_STORAGE_VOLUME = "storage_volume";
 
-    public StorageVolume(String path, String description, boolean removable,
+    public StorageVolume(String path, int descriptionId, boolean removable,
             boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize) {
         mPath = path;
-        mDescription = description;
+        mDescriptionId = descriptionId;
         mRemovable = removable;
         mEmulated = emulated;
         mMtpReserveSpace = mtpReserveSpace;
@@ -54,11 +55,11 @@
     }
 
     // for parcelling only
-    private StorageVolume(String path, String description, boolean removable,
+    private StorageVolume(String path, int descriptionId, boolean removable,
             boolean emulated, int mtpReserveSpace, int storageId,
             boolean allowMassStorage, long maxFileSize) {
         mPath = path;
-        mDescription = description;
+        mDescriptionId = descriptionId;
         mRemovable = removable;
         mEmulated = emulated;
         mMtpReserveSpace = mtpReserveSpace;
@@ -81,8 +82,12 @@
      *
      * @return the volume description
      */
-    public String getDescription() {
-        return mDescription;
+    public String getDescription(Context context) {
+        return context.getResources().getString(mDescriptionId);
+    }
+
+    public int getDescriptionId() {
+        return mDescriptionId;
     }
 
     /**
@@ -172,8 +177,8 @@
 
     @Override
     public String toString() {
-        return "StorageVolume [mAllowMassStorage=" + mAllowMassStorage + ", mDescription="
-                + mDescription + ", mEmulated=" + mEmulated + ", mMaxFileSize=" + mMaxFileSize
+        return "StorageVolume [mAllowMassStorage=" + mAllowMassStorage + ", mDescriptionId="
+                + mDescriptionId + ", mEmulated=" + mEmulated + ", mMaxFileSize=" + mMaxFileSize
                 + ", mMtpReserveSpace=" + mMtpReserveSpace + ", mPath=" + mPath + ", mRemovable="
                 + mRemovable + ", mStorageId=" + mStorageId + "]";
     }
@@ -182,14 +187,14 @@
         new Parcelable.Creator<StorageVolume>() {
         public StorageVolume createFromParcel(Parcel in) {
             String path = in.readString();
-            String description = in.readString();
+            int descriptionId = in.readInt();
             int removable = in.readInt();
             int emulated = in.readInt();
             int storageId = in.readInt();
             int mtpReserveSpace = in.readInt();
             int allowMassStorage = in.readInt();
             long maxFileSize = in.readLong();
-            return new StorageVolume(path, description,
+            return new StorageVolume(path, descriptionId,
                     removable == 1, emulated == 1, mtpReserveSpace,
                     storageId, allowMassStorage == 1, maxFileSize);
         }
@@ -205,7 +210,7 @@
 
     public void writeToParcel(Parcel parcel, int flags) {
         parcel.writeString(mPath);
-        parcel.writeString(mDescription);
+        parcel.writeInt(mDescriptionId);
         parcel.writeInt(mRemovable ? 1 : 0);
         parcel.writeInt(mEmulated ? 1 : 0);
         parcel.writeInt(mStorageId);
diff --git a/media/java/android/mtp/MtpStorage.java b/media/java/android/mtp/MtpStorage.java
index da190a6..2f47aad 100644
--- a/media/java/android/mtp/MtpStorage.java
+++ b/media/java/android/mtp/MtpStorage.java
@@ -16,6 +16,7 @@
 
 package android.mtp;
 
+import android.content.Context;
 import android.os.storage.StorageVolume;
 
 /**
@@ -34,10 +35,10 @@
     private final boolean mRemovable;
     private final long mMaxFileSize;
 
-    public MtpStorage(StorageVolume volume) {
+    public MtpStorage(StorageVolume volume, Context context) {
         mStorageId = volume.getStorageId();
         mPath = volume.getPath();
-        mDescription = volume.getDescription();
+        mDescription = context.getResources().getString(volume.getDescriptionId());
         mReserveSpace = volume.getMtpReserveSpace();
         mRemovable = volume.isRemovable();
         mMaxFileSize = volume.getMaxFileSize();
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 13ab586..1482d22 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -1065,7 +1065,9 @@
     private static final String TAG_STORAGE_LIST = "StorageList";
     private static final String TAG_STORAGE = "storage";
 
-    private void readStorageList(Resources resources) {
+    private void readStorageList() {
+        Resources resources = mContext.getResources();
+
         int id = com.android.internal.R.xml.storage_list;
         XmlResourceParser parser = resources.getXml(id);
         AttributeSet attrs = Xml.asAttributeSet(parser);
@@ -1084,6 +1086,8 @@
 
                     CharSequence path = a.getText(
                             com.android.internal.R.styleable.Storage_mountPoint);
+                    int descriptionId = a.getResourceId(
+                            com.android.internal.R.styleable.Storage_storageDescription, -1);
                     CharSequence description = a.getText(
                             com.android.internal.R.styleable.Storage_storageDescription);
                     boolean primary = a.getBoolean(
@@ -1110,7 +1114,7 @@
                     } else {
                         String pathString = path.toString();
                         StorageVolume volume = new StorageVolume(pathString,
-                                description.toString(), removable, emulated,
+                                descriptionId, removable, emulated,
                                 mtpReserve, allowMassStorage, maxFileSize);
                         if (primary) {
                             if (mPrimaryVolume == null) {
@@ -1151,8 +1155,7 @@
      */
     public MountService(Context context) {
         mContext = context;
-        Resources resources = context.getResources();
-        readStorageList(resources);
+        readStorageList();
 
         if (mPrimaryVolume != null) {
             mExternalStoragePath = mPrimaryVolume.getPath();