Notifications and background execution modernization#5142
Open
shai-almog wants to merge 10 commits into
Open
Conversation
…ichment Adds the cross-platform foundation for the notifications and background execution modernization: Core API (com.codename1.notifications): NotificationPermissionRequest / Result / Callback, NotificationChannelBuilder; LocalNotification enriched backward-compatibly with Action, MessagingStyle and fluent setters for channel, group, full-screen, time-sensitive, ongoing, progress, custom view, actions and quick-reply input actions. com.codename1.share.SharedContent; com.codename1.background WorkRequest / BackgroundWorker / BackgroundWork / ForegroundService / BackgroundTask; Push.subscribeToTopic / unsubscribeFromTopic; Lifecycle.onReceivedSharedContent. CodenameOneImplementation gains concrete safe-default methods (never abstract, so third-party impls keep compiling) plus a cross-port running application instance holder; Display delegators; PushContent actionTitle parity for push and local notification actions. JavaSE simulator: rich Swing notification panel (image, actions, inline quick-reply, progress) routing taps back to LocalNotificationCallback and PushContent; functional background work / processing with live constraint gating; foreground service; a new "Notifications and Background" Simulate menu (constraint toggles, run-work-now, channel inspector, shared content injection); app instance captured in Executor. Android: extended Bundle round-trip carrying all new fields (guarded so in-flight alarms from older builds still parse), notification permission, reflective channel register/delete/group, FCM topic subscribe/unsubscribe, and enriched LocalNotificationPublisher rendering (grouping, ongoing, progress, full-screen, time-sensitive, messaging style, channel). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…OS native Android: action-button routing via per-action content-intent templates with RemoteInput quick reply; constraint-aware background work and one-shot processing via JobScheduler (CodenameOneJobService); foreground service (CodenameOneForegroundService); receive-shared-content via CodenameOneShareReceiverActivity with App-storage file hand-off and pending delivery to the running app. iOS: IOSNative gains sendLocalNotification2 (actions, group/thread, time-sensitive interruption level, image attachment), requestNotificationPermission (maps UNAuthorizationStatus to the granular result), BGTaskScheduler register/submit/cancel, isBackgroundProcessingSupported and getPendingSharedContent. IOSImplementation wires these plus constraint-aware work persisted for cold-launch reconstruction, topics no-op, and shared content parsing. GLAppDelegate registers permitted BGTask identifiers at launch and polls the share App Group on activation. Non-void natives expose redundant base and _R_ symbols so the link step succeeds regardless of the translator mangling. iOS Java compiles; the native sources require an Xcode iOS-port build to verify. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tent extension AndroidGradleBuilder: register the JobScheduler background-work service, and (gated by classpath scan flags) the foreground service with FOREGROUND_SERVICE permission and the share-receiver activity with SEND/SEND_MULTIPLE intent filters (android.shareFilter hint). Generated stub now captures the app instance, flushes pending shared content, and routes local notification action ids and quick-reply text into PushContent. IPhoneBuilder: auto-add the "processing" UIBackgroundMode and inject BGTaskSchedulerPermittedIdentifiers (ios.backgroundProcessingIds) and the CN1ShareAppGroup key (ios.shareAppGroup) so BGTaskScheduler and shared-content delivery work. New IOSNotificationContentExtensionBuilder emits a .ios.appext notification content extension following the PR #5036 share-extension authoring pattern, for custom-view notifications. The equivalent AndroidGradleBuilder / IPhoneBuilder edits are mirrored into the private BuildDaemon repository per the mirror requirement. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds core-unittests for the LocalNotification enrichment (actions, input actions, messaging style, grouping, progress, fluent setters and backward compatibility), the notification permission request/result and channel builder, WorkRequest constraints, SharedContent, and PushContent actionTitle parity. Adds a deterministic-output test for IOSNotificationContentExtensionBuilder in the maven plugin. All 26 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cation Verified the iOS port by building and linking the HelloCodenameOne sample end-to-end (ParparVM translate + xcodebuild, arm64 simulator, BUILD SUCCEEDED). Three issues surfaced and were fixed: - fireSharedContentReceived used java.lang.reflect + caught NoSuchMethodException, which ParparVM's iOS JavaAPI does not provide (missing header). Replaced the reflection with an instanceof Lifecycle dispatch (onReceivedSharedContent is a Lifecycle method, so this is both correct and complete) in the core impl and the Android impl. - IOSImplementation.runBackgroundProcessing used String.split, which ParparVM does not emit for iOS. Switched to Util.split and replaced the raw control-byte separators with � / � escapes (ASCII-clean source). - CodenameOne_GLAppDelegate.m called IOSNative natives without a visible prototype; added the generated IOSNative.h include and corrected the getPendingSharedContent symbol to the param-aware non-void mangling (..._java_lang_String_R_java_lang_String). The linked arm64 binary contains all new native symbols and the native-retained Java callbacks (notificationPermissionResult, runBackgroundProcessing, fireSharedContentFromNative). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Cloudflare Preview
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
…ugs) - javase-simulator-tests (Ant builds with -source 1.7, which requires captured locals in inner classes to be final): made the `port` parameter final in SimulatorNotifications.buildAndShow. - build-test SpotBugs:check (enforced on core via core-unittests): the two anonymous Runnables in CodenameOneImplementation.fireSharedContentReceived and startForegroundService didn't use the enclosing instance and tripped SIC_INNER_SHOULD_BE_STATIC_ANON. Converted both to named static nested classes (SharedContentDispatch, ForegroundServiceRunner). Validated locally: core spotbugs:check BUILD SUCCESS; core/javase/android compile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Compared 11 screenshots: 11 matched. |
Collaborator
Author
- ClassWithOnlyPrivateConstructorsShouldBeFinal: made BackgroundWork, BackgroundTask and ForegroundService final. - MissingOverride: added @OverRide to run() in the SharedContentDispatch and ForegroundServiceRunner static nested classes.
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
The IOSNative background-processing bridge references BGTaskScheduler / BGProcessingTaskRequest unconditionally. Local builds resolved them via clang module auto-linking, but the CI iOS link (run-ios-ui-tests) does not auto-link, so it failed with "Undefined symbols: _OBJC_CLASS_$_BGTaskScheduler, _OBJC_CLASS_$_BGProcessingTaskRequest". Add BackgroundTasks.framework to the iOS link (addLibs), mirroring how UserNotifications.framework is linked. Validated locally: generated project links BackgroundTasks.framework and the arm64 simulator build links cleanly (BUILD SUCCEEDED). Mirrored to the BuildDaemon IPhoneBuilder.
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
… receiver CodenameOneShareReceiverActivity.addStream had three SpotBugs findings: - RV_RETURN_VALUE_IGNORED_BAD_PRACTICE: File.mkdirs() return ignored. - OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE / OS_OPEN_STREAM_EXCEPTION_PATH: the input/output streams could leak on exception paths (opened before the try, and the finally closed them in a way that could skip one if the other threw). Rewrote to declare both streams up front (null), check mkdirs(), and close each independently in a finally with its own try/catch. Verified locally: android port compiles and spotbugs reports total_bugs=0 (555 classes analyzed), with the three findings gone. Note: Android spotbugs:check is not currently gated in CI (only core-unittests enforces it), which is why these were reported as warnings rather than failing the build.
The quality-report gate applies forbidden_rules to every SpotBugs report (core-unittests, android, ios, plugin, ByteCodeTranslator), but RV_RETURN_VALUE_IGNORED_BAD_PRACTICE, OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE and OS_OPEN_STREAM_EXCEPTION_PATH were not in the set, so the share-receiver findings were reported as warnings instead of failing the build. Add the three rules to forbidden_rules. Verified all five analyzed modules currently report zero occurrences of these rules (so this does not surface pre-existing failures), and the gate will now catch ignored return values and unclosed-stream-on-exception bugs anywhere in core or the ports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




















Modernizes the local-notification, push, background-execution and shared-content APIs across core + JavaSE + Android + iOS, with full simulator support and build automation. The iOS native path was verified by a local Xcode build that links end-to-end (
** BUILD SUCCEEDED **, arm64 simulator).What's added
Notifications (
com.codename1.notifications)Display.requestNotificationPermission(...)withNotificationPermissionRequest(provisional / critical / time-sensitive / POST_NOTIFICATIONS via a UNAuthorizationOptions-matching mask) andNotificationPermissionResult.NotificationChannelBuilder(Android O+ runtime channels: importance, sound, vibration, lights, lockscreen visibility, group, badge) routed throughDisplay.LocalNotificationenriched backward-compatibly: image attachment, multiple action buttons,addInputAction(...)quick reply, per-channel sound, grouping (+ summary), full-screen intent, time-sensitive, ongoing/progress, custom view, andasMessagingStyle(...)conversation style. All existing fields/getters/setters unchanged.PushContentgainsactionTitleso push and local-notification actions surface consistently.Shared content (
com.codename1.share.SharedContent)Lifecycle.onReceivedSharedContent(SharedContent)with text/url/file/image items.Background execution (
com.codename1.background)BackgroundWork.schedule(WorkRequest.builder()...)with constraints (network / unmetered / charging / idle / battery-not-low / periodic / input data) -> AndroidJobScheduler, iOSBGTaskScheduler.ForegroundService.start(...)(Android foreground service running a JVM task with a persistent notification).BackgroundTask.scheduleProcessing(id, earliestBeginDate, ...)-> iOSBGProcessingTaskRequest.Push topics
Push.subscribeToTopic(...)/unsubscribeFromTopic(...)-> FCM on Android; documented no-op on iOS (raw APNs has no topics).Build automation
AndroidGradleBuilder: registers the JobScheduler service, and (gated by classpath scan) the foreground service + permission and the share-receiver intent filters; generated stub captures the app instance, flushes pending shared content, and routes action ids + quick-reply text intoPushContent.IPhoneBuilder: auto-adds theprocessingbackground mode,BGTaskSchedulerPermittedIdentifiers(ios.backgroundProcessingIds), andCN1ShareAppGroup(ios.shareAppGroup).IOSNotificationContentExtensionBuilderemits a.ios.appextnotification content extension (custom-view notifications) following the Add ShareResult callback API + iOS Share Extension authoring helper #5036 pattern.Simulator
Full JavaSE support: a rich notification panel (image / actions / inline quick reply / progress) routing taps to
LocalNotificationCallback+PushContent; functional background work / processing with live constraint gating; foreground service; and a new "Notifications and Background" Simulate menu (constraint toggles, run-work-now, channel inspector, shared-content injection).Verification
build-ios-app.sh(ParparVM translate) +xcodebuild(arm64 simulator) link end-to-end; the binary contains all new native symbols and the native-retained Java callbacks.Notes: no
@since/version tags; ASCII-only sources;getImplementation()kept package-private (narrowDisplaydelegators added).🤖 Generated with Claude Code