Fix single-bud NPE crashes, BluetoothSocket reflection, and add rootless Charging Case Sounds - #764
Fix single-bud NPE crashes, BluetoothSocket reflection, and add rootless Charging Case Sounds#764bshea-1 wants to merge 5 commits into
Conversation
…e sounds toggle - Fix KotlinNullPointerException on single-bud usage and uninitialized battery states in AirPodsService - Fix BluetoothSocket reflection constructor with valid fd (-1) and add dynamic fallback resolver - Add rootless Charging Case Sounds toggle for AirPods Pro 2 and AirPods 4 ANC via AACP - Remove per-packet notification updates in raw socket read loop - Fix default conversational awareness volume calculation in MediaController - Add NativeBridge and ProGuard hardening for JNI bindings
|
hey is there a way you can make the toggle sounds setting work for the AirPods Pro 3? I could test if you want |
…hing, and persist case sounds
|
Hi @hanslauch325-eng, I just pushed a fix to support the case sounds toggle for AirPods Pro 3! Could you test it out and see if it works for your device? How it was implemented:
Please let me know if it works for you! |
|
If you'd like an easy way to download and test without building from source, pre-built signed Release APKs are published on the release page: 📦 Release Downloads:
🔗 Release Page: LibrePods v1.0.0-rc2 (AirPods Pro 3 & Stability Fixes) |
|
Hey thank you really much, sadly it did not work for me I dissabled the charging case sounds but it still played them. I collected some logs I hope they can help |
|
Hey @hanslauch325-eng, thank you so much for testing and providing the logs! Those logs were extremely helpful in diagnosing what's going on. What the logs showed:
Additional updates in this new build:
Updated Download:You can download the updated build here: Let me know if placing the buds in the case and closing the lid for ~5s after toggling resolves it for you! |
|
Hey, _data_user_0_me.kavishdevar.librepods_files_logs_airpods_log_20260904_201055.txt |
… dispatch robustness
|
Hey @hanslauch325-eng, I really appreciate you testing this and sharing the updated logs. Insights from the new log:
What was updated in this build:
Download Link:app-foss-release.apk (Updated Build) Please try installing this update, toggling the switch, and placing the buds in the case with the lid closed for a few seconds before testing the charger plug-in sound. Thank you again! |
|
Hello, _data_user_0_me.kavishdevar.librepods_files_logs_airpods_log_20260904_222618.txt |
|
Hey @hanslauch325-eng, Thank you so much for taking the time to test this and capture detailed logs across multiple iterations. Your help was genuinely invaluable in understanding what was happening behind the scenes. Why Case Sounds Cannot Be Toggled From Android:After performing a deep-dive analysis into the logs and Apple's firmware architecture:
How to Turn Off Case Sounds:If you have access to an iPhone, iPad, or Mac, you can connect your AirPods to it once and disable "Enable Charging Case Sounds" in iOS/macOS settings. Because the case saves that preference directly into its onboard EEPROM, it will permanently remember to keep charging sounds disabled even when you use them on Android going forward! Clean Release Build:I've cleaned up the experimental case sounds code from the PR/release to keep the codebase clean, while preserving all the stability improvements (single-bud NPE crash fixes, socket reflection fallback, and AirPods Pro 3 model support): |
|
alright, no problem. Im glad I could help you. |
Summary of Changes
This PR resolves multiple background service crashes, improves Bluetooth socket reflection compatibility, optimizes notification resource usage, and adds rootless Charging Case Sounds toggle support.
1. Background Stability & Crash Prevention
AirPodsService, querying battery state when only one earbud is connected or before battery packets arrive caused multipleNullPointerExceptioncrashes on?.level!!. Added a safegetDisplayBatteryLevel()helper to coalesce left and right bud levels safely.intent.getParcelableExtra("device")without force unwraps (!!) and guarded device access.onBatteryInfoReceived()before indexing battery status elements.2. Bluetooth Connection Hardening
fd = 1parameter (STDOUT_FILENO) passed to reflectedBluetoothSocketconstructors (changed to-1for uninitialized socket state).bluetooth_socketearly inLibrePodsApplication.onCreate().3. Battery & Notification Optimization
updateNotificationContent()calls from the tight raw socket packet read loop (while (socket.isConnected)), preventing SystemUI notification spam and reducing CPU wakeups.4. Media Controller Typo Fix
MediaControllerconversational awareness default volume calculation from/ 0.4to* 0.4.5. New Feature: Charging Case Sounds Toggle (Rootless)
Capability.CASE_SOUNDSfor AirPods Pro 2 and AirPods 4 ANC.IN_CASE_TONE_CONFIG(0x31over AACP), allowing rootless control of case speaker chimes.