Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPEs after OnSharedPreferenceChangeListener changes #9696

Merged
merged 3 commits into from
Jan 17, 2023

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Jan 16, 2023

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

According to OnSharedPreferenceChangeListener's documentation, this was caused by #9306 (even though it is not mentioned in Android 11's upgrading page):

Apps targeting API 30 on devices running OS versions Android R/11 or later, will receive a null value when preferences are cleared.

So I modified all of our overrides of that function to make sure to handle null values gracefully.

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

Apps targeting {@link android.os.Build.VERSION_CODES#R} on devices running OS versions {@link android.os.Build.VERSION_CODES#R Android R} or later, will receive a {@code null} value when preferences are cleared.
@TobiGr
Copy link
Member

TobiGr commented Jan 16, 2023

don't merge yet

@TobiGr TobiGr added the bug Issue is related to a bug label Jan 16, 2023
@Stypox
Copy link
Member Author

Stypox commented Jan 16, 2023

Mmmh, strange, I asked AS to give me a list of all implementors... Apparently I missed something, thanks for double-checking. :-)

@TobiGr
Copy link
Member

TobiGr commented Jan 16, 2023

i used grep, i don't trust AS anymore xD

@sonarcloud
Copy link

sonarcloud bot commented Jan 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Stypox
Copy link
Member Author

Stypox commented Jan 16, 2023

Noteworthy code smell from sonar and Android Studio about this:

Notifications should only launch a Service from notification actions (addAction)

But I just tested in API 33 and there was no issue tapping on the notification

@TobiGr TobiGr merged commit d758e50 into TeamNewPipe:dev Jan 17, 2023
@TobiGr
Copy link
Member

TobiGr commented Jan 17, 2023

Those should be addressed in a separate PR. I only fixed Sonar here because it blocked merging this PR.

@opusforlife2 opusforlife2 added the database Issue is related to database operations label Jan 19, 2023
@Stypox Stypox mentioned this pull request Jan 22, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug database Issue is related to database operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Nightly] Crash on Importing Database
3 participants