Android Bluetooth/WiFi setup automation for Dala.
This module provides automated setup for Android Bluetooth and WiFi functionality by configuring the AndroidManifest.xml with required permissions and features, and ensuring DalaBridge.init() is called in the MainActivity.
Usage
From the command line (via Mix task):
mix dala.setup_bluetooth_wifi --platform androidFrom Elixir code:
Dala.Setup.Android.setup_bluetooth()
Dala.Setup.Android.setup_bluetooth("/path/to/android/directory")What it does
- Finds AndroidManifest.xml in the android/ directory
- Adds required Bluetooth permissions:
- BLUETOOTH
- BLUETOOTH_ADMIN
- BLUETOOTH_SCAN
- BLUETOOTH_CONNECT
- ACCESS_FINE_LOCATION
- Adds required WiFi permissions:
- ACCESS_WIFI_STATE
- CHANGE_WIFI_STATE
- Adds uses-feature for bluetooth_le with required=false
- Ensures DalaBridge.init() is called in MainActivity
Prerequisites
- Android project must exist with an AndroidManifest.xml
- DalaBridge.java should be present in the project
Summary
Functions
Add DalaBridge.init() call to the given Java/Kotlin file.
Check if DalaBridge.java exists in the project.
Check if DalaBridge.init() is called in the project.
Find Java/Kotlin source files in the Android project.
Find the AndroidManifest.xml path.
Check if AndroidManifest.xml exists in the project.
Print setup instructions without making changes.
Run the Android Bluetooth setup.
Run the Android WiFi setup.
Types
Functions
Add DalaBridge.init() call to the given Java/Kotlin file.
Inserts the init call into the onCreate method. If no onCreate method exists, prints instructions for manual addition.
Returns :ok on success, {:error, reason} on failure.
@spec bluetooth_files_present?() :: boolean()
Check if DalaBridge.java exists in the project.
@spec ensure_bridge_init() :: :ok | {:error, String.t()}
Check if DalaBridge.init() is called in the project.
Looks for the init call in MainActivity or Application class files. If not found, prints instructions for adding it. Optionally tries to add it automatically if the file is found.
@spec find_java_files() :: [String.t()]
Find Java/Kotlin source files in the Android project.
Searches both common Android project layouts for .java and .kt files.
@spec find_manifest() :: String.t() | nil
Find the AndroidManifest.xml path.
Searches both common Android project layouts:
android/src/main/AndroidManifest.xmlandroid/app/src/main/AndroidManifest.xml
Returns the path if found, nil otherwise.
@spec manifest_present?() :: boolean()
Check if AndroidManifest.xml exists in the project.
@spec print_instructions() :: :ok
Print setup instructions without making changes.
Run the Android Bluetooth setup.
Adds Bluetooth permissions and features to AndroidManifest.xml. Idempotent — will not duplicate entries.
Returns {:ok, message} on success, {:error, reason} on failure.
Run the Android WiFi setup.
Adds WiFi permissions to AndroidManifest.xml. Idempotent — will not duplicate entries.
Returns {:ok, message} on success, {:error, reason} on failure.