2016-11-09 09:37:40 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Open Whisper Systems
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2017-11-24 22:00:30 -08:00
|
|
|
import android.Manifest;
|
2016-11-09 09:37:40 -08:00
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface.OnClickListener;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.res.Configuration;
|
|
|
|
import android.media.AudioManager;
|
|
|
|
import android.os.Bundle;
|
2020-08-19 10:06:26 +10:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2016-11-09 09:37:40 -08:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.Window;
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
2017-02-17 20:27:11 -08:00
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
2017-11-19 16:24:30 -08:00
|
|
|
import org.thoughtcrime.securesms.components.webrtc.WebRtcAnswerDeclineButton;
|
2016-11-09 09:37:40 -08:00
|
|
|
import org.thoughtcrime.securesms.components.webrtc.WebRtcCallControls;
|
|
|
|
import org.thoughtcrime.securesms.components.webrtc.WebRtcCallScreen;
|
2017-05-19 18:01:40 -07:00
|
|
|
import org.thoughtcrime.securesms.crypto.storage.TextSecureIdentityKeyStore;
|
2017-02-02 18:34:51 -08:00
|
|
|
import org.thoughtcrime.securesms.events.WebRtcViewModel;
|
2019-07-24 12:30:23 +10:00
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
2017-11-24 22:00:30 -08:00
|
|
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
2016-11-09 09:37:40 -08:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
|
|
import org.thoughtcrime.securesms.service.WebRtcCallService;
|
2017-02-03 12:00:00 -08:00
|
|
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
2016-11-09 09:37:40 -08:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
|
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
|
|
|
import org.whispersystems.libsignal.IdentityKey;
|
2017-05-19 18:01:40 -07:00
|
|
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2017-05-19 18:01:40 -07:00
|
|
|
import static org.whispersystems.libsignal.SessionCipher.SESSION_LOCK;
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
public class WebRtcCallActivity extends Activity {
|
|
|
|
|
|
|
|
private static final String TAG = WebRtcCallActivity.class.getSimpleName();
|
|
|
|
|
|
|
|
private static final int STANDARD_DELAY_FINISH = 1000;
|
|
|
|
public static final int BUSY_SIGNAL_DELAY_FINISH = 5500;
|
|
|
|
|
|
|
|
public static final String ANSWER_ACTION = WebRtcCallActivity.class.getCanonicalName() + ".ANSWER_ACTION";
|
|
|
|
public static final String DENY_ACTION = WebRtcCallActivity.class.getCanonicalName() + ".DENY_ACTION";
|
|
|
|
public static final String END_CALL_ACTION = WebRtcCallActivity.class.getCanonicalName() + ".END_CALL_ACTION";
|
|
|
|
|
2017-02-03 11:03:56 -08:00
|
|
|
private WebRtcCallScreen callScreen;
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "onCreate()");
|
2016-11-09 09:37:40 -08:00
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
2017-02-02 19:02:26 -08:00
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
2016-11-09 09:37:40 -08:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
|
|
setContentView(R.layout.webrtc_call_activity);
|
|
|
|
|
|
|
|
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
|
|
|
|
|
|
|
initializeResources();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "onResume()");
|
2016-11-09 09:37:40 -08:00
|
|
|
super.onResume();
|
|
|
|
initializeScreenshotSecurity();
|
2017-02-17 20:27:11 -08:00
|
|
|
EventBus.getDefault().register(this);
|
2016-11-09 09:37:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNewIntent(Intent intent){
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "onNewIntent");
|
2016-11-09 09:37:40 -08:00
|
|
|
if (ANSWER_ACTION.equals(intent.getAction())) {
|
|
|
|
handleAnswerCall();
|
|
|
|
} else if (DENY_ACTION.equals(intent.getAction())) {
|
|
|
|
handleDenyCall();
|
|
|
|
} else if (END_CALL_ACTION.equals(intent.getAction())) {
|
|
|
|
handleEndCall();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPause() {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "onPause");
|
2016-11-09 09:37:40 -08:00
|
|
|
super.onPause();
|
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfiguration) {
|
|
|
|
super.onConfigurationChanged(newConfiguration);
|
|
|
|
}
|
|
|
|
|
2017-11-24 22:00:30 -08:00
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
|
|
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
|
|
|
}
|
|
|
|
|
2016-11-09 09:37:40 -08:00
|
|
|
private void initializeScreenshotSecurity() {
|
2019-03-20 15:09:27 -07:00
|
|
|
if (TextSecurePreferences.isScreenSecurityEnabled(this)) {
|
2016-11-09 09:37:40 -08:00
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
|
|
} else {
|
|
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initializeResources() {
|
|
|
|
callScreen = ViewUtil.findById(this, R.id.callScreen);
|
|
|
|
callScreen.setHangupButtonListener(new HangupButtonListener());
|
|
|
|
callScreen.setIncomingCallActionListener(new IncomingCallActionListener());
|
|
|
|
callScreen.setAudioMuteButtonListener(new AudioMuteButtonListener());
|
|
|
|
callScreen.setVideoMuteButtonListener(new VideoMuteButtonListener());
|
2018-03-23 20:31:03 +01:00
|
|
|
callScreen.setCameraFlipButtonListener(new CameraFlipButtonListener());
|
2017-03-04 15:48:10 -08:00
|
|
|
callScreen.setSpeakerButtonListener(new SpeakerButtonListener());
|
|
|
|
callScreen.setBluetoothButtonListener(new BluetoothButtonListener());
|
2016-11-09 09:37:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void handleSetMuteAudio(boolean enabled) {
|
|
|
|
Intent intent = new Intent(this, WebRtcCallService.class);
|
|
|
|
intent.setAction(WebRtcCallService.ACTION_SET_MUTE_AUDIO);
|
|
|
|
intent.putExtra(WebRtcCallService.EXTRA_MUTE, enabled);
|
|
|
|
startService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleSetMuteVideo(boolean muted) {
|
|
|
|
Intent intent = new Intent(this, WebRtcCallService.class);
|
|
|
|
intent.setAction(WebRtcCallService.ACTION_SET_MUTE_VIDEO);
|
|
|
|
intent.putExtra(WebRtcCallService.EXTRA_MUTE, muted);
|
|
|
|
startService(intent);
|
|
|
|
}
|
|
|
|
|
2018-04-25 11:00:03 -07:00
|
|
|
private void handleFlipCamera() {
|
2018-03-23 20:31:03 +01:00
|
|
|
Intent intent = new Intent(this, WebRtcCallService.class);
|
2018-04-25 11:00:03 -07:00
|
|
|
intent.setAction(WebRtcCallService.ACTION_FLIP_CAMERA);
|
2018-03-23 20:31:03 +01:00
|
|
|
startService(intent);
|
|
|
|
}
|
|
|
|
|
2016-11-09 09:37:40 -08:00
|
|
|
private void handleAnswerCall() {
|
2017-02-02 18:34:51 -08:00
|
|
|
WebRtcViewModel event = EventBus.getDefault().getStickyEvent(WebRtcViewModel.class);
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
if (event != null) {
|
2017-11-24 22:00:30 -08:00
|
|
|
Permissions.with(this)
|
|
|
|
.request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
|
|
|
|
.withRationaleDialog(getString(R.string.WebRtcCallActivity_to_answer_the_call_from_s_give_signal_access_to_your_microphone, event.getRecipient().toShortString()),
|
|
|
|
R.drawable.ic_mic_white_48dp, R.drawable.ic_videocam_white_48dp)
|
|
|
|
.withPermanentDenialDialog(getString(R.string.WebRtcCallActivity_signal_requires_microphone_and_camera_permissions_in_order_to_make_or_receive_calls))
|
|
|
|
.onAllGranted(() -> {
|
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_answering));
|
|
|
|
|
|
|
|
Intent intent = new Intent(this, WebRtcCallService.class);
|
|
|
|
intent.setAction(WebRtcCallService.ACTION_ANSWER_CALL);
|
|
|
|
startService(intent);
|
|
|
|
})
|
|
|
|
.onAnyDenied(this::handleDenyCall)
|
|
|
|
.execute();
|
2016-11-09 09:37:40 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleDenyCall() {
|
2017-02-02 18:34:51 -08:00
|
|
|
WebRtcViewModel event = EventBus.getDefault().getStickyEvent(WebRtcViewModel.class);
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
if (event != null) {
|
|
|
|
Intent intent = new Intent(this, WebRtcCallService.class);
|
|
|
|
intent.setAction(WebRtcCallService.ACTION_DENY_CALL);
|
|
|
|
startService(intent);
|
|
|
|
|
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_ending_call));
|
|
|
|
delayedFinish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleEndCall() {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "Hangup pressed, handling termination now...");
|
2016-11-09 09:37:40 -08:00
|
|
|
Intent intent = new Intent(WebRtcCallActivity.this, WebRtcCallService.class);
|
|
|
|
intent.setAction(WebRtcCallService.ACTION_LOCAL_HANGUP);
|
|
|
|
startService(intent);
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleIncomingCall(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
callScreen.setIncomingCall(event.getRecipient());
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleOutgoingCall(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_dialing));
|
|
|
|
}
|
|
|
|
|
|
|
|
private void handleTerminate(@NonNull Recipient recipient /*, int terminationType */) {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "handleTerminate called");
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
callScreen.setActiveCall(recipient, getString(R.string.RedPhone_ending_call));
|
2017-02-02 18:34:51 -08:00
|
|
|
EventBus.getDefault().removeStickyEvent(WebRtcViewModel.class);
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
delayedFinish();
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleCallRinging(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_ringing));
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleCallBusy(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_busy));
|
|
|
|
|
|
|
|
delayedFinish(BUSY_SIGNAL_DELAY_FINISH);
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleCallConnected(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES);
|
2019-01-29 14:25:49 -08:00
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_connected), "", event.getLocalRenderer(), event.getRemoteRenderer());
|
2016-11-09 09:37:40 -08:00
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleRecipientUnavailable(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_recipient_unavailable));
|
|
|
|
delayedFinish();
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleServerFailure(@NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
callScreen.setActiveCall(event.getRecipient(), getString(R.string.RedPhone_network_failed));
|
|
|
|
delayedFinish();
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleNoSuchUser(final @NonNull WebRtcViewModel event) {
|
2016-11-09 09:37:40 -08:00
|
|
|
if (isFinishing()) return; // XXX Stuart added this check above, not sure why, so I'm repeating in ignorance. - moxie
|
|
|
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
|
|
|
dialog.setTitle(R.string.RedPhone_number_not_registered);
|
|
|
|
dialog.setIconAttribute(R.attr.dialog_alert_icon);
|
|
|
|
dialog.setMessage(R.string.RedPhone_the_number_you_dialed_does_not_support_secure_voice);
|
|
|
|
dialog.setCancelable(true);
|
|
|
|
dialog.setPositiveButton(R.string.RedPhone_got_it, new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
WebRtcCallActivity.this.handleTerminate(event.getRecipient());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
|
|
@Override
|
|
|
|
public void onCancel(DialogInterface dialog) {
|
|
|
|
WebRtcCallActivity.this.handleTerminate(event.getRecipient());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
private void handleUntrustedIdentity(@NonNull WebRtcViewModel event) {
|
|
|
|
final IdentityKey theirIdentity = event.getIdentityKey();
|
2016-11-09 09:37:40 -08:00
|
|
|
final Recipient recipient = event.getRecipient();
|
|
|
|
|
|
|
|
callScreen.setUntrustedIdentity(recipient, theirIdentity);
|
|
|
|
callScreen.setAcceptIdentityListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2017-05-19 18:01:40 -07:00
|
|
|
synchronized (SESSION_LOCK) {
|
2017-05-30 18:30:37 -07:00
|
|
|
TextSecureIdentityKeyStore identityKeyStore = new TextSecureIdentityKeyStore(WebRtcCallActivity.this);
|
2017-07-26 09:59:15 -07:00
|
|
|
identityKeyStore.saveIdentity(new SignalProtocolAddress(recipient.getAddress().serialize(), 1), theirIdentity, true);
|
2017-05-19 18:01:40 -07:00
|
|
|
}
|
2016-11-09 09:37:40 -08:00
|
|
|
|
|
|
|
Intent intent = new Intent(WebRtcCallActivity.this, WebRtcCallService.class);
|
2017-07-26 09:59:15 -07:00
|
|
|
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_ADDRESS, recipient.getAddress());
|
2016-11-09 09:37:40 -08:00
|
|
|
intent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL);
|
|
|
|
startService(intent);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
callScreen.setCancelIdentityButton(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
handleTerminate(recipient);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void delayedFinish() {
|
|
|
|
delayedFinish(STANDARD_DELAY_FINISH);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void delayedFinish(int delayMillis) {
|
|
|
|
callScreen.postDelayed(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
WebRtcCallActivity.this.finish();
|
|
|
|
}
|
|
|
|
}, delayMillis);
|
|
|
|
}
|
|
|
|
|
2017-02-17 20:27:11 -08:00
|
|
|
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
|
2017-02-02 18:34:51 -08:00
|
|
|
public void onEventMainThread(final WebRtcViewModel event) {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "Got message from service: " + event);
|
2016-11-09 09:37:40 -08:00
|
|
|
|
2017-02-02 18:34:51 -08:00
|
|
|
switch (event.getState()) {
|
2016-11-09 09:37:40 -08:00
|
|
|
case CALL_CONNECTED: handleCallConnected(event); break;
|
2017-02-02 18:34:51 -08:00
|
|
|
case NETWORK_FAILURE: handleServerFailure(event); break;
|
2016-11-09 09:37:40 -08:00
|
|
|
case CALL_RINGING: handleCallRinging(event); break;
|
|
|
|
case CALL_DISCONNECTED: handleTerminate(event.getRecipient()); break;
|
|
|
|
case NO_SUCH_USER: handleNoSuchUser(event); break;
|
|
|
|
case RECIPIENT_UNAVAILABLE: handleRecipientUnavailable(event); break;
|
2017-02-02 18:34:51 -08:00
|
|
|
case CALL_INCOMING: handleIncomingCall(event); break;
|
|
|
|
case CALL_OUTGOING: handleOutgoingCall(event); break;
|
2016-11-09 09:37:40 -08:00
|
|
|
case CALL_BUSY: handleCallBusy(event); break;
|
|
|
|
case UNTRUSTED_IDENTITY: handleUntrustedIdentity(event); break;
|
|
|
|
}
|
2017-02-02 18:34:51 -08:00
|
|
|
|
|
|
|
callScreen.setRemoteVideoEnabled(event.isRemoteVideoEnabled());
|
2017-03-04 15:48:10 -08:00
|
|
|
callScreen.updateAudioState(event.isBluetoothAvailable(), event.isMicrophoneEnabled());
|
|
|
|
callScreen.setControlsEnabled(event.getState() != WebRtcViewModel.State.CALL_INCOMING);
|
2018-04-25 11:00:03 -07:00
|
|
|
callScreen.setLocalVideoState(event.getLocalCameraState());
|
2016-11-09 09:37:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private class HangupButtonListener implements WebRtcCallScreen.HangupButtonListener {
|
|
|
|
public void onClick() {
|
|
|
|
handleEndCall();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class AudioMuteButtonListener implements WebRtcCallControls.MuteButtonListener {
|
|
|
|
@Override
|
|
|
|
public void onToggle(boolean isMuted) {
|
|
|
|
WebRtcCallActivity.this.handleSetMuteAudio(isMuted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class VideoMuteButtonListener implements WebRtcCallControls.MuteButtonListener {
|
|
|
|
@Override
|
|
|
|
public void onToggle(boolean isMuted) {
|
|
|
|
WebRtcCallActivity.this.handleSetMuteVideo(isMuted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-23 20:31:03 +01:00
|
|
|
private class CameraFlipButtonListener implements WebRtcCallControls.CameraFlipButtonListener {
|
|
|
|
@Override
|
2018-04-25 11:00:03 -07:00
|
|
|
public void onToggle() {
|
|
|
|
WebRtcCallActivity.this.handleFlipCamera();
|
|
|
|
}
|
2018-03-23 20:31:03 +01:00
|
|
|
}
|
|
|
|
|
2017-03-04 15:48:10 -08:00
|
|
|
private class SpeakerButtonListener implements WebRtcCallControls.SpeakerButtonListener {
|
|
|
|
@Override
|
|
|
|
public void onSpeakerChange(boolean isSpeaker) {
|
|
|
|
AudioManager audioManager = ServiceUtil.getAudioManager(WebRtcCallActivity.this);
|
|
|
|
audioManager.setSpeakerphoneOn(isSpeaker);
|
2017-02-03 12:00:00 -08:00
|
|
|
|
2017-03-04 15:48:10 -08:00
|
|
|
if (isSpeaker && audioManager.isBluetoothScoOn()) {
|
|
|
|
audioManager.stopBluetoothSco();
|
|
|
|
audioManager.setBluetoothScoOn(false);
|
2017-02-03 12:00:00 -08:00
|
|
|
}
|
2017-03-04 15:48:10 -08:00
|
|
|
}
|
2017-02-03 12:00:00 -08:00
|
|
|
}
|
|
|
|
|
2017-03-04 15:48:10 -08:00
|
|
|
private class BluetoothButtonListener implements WebRtcCallControls.BluetoothButtonListener {
|
2016-11-09 09:37:40 -08:00
|
|
|
@Override
|
2017-03-04 15:48:10 -08:00
|
|
|
public void onBluetoothChange(boolean isBluetooth) {
|
|
|
|
AudioManager audioManager = ServiceUtil.getAudioManager(WebRtcCallActivity.this);
|
|
|
|
|
|
|
|
if (isBluetooth) {
|
|
|
|
audioManager.startBluetoothSco();
|
|
|
|
audioManager.setBluetoothScoOn(true);
|
|
|
|
} else {
|
|
|
|
audioManager.stopBluetoothSco();
|
|
|
|
audioManager.setBluetoothScoOn(false);
|
2016-11-09 09:37:40 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-19 16:24:30 -08:00
|
|
|
private class IncomingCallActionListener implements WebRtcAnswerDeclineButton.AnswerDeclineListener {
|
2016-11-09 09:37:40 -08:00
|
|
|
@Override
|
2017-11-19 16:24:30 -08:00
|
|
|
public void onAnswered() {
|
2016-11-09 09:37:40 -08:00
|
|
|
WebRtcCallActivity.this.handleAnswerCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-11-19 16:24:30 -08:00
|
|
|
public void onDeclined() {
|
2016-11-09 09:37:40 -08:00
|
|
|
WebRtcCallActivity.this.handleDenyCall();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|