[Android] Ensure we don't call addDevice with empty args

Geoffrey Métais git at videolan.org
Tue May 30 10:49:08 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 30 09:58:22 2017 +0200| [1d0b98792b3fe9ff081f9f175c3602bd6f648f05] | committer: Geoffrey Métais

Ensure we don't call addDevice with empty args

> https://code.videolan.org/videolan/vlc-android/commit/1d0b98792b3fe9ff081f9f175c3602bd6f648f05
---

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java        | 4 +++-
 vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java   | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
index 88e1c27c6..d0fe69c4a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.java
@@ -43,6 +43,7 @@ import android.support.v4.content.LocalBroadcastManager;
 import android.support.v7.preference.PreferenceManager;
 import android.support.v7.widget.Toolbar;
 import android.support.v7.widget.ViewStubCompat;
+import android.text.TextUtils;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
@@ -415,7 +416,8 @@ public class AudioPlayerContainerActivity extends BaseActivity implements Playba
                     uuid = ((Uri) msg.obj).getLastPathSegment();
                     String path = ((Uri) msg.obj).getPath();
                     removeMessages(ACTION_MEDIA_UNMOUNTED);
-                    if (!PreferenceManager.getDefaultSharedPreferences(owner).getBoolean("ignore_"+ uuid, false)) {
+                    if (!TextUtils.isEmpty(uuid)
+                            && !PreferenceManager.getDefaultSharedPreferences(owner).getBoolean("ignore_"+ uuid, false)) {
                         if (VLCApplication.getMLInstance().addDevice(uuid, path, true, true)) {
                             owner.startActivity(new Intent(owner, DialogActivity.class)
                                     .setAction(DialogActivity.KEY_STORAGE)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java
index 9f2e15682..5ea45bf3d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BaseTvActivity.java
@@ -35,6 +35,7 @@ import android.os.Build;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.support.v4.content.LocalBroadcastManager;
+import android.text.TextUtils;
 import android.view.KeyEvent;
 
 import org.videolan.medialibrary.Medialibrary;
@@ -140,6 +141,8 @@ public abstract class BaseTvActivity extends PlaybackServiceActivity {
             } else if (action.equalsIgnoreCase(Intent.ACTION_MEDIA_MOUNTED)) {
                 String path = intent.getData().getPath();
                 String uuid = intent.getData().getLastPathSegment();
+                if (TextUtils.isEmpty(uuid))
+                    return;
                 boolean isIgnored = mSettings.getBoolean("ignore_"+ uuid, false);
                 if (!isIgnored && mMediaLibrary.addDevice(uuid, path, true, true)) {
                     startActivity(new Intent(BaseTvActivity.this, DialogActivity.class)



More information about the Android mailing list