ZRTP enabled + popup to validate/unvalidate correspondent
This commit is contained in:
parent
6ee7664c23
commit
473311187f
7 changed files with 207 additions and 16 deletions
2
Makefile
2
Makefile
|
@ -49,7 +49,7 @@ prepare-mediastreamer2:
|
||||||
prepare-sources: prepare-ffmpeg prepare-ilbc prepare-vpx prepare-silk prepare-srtp prepare-mediastreamer2
|
prepare-sources: prepare-ffmpeg prepare-ilbc prepare-vpx prepare-silk prepare-srtp prepare-mediastreamer2
|
||||||
|
|
||||||
generate-libs:
|
generate-libs:
|
||||||
$(NDK_PATH)/ndk-build LINPHONE_VERSION=$(LINPHONE_VERSION) BUILD_SILK=1 BUILD_AMRNB=full -j$(NUMCPUS)
|
$(NDK_PATH)/ndk-build LINPHONE_VERSION=$(LINPHONE_VERSION) BUILD_SILK=1 BUILD_AMRNB=full BUILD_GPLV3_ZRTP=1 -j$(NUMCPUS)
|
||||||
|
|
||||||
update-project:
|
update-project:
|
||||||
$(SDK_PATH)/android update project --path .
|
$(SDK_PATH)/android update project --path .
|
||||||
|
|
BIN
res/drawable/zrtp_popup.9.png
Normal file
BIN
res/drawable/zrtp_popup.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -78,6 +78,7 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/content_description_encryption"
|
android:contentDescription="@string/content_description_encryption"
|
||||||
android:id="@+id/encryption"
|
android:id="@+id/encryption"
|
||||||
|
android:paddingRight="5dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
|
22
res/layout/toast.xml
Normal file
22
res/layout/toast.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/toastRoot"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/zrtp_popup"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toastTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toastMessage"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
43
res/layout/zrtp_dialog.xml
Normal file
43
res/layout/zrtp_dialog.xml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/toastRoot"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/zrtp_popup"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/toastMessage"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/toastNotOK"
|
||||||
|
android:src="@drawable/security_pending"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/toastOK"
|
||||||
|
android:src="@drawable/security_ok"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:adjustViewBounds="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -38,7 +38,9 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -49,6 +51,7 @@ import android.view.animation.AnimationUtils;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,9 +292,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
setCallControlsVisibleAndRemoveCallbacks();
|
setCallControlsVisibleAndRemoveCallbacks();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!call.getCurrentParamsCopy().getVideoEnabled()) {
|
LinphoneManager.getInstance().addVideo();
|
||||||
LinphoneManager.getInstance().addVideo();
|
|
||||||
}
|
|
||||||
|
|
||||||
isSpeakerEnabled = true;
|
isSpeakerEnabled = true;
|
||||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
LinphoneManager.getInstance().routeAudioToSpeaker();
|
||||||
|
@ -640,8 +641,8 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCallStateChanged(final LinphoneCall call, State state, String message) {
|
public void onCallStateChanged(final LinphoneCall call, State state, String message) {
|
||||||
if (state==State.Error){
|
if (state==State.Error) {
|
||||||
showToast(R.string.call_error, message);
|
displayCustomToast(null, message, Toast.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
|
@ -681,11 +682,28 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
|
transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showToast(int id, String txt) {
|
private void displayCustomToast(final String title, final String message, final int duration) {
|
||||||
final String msg = String.format(getString(id), txt);
|
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(InCallActivity.this, msg, Toast.LENGTH_SHORT).show();
|
LayoutInflater inflater = getLayoutInflater();
|
||||||
|
View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot));
|
||||||
|
|
||||||
|
TextView toastTitle = (TextView) layout.findViewById(R.id.toastTitle);
|
||||||
|
if (title == null) {
|
||||||
|
toastTitle.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
toastTitle.setText(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
|
||||||
|
toastText.setText(message);
|
||||||
|
|
||||||
|
final Toast toast = new Toast(getApplicationContext());
|
||||||
|
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||||
|
toast.setDuration(duration);
|
||||||
|
toast.setView(layout);
|
||||||
|
toast.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,11 @@ import org.linphone.ui.SlidingDrawer.OnDrawerOpenListener;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -44,6 +46,7 @@ import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
|
@ -59,6 +62,10 @@ public class StatusFragment extends Fragment {
|
||||||
private Runnable mCallQualityUpdater;
|
private Runnable mCallQualityUpdater;
|
||||||
private boolean isInCall, isAttached = false;
|
private boolean isInCall, isAttached = false;
|
||||||
|
|
||||||
|
private Toast zrtpToast;
|
||||||
|
private CountDownTimer zrtpHack;
|
||||||
|
private boolean hideZrtpToast = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -85,7 +92,9 @@ public class StatusFragment extends Fragment {
|
||||||
exit.setOnClickListener(new OnClickListener() {
|
exit.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LinphoneActivity.instance().exit();
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
LinphoneActivity.instance().exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -267,9 +276,9 @@ public class StatusFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (isInCall) {
|
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
||||||
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
|
if (isInCall && call != null) {
|
||||||
startCallQuality();
|
startCallQuality();
|
||||||
refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
|
refreshStatusItems(call, call.getCurrentParamsCopy().getVideoEnabled());
|
||||||
|
|
||||||
|
@ -293,16 +302,19 @@ public class StatusFragment extends Fragment {
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
|
if (zrtpToast != null) {
|
||||||
|
hideZRTPDialog();
|
||||||
|
}
|
||||||
|
|
||||||
if (mCallQualityUpdater != null) {
|
if (mCallQualityUpdater != null) {
|
||||||
refreshHandler.removeCallbacks(mCallQualityUpdater);
|
refreshHandler.removeCallbacks(mCallQualityUpdater);
|
||||||
mCallQualityUpdater = null;
|
mCallQualityUpdater = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshStatusItems(LinphoneCall call, boolean isVideoEnabled) {
|
public void refreshStatusItems(final LinphoneCall call, boolean isVideoEnabled) {
|
||||||
if (call != null && encryption != null) {
|
if (call != null && encryption != null) {
|
||||||
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
|
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
|
||||||
Log.e("MediaEncryption = " + mediaEncryption);
|
|
||||||
|
|
||||||
exit.setVisibility(View.GONE);
|
exit.setVisibility(View.GONE);
|
||||||
statusText.setVisibility(View.GONE);
|
statusText.setVisibility(View.GONE);
|
||||||
|
@ -311,6 +323,9 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
encryption.setVisibility(View.VISIBLE);
|
encryption.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
Log.e("MediaEncryption = " + mediaEncryption);
|
||||||
|
Log.e("TokenVerified = " + call.isAuthenticationTokenVerified());
|
||||||
|
|
||||||
if (mediaEncryption == MediaEncryption.SRTP || (mediaEncryption == MediaEncryption.ZRTP && call.isAuthenticationTokenVerified())) {
|
if (mediaEncryption == MediaEncryption.SRTP || (mediaEncryption == MediaEncryption.ZRTP && call.isAuthenticationTokenVerified())) {
|
||||||
encryption.setImageResource(R.drawable.security_ok);
|
encryption.setImageResource(R.drawable.security_ok);
|
||||||
} else if (mediaEncryption == MediaEncryption.ZRTP && !call.isAuthenticationTokenVerified()) {
|
} else if (mediaEncryption == MediaEncryption.ZRTP && !call.isAuthenticationTokenVerified()) {
|
||||||
|
@ -318,6 +333,17 @@ public class StatusFragment extends Fragment {
|
||||||
} else {
|
} else {
|
||||||
encryption.setImageResource(R.drawable.security_ko);
|
encryption.setImageResource(R.drawable.security_ko);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mediaEncryption == MediaEncryption.ZRTP) {
|
||||||
|
encryption.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showZRTPDialog(call);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
encryption.setOnClickListener(null);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
exit.setVisibility(View.VISIBLE);
|
exit.setVisibility(View.VISIBLE);
|
||||||
statusText.setVisibility(View.VISIBLE);
|
statusText.setVisibility(View.VISIBLE);
|
||||||
|
@ -326,6 +352,82 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void hideZRTPDialog() {
|
||||||
|
hideZrtpToast = true;
|
||||||
|
|
||||||
|
if (zrtpToast != null) {
|
||||||
|
zrtpToast.cancel();
|
||||||
|
}
|
||||||
|
if (zrtpHack != null) {
|
||||||
|
zrtpHack.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showZRTPDialog(final LinphoneCall call) {
|
||||||
|
boolean authVerified = call.isAuthenticationTokenVerified();
|
||||||
|
String format = getString(authVerified ? R.string.reset_sas_fmt : R.string.verify_sas_fmt);
|
||||||
|
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||||
|
View layout = inflater.inflate(R.layout.zrtp_dialog, (ViewGroup) getActivity().findViewById(R.id.toastRoot));
|
||||||
|
|
||||||
|
TextView toastText = (TextView) layout.findViewById(R.id.toastMessage);
|
||||||
|
toastText.setText(String.format(format, call.getAuthenticationToken()));
|
||||||
|
|
||||||
|
zrtpToast = new Toast(getActivity());
|
||||||
|
zrtpToast.setGravity(Gravity.TOP | Gravity.RIGHT, 0, LinphoneUtils.pixelsToDpi(getResources(), 40));
|
||||||
|
zrtpToast.setDuration(Toast.LENGTH_LONG);
|
||||||
|
zrtpToast.setView(layout);
|
||||||
|
|
||||||
|
ImageView ok = (ImageView) layout.findViewById(R.id.toastOK);
|
||||||
|
ok.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (call != null) {
|
||||||
|
call.setAuthenticationTokenVerified(true);
|
||||||
|
}
|
||||||
|
if (encryption != null) {
|
||||||
|
encryption.setImageResource(R.drawable.security_ok);
|
||||||
|
}
|
||||||
|
hideZRTPDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageView notOk = (ImageView) layout.findViewById(R.id.toastNotOK);
|
||||||
|
notOk.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (call != null) {
|
||||||
|
call.setAuthenticationTokenVerified(false);
|
||||||
|
}
|
||||||
|
if (encryption != null) {
|
||||||
|
encryption.setImageResource(R.drawable.security_pending);
|
||||||
|
}
|
||||||
|
hideZRTPDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
zrtpHack = new CountDownTimer(3000, 1000)
|
||||||
|
{
|
||||||
|
public void onTick(long millisUntilFinished)
|
||||||
|
{
|
||||||
|
if (!hideZrtpToast) {
|
||||||
|
zrtpToast.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void onFinish() {
|
||||||
|
if (!hideZrtpToast) {
|
||||||
|
zrtpToast.show();
|
||||||
|
zrtpHack.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
zrtpToast.show();
|
||||||
|
hideZrtpToast = false;
|
||||||
|
zrtpHack.start();
|
||||||
|
}
|
||||||
|
|
||||||
class AccountsListAdapter extends BaseAdapter {
|
class AccountsListAdapter extends BaseAdapter {
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
private List<CheckBox> checkboxes;
|
private List<CheckBox> checkboxes;
|
||||||
|
@ -363,7 +465,12 @@ public class StatusFragment extends Fragment {
|
||||||
};
|
};
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return LinphoneManager.getLc().getProxyConfigList().length;
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
return lc.getProxyConfigList().length;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
|
|
Loading…
Reference in a new issue