Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ name: Android CI

on:
push:
branches: [ main, develop ]
branches:
- main
- 'releases/**'
pull_request:
branches: [ main, develop ]

jobs:
code-quality:
runs-on: ubuntu-latest
name: Code Quality Checks

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*.aab
*.aar
*.apk
/app/release/
/app/debug/

# Files for the Dalvik VM
*.dex
Expand All @@ -27,6 +29,8 @@ build/
.idea/kotlinScripting.xml
.idea/artifacts/
.idea/inspectionProfiles/
.idea/androidTestResultsUserPreferences.xml
.idea/deploymentTargetSelector.xml

# Local configuration files (e.g., for Android Studio)
local.properties
Expand Down Expand Up @@ -54,4 +58,7 @@ captures/
*.keystore

# External libraries
libs/ # If you are not managing libraries through Gradle dependencies
libs/ # If you are not managing libraries through Gradle dependencies

.kiro
.vscode
194 changes: 0 additions & 194 deletions .idea/androidTestResultsUserPreferences.xml

This file was deleted.

18 changes: 0 additions & 18 deletions .idea/deploymentTargetSelector.xml

This file was deleted.

37 changes: 31 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2025-01-24
## [1.1.1] - 2025-10-09

### Added
- **Configurable Screen-Off Behavior**:
Default configuration is set to 1.3 seconds of Delayed Reactivation. Configuration options are:
a. **Always-On**: Keeps the microphone usage on even when the screen is off. Might be a good option for those who have quick microphone usage even when the screen is off (more battery usage, less recommended).
b. **Delayed Reactivation**: (Recommended Approach) Microphone turns off when the screen is off with a configurable delay for reactivating the microphone when the screen turns back on, preventing unnecessary battery drain during brief screen interactions like checking notifications or battery level.
c. **Stays-Off**: Turns the microphone usage off once the screen turns off and does not reactivate it. (Recommended for those who want minimum battery usage, but requires manual reactivation before usage.)

- **DelayedActivationManager**: New component for robust delay handling with proper race condition management and coroutine-based implementation.


### Enhanced
- **Battery Optimization**: Significantly reduced power consumption by avoiding microphone operations during brief screen interactions while maintaining responsive behavior for legitimate usage.
- **Quick Settings Tile**: Enhanced tile to display "Activating..." state during delay periods with manual override capability.


### Technical Improvements
- Coroutine-based delay implementation with proper job cancellation and cleanup
- Atomic state updates and synchronized operations for thread safety
- Timestamp-based race condition detection and latest-event-wins strategy
- Enhanced service lifecycle integration with delay state persistence

## [1.1.0] - 2025-10-01

### Added
- **Intelligent Quick Settings Tile**: A new state-aware Quick Settings tile that provides at-a-glance status (On, Off, Paused) and one-tap control of the MicLock service.
Expand All @@ -15,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The tile now displays a "Paused" state when another app is using the microphone, providing clearer feedback to the user.
- The tile shows an unavailable state with a "No Permission" label if required permissions have not been granted.

## [1.0.1] - 2025-01-23
## [1.0.1] - 2025-09-23

### Enhanced
- **Improved Service Reliability (Always-On Foreground Service):** The MicLockService now remains in the foreground at all times when active, even when the screen is off. This significantly improves service reliability by preventing the Android system from terminating the background process.
Expand All @@ -26,10 +49,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Addressed issues where the service could be terminated by aggressive OEM power management when the screen was off

## [1.0.0] - 2024-01-20
## [1.0.0] - 2025-09-21

### Added
- Initial public release of Mic-Lock
- Initial public release of MicLock
- Core functionality to reroute audio from faulty bottom microphone to earpiece microphone on Google Pixel devices
- Battery-efficient background service with dual recording strategy (MediaRecorder/AudioRecord modes)
- Polite background holding mechanism that yields to foreground applications
Expand Down Expand Up @@ -59,5 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Contributing guidelines for open source development
- Issue templates for bug reports and feature requests

[1.1.0]: https://github.com/yourusername/mic-lock/releases/tag/v1.1.0
[1.0.0]: https://github.com/yourusername/mic-lock/releases/tag/v1.0.0
[1.1.1]: https://github.com/Dan8Oren/MicLock/releases/tag/v1.1.1
[1.1.0]: https://github.com/Dan8Oren/MicLock/releases/tag/v1.1.0
[1.0.1]: https://github.com/Dan8Oren/MicLock/releases/tag/v1.0.1
[1.0.0]: https://github.com/Dan8Oren/MicLock/releases/tag/v1.0.0
25 changes: 21 additions & 4 deletions DEV_SPECS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Mic-Lock should avoid requesting audio modes or flags that might inadvertently b

### 2.6 Proper Foreground Service (FGS) Lifecycle and Android 14+ Compatibility

Mic-Lock must integrate correctly with Android's Foreground Service lifecycle to ensure stable policy classification, while gracefully handling Android 14+ background service restrictions:
Mic-Lock must integrate correctly with Android's Foreground Service lifecycle to ensure stable policy classification, while gracefully handling Android 14+ background service restrictions and implementing intelligent delayed activation:

* **Open Input After FGS Start:** The microphone input should only be opened *after* the Foreground Service is fully running and its notification is visible.
* **Persistent Notification:** Maintain a clear, ongoing notification that indicates the service status and allows user control.
Expand All @@ -74,9 +74,26 @@ Mic-Lock must integrate correctly with Android's Foreground Service lifecycle to
- Using regular `startService()` for already-running services to avoid background restrictions
* **Screen State Integration:** To prevent termination by the OS, the service remains in the foreground at all times when active.
- When the screen turns **off**, the service pauses microphone usage to save battery but **does not exit the foreground state**. The notification is updated to show a "Paused (Screen off)" status.
- When the screen turns **on**, the service resumes active microphone holding.
- When the screen turns **on**, the service implements intelligent delayed activation with configurable delays (default 1.3 seconds) to prevent unnecessary battery drain during brief screen interactions.
* **Delayed Activation Management:** The service must properly handle delayed microphone re-activation:
- Start foreground service immediately when delay is scheduled to comply with Android 14+ restrictions
- Cancel pending delays if screen turns off during delay period
- Restart delay from beginning if screen turns on again during existing delay
- Respect existing service states (manual stops, active sessions, paused by other apps) when applying delays

### 2.7 User Interface and Preferences
### 2.7 Intelligent Screen State Management

Mic-Lock must implement configurable delayed activation to optimize battery usage while maintaining responsive behavior:

* **Configurable Delay Period:** Provide user-configurable delay (0-5000ms) before re-activating microphone when screen turns on
* **Smart Cancellation Logic:** Cancel pending activation if screen turns off during delay period, preventing unnecessary operations
* **Race Condition Handling:** Handle rapid screen state changes with latest-event-wins strategy and proper coroutine job management
* **State Validation:** Ensure delays only apply when appropriate (service paused by screen-off, not manually stopped or already active)
* **Foreground Service Coordination:** Start foreground service immediately when delay is scheduled to comply with Android 14+ background restrictions
* **Notification Updates:** Update service notification to reflect delay status with countdown display during delay periods
* **Manual Override Support:** Allow immediate activation through Quick Settings tile or manual service start, cancelling any pending delays

### 2.8 User Interface and Preferences

* **Quick Settings Tile**: A state-aware tile provides at-a-glance status and one-tap control. It must reflect the service's state (On, Off, Paused) and become unavailable if permissions are missing.

Expand All @@ -90,7 +107,7 @@ Mic-Lock must integrate correctly with Android's Foreground Service lifecycle to
* **Battery Usage Awareness:** Clearly communicate to users that MediaRecorder mode uses more battery but provides better compatibility.
* **Battery Optimization Exemption:** Upon first launch, the app prompts the user to grant an exemption from battery optimizations. This is critical to prevent the Android system from terminating the service during long periods of device inactivity, ensuring continuous background operation.

### 2.8 Service Resilience and User Experience
### 2.9 Service Resilience and User Experience

To ensure the service remains active and is easy to manage, Mic-Lock implements several resilience features:

Expand Down
Loading