Codex/background task#19
Conversation
marcprux
left a comment
There was a problem hiding this comment.
This looks useful overall! It does look like there's a concurrency issue in CI that we'll need to get fixed.
| contents: | ||
| - block: 'dependencies' | ||
| contents: | ||
| - 'implementation("androidx.core:core:1.13.1")' |
There was a problem hiding this comment.
Is there any reason to not use the latest (1.9.0) version of the dependency?
There was a problem hiding this comment.
Android’s foreground-service docs say the ServiceCompat overload that accepts foreground-service types is available in androidx-core 1.12+
- minimum defensible version:
androidx.core:core:1.12.0 - conservative current choice:
androidx.core:core:1.13.1 - latest stable if the Skip Android toolchain supports it:
androidx.core:core:1.17.0
I picked 1.13.1 as a conservative stable version above that minimum. AndroidX’s release notes say 1.17.0 requires Kotlin Gradle Plugin 2.0.0+, so I’d prefer to only bump that far if skip-device’s Android build/toolchain is already aligned with that requirement.
Happy to update the PR to whichever version you prefer.
…. Reads full UIDevice data inside MainActor.assumeIsolated when safe, and returns a reduced Apple identity from background threads without touching UIKit.
|
@marcprux pinging your because it feels like PR that have a |
Thank you for contributing to the Skip project! Please use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.
Please review the contribution guide at https://skip.dev/docs/contributing/ for advice and guidance on making high-quality PRs.
Skip Pull Request Checklist:
swift testCodex generated the code, manually validate from a sandbox native app
Summary
Adds three dual-platform device/app-shell capabilities to
SkipDevice:ApplicationRuntimeProviderfor app lifecycle and memory pressure eventsBackgroundActivityfor finite user-visible background workDeviceIdentity.currentfor basic platform device metadataChanges
Application runtime events
Adds
ApplicationRuntimeProvider, which exposes:currentLifecyclePhasemonitorLifecycle() -> AsyncStream<ApplicationLifecycleEvent>monitorMemoryPressure() -> AsyncStream<MemoryPressureEvent>stop()On Apple platforms this uses
UIApplicationnotifications for lifecycle and memory warnings.On Android this uses:
Application.ActivityLifecycleCallbacksfor lifecycleComponentCallbacks2for memory pressureAndroid memory pressure maps
onLowMemory,TRIM_MEMORY_RUNNING_CRITICAL, andTRIM_MEMORY_COMPLETEto.critical; other trim callbacks map to.warning.Lifecycle events expose both:
kind, preserving iOS-style event names where possiblephase, a normalized app phaseBackground activity
Adds
BackgroundActivity.begin(_:)/BackgroundActivity.end(_:)for finite background work.On iOS/tvOS this wraps
UIApplication.beginBackgroundTaskandendBackgroundTask.On Android this adds a generic
BackgroundActivityServiceforeground service with a registry of active activity IDs. The service stops when no activities remain.Android foreground-service type mapping:
localNetworkTransferdataSyncmediaProcessingmediaProcessingon Android 15+,dataSyncfallbackconnectedDeviceTransferconnectedDeviceshortCriticalWorkshortServicewhen available,dataSyncfallbackThe Android service implements foreground-service timeout handling and stops promptly when Android reports a timeout.
Device identity
Adds
DeviceIdentity.current, exposing low-level device metadata:namemodellocalizedModelsystemNamesystemVersionvendorIdentifiermanufacturerbranddeviceproductOn Apple platforms this wraps
UIDevice. On Android this reads fromBuild,Settings.Global, andSettings.Secure.vendorIdentifiermaps toUIDevice.identifierForVendoron Apple platforms andSettings.Secure.ANDROID_IDon Android.Android setup
Adds an
androidx.core:coredependency forNotificationCompat,ServiceCompat, andContextCompat.Updates README documentation with required Android manifest entries for apps using
BackgroundActivity, including foreground-service permissions and service declaration.Background task example usage
Background task in the sandbox
Notice the number of
ticksexecuted in the background, from the UI report + logsvideo-capture-20260610-143302-stream.mp4