[Android] Catch exception in case bitmap fails to parcelize

Geoffrey Métais git at videolan.org
Wed Nov 15 15:48:46 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 15 12:21:58 2017 +0100| [3ed359bd41872e0a2ba18343614f27dc5fb49a97] | committer: Geoffrey Métais

Catch exception in case bitmap fails to parcelize

(cherry picked from commit 85aac90675cdcab2aa3be8d27601ba8ea44367a4)

> https://code.videolan.org/videolan/vlc-android/commit/3ed359bd41872e0a2ba18343614f27dc5fb49a97
---

 .../src/org/videolan/vlc/PlaybackService.java      | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 9fc38efbe..b410643d0 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -2689,21 +2689,22 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
             registerMedialibrary(new Runnable() {
                 @Override
                 public void run() {
-                    VLCApplication.runBackground(new Runnable() {
-                        @Override
-                        public void run() {
-                            result.sendResult(BrowserProvider.browse(parentId));
-                        }
-                    });
+                    sendResults(result, parentId);
                 }
             });
         else
-            VLCApplication.runBackground(new Runnable() {
-                @Override
-                public void run() {
+            sendResults(result, parentId);
+    }
+
+    private void sendResults(@NonNull final MediaBrowserServiceCompat.Result result, @NonNull final String parentId) {
+        VLCApplication.runBackground(new Runnable() {
+            @Override
+            public void run() {
+                try {
                     result.sendResult(BrowserProvider.browse(parentId));
-                }
-            });
+                } catch (RuntimeException ignored) {} //bitmap parcelization can fail
+            }
+        });
     }
 
     private class MedialibraryReceiver extends BroadcastReceiver {



More information about the Android mailing list