Skip to content

Battery not low constraint#30

Merged
rteyssandier merged 9 commits into
rteyssandier:mainfrom
dombroks:battery-not-low-constraint
Jan 13, 2026
Merged

Battery not low constraint#30
rteyssandier merged 9 commits into
rteyssandier:mainfrom
dombroks:battery-not-low-constraint

Conversation

@dombroks

Copy link
Copy Markdown
Contributor

This pull request adds support for a new "require battery not low" constraint throughout the Lorraine job scheduling library, including both data model and platform-specific implementations. The main changes include updating the constraints data structures, database schema, and adding iOS-specific logic for checking battery state.

Constraint Model and Entity Updates:

  • Added a new requireBatteryNotLow property to LorraineConstraints, ConstraintEntity, and their conversion functions, allowing jobs to specify this constraint. [1] [2]
  • Updated the builder API (LorraineConstraintsDefinition) to support the new constraint.

Database Schema Migration:

  • Increased database version to 3 and updated the schema to store the new require_battery_not_low field in the worker table. [1] [2]

Android and iOS Platform Integration:

  • Modified the Android mapping (asWorkManagerConstraints) to set requiresBatteryNotLow based on the new property.
  • Registered a new BatteryNotLowCheck constraint check on iOS, integrating it into the platform's constraint checks. [1] [2]

iOS Battery Constraint Implementation:

  • Introduced BatteryNotLowCheck and AppleBatteryObserver classes to monitor battery state and expose the "not low" status to the scheduler, using UIKit battery notifications.

Comment thread lorraine/src/iosMain/kotlin/io/dot/lorraine/constraint/BatteryNotLowCheck.ios.kt Outdated
Comment thread lorraine/src/iosMain/kotlin/io/dot/lorraine/constraint/BatteryNotLowCheck.ios.kt Outdated
@rteyssandier rteyssandier added the enhancement New feature or request label Jan 10, 2026
@rteyssandier rteyssandier merged commit 4a89d26 into rteyssandier:main Jan 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants