Skip to content

Latest commit

 

History

History
326 lines (249 loc) · 10.9 KB

File metadata and controls

326 lines (249 loc) · 10.9 KB

Build and Release

CarOS Profile Switcher

A Magisk module for Android that automatically switches device profiles based on Android Auto connection state (wired/wireless) and intelligently manages device resources for in-car use.

🚗 Features

Automatic Profile Switching

  • WIRED Mode: Activated when USB is connected AND Android Auto is running
  • WIRELESS Mode: Activated when Bluetooth is connected to your car AND Android Auto is running
  • IDLE Mode: Activated when not in car (battery saving mode)

Intelligent Resource Management

  • WiFi Control: Keep WiFi on/off in wired/idle modes (useful for VW Polo 6 compatibility)
  • Mobile Data Management: Automatically enable/disable mobile data based on mode
  • Bluetooth Control: Smart BT management in wired mode
  • CPU Throttling: Limit CPU frequency when idle to save battery
  • Charge Limiting: Reduce fast charging in wired mode to prevent overheating
  • Battery Saver: Automatically enable when not in car
  • Nova Launcher: Set as default launcher automatically
  • 🔔 Auto Permissions: Automatically grants notification and location permissions to Android Auto, Waze, Google Maps, and Nova Launcher
  • 🎵 Audio Streaming: Stream audio from another device to car speakers via Bluetooth A2DP sink or WiFi hotspot

Configuration

  • User-configurable via /sdcard/CarOS/config.env
  • Supports multiple car Bluetooth names (regex patterns)
  • MAC address matching support
  • Verbose logging for troubleshooting
  • 📚 See EXAMPLES.md for car-specific configurations

📋 Requirements

  • Android device with root access
  • Magisk v20.4 or higher
  • Android Auto app installed
  • Optional: Nova Launcher (for launcher switching feature)

🔧 Installation

  1. Download the latest release ZIP from the rel/ directory or [releases page]
  2. Open Magisk Manager
  3. Go to ModulesInstall from storage
  4. Select the downloaded ZIP file
  5. Reboot your device

⚙️ Configuration

After installation, edit the configuration file at /sdcard/CarOS/config.env:

💡 Quick Start: See EXAMPLES.md for ready-to-use configurations for Audi, VW, BMW, Mercedes, and more!

# Car Bluetooth name(s) - supports regex (e.g., "Audi|VW|Volkswagen")
AUDI_BT_NAMES="Audi"

# Optional: Match by MAC address instead
AUDI_BT_MAC=""

# Wired mode: Keep Bluetooth on (1) or off (0)
ALLOW_BT_IN_WIRED=1

# Mobile data management
DATA_OFF_OUTSIDE=1        # Disable data when idle
KEEP_DATA_IN_CAR=1        # Keep data on in car (for Waze/Spotify)

# CPU throttling when idle (in kHz, e.g., 1516800 = ~1.5 GHz)
IDLE_MAX_CPU_FREQ=""

# Limit fast charging in wired mode (reduces heat)
LIMIT_QUICK_CHARGE_WIRED=1

# Set Nova Launcher as default
SET_NOVA_DEFAULT=1

# WiFi management
KEEP_WIFI_IN_WIRED=1      # Keep WiFi on in wired mode (VW Polo 6, etc.)
KEEP_WIFI_IN_IDLE=1       # Keep WiFi on when idle

# Automatic permission management
AUTO_GRANT_PERMISSIONS=1  # Auto-grant notifications & location to AA, Waze, Maps

# Audio streaming options (choose one or both based on what works for your setup)
ENABLE_BT_AUDIO_SINK=0     # Bluetooth A2DP sink (may not work if BT used for car audio)
ENABLE_WIFI_AUDIO_HOTSPOT=0  # WiFi hotspot for audio streaming (alternative to BT)

# WiFi hotspot settings (if using WiFi audio streaming)
WIFI_AUDIO_HOTSPOT_SSID="CarOS-Audio"
WIFI_AUDIO_HOTSPOT_PASSWORD="caros123"

# Verbose logging
VERBOSE=1

🎵 Audio Streaming Feature

Stream audio from another phone to your car speakers via Bluetooth or WiFi. Two methods available:

Method 1: Bluetooth A2DP Sink

When enabled (ENABLE_BT_AUDIO_SINK=1), your CarOS device can receive audio from another phone via Bluetooth.

Limitation: May not work if Bluetooth is already used for car audio/calls (even in wired mode).

How to use:

  1. Enable in config: ENABLE_BT_AUDIO_SINK=1
  2. Connect your CarOS phone to car via USB
  3. On the emitting phone:
    • Go to Bluetooth settings
    • Find and pair with your CarOS device
    • Connect and play music

Method 2: WiFi Hotspot (Recommended Alternative)

When enabled (ENABLE_WIFI_AUDIO_HOTSPOT=1), your CarOS device creates a WiFi hotspot that other devices can connect to for streaming audio.

Advantages:

  • ✓ Works even if Bluetooth is used for car audio
  • ✓ Higher quality audio streaming
  • ✓ Can work in WIRED mode when WiFi is not used by the car

How to use:

  1. Enable in config:
    ENABLE_WIFI_AUDIO_HOTSPOT=1
    WIFI_AUDIO_HOTSPOT_SSID="CarOS-Audio"
    WIFI_AUDIO_HOTSPOT_PASSWORD="caros123"
  2. Connect your CarOS phone to car via USB
  3. On the emitting phone:
    • Connect to the WiFi hotspot (SSID: CarOS-Audio)
    • Use an audio streaming app (e.g., SoundWire, AudioRelay, etc.)
    • Stream audio to CarOS device

Use Cases

  • Stream music from a passenger's phone to your car speakers
  • Multiple people can share music during the drive
  • Alternative to passing phone cables around

Important Notes

  • Both methods work in WIRED mode only (USB connection to car)
  • Does NOT work in WIRELESS mode (both Bluetooth and WiFi may be used by car)
  • Automatically disabled when IDLE to save battery
  • WiFi hotspot method requires an audio streaming app on the emitting phone
  • Bluetooth method may not work on all devices (A2DP sink support required)

📝 How It Works

  1. Boot: The module starts automatically via service.sh
  2. Permissions: Automatically grants notification and location permissions to critical apps (Android Auto, Waze, Google Maps, Nova Launcher)
  3. Monitoring: Every 3 seconds, the module checks:
    • USB connection status
    • Bluetooth connection to configured car device
    • Android Auto process state
  4. Profile Application: When state changes, applies appropriate profile:

Profile Details

Profile WiFi Bluetooth Mobile Data CPU Battery Saver Charging
WIRED Configurable Configurable Configurable Max Off Limited*
WIRELESS On On Configurable Max Off Normal
IDLE Configurable N/A Off* Limited* On Normal

*Configurable via config file

📦 Building a New Release

Quick Build (PowerShell)

# Set version number
$VERSION = "0.2.4"

# Create release directory if it doesn't exist
New-Item -ItemType Directory -Force -Path "rel"

# Create the ZIP file (from project root)
Compress-Archive -Path "caros_config.sh", "module.prop", "post-fs-data.sh", "service.sh", "system.prop", "grant_permissions.sh", "META-INF" -DestinationPath "rel/CarOS_Profile_Switcher-v$VERSION.zip" -Force

Write-Host "Release created: rel/CarOS_Profile_Switcher-v$VERSION.zip"

Manual Build Steps

  1. Update Version Numbers:

    # Edit module.prop
    version=0.2.4
    versionCode=5  # Increment by 1
    description=... # Update changelog
  2. Update Service Script Version:

    # Edit service.sh (around line 257)
    log "CarOS Profile Switcher service v0.2.4 started"
  3. Create ZIP Archive: Include these files/directories:

    • caros_config.sh
    • module.prop
    • post-fs-data.sh
    • service.sh
    • system.prop
    • grant_permissions.sh
    • META-INF/ (entire directory)
  4. Name Convention:

    CarOS_Profile_Switcher-v{VERSION}.zip
    

    Example: CarOS_Profile_Switcher-v0.2.4.zip

  5. Save to Release Directory:

    # Move to rel/ directory
    Move-Item "CarOS_Profile_Switcher-v0.2.4.zip" "rel/"

Using Git Bash (Alternative)

#!/bin/bash
VERSION="0.2.4"
mkdir -p rel
zip -r "rel/CarOS_Profile_Switcher-v${VERSION}.zip" \
    caros_config.sh \
    module.prop \
    post-fs-data.sh \
    service.sh \
    system.prop \
    grant_permissions.sh \
    META-INF
echo "Release created: rel/CarOS_Profile_Switcher-v${VERSION}.zip"

🐛 Troubleshooting

💡 Tip: Check the FAQ.md for common issues and solutions!

Check Logs

View module logs:

adb shell cat /data/adb/modules/caros-switcher/log.txt

Check Current State

adb shell cat /data/adb/modules/caros-switcher/state.json

Common Issues

Module not working:

  • Ensure Magisk is properly installed
  • Check that Android Auto is installed
  • Verify Bluetooth name in config matches your car

Bluetooth not detected:

  • Enable verbose logging (VERBOSE=1)
  • Check logs for Bluetooth dump
  • Try using MAC address instead of name

WiFi/Data not switching:

  • Some Android versions have restricted APIs
  • Check logs for error messages
  • May require additional permissions/SELinux changes

📄 Files Structure

caros-profile-switcher/
├── build.ps1                # PowerShell build script
├── build.sh                 # Bash build script
├── caros_config.sh          # Central configuration defaults
├── grant_permissions.sh     # Automatic permission management
├── module.prop              # Magisk module metadata
├── post-fs-data.sh          # Early boot initialization
├── service.sh               # Main service loop
├── system.prop              # System property overrides
├── README.md                # This file
├── CHANGELOG.md             # Version history
├── CONTRIBUTING.md          # Developer guide
├── EXAMPLES.md              # Configuration examples
├── LICENSE                  # MIT License
├── .gitignore               # Git ignore rules
├── META-INF/                # Magisk installer
│   └── com/google/android/
│       ├── update-binary    # Installation script
│       └── updater-script   # Magisk marker
└── rel/                     # Release builds (not in repo)

🔄 Version History

  • v0.2.3: WiFi smart management + VW Polo 6 compatible + bug fixes
  • v0.2.2: Nova Launcher default setting
  • v0.2.1: Configuration fixes
  • v0.2.0: Initial release with profile switching

See CHANGELOG.md for detailed version history.

📚 Documentation

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Authors

🙏 Acknowledgments

  • Magisk community for the module framework
  • Android Auto developers

Note: This module requires root access and modifies system behavior. Use at your own risk. Always test in a safe environment first.