summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-05-24 10:42:23 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-24 10:42:23 -0700
commit0100625bb316ecbd99873b72756ffba8613c3456 (patch)
tree3493a8349facdef995995090c32f7d64d14b48da
parent222f56135026627637e9db4801d6532b1ff16657 (diff)
parent13fe2a5330a5df662d7b1b136e7b08fe34c94a42 (diff)
downloadframeworks_base-0100625bb316ecbd99873b72756ffba8613c3456.zip
frameworks_base-0100625bb316ecbd99873b72756ffba8613c3456.tar.gz
frameworks_base-0100625bb316ecbd99873b72756ffba8613c3456.tar.bz2
Merge "Fix bug #6522190 MountService should respond to configuration changes ("INTERNAL STORAGE" string should be translated dynamically)" into jb-dev
-rw-r--r--core/java/android/os/storage/StorageVolume.java29
-rw-r--r--media/java/android/mtp/MtpStorage.java5
-rw-r--r--services/java/com/android/server/MountService.java11
3 files changed, 27 insertions, 18 deletions
diff --git a/core/java/android/os/storage/StorageVolume.java b/core/java/android/os/storage/StorageVolume.java
index 2c4b863..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 @@ public class StorageVolume implements Parcelable {
//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 @@ public class StorageVolume implements Parcelable {
// 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 @@ public class StorageVolume implements Parcelable {
}
// 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 @@ public class StorageVolume implements Parcelable {
*
* @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 @@ public class StorageVolume implements Parcelable {
@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 @@ public class StorageVolume implements Parcelable {
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 class StorageVolume implements Parcelable {
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 @@ public class MtpStorage {
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 @@ class MountService extends IMountService.Stub
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 @@ class MountService extends IMountService.Stub
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 @@ class MountService extends IMountService.Stub
} 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 @@ class MountService extends IMountService.Stub
*/
public MountService(Context context) {
mContext = context;
- Resources resources = context.getResources();
- readStorageList(resources);
+ readStorageList();
if (mPrimaryVolume != null) {
mExternalStoragePath = mPrimaryVolume.getPath();