[Android] Prevent race conditions

Geoffrey Métais git at videolan.org
Thu Jun 22 15:50:10 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jun 22 15:49:09 2017 +0200| [1ff3ef738fac6d951ddbc9e3ebcd07aef2d3927b] | committer: Geoffrey Métais

Prevent race conditions

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 3b3341878..fbfc56397 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -935,9 +935,9 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
                         startService(new Intent(ctx, PlaybackService.class));
                         if (!AndroidUtil.isLolliPopOrLater || playing)
-                            startForeground(3, builder.build());
+                            PlaybackService.this.startForeground(3, builder.build());
                         else {
-                            stopForeground(false);
+                            PlaybackService.this.stopForeground(false);
                             NotificationManagerCompat.from(ctx).notify(3, builder.build());
                         }
                     } catch (IllegalArgumentException e){
@@ -976,8 +976,13 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
     }
 
     private void hideNotification() {
-        stopForeground(true);
-        NotificationManagerCompat.from(this).cancel(3);
+        mExecutorService.execute(new Runnable() {
+            @Override
+            public void run() {
+                PlaybackService.this.stopForeground(true);
+                NotificationManagerCompat.from(PlaybackService.this).cancel(3);
+            }
+        });
     }
 
     @MainThread



More information about the Android mailing list