diff options
| author | 2016-03-02 23:03:39 +0000 | |
|---|---|---|
| committer | 2016-03-02 23:03:40 +0000 | |
| commit | d53f0df7dfb1eee22f7953870ed9d24688596712 (patch) | |
| tree | d88b936077e09fd27980996d6eb237e42e62b5fa | |
| parent | 042a68ae3297db27c4bd6aca7f1c39001261b85e (diff) | |
| parent | ecec7cb0623100526ef9ff68cc2d841ca8f71729 (diff) | |
Merge "Use device model and name for internal storage." into nyc-dev
| -rw-r--r-- | packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java index d31a121233e3..3eda8ec1ee35 100644 --- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java @@ -41,6 +41,7 @@ import android.provider.DocumentsContract.Document; import android.provider.DocumentsContract.Root; import android.provider.DocumentsProvider; import android.provider.MediaStore; +import android.provider.Settings; import android.support.provider.DocumentArchiveHelper; import android.text.TextUtils; import android.util.ArrayMap; @@ -62,6 +63,7 @@ import java.util.List; public class ExternalStorageProvider extends DocumentsProvider { private static final String TAG = "ExternalStorage"; + private static final boolean DEBUG = false; private static final boolean LOG_INOTIFY = false; public static final String AUTHORITY = "com.android.externalstorage.documents"; @@ -136,10 +138,25 @@ public class ExternalStorageProvider extends DocumentsProvider { if (volume.getType() == VolumeInfo.TYPE_EMULATED) { // We currently only support a single emulated volume mounted at // a time, and it's always considered the primary + if (DEBUG) Log.d(TAG, "Found primary volume: " + volume); rootId = ROOT_ID_PRIMARY_EMULATED; + if (VolumeInfo.ID_EMULATED_INTERNAL.equals(volume.getId())) { - title = getContext().getString(R.string.root_internal_storage); + // This is basically the user's primary device storage. + // Use device name for the volume since this is likely same thing + // the user sees when they mount their phone on another device. + String deviceName = Settings.Global.getString( + getContext().getContentResolver(), Settings.Global.DEVICE_NAME); + + // Device name should always be set. In case it isn't, though, + // fall back to a localized "Internal Storage" string. + title = !TextUtils.isEmpty(deviceName) + ? deviceName + : getContext().getString(R.string.root_internal_storage); } else { + // This should cover all other storage devices, like an SD card + // or USB OTG drive plugged in. Using getBestVolumeDescription() + // will give us a nice string like "Samsung SD card" or "SanDisk USB drive" final VolumeInfo privateVol = mStorageManager.findPrivateForEmulated(volume); title = mStorageManager.getBestVolumeDescription(privateVol); } @@ -192,8 +209,9 @@ public class ExternalStorageProvider extends DocumentsProvider { } } - // Finally, if primary storage is available we add the "Home" directory, - // creating it as needed. + // Finally, if primary storage is available we add the "Documents" directory. + // If I recall correctly the actual directory is created on demand + // by calling either getPathForUser, or getInternalPathForUser. if (primaryVolume != null && primaryVolume.isVisible()) { final RootInfo root = new RootInfo(); root.rootId = ROOT_ID_HOME; @@ -210,8 +228,7 @@ public class ExternalStorageProvider extends DocumentsProvider { root.flags |= Root.FLAG_SUPPORTS_CREATE; } - // Create the "Home" directory on disk, but don't the localized root.title - // since the directories shouldn't be localized. + // Create the "Documents" directory on disk (don't use the localized title). root.visiblePath = new File( primaryVolume.getPathForUser(userId), Environment.DIRECTORY_DOCUMENTS); root.path = new File( |