Skip to content

Commit

Permalink
Support key continuity features of ZRTP.
Browse files Browse the repository at this point in the history
1) Add verification button to SAS UI.

2) Support the retained secret stuff from ZRTP.

3) Add a few additional visual indicators to denominate the in-call
   screen as belonging to RedPhone.
  • Loading branch information
moxie0 committed Jun 3, 2013
1 parent 8c911a1 commit 2435af9
Show file tree
Hide file tree
Showing 37 changed files with 863 additions and 90 deletions.
Binary file added res/drawable-hdpi/check_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/check_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/check_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions res/layout/call_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
android:paddingRight="24dp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:background="#A0000000"
android:background="#A0444444"
>

<!-- Name (or the phone number, if we don't have a name to display). -->
Expand Down Expand Up @@ -123,8 +123,8 @@
android:textColor="#FFFFFF"
android:maxLines="1"
android:ellipsize="end"
android:visibility="gone"
android:text="RedPhone Call"
android:visibility="visible"
android:text="@string/call_card__redphone_call"
/>

<!-- Social status (currently unused) -->
Expand Down Expand Up @@ -176,6 +176,5 @@
android:textAllCaps="true"
android:background="#8033b5e5"
/>

</RelativeLayout>
</LinearLayout>
68 changes: 50 additions & 18 deletions res/layout/call_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@
android:visibility="gone"
/>

<TextView android:id="@+id/redphone_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@id/incomingCallWidget"
android:gravity="center"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#A0000000"
android:textAllCaps="true"
android:background="#ccf0a621"
android:text="@string/call_controls__redphone_call"/>


<!--
(2) inCallControls: the widgets visible while a regular call
(or calls) is in progress
Expand All @@ -70,8 +84,42 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
android:layout_alignParentBottom="true">

<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView android:id="@+id/sas"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
android:background="#a0000000"
android:gravity="center"
android:padding="20dip"
android:singleLine="true"
android:visibility="gone"/>

<LinearLayout android:id="@+id/confirm_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/sas"
android:layout_alignBottom="@id/sas"
android:background="@drawable/dialpad_dark_background">

<ImageButton android:id="@+id/confirm_sas"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center"
android:layout_gravity="center"
android:paddingRight="10dip"
android:paddingLeft="10dip"
android:contentDescription="verify sas"
android:src="@drawable/check_light"
android:background="@drawable/selectable_item_background"/>
</LinearLayout>
</RelativeLayout>


<!-- Row 2: The "End call" button. -->
Expand Down Expand Up @@ -212,22 +260,6 @@

</LinearLayout>

<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView android:id="@+id/sas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF"
android:background="#000000"
android:gravity="center"
android:padding="20dip"
android:singleLine="true"
android:visibility="gone"/>

</LinearLayout>

<!-- Row 3: The main batch of in-call buttons:
Dialpad / Audio mode / Mute / Hold / Add call
Expand Down
3 changes: 2 additions & 1 deletion res/layout/call_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

<org.thoughtcrime.redphone.ui.CallControls android:id="@+id/callControls"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
/>

</FrameLayout>
9 changes: 6 additions & 3 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@
<string name="about_activity__additional_information">Additional information:</string>
<string name="about_activity__attribution">Attribution:</string>
<string name="about_activity__aboutText">Please see whispersystems.org for additional information, or contact [email protected] with problems, questions, or comments.</string>
<string name="about_activity__attributionText">RedPhone links to the SpanDSP library, which is licensed under the LGPL.\n\nRedPhone uses the SPEEX Codec, which is used under the Xiph.Org variant of the BSD license: © 2002-2003, Jean-Marc Valin/Xiph.Org Foundation\n\nRedistribution and use of the SPEEX library in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n\t* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\t* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\t* Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nThe SPEEX library is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the foundation or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.\n\n\nSome sound samples are licensed under the Creative Commons Sampling Plus License: http://creativecommons.org/licenses/sampling+/1.0/\n\nBy acclivity (http://www.freesound.org/usersViewSingle.php?id=37876):\nShipsBell.wav (http://www.freesound.org/samplesViewSingle.php?id=32304)\n\nBy Splashdust (http://www.freesound.org/usersViewSingle.php?id=754949):\nnegativebeep.wav (http://www.freesound.org/samplesViewSingle.php?id=67454)\n\nBy Peter_Gross (http://www.freesound.org/usersViewSingle.php?id=33429):\nSonar_pings.ogg (http://www.freesound.org/samplesViewSingle.php?id=12677\n\nBy suonho: http://www.freesound.org/samplesViewSingle.php?id=58348: ambienta_soundtrack_moog_sweep\n\nBy Mike Koenig: Busy Signal</string>

<string name="about_activity__attributionText">RedPhone links to the SpanDSP library, which is licensed under the LGPL.\n\nRedPhone uses the SPEEX Codec, which is used under the Xiph.Org variant of the BSD license: © 2002-2003, Jean-Marc Valin/Xiph.Org Foundation\n\nRedistribution and use of the SPEEX library in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n\t* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\t* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\t* Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nThe SPEEX library is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the foundation or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.\n\n\nSome sound samples are licensed under the Creative Commons Sampling Plus License: http://creativecommons.org/licenses/sampling+/1.0/\n\nBy acclivity (http://www.freesound.org/usersViewSingle.php?id=37876):\nShipsBell.wav (http://www.freesound.org/samplesViewSingle.php?id=32304)\n\nBy Splashdust (http://www.freesound.org/usersViewSingle.php?id=754949):\nnegativebeep.wav (http://www.freesound.org/samplesViewSingle.php?id=67454)\n\nBy Peter_Gross (http://www.freesound.org/usersViewSingle.php?id=33429):\nSonar_pings.ogg (http://www.freesound.org/samplesViewSingle.php?id=12677\n\nBy suonho: http://www.freesound.org/samplesViewSingle.php?id=58348: ambienta_soundtrack_moog_sweep\n\nBy Mike Koenig: Busy Signal</string>

<string name="call_controls__redphone_call">REDPHONE CALL</string>

<string name="call_card__redphone_call">RedPhone Call</string>

<string name="create_account__register">Register</string>
<string name="create_acount__please_confirm_your_country_code_and_phone_number">In order to make and receive secure calls, RedPhone needs to verify your phone number and register it with the system.\n\nPlease confirm your country code and phone number for this device.</string>
<string name="create_account__your_country">YOUR COUNTRY</string>
Expand Down Expand Up @@ -150,6 +154,5 @@
<string name="registration_progress__waiting_for_sms_verification">Waiting for SMS verification...</string>
<string name="registration_progress__this_could_take_a_moment_please_be_patient_well_notify_you_when_verification_is_complete">This could take a moment. Please be patient, we\'ll notify you when verification is complete.</string>
<string name="registration_progress__waiting_for_sms">WAITING FOR SMS</string>

<!-- EOF -->
</resources>
14 changes: 12 additions & 2 deletions src/org/thoughtcrime/redphone/RedPhone.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import org.thoughtcrime.redphone.codec.CodecSetupException;
import org.thoughtcrime.redphone.contacts.PersonInfo;
import org.thoughtcrime.redphone.crypto.zrtp.SASInfo;
import org.thoughtcrime.redphone.directory.DirectoryUpdateReceiver;
import org.thoughtcrime.redphone.ui.ApplicationPreferencesActivity;
import org.thoughtcrime.redphone.ui.CallControls;
Expand Down Expand Up @@ -168,6 +169,7 @@ private void initializeResources() {
callScreen.setIncomingCallActionListener(new IncomingCallActionListener());
callScreen.setMuteButtonListener(new MuteButtonListener());
callScreen.setAudioButtonListener(new AudioButtonListener());
callScreen.setConfirmSasButtonListener(new ConfirmSasButtonListener());

DirectoryUpdateReceiver.scheduleDirectoryUpdate(this);
}
Expand Down Expand Up @@ -255,7 +257,7 @@ private void handleCallBusy() {
delayedFinish(BUSY_SIGNAL_DELAY_FINISH);
}

private void handleCallConnected(String sas) {
private void handleCallConnected(SASInfo sas) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES);
callScreen.setActiveCall(redPhoneService.getRemotePersonInfo(),
getString(R.string.RedPhone_connected), sas);
Expand Down Expand Up @@ -389,7 +391,7 @@ private class CallStateHandler extends Handler {
public void handleMessage(Message message) {
Log.w("RedPhone", "Got message from service: " + message.what);
switch (message.what) {
case HANDLE_CALL_CONNECTED: handleCallConnected((String)message.obj); break;
case HANDLE_CALL_CONNECTED: handleCallConnected((SASInfo)message.obj); break;
case HANDLE_SERVER_FAILURE: handleServerFailure(); break;
case HANDLE_PERFORMING_HANDSHAKE: handlePerformingHandshake(); break;
case HANDLE_HANDSHAKE_FAILED: handleHandshakeFailed(); break;
Expand All @@ -410,6 +412,14 @@ public void handleMessage(Message message) {
}
}

private class ConfirmSasButtonListener implements CallControls.ConfirmSasButtonListener {
public void onClick() {
Intent intent = new Intent(RedPhone.this, RedPhoneService.class);
intent.setAction(RedPhoneService.ACTION_CONFIRM_SAS);
startService(intent);
}
}

private class HangupButtonListener implements CallControls.HangupButtonListener {
public void onClick() {
Log.w("RedPhone", "Hangup pressed, handling termination now...");
Expand Down
14 changes: 11 additions & 3 deletions src/org/thoughtcrime/redphone/RedPhoneService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.thoughtcrime.redphone.call.ResponderCallManager;
import org.thoughtcrime.redphone.codec.CodecSetupException;
import org.thoughtcrime.redphone.contacts.PersonInfo;
import org.thoughtcrime.redphone.crypto.zrtp.SASInfo;
import org.thoughtcrime.redphone.gcm.GCMRegistrarHelper;
import org.thoughtcrime.redphone.pstn.CallStateView;
import org.thoughtcrime.redphone.pstn.IncomingPstnCallListener;
Expand Down Expand Up @@ -73,6 +74,7 @@ public class RedPhoneService extends Service implements CallStateListener, CallS
public static final String ACTION_DENY_CALL = "org.thoughtcrime.redphone.RedPhoneService.DENYU_CALL";
public static final String ACTION_HANGUP_CALL = "org.thoughtcrime.redphone.RedPhoneService.HANGUP";
public static final String ACTION_SET_MUTE = "org.thoughtcrime.redphone.RedPhoneService.SET_MUTE";
public static final String ACTION_CONFIRM_SAS = "org.thoughtcrime.redphone.RedPhoneService.CONFIRM_SAS";

private static final String TAG = RedPhoneService.class.getName();

Expand Down Expand Up @@ -141,6 +143,7 @@ private synchronized void onIntentReceived(Intent intent) {
else if (intent.getAction().equals(ACTION_DENY_CALL)) handleDenyCall(intent);
else if (intent.getAction().equals(ACTION_HANGUP_CALL)) handleHangupCall(intent);
else if (intent.getAction().equals(ACTION_SET_MUTE)) handleSetMute(intent);
else if (intent.getAction().equals(ACTION_CONFIRM_SAS)) handleConfirmSas(intent);
}

///// Initializers
Expand Down Expand Up @@ -263,6 +266,11 @@ private void handleSetMute(Intent intent) {
}
}

private void handleConfirmSas(Intent intent) {
if (currentCallManager != null)
currentCallManager.setSasVerified();
}

/// Helper Methods

private boolean isBusy() {
Expand All @@ -284,9 +292,9 @@ public int getState() {
return state;
}

public String getCurrentCallSAS() {
public SASInfo getCurrentCallSAS() {
if (currentCallManager != null)
return currentCallManager.getSAS();
return currentCallManager.getSasInfo();
else
return null;
}
Expand Down Expand Up @@ -418,7 +426,7 @@ public void notifyCallRinging() {
sendMessage(RedPhone.HANDLE_CALL_RINGING, null);
}

public void notifyCallConnected(String sas) {
public void notifyCallConnected(SASInfo sas) {
outgoingRinger.playComplete();
lockManager.updatePhoneState(LockManager.PhoneState.IN_CALL);
state = RedPhone.STATE_CONNECTED;
Expand Down
17 changes: 11 additions & 6 deletions src/org/thoughtcrime/redphone/call/CallManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.thoughtcrime.redphone.crypto.zrtp.MasterSecret;
import org.thoughtcrime.redphone.crypto.zrtp.NegotiationFailedException;
import org.thoughtcrime.redphone.crypto.zrtp.RecipientUnavailableException;
import org.thoughtcrime.redphone.crypto.zrtp.SASCalculator;
import org.thoughtcrime.redphone.crypto.zrtp.SASInfo;
import org.thoughtcrime.redphone.crypto.zrtp.ZRTPSocket;
import org.thoughtcrime.redphone.signaling.SessionDescriptor;
import org.thoughtcrime.redphone.signaling.SignalingSocket;
Expand Down Expand Up @@ -62,7 +62,7 @@ public abstract class CallManager extends Thread {
private boolean loopbackMode;
private CallAudioManager callAudioManager;
private SignalManager signalManager;
private String sas;
private SASInfo sasInfo;
private boolean muteEnabled;

protected SessionDescriptor sessionDescriptor;
Expand Down Expand Up @@ -103,8 +103,8 @@ public void run() {

if (!terminated) {
setSecureSocketKeys(zrtpSocket.getMasterSecret());
sas = SASCalculator.calculateSAS(zrtpSocket.getMasterSecret().getSAS());
callStateListener.notifyCallConnected(sas);
sasInfo = zrtpSocket.getSasInfo();
callStateListener.notifyCallConnected(sasInfo);
}

if (!terminated) {
Expand Down Expand Up @@ -144,8 +144,13 @@ public SessionDescriptor getSessionDescriptor() {
return this.sessionDescriptor;
}

public String getSAS() {
return this.sas;
public SASInfo getSasInfo() {
return this.sasInfo;
}

public void setSasVerified() {
if (zrtpSocket != null)
zrtpSocket.setSasVerified();
}

protected void processSignals() {
Expand Down
3 changes: 2 additions & 1 deletion src/org/thoughtcrime/redphone/call/CallStateListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.thoughtcrime.redphone.call;

import org.thoughtcrime.redphone.codec.CodecSetupException;
import org.thoughtcrime.redphone.crypto.zrtp.SASInfo;

/**
* An interface for those interested in receiving information
Expand All @@ -37,7 +38,7 @@ public interface CallStateListener {
public void notifyServerMessage(String serverMessage);
public void notifyCallDisconnected();
public void notifyCallRinging();
public void notifyCallConnected(String sas);
public void notifyCallConnected(SASInfo sas);
public void notifyPerformingHandshake();
public void notifyHandshakeFailed();
public void notifyRecipientUnavailable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void run() {

secureSocket = new SecureRtpSocket(new RtpSocket(localPort, remoteAddress));

zrtpSocket = new ZRTPInitiatorSocket(secureSocket, zid);
zrtpSocket = new ZRTPInitiatorSocket(context, secureSocket, zid, remoteNumber);

processSignals();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void run() {
sessionDescriptor.relayPort);

secureSocket = new SecureRtpSocket(new RtpSocket(localPort, remoteAddress));
zrtpSocket = new ZRTPResponderSocket(secureSocket, zid);
zrtpSocket = new ZRTPResponderSocket(context, secureSocket, zid, remoteNumber);

callStateListener.notifyConnectingtoInitiator();

Expand Down
Loading

0 comments on commit 2435af9

Please sign in to comment.