From e9e1e7aa39ff15cea61ae731afdba17549f125df Mon Sep 17 00:00:00 2001 From: Saeed Rezaee Date: Tue, 12 Nov 2024 16:54:50 +0100 Subject: [PATCH] Remove redundant parameter from Authorization states Remove forced flag from WaitingUpdateAuthorization and WaitingDownloadAuthorization States, as these states are only triggered during soft updates and are never applicable for forced updates. Signed-off-by: Saeed Rezaee Signed-off-by: Saeed Rezaee --- .../org/eclipse/hara/ddiclient/api/MessageListener.kt | 6 ++---- .../eclipse/hara/ddiclient/api/actors/DownloadManager.kt | 3 +-- .../org/eclipse/hara/ddiclient/api/actors/UpdateManager.kt | 5 ++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hara-ddiclient-api/src/main/kotlin/org/eclipse/hara/ddiclient/api/MessageListener.kt b/hara-ddiclient-api/src/main/kotlin/org/eclipse/hara/ddiclient/api/MessageListener.kt index d6013ab..7437cb2 100644 --- a/hara-ddiclient-api/src/main/kotlin/org/eclipse/hara/ddiclient/api/MessageListener.kt +++ b/hara-ddiclient-api/src/main/kotlin/org/eclipse/hara/ddiclient/api/MessageListener.kt @@ -59,15 +59,13 @@ interface MessageListener { /** * Client is waiting for the authorization to start downloading - * @property forcedDownload: if true, immediate download is requested from server */ - class WaitingDownloadAuthorization(val forcedDownload:Boolean) : State("Waiting authorization to start download") + object WaitingDownloadAuthorization : State("Waiting authorization to start download") /** * Client is waiting for the authorization to start updating - * @property forcedUpdate: if true, immediate update is requested from server */ - class WaitingUpdateAuthorization(val forcedUpdate:Boolean) : State("Waiting authorization to start update") + object WaitingUpdateAuthorization : State("Waiting authorization to start update") /** * Client is waiting for new requests from server diff --git a/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/DownloadManager.kt b/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/DownloadManager.kt index 85989f3..2495590 100644 --- a/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/DownloadManager.kt +++ b/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/DownloadManager.kt @@ -93,8 +93,7 @@ private constructor(scope: ActorScope) : AbstractActor(scope) { waitingAuthJob?.cancel() waitingAuthJob = launch { softRequest.onAuthorizationReceive(onWaitForAuthorization = { - notificationManager.send(MessageListener.Message.State - .WaitingDownloadAuthorization(false)) + notificationManager.send(MessageListener.Message.State.WaitingDownloadAuthorization) }, onGrantAuthorization = { channel.send(Message.DownloadGranted) }) diff --git a/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/UpdateManager.kt b/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/UpdateManager.kt index a7b248a..3ee2187 100644 --- a/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/UpdateManager.kt +++ b/src/main/kotlin/org/eclipse/hara/ddiclient/api/actors/UpdateManager.kt @@ -103,14 +103,13 @@ private constructor(scope: ActorScope) : AbstractActor(scope) { return "Start updating the device" } - private suspend fun attemptUpdateDevice(state: State): String { + private fun attemptUpdateDevice(state: State): String { become(waitingUpdateAuthorization(state)) waitingAuthJob = launch { softRequest.onAuthorizationReceive( onWaitForAuthorization = { notificationManager.send( - MessageListener.Message.State.WaitingUpdateAuthorization( - state.isUpdateForced)) + MessageListener.Message.State.WaitingUpdateAuthorization) }, onGrantAuthorization = { channel.send(Message.UpdateGranted) })