Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Note to not merge with current implementation
  • Loading branch information
reidbaker committed May 12, 2023
commit 4a15f6a8ae2355f150a8649f972089480180fa40
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.os.PowerManager
import android.provider.Settings
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.RECEIVER_EXPORTED


/** BatteryPlusPlugin */
Expand Down Expand Up @@ -81,11 +82,13 @@ class BatteryPlusPlugin : MethodCallHandler, EventChannel.StreamHandler, Flutter

override fun onListen(arguments: Any?, events: EventSink) {
chargingStateChangeReceiver = createChargingStateChangeReceiver(events)
ContextCompat.registerReceiver(
applicationContext!,
chargingStateChangeReceiver,
IntentFilter(Intent.ACTION_BATTERY_CHANGED),
ContextCompat.RECEIVER_EXPORTED)
// DO NOT MERGE, this alternates states. reidbaker debug before review.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a forgotten comment? Because I see that the PR is marked as ready for review, but this comment is here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry I wanted to make sure not to merge/reivew until my local testing worked. Sorry, removed.

applicationContext?.let {
ContextCompat.registerReceiver(
it, chargingStateChangeReceiver,
IntentFilter(Intent.ACTION_BATTERY_CHANGED), RECEIVER_EXPORTED
)
}
val status = getBatteryStatus()
publishBatteryStatus(events, status)
}
Expand Down