From 64b79b8ce37ba3b960c4b6b3302cbccfc5bc4c8b Mon Sep 17 00:00:00 2001 From: Grigory Entin Date: Sun, 18 Aug 2024 21:54:38 +0200 Subject: [PATCH] Enabled primitive optimistic call handling. --- WatchApp/resources/properties.xml | 6 ++++++ .../source/BusinessLogic/CallActionTask.mc | 9 +++++++-- .../source/BusinessLogic/ScheduleCallTask.mc | 3 +-- WatchApp/source/CallStates/CallActing.mc | 18 +++++++++++++++++- WatchApp/source/CallStates/SchedulingCall.mc | 4 ++++ WatchApp/source/Utilities/Settings.mc | 1 + 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/WatchApp/resources/properties.xml b/WatchApp/resources/properties.xml index 46b3e06c..a47a95b5 100644 --- a/WatchApp/resources/properties.xml +++ b/WatchApp/resources/properties.xml @@ -21,6 +21,7 @@ v3;p3;v3;p3 <;>;app false + true @@ -45,6 +46,7 @@ means 'vibrate 3s, pause 1s, vibrate 3s, pause 2s') Verbose logs Flush incoming messages on launch + Optimistic call handling @@ -62,6 +64,10 @@ title="@Strings.incomingCallMessageFormat"> + + + diff --git a/WatchApp/source/BusinessLogic/CallActionTask.mc b/WatchApp/source/BusinessLogic/CallActionTask.mc index 3cd97477..a9244d19 100644 --- a/WatchApp/source/BusinessLogic/CallActionTask.mc +++ b/WatchApp/source/BusinessLogic/CallActionTask.mc @@ -54,8 +54,13 @@ class CallActionTask extends Communications.ConnectionListener { _3(L_CALL_ACTION, "onComplete.callStateInvalidated", oldState); return; } - var newState = oldState.clone(); - newState.commStatus = SUCCEEDED; + var newState; + if (AppSettings.isOptimisticCallHandlingEnabled) { + newState = oldState.wouldBeNextState(); + } else { + newState = oldState.clone(); + newState.commStatus = SUCCEEDED; + } setCallState(newState); } diff --git a/WatchApp/source/BusinessLogic/ScheduleCallTask.mc b/WatchApp/source/BusinessLogic/ScheduleCallTask.mc index 0b51ff9b..32e6afaa 100644 --- a/WatchApp/source/BusinessLogic/ScheduleCallTask.mc +++ b/WatchApp/source/BusinessLogic/ScheduleCallTask.mc @@ -30,8 +30,7 @@ class ScheduleCallTask extends Communications.ConnectionListener { _3(L_SCHEDULE_CALL, "onComplete.callStateInvalidated", oldState); return; } - var newState = oldState.clone(); - newState.commStatus = SUCCEEDED; + var newState = oldState.wouldBeNextState(); setCallState(newState); } diff --git a/WatchApp/source/CallStates/CallActing.mc b/WatchApp/source/CallStates/CallActing.mc index 2182374b..1fa1b040 100644 --- a/WatchApp/source/CallStates/CallActing.mc +++ b/WatchApp/source/CallStates/CallActing.mc @@ -11,6 +11,10 @@ class HangingUp extends CallActing { return new HangingUp(phone, commStatus); } + function wouldBeNextState() as CallState { + return new Idle(); + } + function stateId() as Lang.String { return "hangingUp"; } @@ -26,6 +30,10 @@ class Declining extends CallActing { return new Declining(phone, commStatus); } + function wouldBeNextState() as CallState { + return new Idle(); + } + function stateId() as Lang.String { return "declining"; } @@ -41,6 +49,10 @@ class Accepting extends CallActing { return new Accepting(phone, commStatus); } + function wouldBeNextState() as CallState { + return new CallInProgress(phone); + } + function stateId() as Lang.String { return "accepting"; } @@ -58,7 +70,11 @@ class CallActing extends CallStateImp { } function clone() as CallActing { - return new CallActing(phone, commStatus); + System.error("CallActing.clone() must be overridden"); + } + + function wouldBeNextState() as CallState { + System.error("CallActing.wouldBeNextState() must be overridden"); } function stateId() as Lang.String { diff --git a/WatchApp/source/CallStates/SchedulingCall.mc b/WatchApp/source/CallStates/SchedulingCall.mc index 8918ea4d..48577c41 100644 --- a/WatchApp/source/CallStates/SchedulingCall.mc +++ b/WatchApp/source/CallStates/SchedulingCall.mc @@ -15,6 +15,10 @@ class SchedulingCall extends CallStateImp { return new SchedulingCall(phone, commStatus); } + function wouldBeNextState() as CallInProgress { + return new CallInProgress(phone); + } + function toString() as Lang.String { return "SchedulingCall(" + phone + ", " + commStatus + ")"; } diff --git a/WatchApp/source/Utilities/Settings.mc b/WatchApp/source/Utilities/Settings.mc index 5b6479e5..7aba306f 100644 --- a/WatchApp/source/Utilities/Settings.mc +++ b/WatchApp/source/Utilities/Settings.mc @@ -17,6 +17,7 @@ module AppSettings { const initialAttemptsToCheckin as Lang.Number = Application.Properties.getValue("syncAttempts") as Lang.Number; const initialSecondsToCheckin as Lang.Number = Application.Properties.getValue("secondsToCheckIn") as Lang.Number; const isSyncingCallStateOnCheckinEnabled as Lang.Boolean = Application.Properties.getValue("syncCallStateOnLaunch") as Lang.Boolean; + const isOptimisticCallHandlingEnabled as Lang.Boolean = Application.Properties.getValue("optimisticCallHandling") as Lang.Boolean; const isExitToSystemAfterCallCompletionEnabled as Lang.Boolean = Application.Properties.getValue("popOutOfAppInsteadOfPhones") as Lang.Boolean; const isBeepOnCommuncationEnabled as Lang.Boolean = Application.Properties.getValue("beepOnComm") as Lang.Boolean;