summaryrefslogtreecommitdiff
authorxiaoliang.wang <xiaoliang.wang@amlogic.com>2017-09-16 08:26:23 (GMT)
committer Lu Wang <lu.wang@amlogic.com>2017-09-26 04:24:48 (GMT)
commit76e25014ace0147f109a80bb94cf363b20ad377d (patch)
tree36604a4e10f2ee6497daca54c72b91a26caa347a
parentf30eccb9a2e518b7345baba41618206d85772ba6 (diff)
downloadVideoPlayer-76e25014ace0147f109a80bb94cf363b20ad377d.zip
VideoPlayer-76e25014ace0147f109a80bb94cf363b20ad377d.tar.gz
VideoPlayer-76e25014ace0147f109a80bb94cf363b20ad377d.tar.bz2
VideoPlayer: add ntfs support on apk [2/2]
PD# 147260 add ntfs support on videoplayer Change-Id: Icb6cbf4e3c93ededd590bde5fa1114b5ddba3cb3
Diffstat
-rw-r--r--src/com/droidlogic/videoplayer/FileList.java76
-rw-r--r--src/com/droidlogic/videoplayer/VideoPlayer.java11
2 files changed, 76 insertions, 11 deletions
diff --git a/src/com/droidlogic/videoplayer/FileList.java b/src/com/droidlogic/videoplayer/FileList.java
index 2a5f5ed..4e2d7b0 100644
--- a/src/com/droidlogic/videoplayer/FileList.java
+++ b/src/com/droidlogic/videoplayer/FileList.java
@@ -55,6 +55,7 @@ import com.droidlogic.app.SystemControlManager;
public class FileList extends ListActivity {
private static final String ROOT_PATH = "/storage";
+ private static final String MEDIA_RW_PATH = "/mnt/media_rw";
private static final String SHEILD_EXT_STOR = Environment.getExternalStorageDirectory().getPath() + "/external_storage";//"/storage/sdcard0/external_storage";
private static final String NAND_PATH = Environment.getExternalStorageDirectory().getPath();//"/storage/sdcard0";
private static final String SD_PATH = "/storage/external_storage/sdcard1";
@@ -82,6 +83,12 @@ public class FileList extends ListActivity {
private String extensions ;
private static String ISOpath = null;
+ private String ntfsPath = null;
+ private boolean ntfsFlg = false;
+
+ private ArrayList<String> nfPath = new ArrayList<String> ();
+ private ArrayList<String> nfPathFileName = new ArrayList<String> ();
+
private TextView tileText;
private TextView nofileText;
private TextView searchText;
@@ -183,13 +190,14 @@ public class FileList extends ListActivity {
String action = intent.getAction();
Uri uri = intent.getData();
String path = uri.getPath();
-
+ if (path.startsWith(MEDIA_RW_PATH)) {
+ ntfsPath = path;
+ }
if (action == null || path == null) {
return;
}
-
if (action.equals(Intent.ACTION_MEDIA_EJECT)
- || action.equals(Intent.ACTION_MEDIA_UNMOUNTED)) {
+ || action.equals(Intent.ACTION_MEDIA_UNMOUNTED) ) {
if (listAllFiles) {
prepareFileForList();
}
@@ -201,7 +209,17 @@ public class FileList extends ListActivity {
}
}
}
- else if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
+
+
+ if ((action.equals ("com.droidvold.action.MEDIA_UNMOUNTED")
+ || action.equals ("com.droidvold.action.MEDIA_EJECT")) && !path.equals("/dev/null")) {
+ if (PlayList.getinstance().rootPath.startsWith (path)
+ || PlayList.getinstance().rootPath.equals (root_path)
+ || (PlayList.getinstance().rootPath.startsWith (SD_PATH) && path.equals ("/storage/sdcard1"))) {
+ BrowserFile(root_path);
+ }
+ }
+ else if (action.equals(Intent.ACTION_MEDIA_MOUNTED) || action.equals ("com.droidvold.action.MEDIA_MOUNTED")) {
if (PlayList.getinstance().rootPath == null
|| PlayList.getinstance().rootPath.equals(root_path)) {
BrowserFile (root_path);
@@ -232,6 +250,9 @@ public class FileList extends ListActivity {
f.addAction (Intent.ACTION_MEDIA_EJECT);
f.addAction (Intent.ACTION_MEDIA_MOUNTED);
f.addAction (Intent.ACTION_MEDIA_UNMOUNTED);
+ f.addAction ("com.droidvold.action.MEDIA_UNMOUNTED");
+ f.addAction ("com.droidvold.action.MEDIA_MOUNTED");
+ f.addAction ("com.droidvold.action.MEDIA_EJECT");
f.addDataScheme ("file");
if (!listAllFiles) {
@@ -470,6 +491,8 @@ public class FileList extends ListActivity {
String[] files = file.list();
listFiles.clear();
+ nfPathFileName.clear();
+ nfPath.clear();
searchFile (file);
if (listFiles.isEmpty()) {
Toast.makeText (FileList.this, R.string.str_no_file, Toast.LENGTH_SHORT).show();
@@ -557,17 +580,25 @@ public class FileList extends ListActivity {
getType = volumeInfoClazz.getMethod("getType");
getPath = volumeInfoClazz.getMethod("getPath");
volumes = (List<?>)getVolumes.invoke(mStorageManager);
-
for (Object vol : volumes) {
if (vol != null && (boolean)isMountedReadable.invoke(vol) && (int)getType.invoke(vol) == 0) {
File path = (File)getPath.invoke(vol);
- //Log.d(TAG, "BrowserFile() tmppath:"+tmppath + ", path.getName():" + path.getName() + ", path.getPath():" + path.getPath());
+// Log.d(TAG, "BrowserFile() tmppath:"+tmppath + ", path.getName():" + path.getName() + ", path.getPath():" + path.getPath());
if (tmppath.equals(path.getName())) {
items.add((String)getBestVolumeDescription.invoke(mStorageManager, vol));
paths.add(path.getPath());
}
}
}
+
+ for (int k = 0; k < nfPath.size(); k++) {
+ if (tpath.startsWith(MEDIA_RW_PATH)) {
+ if (tmppath.equals(nfPathFileName.get(k))) {
+ items.add(tmppath);
+ paths.add(nfPath.get(k));
+ }
+ }
+ }
}catch (Exception ex) {
ex.printStackTrace();
}
@@ -632,6 +663,26 @@ public class FileList extends ListActivity {
public void searchFile (File file) {
File filetmp;
File[] the_Files;
+ File[] storageFiles;
+ File ntfsFile;
+ File[] nfFiles;
+ String[] storageFileNames;
+ String[] ntfsFileNames;
+ storageFiles = new File(root_path).listFiles();
+ storageFileNames = new File(root_path).list();
+ ntfsFile = new File(MEDIA_RW_PATH);
+ nfFiles = ntfsFile.listFiles();
+ ntfsFileNames = ntfsFile.list();
+
+ if (nfFiles != null) {
+ for (int j = 0; j < nfFiles.length; j++) {
+ if (!Arrays.asList(storageFileNames).contains(ntfsFileNames[j]) ) {
+ nfPath.add(nfFiles[j].getAbsolutePath());
+ nfPathFileName.add(nfFiles[j].getName());
+ }
+ }
+ }
+
the_Files = file.listFiles (new MyFilter (extensions));
if (the_Files == null) {
Toast.makeText (FileList.this, R.string.str_no_file, Toast.LENGTH_SHORT).show();
@@ -666,13 +717,17 @@ public class FileList extends ListActivity {
getType = volumeInfoClazz.getMethod("getType");
getPath = volumeInfoClazz.getMethod("getPath");
volumes = (List<?>)getVolumes.invoke(mStorageManager);
-
for (Object vol : volumes) {
if (vol != null && (boolean)isMountedReadable.invoke(vol) && (int)getType.invoke(vol) == 0) {
File path = (File)getPath.invoke(vol);
listFiles.add(path);
}
}
+ for (int k = 0; k < nfPath.size(); k++) {
+ if (new File(nfPath.get(k)).exists()) {
+ listFiles.add(new File(nfPath.get(k)));
+ }
+ }
}catch (Exception ex) {
ex.printStackTrace();
}
@@ -935,7 +990,12 @@ public class FileList extends ListActivity {
BrowserFile (ROOT_PATH);
}
else {
- BrowserFile (currenturl);
+ if (pathLevel == 1) {
+ BrowserFile (ROOT_PATH);
+ } else {
+ BrowserFile (currenturl);
+ }
+// BrowserFile (currenturl);
pathLevel--;
getListView().setSelectionFromTop (fileDirectory_position_selected.get (pathLevel), fileDirectory_position_piexl.get (pathLevel));
fileDirectory_position_selected.remove (pathLevel);
diff --git a/src/com/droidlogic/videoplayer/VideoPlayer.java b/src/com/droidlogic/videoplayer/VideoPlayer.java
index 7e7715b..d02de82 100644
--- a/src/com/droidlogic/videoplayer/VideoPlayer.java
+++ b/src/com/droidlogic/videoplayer/VideoPlayer.java
@@ -75,6 +75,8 @@ import com.droidlogic.app.MediaPlayerExt;
import com.droidlogic.app.SubtitleManager;
import com.droidlogic.app.SystemControlManager;
+
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -1200,7 +1202,7 @@ public class VideoPlayer extends Activity {
if (mRetrying == true) {
return;
}
- if ( (action.equals (Intent.ACTION_MEDIA_EJECT)) || (action.equals (Intent.ACTION_MEDIA_UNMOUNTED))) {
+ if ( (action.equals (Intent.ACTION_MEDIA_EJECT)) || (action.equals (Intent.ACTION_MEDIA_UNMOUNTED)) || (action.equals ("com.droidvold.action.MEDIA_UNMOUNTED")) || (action.equals ("com.droidvold.action.MEDIA_EJECT"))) {
if (mPlayList.getcur() != null) {
if (mPlayList.getcur().startsWith (path)) {
if (isEjectOrUnmoutProcessed) {
@@ -1213,7 +1215,7 @@ public class VideoPlayer extends Activity {
}
}
}
- else if (action.equals (Intent.ACTION_MEDIA_MOUNTED)) {
+ else if ( (action.equals (Intent.ACTION_MEDIA_MOUNTED)) || (action.equals ("com.droidvold.action.MEDIA_MOUNTED")) ) {
isEjectOrUnmoutProcessed = false;
// Nothing
}
@@ -1245,8 +1247,11 @@ public class VideoPlayer extends Activity {
private void registerMountReceiver() {
IntentFilter intentFilter = new IntentFilter (Intent.ACTION_MEDIA_MOUNTED);
- intentFilter.addAction (Intent.ACTION_MEDIA_EJECT);
intentFilter.addAction (Intent.ACTION_MEDIA_UNMOUNTED);
+ intentFilter.addAction (Intent.ACTION_MEDIA_EJECT);
+ intentFilter.addAction ("com.droidvold.action.MEDIA_UNMOUNTED");
+ intentFilter.addAction ("com.droidvold.action.MEDIA_MOUNTED");
+ intentFilter.addAction ("com.droidvold.action.MEDIA_EJECT");
intentFilter.addDataScheme ("file");
registerReceiver (mMountReceiver, intentFilter);
LOGI (TAG, "[registerMountReceiver]mMountReceiver:" + mMountReceiver);