diff options
author | Ashwini Munigala <AshwiniM@codeaurora.org> | 2015-10-06 17:07:09 +0530 |
---|---|---|
committer | Ashwini Munigala <AshwiniM@codeaurora.org> | 2015-10-06 17:43:13 +0530 |
commit | aade8b00b788b258b6537bb0d5efab4dbde19f98 (patch) | |
tree | 6ba6615f949a71267115199621f3945b3a3aab25 /src | |
parent | 1a8f27a91c83562015648b592340e543d2d6937f (diff) | |
download | android_packages_apps_BluetoothExt-aade8b00b788b258b6537bb0d5efab4dbde19f98.tar.gz android_packages_apps_BluetoothExt-aade8b00b788b258b6537bb0d5efab4dbde19f98.tar.bz2 android_packages_apps_BluetoothExt-aade8b00b788b258b6537bb0d5efab4dbde19f98.zip |
FTP: Get External mount points from StorageManager volume list.
Fetch external primary and secondary storage mount points from
system StorageManger volumes list instead from obsolete
Environment.getExternalStorageDirectory() API and
System.getenv(ENV_SECONDARY_EXTERNAL_STORAGE) variable;
Change-Id: I33c72e194b7a10662bffcf94d33231f0da0bf140
CRs-Fixed: 919025
Diffstat (limited to 'src')
-rw-r--r-- | src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java index b602eec..11935c6 100644 --- a/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java +++ b/src/org/codeaurora/bluetooth/ftp/BluetoothFtpObexServer.java @@ -63,6 +63,8 @@ import javax.obex.Operation; import javax.obex.HeaderSet; import javax.obex.ObexHelper; import android.os.Environment; +import android.os.storage.StorageManager; +import android.os.storage.StorageVolume; public class BluetoothFtpObexServer extends ServerRequestHandler { @@ -109,6 +111,7 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { public static final String ENV_SECONDARY_EXTERNAL_STORAGE = "SECONDARY_STORAGE"; private String rootPrimaryStoragePath = null; private String rootSecondaryStoragePath = null; + private StorageManager mStorageManager; public static final String PRIMARY_INTERNAL_FOLDERNAME = "PHONE_MEMORY"; public static final String SECONDARY_EXTERNAL_FOLDERNAME = "EXTERNAL_MEMORY"; private static final String FOLDER_NAME_DOT = "."; @@ -209,9 +212,22 @@ public class BluetoothFtpObexServer extends ServerRequestHandler { Message msg = Message.obtain(mCallback); msg.what = BluetoothFtpService.MSG_SESSION_ESTABLISHED; msg.sendToTarget(); - /*Initialize the internal, external storage root paths from Enivronment*/ - rootPrimaryStoragePath = Environment.getExternalStorageDirectory().getPath(); - rootSecondaryStoragePath = System.getenv(ENV_SECONDARY_EXTERNAL_STORAGE); + mStorageManager = StorageManager.from(mContext); + StorageVolume[] volumes = mStorageManager.getVolumeList(); + for (int i = 0; i < volumes.length; i++) { + String path = volumes[i].getPath(); + if(V) Log.v(TAG, "Fetch storageManager volumeList : " + path + " :: isRemovable= " + + volumes[i].isRemovable() + ", getDescription= " + volumes[i] + .getDescription(mContext.getApplicationContext()) + " , isEmulated= " + + volumes[i].isEmulated()+ ", isPrimary=" + volumes[i].isPrimary()); + /*Initialize the internal, external storage root paths from Enivronment*/ + if ( rootPrimaryStoragePath == null && volumes[i].isPrimary()) { + rootPrimaryStoragePath = path; + } else if (rootSecondaryStoragePath == null && volumes[i].isRemovable()) { + //TODO: Support only first external SDCARD in list , in case of multiple + rootSecondaryStoragePath = path; + } + } /*Initialize mCurrentPath to null to show Internal and External memory options*/ mCurrentPath = null; if(D) Log.d(TAG,"ENV: PRIMARY: "+ rootPrimaryStoragePath + |