本文由 GitRead 中文社区 使用 AI 辅助生成,基于项目 README 与公开资料整理成中文解读, 并结合中文开发者的常见使用场景补充技术选型参考。内容可能存在疏漏,具体以项目官方文档为准。
librepods-org/librepods:AirPods 解放 Apple 生态系统的开源套件
项目背景与痛点
开源社区一直追求独立和自由,而 Apple 的硬件设备因其封闭性用户很难摆脱其生态系统。AirPods 作为 Apple 的标志性产品之一,尽管具有出色的蓝牙无线传输和音频质量,用户仍被 Apple 自家的应用和服务限制。librepods 项目旨在打破这种限制,让用户能够更自由地控制和修改 AirPods 的功能。
项目的痛点在于,现有生态链中的生态系统过于封闭,限制了用户对设备的控制和修改能力。例如,AirPods 的功能只能在特定的 Apple 设备上访问和控制,用户无法自己根据需求定制功能或是添加其他操作方式。这种封闭性使得硬件设备的灵活性与扩展性大打折扣。
核心技术揭秘
librepods 的核心技术在于通过逆向工程分析 Apple 自家的蓝牙协议。项目团队研究了蓝牙数据包的结构和传输机制,揭示了与 AirPods 交互的具体方式。这些研究为开源社区提供了强大的工具,不仅能够增强设备的开箱即用性,还能够允许用户自己开发更丰富的功能。
技术架构分析
librepods 使用了 C/C++ 作为其主要编程语言,并且依赖于 libusb 设备库来实现底层的 USB 协议通信。项目的核心在于数据传输层和应用层的交互方式,具体情况参见下方的数据流图。
graph TD
A[用户设备请求] --> B{"AirPods 数据请求"}
B -->|"蓝牙数据包请求"| C[发送请求]
C --> D[接收数据]
D --> E[数据解析与处理]
E --> F[返回结果]
librepods.org is not an official website of the LibrePods project. It inaccurately claims to be the official website of the project by claiming copyrights and using the LibrePods logo in the footer. And at the same time, they say that the project is not affiliated with the LibrePods project or its developers.
LibrePods allows you to use AirPods features that are exclusive to Apple devices. It implements the proprietary protocol used to exchange data between AirPods and Apple devices, enabling features like changing noise control modes, fast ear detection, accurate battery status, head gestures, conversational awareness, and more on non-Apple platforms.
Feature availability
Feature
Linux
Android
Changing Listening Mode
✅
✅
Ear detection
✅
✅
Battery status
✅
✅
Renaming AirPods Note for AndroidOn Android, you need to re-pair your AirPods after renaming them because Android might not use the latest name.
The following features related to Find My are planned, but require further RE and might need root on Android:
Add your AirPods to the Find My network
Play sound through charging case to find it
Notify when leaving behind
Toggle case charging sounds
Spatial Audio
The app does not currently provide head tracking information to Android for the OS to perform HRTF. This has not been explored completely, and it might need root.
Spatializing stereo sound is beyond this project’s scope and will never be available. Many OEMs have an implementation of their own for this.
Not available yet (doesn’t seem like something that would be useful on a computer anyway. If you have any suggestions, create a discussion.)
High quality two-way audio
On iOS/iPadOS, you can continue using A2DP while AirPods send the hi-res (AAC-ELD mono 64kHz?) audio stream from its microphone over AACP.
Android
Record audio within the app using the AirPods’ microphone without switching to Headset/Handsfree profile degrading the playback quality. But, making this available to other apps/telephony might need root, if possible at all.
Recorder is work in progress; available in the android/rewrite branch. builds
Turns out, if you change the VendorID in DID Profile to that of Apple, you get access to several special features!
You can do this on Linux by editing the DeviceID in /etc/bluetooth/main.conf. Add this line to the config file DeviceID = bluetooth:004C:0000:0000. For android you can enable the act as Apple device setting in the app’s settings (shown only when Xposed is available and LibrePods module is enabled).
Multi-device Connectivity
Upto two devices can be simultaneously connected to AirPods, for audio and control both. Seamless connection switching. The same notification shows up on Apple device when Android takes over the AirPods as if it were an Apple device (“Move to iPhone”). Android also shows a popup when the other device takes over.
Accessibility Settings and Hearing Aid
Accessibility settings like customizing transparency mode (amplification, balance, tone, conversation boost, and ambient noise reduction), and loud sound reduction can be configured.
All hearing aid customizations can be done from Android (linux soon), including setting the audiogram result. The app doesn’t provide a way to take a hearing test because it requires much more precision. It is much better to use an already available audiogram result.
Protocol and Reverse Engineering
Please refer to the Wireshark dissector plugin by Nojus (@pabloaul) for more information on the protocols used: pabloaul/apple-wireshark
The dissector had not been used in LibrePods for most of the implementation; I had reverse engineered the protocol myself before this dissector was made. But many (future) features including two-way high quality audio and spatial audio would not have been possible without their RE efforts!
Use of AI
Android app
These parts of the app were completely AI-generated:
Head Gestures - all of it, including logic and the UI
The offset setup with r2+the xposed module (both versions)
Troubleshooter and LogCollector
Rest everything- the background service, the Bluetooth manager classes (AACP and ATT), the entire UI, even the smallest components were written manually.
The aacp.rs and the att.rs files were translated from Kotlin to Rust with AI. Some parts of the media_controller.rs file, mainly the pulse integration, was also AI-generated.
Supporters
A huge thank you to everyone supporting the project!
Of course, everyone who has contributed to the project in any way, including by testing, sharing feedback, or just showing interest!
Alternates for other platforms:
CAPod - A companion app for AirPods on Android. (play store | source code). Use this if you’re using Android version 16 QPR3 or below and are not rooted.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.
Trademark Notice
The GPL does not grant any rights to use the LibrePods name, logo, or branding. The LibrePods name and logo may not be used for software, websites, domains, products, services, or other projects in a manner that suggests affiliation with, endorsement by, or association with the official LibrePods project without prior permission.
If you see any misuse of the LibrePods name or logo, please report it to [email protected].
The SF Pro font used in the Android app is the property of Apple Inc… This will be removed in future versions of the app and replaced with an open alternative soon.
AirPods, AirPods Pro, AirPods Max, and the AirPods logo are trademarks of Apple Inc. The LibrePods project is not affiliated with or endorsed by Apple Inc. in any way.
评论