Skip to content

Commit

Permalink
Remove redundant parameter from Authorization states
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Saeed Rezaee <[email protected]>
  • Loading branch information
SaeedRe committed Nov 12, 2024
1 parent a79b11c commit e9e1e7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit e9e1e7a

Please sign in to comment.