Skip to content

Start audio player using foreground service API on Android 26+ - #6798

Merged
tobiasKaminsky merged 1 commit into
masterfrom
ezaquarii/fix-illegal-state-exception-when-stopping-audio-player
Sep 2, 2020
Merged

tobiasKaminsky merged 1 commit into
masterfrom
ezaquarii/fix-illegal-state-exception-when-stopping-audio-player

Conversation

@ezaquarii

@ezaquarii ezaquarii commented Aug 24, 2020 •

Copy link
Copy Markdown
Collaborator

Start audio player using foreground service API on Android 26+

On API 26+ (Oreo, 8.0) running background services is restricted
by power saving mechanisms, causing occasional IllegalStateException
when service intent is rejected by the OS.

Migrate to startForegroundService API to mitigate this problem.
Audio player service is foreground by design.

Fixes #6665

Signed-off-by: Chris Narkiewicz [email protected]

@ezaquarii

Copy link
Copy Markdown
Collaborator Author

@AndyScherzinger @tobiasKaminsky
I think this is what we need to do. I still need to test it and confirm if foreground is properly handled, so no merging yet.

@ezaquarii ezaquarii changed the title Start audio player using foreground service API on Android 26+ [WIP] Start audio player using foreground service API on Android 26+ Aug 24, 2020
@ezaquarii
ezaquarii force-pushed the ezaquarii/fix-illegal-state-exception-when-stopping-audio-player branch 2 times, most recently from b6d737b to 9c7cb6c Compare August 25, 2020 17:43
@ezaquarii

ezaquarii commented Aug 25, 2020 •

Copy link
Copy Markdown
Collaborator Author

@tobiasKaminsky @AndyScherzinger
Tested, it seems to work ok, although it's a bit speculative fix, TBH.
This needs #6805 to be merged first to make media controls responsive.

@ezaquarii
ezaquarii force-pushed the ezaquarii/fix-illegal-state-exception-when-stopping-audio-player branch from 9c7cb6c to 3c0157c Compare August 25, 2020 17:46
@ezaquarii ezaquarii changed the title [WIP] Start audio player using foreground service API on Android 26+ Start audio player using foreground service API on Android 26+ Aug 25, 2020
On API 26+ (Oreo, 8.0) running background services is restricted
by power saving mechanisms, causing occasional IllegalStateException
when service intent is rejected by the OS.

Migrate to startForegroundService API to mitigate this problem.
Audio player service is foreground by design.

Fixes #6665

Signed-off-by: Chris Narkiewicz <[email protected]>
@ezaquarii
ezaquarii force-pushed the ezaquarii/fix-illegal-state-exception-when-stopping-audio-player branch from 3c0157c to 6feedf8 Compare August 25, 2020 17:55
@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15565.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@codecov

codecov Bot commented Aug 25, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #6798 into master will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##             master    #6798      +/-   ##
============================================
- Coverage     27.76%   27.76%   -0.01%     
  Complexity        5        5              
============================================
  Files           427      427              
  Lines         34251    34254       +3     
  Branches       4735     4735              
============================================
  Hits           9511     9511              
- Misses        23323    23327       +4     
+ Partials       1417     1416       -1     
Impacted Files Coverage 螖 Complexity 螖
.../nextcloud/client/media/PlayerServiceConnection.kt 4.87% <0.00%> (-0.39%) 0.00 <0.00> (酶)
...ud/android/operations/GetUserProfileOperation.java 88.88% <0.00%> (-11.12%) 0.00% <0.00%> (酶%)
.../third_parties/daveKoeller/AlphanumComparator.java 80.95% <0.00%> (-1.20%) 0.00% <0.00%> (酶%)
...oud/android/operations/RefreshFolderOperation.java 69.84% <0.00%> (+0.76%) 0.00% <0.00%> (酶%)

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

Codacy

408

Lint

TypemasterPR
Warnings8181
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings61
Internationalization Warnings9
Multithreaded correctness Warnings9
Performance Warnings73
Security Warnings44
Dodgy code Warnings106
Total329

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings61
Internationalization Warnings9
Multithreaded correctness Warnings9
Performance Warnings73
Security Warnings44
Dodgy code Warnings106
Total329

@tobiasKaminsky
tobiasKaminsky merged commit 75066c8 into master Sep 2, 2020
@delete-merged-branch
delete-merged-branch Bot deleted the ezaquarii/fix-illegal-state-exception-when-stopping-audio-player branch September 2, 2020 07:04
@AndyScherzinger AndyScherzinger added this to the Nextcloud App 3.14.0 milestone Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IllegalStateException @ PlayerServiceConnection.stop

4 participants