Skip to content

Commit acce49d

Browse files
committed
do not reset values for incoming call. solves #572
1 parent 67b3169 commit acce49d

File tree

8 files changed

+46
-8
lines changed

8 files changed

+46
-8
lines changed

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/CallingActivity.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package com.zoffcc.applications.trifa;
2121

22+
import android.annotation.SuppressLint;
2223
import android.annotation.TargetApi;
2324
import android.app.Activity;
2425
import android.app.KeyguardManager;
@@ -1256,43 +1257,53 @@ public void run()
12561257
@Override
12571258
public boolean onTouch(View v, MotionEvent event)
12581259
{
1260+
Log.i(TAG, "accept_button:onTouch:001");
12591261
try
12601262
{
12611263
if (event.getAction() != MotionEvent.ACTION_UP)
12621264
{
1265+
Log.i(TAG, "accept_button:onTouch:002");
12631266
}
12641267
else
12651268
{
1269+
Log.i(TAG, "accept_button:onTouch:003 " + Callstate.accepted_call + " " + Callstate.friend_pubkey);
12661270
if (Callstate.accepted_call != 1)
12671271
{
12681272
Log.i(TAG, "answer button pressed");
1273+
Log.i(TAG, "accept_button:onTouch:004 " + Callstate.audio_call);
12691274

12701275
if (Callstate.audio_call)
12711276
{
12721277
int res1 = toxav_answer(tox_friend_by_public_key__wrapper(Callstate.friend_pubkey),
12731278
GLOBAL_AUDIO_BITRATE, 0);
12741279

1280+
Log.i(TAG, "accept_button:onTouch:004:001" + res1);
12751281
if (res1 != 1)
12761282
{
1283+
Log.i(TAG, "accept_button:onTouch:004:002");
12771284
return true;
12781285
}
12791286
Callstate.tox_call_state = ToxVars.TOXAV_FRIEND_CALL_STATE.TOXAV_FRIEND_CALL_STATE_SENDING_V.value;
1287+
Log.i(TAG, "accept_button:onTouch:004:003");
12801288
}
12811289
else
12821290
{
12831291
int res2 = toxav_answer(tox_friend_by_public_key__wrapper(Callstate.friend_pubkey),
12841292
GLOBAL_AUDIO_BITRATE, GLOBAL_VIDEO_BITRATE);
1293+
Log.i(TAG, "accept_button:onTouch:004:011: " + res2);
12851294

12861295
if (res2 != 1)
12871296
{
1297+
Log.i(TAG, "accept_button:onTouch:004:012");
12881298
return true;
12891299
}
12901300

12911301
Callstate.tox_call_state = ToxVars.TOXAV_FRIEND_CALL_STATE.TOXAV_FRIEND_CALL_STATE_SENDING_V.value;
1292-
1302+
Log.i(TAG, "accept_button:onTouch:004:014");
12931303
}
12941304

12951305
Callstate.accepted_call = 1;
1306+
Log.i(TAG, "accept_button:onTouch:005");
12961307

12971308
caller_avatar_view.setVisibility(View.GONE);
12981309
accept_button.setVisibility(View.GONE);
@@ -1308,8 +1319,12 @@ public boolean onTouch(View v, MotionEvent event)
13081319

13091320
Log.i(TAG, "on_call_started_actions:01");
13101321
on_call_started_actions();
1322+
Log.i(TAG, "accept_button:onTouch:006");
1323+
13111324
if (Callstate.audio_call)
13121325
{
1326+
Log.i(TAG, "accept_button:onTouch:006 " + Callstate.audio_call);
1327+
13131328
toggle_osd_view_including_cam_preview(!Callstate.audio_call);
13141329
}
13151330

@@ -1319,6 +1334,7 @@ public boolean onTouch(View v, MotionEvent event)
13191334
catch (Exception e)
13201335
{
13211336
e.printStackTrace();
1337+
Log.i(TAG, "accept_button:onTouch:006:EE01:" + e.getMessage());
13221338
}
13231339
return true;
13241340
}
@@ -1447,6 +1463,7 @@ else if (PREF__video_cam_resolution == 1)
14471463

14481464
public static void close_calling_activity()
14491465
{
1466+
Log.i(TAG, "reset_values:001");
14501467
Callstate.reset_values();
14511468
// close calling activity --------
14521469
ca.finish();
@@ -1582,6 +1599,7 @@ public static void initializeScreenshotSecurity(Activity a)
15821599
}
15831600
}
15841601

1602+
@SuppressLint("MissingSuperCall")
15851603
@Override
15861604
public void onBackPressed()
15871605
{
@@ -1602,6 +1620,7 @@ protected void onResume()
16021620
super.onResume();
16031621

16041622
tox_set_onion_active(0);
1623+
Callstate.incoming_one_on_one_call = false;
16051624

16061625
try
16071626
{

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/Callstate.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import android.provider.CallLog;
2424
import android.telecom.Call;
25+
import android.util.Log;
2526

2627
import static com.zoffcc.applications.trifa.CallingActivity.set_debug_text;
2728
import static com.zoffcc.applications.trifa.TRIFAGlobals.GLOBAL_AUDIO_BITRATE;
@@ -31,10 +32,13 @@
3132

3233
public class Callstate
3334
{
35+
private static final String TAG = "trifa.Callstate";
36+
3437
static int state = 0; // 0 -> not in a call, 1 -> ringing/calling
3538
static int tox_call_state = ToxVars.TOXAV_FRIEND_CALL_STATE.TOXAV_FRIEND_CALL_STATE_NONE.value;
3639
static boolean audio_call = false;
3740
static String friend_pubkey = "-1";
41+
static boolean incoming_one_on_one_call = false;
3842
static String friend_alias_name = "";
3943
static int other_audio_enabled = 1;
4044
static int other_video_enabled = 1;
@@ -79,7 +83,9 @@ static void reset_values()
7983
Callstate.call_first_audio_frame_received = -1;
8084
Callstate.call_start_timestamp = -1;
8185
Callstate.call_init_timestamp = -1;
86+
Log.i(TAG, "friend_pubkey:set:001");
8287
Callstate.friend_pubkey = "-1";
88+
Callstate.incoming_one_on_one_call = false;
8389
Callstate.friend_alias_name = "";
8490
Callstate.other_audio_enabled = 1;
8591
Callstate.other_video_enabled = 1;

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConfGroupAudioService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ public static void stop_me(boolean stop_full)
538538
Callstate.audio_group_active = false;
539539
if (stop_full)
540540
{
541+
Log.i(TAG, "reset_values:003");
541542
Callstate.reset_values();
542543
}
543544
ConferenceAudioActivity.conf_id = "-1";

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceAudioActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,7 @@ static void on_groupaudio_ended_actions(boolean close)
14891489

14901490
public static void close_conference_audio_activity()
14911491
{
1492+
Log.i(TAG, "reset_values:002");
14921493
Callstate.reset_values();
14931494
conf_id = "-1";
14941495
conf_id_prev = "-1";

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/GroupGroupAudioService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ private static void removeNotification()
474474
}
475475
}
476476

477-
public static void stop_me(boolean stop_full)
477+
public static void stop_me(boolean stop_full, boolean reset_call_values)
478478
{
479479
ngc_running = false;
480480
try
@@ -493,7 +493,11 @@ public static void stop_me(boolean stop_full)
493493
Callstate.audio_ngc_group_active = false;
494494
if (stop_full)
495495
{
496-
Callstate.reset_values();
496+
if (reset_call_values)
497+
{
498+
Log.i(TAG, "reset_values:004");
499+
Callstate.reset_values();
500+
}
497501
}
498502
GroupGroupAudioService.group_id = "-1";
499503
AudioRecording.global_audio_group_send_res = -999;

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/GroupMessageListActivity.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,10 @@ protected void onPause()
16551655
ml_is_recording = false;
16561656
ml_is_rec_ok = false;
16571657

1658-
stop_group_video(this);
1658+
// HINT: here we leave the GroupMessageListActivity
1659+
// but it could be that we are starting the CallingActivity because there is an icoming call
1660+
// then this would reset the values for the incoming call :-(
1661+
stop_group_video(this, !Callstate.incoming_one_on_one_call);
16591662
closeCamera();
16601663
MainActivity.group_message_list_fragment = null;
16611664
MainActivity.group_message_list_activity = null;
@@ -1708,7 +1711,7 @@ protected void onResume()
17081711
// reset update trigger timestamp
17091712
update_group_all_users_last_trigger_ts = 0;
17101713

1711-
stop_group_video(this);
1714+
stop_group_video(this, true);
17121715
closeCamera();
17131716
ngc_video_packet_last_incoming_ts = -1;
17141717
ngc_incoming_video_peer_toggle_current_index = 0;
@@ -3097,7 +3100,7 @@ private Size chooseOptimalSize(Size[] choices, int width, int height) {
30973100
}
30983101
}
30993102

3100-
synchronized public static void stop_group_video(final Context c)
3103+
synchronized public static void stop_group_video(final Context c, boolean reset_call_values)
31013104
{
31023105
ngc_video_showing_video_from_peer_pubkey = "-1";
31033106
NGC_Group_video_play_thread_running = false;
@@ -3109,7 +3112,7 @@ synchronized public static void stop_group_video(final Context c)
31093112
// ---- stop audio stuff
31103113
try
31113114
{
3112-
GroupGroupAudioService.stop_me(true);
3115+
GroupGroupAudioService.stop_me(true, reset_call_values);
31133116
}
31143117
catch (Exception e)
31153118
{
@@ -3851,7 +3854,7 @@ public void toggle_group_video(final View view)
38513854
{
38523855
if (sending_video_to_group)
38533856
{
3854-
stop_group_video(view.getContext());
3857+
stop_group_video(view.getContext(), true);
38553858
closeCamera();
38563859
}
38573860
else

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,7 @@ else if (position == 10)
17291729
last_video_frame_received = -1;
17301730
count_video_frame_received = 0;
17311731
count_video_frame_sent = 0;
1732+
Log.i(TAG, "friend_pubkey:set:002");
17321733
Callstate.friend_pubkey = "-1";
17331734
Callstate.audio_speaker = true;
17341735
Callstate.other_audio_enabled = 1;
@@ -3750,6 +3751,7 @@ public void run()
37503751
}
37513752

37523753
Callstate.state = 1;
3754+
Callstate.incoming_one_on_one_call = true;
37533755
Callstate.accepted_call = 0;
37543756
Callstate.call_first_video_frame_received = -1;
37553757
Callstate.call_first_audio_frame_received = -1;
@@ -3775,6 +3777,7 @@ public void run()
37753777
{
37763778
}
37773779
Intent intent = new Intent(context_s.getApplicationContext(), CallingActivity.class);
3780+
Log.i(TAG, "friend_pubkey:set:003");
37783781
Callstate.friend_pubkey = HelperFriend.tox_friend_get_public_key__wrapper(fn);
37793782
Callstate.friend_alias_name = get_friend_name_from_pubkey(Callstate.friend_pubkey);
37803783
Callstate.other_audio_enabled = f_audio_enabled;

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,7 @@ public void run()
20232023
Callstate.accepted_call = 1; // we started the call, so it's already accepted on our side
20242024
Callstate.call_first_video_frame_received = -1;
20252025
Callstate.call_start_timestamp = -1;
2026+
Log.i(TAG, "friend_pubkey:set:004");
20262027
Callstate.friend_pubkey = tox_friend_get_public_key__wrapper(fn);
20272028
Callstate.camera_opened = false;
20282029
Callstate.audio_speaker = true;

0 commit comments

Comments
 (0)