Added missing dialog when SAS is denied in chat room security process call
This commit is contained in:
parent
d1820168dd
commit
f35380958d
6 changed files with 128 additions and 35 deletions
|
@ -193,6 +193,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
private MediaPlayer mRingerPlayer;
|
||||
private final Vibrator mVibrator;
|
||||
private boolean mIsRinging;
|
||||
private boolean mHasLastCallSasBeenRejected;
|
||||
|
||||
private LinphoneManager(Context c) {
|
||||
mUnreadChatsPerRoom = new HashMap();
|
||||
|
@ -220,6 +221,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
mSensorManager = (SensorManager) c.getSystemService(Context.SENSOR_SERVICE);
|
||||
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
mRessources = c.getResources();
|
||||
mHasLastCallSasBeenRejected = false;
|
||||
|
||||
File f = new File(mUserCertsPath);
|
||||
if (!f.exists()) {
|
||||
|
@ -493,13 +495,42 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
newOutgoingCall(to, address.getDisplayedName());
|
||||
}
|
||||
|
||||
public void newOutgoingCall(String to, String displayName) {
|
||||
// if (mCore.inCall()) {
|
||||
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
|
||||
// return;
|
||||
// }
|
||||
public void newOutgoingCall(Address to) {
|
||||
if (to == null) return;
|
||||
|
||||
ProxyConfig lpc = mCore.getDefaultProxyConfig();
|
||||
if (mRessources.getBoolean(R.bool.forbid_self_call)
|
||||
&& lpc != null
|
||||
&& to.weakEqual(lpc.getIdentityAddress())) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isLowBandwidthConnection =
|
||||
!LinphoneUtils.isHighBandwidthConnection(
|
||||
LinphoneService.instance().getApplicationContext());
|
||||
|
||||
if (mCore.isNetworkReachable()) {
|
||||
if (Version.isVideoCapable()) {
|
||||
boolean prefVideoEnable = mPrefs.isVideoEnabled();
|
||||
boolean prefInitiateWithVideo = mPrefs.shouldInitiateVideoCall();
|
||||
CallManager.getInstance()
|
||||
.inviteAddress(
|
||||
to,
|
||||
prefVideoEnable && prefInitiateWithVideo,
|
||||
isLowBandwidthConnection);
|
||||
} else {
|
||||
CallManager.getInstance().inviteAddress(to, false, isLowBandwidthConnection);
|
||||
}
|
||||
} else if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance()
|
||||
.displayCustomToast(
|
||||
getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
||||
} else {
|
||||
Log.e("[Manager] Error: " + getString(R.string.error_network_unreachable));
|
||||
}
|
||||
}
|
||||
|
||||
public void newOutgoingCall(String to, String displayName) {
|
||||
// If to is only a username, try to find the contact to get an alias if existing
|
||||
if (!to.startsWith("sip:") || !to.contains("@")) {
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromPhoneNumber(to);
|
||||
|
@ -518,37 +549,9 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
return;
|
||||
}
|
||||
|
||||
ProxyConfig lpc = mCore.getDefaultProxyConfig();
|
||||
if (mRessources.getBoolean(R.bool.forbid_self_call)
|
||||
&& lpc != null
|
||||
&& lAddress.weakEqual(lpc.getIdentityAddress())) {
|
||||
return;
|
||||
}
|
||||
lAddress.setDisplayName(displayName);
|
||||
if (displayName != null) lAddress.setDisplayName(displayName);
|
||||
|
||||
boolean isLowBandwidthConnection =
|
||||
!LinphoneUtils.isHighBandwidthConnection(
|
||||
LinphoneService.instance().getApplicationContext());
|
||||
|
||||
if (mCore.isNetworkReachable()) {
|
||||
if (Version.isVideoCapable()) {
|
||||
boolean prefVideoEnable = mPrefs.isVideoEnabled();
|
||||
boolean prefInitiateWithVideo = mPrefs.shouldInitiateVideoCall();
|
||||
CallManager.getInstance()
|
||||
.inviteAddress(
|
||||
lAddress,
|
||||
prefVideoEnable && prefInitiateWithVideo,
|
||||
isLowBandwidthConnection);
|
||||
} else {
|
||||
CallManager.getInstance().inviteAddress(lAddress, false, isLowBandwidthConnection);
|
||||
}
|
||||
} else if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance()
|
||||
.displayCustomToast(
|
||||
getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
||||
} else {
|
||||
Log.e("[Manager] Error: " + getString(R.string.error_network_unreachable));
|
||||
}
|
||||
newOutgoingCall(lAddress);
|
||||
}
|
||||
|
||||
private void resetCameraFromPreferences() {
|
||||
|
@ -1867,4 +1870,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
|
||||
void setDisplayedName(String s);
|
||||
}
|
||||
|
||||
public boolean hasLastCallSasBeenRejected() {
|
||||
return mHasLastCallSasBeenRejected;
|
||||
}
|
||||
|
||||
public void lastCallSasRejected(boolean rejected) {
|
||||
mHasLastCallSasBeenRejected = rejected;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,6 +376,11 @@ public class ChatMessagesFragment extends Fragment
|
|||
displayChatRoomHeader();
|
||||
displayChatRoomHistory();
|
||||
LinphoneManager.getInstance().setCurrentChatRoomAddress(mRemoteSipAddress);
|
||||
|
||||
if (LinphoneManager.getInstance().hasLastCallSasBeenRejected()) {
|
||||
LinphoneManager.getInstance().lastCallSasRejected(false);
|
||||
LinphoneUtils.showTrustDeniedDialog(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
public void changeDisplayedChat(String localSipUri, String remoteSipUri) {
|
||||
|
|
|
@ -145,6 +145,11 @@ public class DevicesFragment extends Fragment {
|
|||
}
|
||||
|
||||
initValues();
|
||||
|
||||
if (LinphoneManager.getInstance().hasLastCallSasBeenRejected()) {
|
||||
LinphoneManager.getInstance().lastCallSasRejected(false);
|
||||
LinphoneUtils.showTrustDeniedDialog(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void initChatRoom() {
|
||||
|
|
|
@ -483,6 +483,7 @@ public class StatusFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (call != null) {
|
||||
LinphoneManager.getInstance().lastCallSasRejected(true);
|
||||
call.setAuthenticationTokenVerified(false);
|
||||
if (mEncryption != null) {
|
||||
mEncryption.setImageResource(R.drawable.security_ko);
|
||||
|
|
|
@ -21,8 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Handler;
|
||||
|
@ -32,9 +35,14 @@ import android.text.Html;
|
|||
import android.text.Spanned;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -49,6 +57,7 @@ import org.linphone.core.AccountCreator;
|
|||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Call.State;
|
||||
import org.linphone.core.CallLog;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomCapabilities;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -502,4 +511,65 @@ public final class LinphoneUtils {
|
|||
}
|
||||
return newRooms;
|
||||
}
|
||||
|
||||
public static void showTrustDeniedDialog(Context context) {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
Drawable d = new ColorDrawable(ContextCompat.getColor(context, R.color.dark_grey_color));
|
||||
d.setAlpha(200);
|
||||
dialog.setContentView(R.layout.dialog);
|
||||
dialog.getWindow()
|
||||
.setLayout(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT);
|
||||
dialog.getWindow().setBackgroundDrawable(d);
|
||||
|
||||
TextView title = dialog.findViewById(R.id.dialog_title);
|
||||
title.setVisibility(View.GONE);
|
||||
|
||||
TextView message = dialog.findViewById(R.id.dialog_message);
|
||||
message.setVisibility(View.VISIBLE);
|
||||
message.setText(context.getString(R.string.trust_denied));
|
||||
|
||||
ImageView icon = dialog.findViewById(R.id.dialog_icon);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
icon.setImageResource(R.drawable.security_alert_indicator);
|
||||
|
||||
Button delete = dialog.findViewById(R.id.dialog_delete_button);
|
||||
delete.setVisibility(View.GONE);
|
||||
Button cancel = dialog.findViewById(R.id.dialog_cancel_button);
|
||||
cancel.setVisibility(View.VISIBLE);
|
||||
Button call = dialog.findViewById(R.id.dialog_ok_button);
|
||||
call.setVisibility(View.VISIBLE);
|
||||
call.setText(R.string.call);
|
||||
|
||||
cancel.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
call.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
CallLog[] logs =
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().getCallLogs();
|
||||
CallLog lastLog = logs[0];
|
||||
Address addressToCall =
|
||||
lastLog.getDir() == Call.Dir.Incoming
|
||||
? lastLog.getFromAddress()
|
||||
: lastLog.getToAddress();
|
||||
LinphoneManager.getInstance()
|
||||
.newOutgoingCall(addressToCall.asString(), null);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@
|
|||
<string name="unexpected_event">Unexpected event %i for %s</string>
|
||||
<string name="download_file">Download</string>
|
||||
<string name="toast_choose_chat_room_for_sharing">Select a conversation or create a new one</string>
|
||||
<string name="trust_denied">Trust has been denied. Make a call to start the authentication process again.</string>
|
||||
|
||||
<!-- Status Bar -->
|
||||
<string name="status_connected">Connected</string>
|
||||
|
|
Loading…
Reference in a new issue