Skip to content

Conversation

@Dan8Oren
Copy link
Owner

🚀 Screen-Off Behavior Configuration & Bug fix

added Screen-Off Behavior Configuration - giving you complete control over how MicLock handles microphone usage when your screen turns off and back on.

⚙️ Three Power Management Options

1. 🔋 Always-On

Keeps microphone protection active even with screen off. Choose this if you frequently use voice features without looking at your phone.

Best for: Quick voice commands, hands-free usage
Battery impact: Higher usage
Convenience: Maximum - always ready

2. 🎯 Delayed Reactivation (Recommended)

Microphone turns off when screen goes off, then waits before reactivating when screen turns on. Perfect balance of battery savings and usability.

Configurable delay: 0-5000ms (default: 1.3 seconds)
Smart cancellation: Brief screen interactions won't waste battery
Best for: Most users - optimal battery vs convenience
Battery impact: Significantly reduced

3. 💡 Stays-Off

Turns off microphone protection when screen goes off and keeps it off until you manually restart.

Best for: Maximum battery conservation
Battery impact: Minimal
Trade-off: Requires manual reactivation before voice usage

🐞 Bug Fix

  • Fixed a bug where the app got stuck in a "paused" state when another app used the microphone while the screen was off.

* DelayPrefs object with getter/setter methods for screen-on delay configuration

* DelayedActivationManager class with coroutine-based delay handling

* Enhance MicLockService with delay integration

* modified ScreenStateReceiver for delay support and added unit tests

* updated UI to set delay

* Fix delay logic to distinguish between service running and mic actively held

* Fix state management to distinguish screen-off pause from silence pause

* Update Quick Settings tile for delay states

* fixed a bug when the tile wasn't updating back to active after delay

* delay slider share the same constant as the code

* change the logic into screen behavior with option to never and always on

* working on slider UI

* some UI tweaks and fixed MicLockService.kt not taking into account Never configuration

* fixed tile functionality and app status on paused by screen off.

* fixed tile functionality and app status on paused by screen off.

* added some more unit tests

* refined feature labels and extracted to strings.xml

* MainActivity start button to handle screen-off pause state

* updated docs and version

* gitignore update

* updated Changelog

* minor changes

* updated versionCode to count past releases

* Update CHANGELOG.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* gitignore update

* stuck in isPausedBySilence state bug fix (#10)

* implement hybrid solution for stuck isPausedBySilence state

* removed pausedBySilenceTimestamp

* modified log

* Fixes issue where service would remain stuck in silenced state
* removed pausedBySilenceTimestamp

* modified log

* Fixes issue where service would remain stuck in silenced state
Copilot AI review requested due to automatic review settings October 13, 2025 07:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces configurable screen-off behavior for MicLock with battery optimization features and bug fixes. The primary purpose is to give users control over how the microphone protection behaves when the screen turns off and back on, with three power management options: Always-On, Delayed Reactivation (recommended), and Stays-Off.

Key changes include:

  • New DelayedActivationManager component for intelligent screen-on delay handling with race condition management
  • Enhanced UI with slider-based configuration for screen-off behavior
  • Fixed bug where app got stuck in "paused" state when another app used microphone while screen was off

Reviewed Changes

Copilot reviewed 27 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/src/main/java/io/github/miclock/service/DelayedActivationManager.kt New component implementing coroutine-based delay scheduling with proper cancellation and state validation
app/src/main/java/io/github/miclock/service/MicLockService.kt Enhanced service with global callback registration, screen state management, and delay integration
app/src/main/java/io/github/miclock/ui/MainActivity.kt Added screen-on delay configuration UI with slider control and snapping behavior
app/src/main/java/io/github/miclock/data/Prefs.kt New preference handling for screen-on delay with validation and slider mapping functions
app/src/main/java/io/github/miclock/tile/MicLockTileService.kt Enhanced tile service with delay state display and manual override capability
app/src/main/res/layout/activity_main.xml New UI components for screen-off behavior configuration with visual zones
docs/architecture.md Updated architecture documentation to include DelayedActivationManager and intelligent screen state management
Files not reviewed (2)
  • .idea/androidTestResultsUserPreferences.xml: Language not supported
  • .idea/deploymentTargetSelector.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

* linter and removed idea files

* bug, probably inserted due to the merge?

* updated to latest app bundle's code version
Copilot AI review requested due to automatic review settings October 15, 2025 17:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 28 out of 33 changed files in this pull request and generated 11 comments.

Files not reviewed (2)
  • .idea/androidTestResultsUserPreferences.xml: Language not supported
  • .idea/deploymentTargetSelector.xml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

/**
* Schedules a delayed activation after the specified delay period.
* Cancels any existing pending activation before scheduling new one.
* * @param delayMs delay in milliseconds before activation
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc parameter documentation should use single asterisk. Change * @param to @param.

Suggested change
* * @param delayMs delay in milliseconds before activation
* @param delayMs delay in milliseconds before activation

Copilot uses AI. Check for mistakes.

/**
* Cancels any pending delayed activation operation.
* * @return true if there was a pending operation that was cancelled, false otherwise
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Suggested change
* * @return true if there was a pending operation that was cancelled, false otherwise
* @return true if there was a pending operation that was cancelled, false otherwise

Copilot uses AI. Check for mistakes.

/**
* Checks if there is currently a delayed activation pending.
* * @return true if activation is pending, false otherwise
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Copilot uses AI. Check for mistakes.

/**
* Gets the remaining time in milliseconds for the current delay operation.
* * @return remaining milliseconds, or 0 if no delay is pending
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Copilot uses AI. Check for mistakes.
/**
* Determines if the current service state should prevent delayed activation.
* This method checks for conditions that should be respected (manual stops, active sessions, paused states).
* * @return true if existing state should be respected (delay should not proceed), false otherwise
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Copilot uses AI. Check for mistakes.

/**
* Checks if the app is configured to always keep mic on (ignore screen state).
* * @return true if always-on mode is active, false otherwise
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Copilot uses AI. Check for mistakes.

/**
* Determines if delay should be applied based on current conditions.
* * @return true if delay should be applied, false otherwise
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Copilot uses AI. Check for mistakes.
/**
* Gets the timestamp of the last screen-on event.
* Used for race condition detection and debugging.
* * @return timestamp in milliseconds
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Copilot uses AI. Check for mistakes.

/**
* Gets the timestamp when the current delay operation started.
* * @return timestamp in milliseconds, or 0 if no delay is active
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDoc return documentation should use single asterisk. Change * @return to @return.

Suggested change
* * @return timestamp in milliseconds, or 0 if no delay is active
* @return timestamp in milliseconds, or 0 if no delay is active

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +113
* Resets all timestamps to zero. For testing purposes only.
* @VisibleForTesting
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use proper annotation syntax @androidx.annotation.VisibleForTesting instead of KDoc comment.

Copilot uses AI. Check for mistakes.
@Dan8Oren Dan8Oren merged commit 13594f1 into main Oct 15, 2025
4 checks passed
@Dan8Oren Dan8Oren deleted the releases/version-1.1.1 branch October 15, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants