Skip to content

Commit

Permalink
Enabled primitive optimistic call handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
grigorye committed Aug 19, 2024
1 parent 971fa8e commit 64b79b8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions WatchApp/resources/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<property id="incomingCallVibration" type="string">v3;p3;v3;p3</property>
<property id="forcedLogComponents" type="string">&lt;;&gt;;app</property>
<property id="forceLogAll" type="boolean">false</property>
<property id="optimisticCallHandling" type="boolean">true</property>
</properties>

<strings>
Expand All @@ -45,6 +46,7 @@
means 'vibrate 3s, pause 1s, vibrate 3s, pause 2s')</string>
<string id="forceLogAll">Verbose logs</string>
<string id="flushIncomingMessagesOnLaunch">Flush incoming messages on launch</string>
<string id="optimisticCallHandling">Optimistic call handling</string>
</strings>

<settings>
Expand All @@ -62,6 +64,10 @@
title="@Strings.incomingCallMessageFormat">
<settingConfig type="alphaNumeric" />
</setting>
<setting propertyKey="@Properties.optimisticCallHandling"
title="@Strings.optimisticCallHandling">
<settingConfig type="boolean" />
</setting>
<setting propertyKey="@Properties.beepOnComm" title="@Strings.beepOnComm">
<settingConfig type="boolean" />
</setting>
Expand Down
9 changes: 7 additions & 2 deletions WatchApp/source/BusinessLogic/CallActionTask.mc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions WatchApp/source/BusinessLogic/ScheduleCallTask.mc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
18 changes: 17 additions & 1 deletion WatchApp/source/CallStates/CallActing.mc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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";
}
Expand All @@ -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";
}
Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions WatchApp/source/CallStates/SchedulingCall.mc
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ")";
}
Expand Down
1 change: 1 addition & 0 deletions WatchApp/source/Utilities/Settings.mc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 64b79b8

Please sign in to comment.