When I try to enable the charge limit, the app crashes. When I toggle the option to suspend charging (3rd toggle in the UI), the app works as intended.
I believe I found the culprit in the logcat:
[08-15 05:29:18.721 19923:19923 E/AndroidRuntime]
FATAL EXCEPTION: main
Process: io.github.muntashirakon.bcl, PID: 19923
java.lang.IllegalArgumentException: io.github.muntashirakon.bcl: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:651)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:638)
at io.github.muntashirakon.bcl.EnableWidget.buildButtonPendingIntent(EnableWidget.kt:2)
at io.github.muntashirakon.bcl.EnableWidget.updateWidget(EnableWidget.kt:3)
at io.github.muntashirakon.bcl.activities.MainFragment$$ExternalSyntheticLambda3.onCheckedChanged(Unknown Source:21)
at android.widget.CompoundButton.setChecked(CompoundButton.java:222)
at androidx.appcompat.widget.SwitchCompat.setChecked(SwitchCompat.java:1)
at androidx.appcompat.widget.SwitchCompat.toggle(SwitchCompat.java:1)
at android.widget.CompoundButton.performClick(CompoundButton.java:144)
at android.view.View.performClickInternal(View.java:7471)
at android.view.View.access$3700(View.java:843)
at android.view.View$PerformClick.run(View.java:29077)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:233)
at android.os.Looper.loop(Looper.java:344)
at android.app.ActivityThread.main(ActivityThread.java:8223)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:589)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1071)
[08-15 05:29:18.722 1861:2528 D/OplusAppStartupMonitor]
notifyUnstableAppInfo: Bundle[{unstableTime=1660534158722, reason=crash, userId=0, safecenter=unstable, exceptionMsg=io.github.muntashirakon.bcl: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles., exceptionClass=java.lang.IllegalArgumentException, packageName=io.github.muntashirakon.bcl, unstable_restrict_switch=true}]
OS: Android 12
Phone: OnePlus Nord 2t
Battery Charge Limit works flawlessly
When I try to enable the charge limit, the app crashes. When I toggle the option to suspend charging (3rd toggle in the UI), the app works as intended.
I believe I found the culprit in the logcat: