aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Garnes <matt@cyngn.com>2015-04-01 18:25:45 -0700
committerRajesh Yengisetty <rajesh@cyngn.com>2015-04-02 18:06:54 +0000
commit374fe7785d0a130407978a3fa9a633d6371b1301 (patch)
treed9215f24ec11e7ae5a92e445fbf1b367fa8132ae
parent007c561ec7cf0a48d4347c13f416fd9834b36f77 (diff)
downloadandroid_packages_apps_CMFileManager-374fe7785d0a130407978a3fa9a633d6371b1301.tar.gz
android_packages_apps_CMFileManager-374fe7785d0a130407978a3fa9a633d6371b1301.tar.bz2
android_packages_apps_CMFileManager-374fe7785d0a130407978a3fa9a633d6371b1301.zip
Fix support for USB OTG.
Properly listen for the Broadcast with an IntentFilter that includes the path data scheme. Reload the mounted volumes upon ACTION_MEDIA_MOUNTED AND ACTION_MEDIA_UNMOUNTED. Change-Id: I71d90978fef05419d912ef2398bf99c23fdefee6 (cherry picked from commit e3922e43c8988c499c85115f1f14bef8c925e1ee) (cherry picked from commit 8656db649d0a88fc126e468b7ac81d8d3ea091ae) (cherry picked from commit 860ef9fbf513e1a4267e391453a2021d0ac20f63)
-rw-r--r--src/com/cyanogenmod/filemanager/activities/NavigationActivity.java21
-rw-r--r--src/com/cyanogenmod/filemanager/activities/PickerActivity.java2
-rw-r--r--src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java4
-rw-r--r--src/com/cyanogenmod/filemanager/util/StorageHelper.java14
4 files changed, 25 insertions, 16 deletions
diff --git a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java
index 2bb34996..1f4946a3 100644
--- a/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java
+++ b/src/com/cyanogenmod/filemanager/activities/NavigationActivity.java
@@ -21,6 +21,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.SearchManager;
import android.content.BroadcastReceiver;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -319,11 +320,9 @@ public class NavigationActivity extends Activity
NavigationActivity.this.getCurrentNavigationView().refresh();
}
} else if (intent.getAction().compareTo(
- FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED) == 0) {
- onRequestBookmarksRefresh();
- removeUnmountedHistory();
- removeUnmountedSelection();
- } else if(intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
+ FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED) == 0 ||
+ intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED) ||
+ intent.getAction().equals(Intent.ACTION_MEDIA_UNMOUNTED)) {
onRequestBookmarksRefresh();
removeUnmountedHistory();
removeUnmountedSelection();
@@ -502,9 +501,15 @@ public class NavigationActivity extends Activity
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(FileManagerSettings.INTENT_MOUNT_STATUS_CHANGED);
- filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
registerReceiver(this.mNotificationReceiver, filter);
+ // This filter needs the file data scheme, so it must be defined separately.
+ IntentFilter newFilter = new IntentFilter();
+ newFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
+ newFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
+ newFilter.addDataScheme(ContentResolver.SCHEME_FILE);
+ registerReceiver(mNotificationReceiver, newFilter);
+
// Set the theme before setContentView
Theme theme = ThemeManager.getCurrentTheme(this);
theme.setBaseThemeNoActionBar(this);
@@ -1301,7 +1306,7 @@ public class NavigationActivity extends Activity
try {
// Recovery sdcards from storage manager
StorageVolume[] volumes = StorageHelper
- .getStorageVolumes(getApplication());
+ .getStorageVolumes(getApplication(), true);
for (StorageVolume volume: volumes) {
if (volume != null) {
String mountedState = volume.getState();
@@ -1569,7 +1574,7 @@ public class NavigationActivity extends Activity
// Initial directory is the first external sdcard (sdcard, emmc, usb, ...)
if (!StorageHelper.isPathInStorageVolume(initialDir)) {
StorageVolume[] volumes =
- StorageHelper.getStorageVolumes(this);
+ StorageHelper.getStorageVolumes(this, false);
if (volumes != null && volumes.length > 0) {
initialDir = volumes[0].getPath();
//Ensure that initial directory is an absolute directory
diff --git a/src/com/cyanogenmod/filemanager/activities/PickerActivity.java b/src/com/cyanogenmod/filemanager/activities/PickerActivity.java
index 120fd1d4..bff98b52 100644
--- a/src/com/cyanogenmod/filemanager/activities/PickerActivity.java
+++ b/src/com/cyanogenmod/filemanager/activities/PickerActivity.java
@@ -596,7 +596,7 @@ public class PickerActivity extends Activity
*/
private void showStorageVolumesPopUp(View anchor) {
// Create a list (but not checkable)
- final StorageVolume[] volumes = StorageHelper.getStorageVolumes(PickerActivity.this);
+ final StorageVolume[] volumes = StorageHelper.getStorageVolumes(PickerActivity.this, false);
List<CheckableItem> descriptions = new ArrayList<CheckableItem>();
if (volumes != null) {
int cc = volumes.length;
diff --git a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java
index 9573f682..099f0edb 100644
--- a/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java
+++ b/src/com/cyanogenmod/filemanager/ui/widgets/NavigationView.java
@@ -1372,7 +1372,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe
//Change to first storage volume
StorageVolume[] volumes =
- StorageHelper.getStorageVolumes(getContext());
+ StorageHelper.getStorageVolumes(getContext(), false);
if (volumes != null && volumes.length > 0) {
changeCurrentDir(volumes[0].getPath(), false, true, false, null, null);
}
@@ -1403,7 +1403,7 @@ BreadcrumbListener, OnSelectionChangedListener, OnSelectionListener, OnRequestRe
// Check if the path is owned by one of the storage volumes
if (!StorageHelper.isPathInStorageVolume(newDir)) {
- StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext());
+ StorageVolume[] volumes = StorageHelper.getStorageVolumes(getContext(), false);
if (volumes != null && volumes.length > 0) {
return volumes[0].getPath();
}
diff --git a/src/com/cyanogenmod/filemanager/util/StorageHelper.java b/src/com/cyanogenmod/filemanager/util/StorageHelper.java
index 9b04a6b3..ed07fd5e 100644
--- a/src/com/cyanogenmod/filemanager/util/StorageHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/StorageHelper.java
@@ -41,11 +41,12 @@ public final class StorageHelper {
* as first parameter, that AOSP hasn't.
*
* @param ctx The current context
+ * @param reload If true, re-query the volumes and do not return the already cached list.
* @return StorageVolume[] The storage volumes defined in the system
*/
@SuppressWarnings("boxing")
- public static synchronized StorageVolume[] getStorageVolumes(Context ctx) {
- if (sStorageVolumes == null) {
+ public static synchronized StorageVolume[] getStorageVolumes(Context ctx, boolean reload) {
+ if (sStorageVolumes == null || reload) {
//IMP!! Android SDK doesn't have a "getVolumeList" but is supported by CM10.
//Use reflect to get this value (if possible)
try {
@@ -129,7 +130,8 @@ public final class StorageHelper {
public static boolean isPathInStorageVolume(String path) {
String fso = FileHelper.getAbsPath(path);
StorageVolume[] volumes =
- getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext());
+ getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext(),
+ false);
int cc = volumes.length;
for (int i = 0; i < cc; i++) {
StorageVolume vol = volumes[i];
@@ -148,7 +150,8 @@ public final class StorageHelper {
*/
public static boolean isStorageVolume(String path) {
StorageVolume[] volumes =
- getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext());
+ getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext(),
+ false);
int cc = volumes.length;
for (int i = 0; i < cc; i++) {
StorageVolume vol = volumes[i];
@@ -169,7 +172,8 @@ public final class StorageHelper {
*/
public static String getChrootedPath(String path) {
StorageVolume[] volumes =
- getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext());
+ getStorageVolumes(FileManagerApplication.getInstance().getApplicationContext(),
+ false);
int cc = volumes.length;
for (int i = 0; i < cc; i++) {
StorageVolume vol = volumes[i];