Commit Graph

9 Commits

Author SHA1 Message Date
Synced Synapse 7dfd982643 Tweak connection threads
This PR fixes some issues with connections and threading. Specifically, the  change in #618 introduced threading in `HostConnection`, which had some issues. To fix them, the following changes were made:
- A specific TCP listener thread is used and manually started, instead of using one of the threads in the pool. The TCP listener thread is a long lived thread that should always be running (as long as the connection is through TCP), blocked listening on the TCP socket, so it shouldn't be managed in a pool, where, theoretically, it can be paused and reused. 
- Changed the number of threads to 5. We shouldn't need more than this, otherwise we can overwhelm some Kodi hardware.
- Had to sprinkle some `synchronized` to avoid race conditions. For instance, through a TCP connection, as soon as Kore is opened (on the remote screen) it will call at least `GetActivePlayers`, `GetProperties`, `Ping`. If the TCP socket isn't set up yet, each of these calls would create a socket (and a TCP listener thread), so we would open 3 or more sockets when we should just open 1. A `synchronized` in `executeThroughTcp` prevents this. The others prevent similar issues.

Aditionally:
- Tweaked the playlist fetching code, so that it happens exclusively in `HostConnectionObserver` and when PlaylistFragment is notified of changes, it already gets the playlist data. This somewhat simplifies the code, and makes it more consistent with the Player Observer code;
- Change `EventServerConnection` to accept a Handler on which to post the result of the connection, so that the caller can control on which thread the result is called;
- Calls to the various `RegisterObserver` loose the reply immediately parameter, as it was always true.
2019-09-28 22:10:04 +02:00
Synced Synapse c7fef43deb Fix ANR in service launch
Some ANRs are reported on Google Play. This is an atempt to remove them, by making sure that `startForeground` is always called when the service starts.
2019-05-14 22:06:34 +02:00
Synced Synapse 3077653dd9 Fix notifications to work with Android Oreo
Whan the background service is launcher, it is launched on the foreground and a notification is always shown.
The service stays on while something is playing. It stops itself on a connection error, quitting Kodi or 5 seconds after stopping
Make the Pause Phone Calls preference dependent on the Show Notification preference, as we always need to show a notification when the service is running
2017-12-24 17:49:40 +00:00
Martijn Brekhof cb430aa20d Implemented a slideup panel with media controls and info (#320)
* The slideup panel is only displayed when something is
         playing. It starts collapsed showing the media poster
         and title of what is currently playing.

       * Media controls implemented are volume, progress, shuffle,
         repeat and play/pause for all items. Next and previous are only
         available when a music item is playing.

       * In collapsed mode the panel will display the mute button only
         if Kodi is muted. The mute button in expanded mode is always
         visible.

       * Panel is enabled by default. Users can disable the panel
         in Settings

       * Implemented listening to Player.OnPropertyChanged notifications
         to update shuffle and repeat button states.
2017-07-13 19:10:49 +01:00
Martijn Brekhof fcd1730784 Fixes NPE in ConnectionObserversManagerService.onDestroy (#372) 2017-03-15 18:49:38 +00:00
Martijn Brekhof b01e3c8ddc Fixes reported crashes caused by a NullPointerException (#325)
Multiple NullPointerExceptions have been reported in Google Play (dev).
Probably caused by calling onTaskRemoved more than once.
2016-12-19 18:57:08 +00:00
George Kankava 079cf4e759 squid:S1155 - Collection.isEmpty() should be used to test for emptiness 2016-06-29 14:17:39 +04:00
Synced Synapse 6dcf412140 Update android sdk to v23
Deal with Android 6 permission system
Update gradle version
2016-05-25 17:18:25 +01:00
Synced Synapse e65b4536d7 Refactor Notification and PauseCall services: Create a single connection observer service that manages the notification and call pause/play. 2016-05-20 19:24:34 +01:00