carp.sensing-flutter
carp.sensing-flutter copied to clipboard
AppTaskControlExecutor seems to run multiple times
It seems like the AppTaskControlExecutor runs multiple time, resulting in several tasks being enqued in the AppTaskController.
Protocol:
// Add a task after deployment and make a notification.
protocol.addTaskControl(
ElapsedTimeTrigger(elapsedTime: const Duration(seconds: 10)),
AppTask(
type: BackgroundSensingUserTask.ONE_TIME_SENSING_TYPE,
title: "Elapsed Time Trigger - App Task",
description: 'Collection of Device Information.',
measures: [Measure(type: DeviceSamplingPackage.DEVICE_INFORMATION)],
notification: true,
),
phone,
);
(from main.dart in example app).
However, it seems like this has no effect on the UI - only one notification is issued...?
Log dump:
[log] [CAMS DEBUG] Persistence - Saving task to database 'OneTimeBackgroundSensingUserTask - id: 13ab2070-1e8b-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 19:07:45.055841Z'.
[log] [CAMS DEBUG] Persistence - Saving task to database 'OneTimeBackgroundSensingUserTask - id: 286e5f90-1e8b-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 19:07:45.055841Z'.
[log] [CAMS DEBUG] AppTaskController - Enqueued OneTimeBackgroundSensingUserTask - id: 286e5f90-1e8b-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 19:07:45.055841Z
D/CompatibilityChangeReporter(21916): Compat change id reported: 160794467; UID 11149; state: ENABLED
[log] [CAMS INFO] Stopping AppTaskControlExecutor [473206463] (initialized)
[log] [CAMS DEBUG] FlutterLocalNotificationController - Notification scheduled for OneTimeBackgroundSensingUserTask - id: 13ab2070-1e8b-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 19:07:45.055841Z at 2024-04-24 21:07:45.055841+0200
[log] [CAMS INFO] Stopping AppTaskControlExecutor [473206463] (stopped)
[log] [CAMS WARNING] Trying to stop a AppTaskControlExecutor but it is already stopped. Ignoring this.
[log] [CAMS DEBUG] FlutterLocalNotificationController - Notification scheduled for OneTimeBackgroundSensingUserTask - id: 286e5f90-1e8b-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 19:07:45.055841Z at 2024-04-24 21:07:45.055841+0200
[log] [CAMS INFO] Starting AppTaskControlExecutor [473206463] (started)
[log] [CAMS INFO] Stopping AppTaskControlExecutor [473206463] (started)
[log] [CAMS INFO] Starting AppTaskControlExecutor [473206463] (started)
[log] [CAMS INFO] Stopping AppTaskControlExecutor [473206463] (started)
[log] [CAMS INFO] Starting AppTaskExecutor<AppTask> [272358210] (initialized)
[log] [CAMS DEBUG] AppTaskController - Enqueued OneTimeBackgroundSensingUserTask - id: 344c4770-1ea2-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 21:07:45.074747
I/flutter (21916): {
I/flutter (21916): "sensorStartTime": 1713985665072624,
I/flutter (21916): "data": {
I/flutter (21916): "__type": "dk.cachet.carp.triggeredtask",
I/flutter (21916): "triggerId": 0,
I/flutter (21916): "taskName": "Task #7",
I/flutter (21916): "destinationDeviceRoleName": "Primary Phone",
I/flutter (21916): "control": "Start"
I/flutter (21916): }
I/flutter (21916): }
[log] [CAMS DEBUG] Persistence - Saving task to database 'OneTimeBackgroundSensingUserTask - id: 344c4770-1ea2-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 21:07:45.074747'.
[log] [CAMS INFO] FlutterLocalNotificationController - Notification created for OneTimeBackgroundSensingUserTask - id: 344c4770-1ea2-1f8f-8b34-b3831077c7f4, type: one_time_sensing, title: Elapsed Time Trigger - App Task, state: UserTaskState.enqueued, triggerTime: 2024-04-24 21:07:45.074747
[log] [CAMS DEBUG] SQLiteDataManager - wrote measurement to SQLite - id: 28, type: dk.cachet.carp.triggeredtask, device role name: Primary Phone.