Skip to content

Conversation

@Darkx-dev
Copy link

Description

This PR improves the null safety of the checkPowerServiceSaveMode method on the Android platform to prevent a potential crash.

The Problem

Currently, the checkPowerServiceSaveMode method uses a non-null assertion (!!) on applicationContext. While the context is very unlikely to be null in normal operation, a library should be as resilient as possible against rare edge cases (e.g., race conditions during plugin detachment). A NullPointerException here would crash the entire host application.

The Solution

I have replaced the !! operator with a safe-call (?.let) block. If applicationContext happens to be null, the method will now safely return a default value of false instead of crashing.

This is a small, targeted change that increases the stability of the plugin without altering its core logic.

The checkPowerServiceSaveMode method used a non-null assertion (!!)
on applicationContext. This could potentially lead to a NullPointerException
in rare edge cases.

This change replaces the assertion with a safe-call block (`?.let`),
ensuring the method safely returns `false` if the context is null,
thereby improving the plugin's robustness.
@vbuberen
Copy link
Collaborator

vbuberen commented Sep 7, 2025

Could you list at least one case when it will be null?

Reading the description I clearly see some AI generated text. Looks like the change is the same vibe coded thing.
Since no real motivation and example on how to crash the app provided I am just closing it and would request to avoid opening some AI generated PR in future.

@vbuberen vbuberen closed this Sep 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants