Files

105 lines
4.6 KiB
Markdown
Raw Permalink Normal View History

# Miracast Enabler
An LSPosed/Xposed module that unlocks native Miracast (Wi-Fi Display) on Android 12+ devices where it has been hidden by the OEM.
Android still ships the full Miracast/WFD protocol stack in the framework — `WifiDisplayAdapter`, `WifiDisplayController`, `RemoteDisplay`, and all supporting classes. OEMs simply disable it via a config flag and hide it behind the Chromecast-only Cast UI. This module hooks the framework to re-enable it, giving you native Miracast with zero custom streaming code.
## Features
- **Native Wi-Fi Display** — uses Android's built-in Miracast stack, not a custom implementation
- **Quick Settings tile** — scan for and connect to Miracast receivers from the notification shade
- **Framework hooks** — forces `config_enableWifiDisplay` and `config_wifiDisplaySupportsProtectedBuffers` to true at the resource level
- **Cast UI integration** — unhides WFD routes in Settings > Cast so Miracast sinks appear alongside Chromecast devices
- **Permission grants** — automatically grants `CONFIGURE_WIFI_DISPLAY` and `CONTROL_WIFI_DISPLAY` to the module
- **Feature injection** — forces `android.software.wifi_display` system feature to report as available
- **Foldable support** — display source selector for Pixel Fold, Pixel 9 Pro Fold, and Pixel 10 Pro Fold
- **Settings app** — configure resolution, HDCP, GPU composition, Wi-Fi concurrency
## Requirements
- Android 12+ (API 31+)
- LSPosed or LSPosed-IT installed and active
- Root (KernelSU, Magisk, or APatch)
- Wi-Fi Direct capable hardware (most modern phones)
## Installation
1. Install the APK
2. Open LSPosed manager
3. Enable "Miracast Enabler" module
4. Set scope to: `System Framework`, `System UI`, `Settings`
5. Reboot
6. Add the Miracast tile to Quick Settings, or go to Settings > Connected devices > Cast
## Supported Devices
Primarily tested on Pixel devices with Tensor SoCs:
| Device | Codename | SoC | Status |
|--------|----------|-----|--------|
| Pixel 10 Pro Fold | rango | Tensor G5 | Primary target |
| Pixel 9 Pro Fold | comet/cometl | Tensor G4 | Supported |
| Pixel Fold | felix | Tensor G2 | Supported |
| Pixel 9 series | caiman/komodo/tokay/blazer | Tensor G4 | Supported |
| Pixel 10 series | laguna platform | Tensor G5 | Supported |
| Other Android 12+ | — | — | Should work if WFD classes exist in framework |
## Configuration
Open the Miracast Enabler app to access settings:
| Setting | Description | Default |
|---------|-------------|---------|
| Resolution | Max output resolution (auto, 720p, 1080p @ 30/60fps) | 1080p 30fps |
| HDCP | Content protection (disable for better compatibility) | Off |
| Display source | Inner/outer display on foldables | Inner |
| GPU composition | Fix black/green screen on Tensor devices | On |
| Single-channel concurrency | Prevent Wi-Fi latency spikes during cast | Off |
## How It Works
The module hooks into four processes:
1. **System Server (`android`)** — hooks `Resources.getBoolean()` to force Wi-Fi Display config flags true, hooks `hasSystemFeature()` to report WFD support, hooks `WifiDisplayStatus.getFeatureState()` to return `FEATURE_STATE_ON`, and grants WFD permissions to the module package.
2. **Settings (`com.android.settings`)** — hooks `WifiDisplayStatus.getFeatureState()` and `WifiDisplayPreferenceController.getAvailabilityStatus()` so the Wi-Fi Display section appears in Cast preferences.
3. **SystemUI (`com.android.systemui`)** — provides the Quick Settings tile for scanning and connecting.
4. **App process** — the settings activity reads/writes `SharedPreferences` which the hooks consume via `XSharedPreferences`.
## Building
```bash
# Requires Android SDK with API 34 and build-tools 34.0.0
echo "sdk.dir=/path/to/android-sdk" > local.properties
./gradlew assembleRelease
```
Output APK: `app/build/outputs/apk/release/app-release.apk`
## Troubleshooting
**Miracast option doesn't appear after reboot**
- Verify the module is enabled in LSPosed with correct scope
- Check LSPosed logs for "MiracastEnabler" entries
- Some ROMs may need a second reboot after first activation
**Black or green screen during cast**
- Enable "Force GPU composition" in module settings
- This is a known issue on Tensor SoCs where the HWC doesn't handle virtual display layers
**Connection drops or high latency**
- Enable "Single-channel concurrency" to prevent the Wi-Fi chip from splitting STA and P2P across bands
- Move closer to the Miracast receiver
- Ensure no heavy Wi-Fi traffic on the same network
**No Miracast receivers found**
- Ensure the receiver is in pairing/discovery mode
- Check that Wi-Fi Direct is not disabled by MDM or device policy
- Verify Wi-Fi is on and connected
## License
MIT