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

This commit is contained in:
Fabrice Di Meglio
2012-05-24 10:42:23 -07:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 18 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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();