mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Showing media encryption icon
This commit is contained in:
parent
c3de2e906b
commit
a66d29ba2e
7 changed files with 109 additions and 6 deletions
|
|
@ -94,6 +94,10 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val halfOpenedFolded = MutableLiveData<Boolean>()
|
||||
|
||||
val isZrtpPq = MutableLiveData<Boolean>()
|
||||
|
||||
val isMediaEncrypted = MutableLiveData<Boolean>()
|
||||
|
||||
val incomingCallTitle: MutableLiveData<String> by lazy {
|
||||
MutableLiveData<String>()
|
||||
}
|
||||
|
|
@ -636,18 +640,35 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun showZrtpSasDialogIfPossible() {
|
||||
coreContext.postOnCoreThread {
|
||||
if (currentCall.currentParams.mediaEncryption == MediaEncryption.ZRTP) {
|
||||
val authToken = currentCall.authenticationToken
|
||||
val isDeviceTrusted = currentCall.authenticationTokenVerified && authToken != null
|
||||
Log.i(
|
||||
"$TAG Current call media encryption is ZRTP, auth token is ${if (isDeviceTrusted) "trusted" else "not trusted yet"}"
|
||||
)
|
||||
if (!authToken.isNullOrEmpty()) {
|
||||
showZrtpSasDialog(authToken)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun showZrtpSasDialog(authToken: String) {
|
||||
val upperCaseAuthToken = authToken.uppercase(Locale.getDefault())
|
||||
val toRead: String
|
||||
val toListen: String
|
||||
when (currentCall.dir) {
|
||||
Call.Dir.Incoming -> {
|
||||
toRead = authToken.substring(0, 2)
|
||||
toListen = authToken.substring(2)
|
||||
toRead = upperCaseAuthToken.substring(0, 2)
|
||||
toListen = upperCaseAuthToken.substring(2)
|
||||
}
|
||||
else -> {
|
||||
toRead = authToken.substring(2)
|
||||
toListen = authToken.substring(0, 2)
|
||||
toRead = upperCaseAuthToken.substring(2)
|
||||
toListen = upperCaseAuthToken.substring(0, 2)
|
||||
}
|
||||
}
|
||||
showZrtpSasDialogEvent.postValue(Event(Pair(toRead, toListen)))
|
||||
|
|
@ -666,16 +687,24 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
val securityLevel = if (isDeviceTrusted) SecurityLevel.Encrypted else SecurityLevel.Safe
|
||||
contact.value?.trust?.postValue(securityLevel)
|
||||
|
||||
if (!isDeviceTrusted && authToken.orEmpty().isNotEmpty()) {
|
||||
isMediaEncrypted.postValue(true)
|
||||
// When Post Quantum is available, ZRTP is Post Quantum
|
||||
isZrtpPq.postValue(coreContext.core.postQuantumAvailable)
|
||||
|
||||
if (!isDeviceTrusted && !authToken.isNullOrEmpty()) {
|
||||
Log.i("$TAG Showing ZRTP SAS confirmation dialog")
|
||||
showZrtpSasDialog(authToken!!.uppercase(Locale.getDefault()))
|
||||
showZrtpSasDialog(authToken)
|
||||
}
|
||||
|
||||
return isDeviceTrusted
|
||||
}
|
||||
MediaEncryption.SRTP, MediaEncryption.DTLS -> {
|
||||
isMediaEncrypted.postValue(true)
|
||||
isZrtpPq.postValue(false)
|
||||
}
|
||||
else -> {
|
||||
isMediaEncrypted.postValue(false)
|
||||
isZrtpPq.postValue(false)
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
|
|
|||
12
app/src/main/res/drawable/media_encryption_srtp.xml
Normal file
12
app/src/main/res/drawable/media_encryption_srtp.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M23,2.526V9.236C23,19.465 14.312,22.859 12.573,23.436C12.201,23.561 11.799,23.561 11.427,23.436C9.685,22.859 1,19.465 1,9.236V2.526C1,2.042 1.193,1.577 1.537,1.235C1.881,0.892 2.347,0.7 2.833,0.7H21.167C21.653,0.7 22.119,0.892 22.463,1.235C22.807,1.577 23,2.042 23,2.526Z"
|
||||
android:fillColor="#364860"/>
|
||||
<path
|
||||
android:pathData="M22,3.267V9.389C22,18.723 14.102,21.82 12.521,22.346C12.183,22.461 11.817,22.461 11.479,22.346C9.896,21.82 2,18.723 2,9.389V3.267C2,2.825 2.176,2.401 2.488,2.088C2.801,1.776 3.225,1.6 3.667,1.6H20.333C20.775,1.6 21.199,1.776 21.512,2.088C21.824,2.401 22,2.825 22,3.267Z"
|
||||
android:fillColor="#4AA8FF"/>
|
||||
</vector>
|
||||
13
app/src/main/res/drawable/media_encryption_zrtp_pq.xml
Normal file
13
app/src/main/res/drawable/media_encryption_zrtp_pq.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M23,2.526V9.236C23,19.465 14.312,22.859 12.573,23.436C12.201,23.561 11.799,23.561 11.427,23.436C9.685,22.859 1,19.465 1,9.236V2.526C1,2.042 1.193,1.577 1.537,1.235C1.881,0.892 2.347,0.7 2.833,0.7H21.167C21.653,0.7 22.119,0.892 22.463,1.235C22.807,1.577 23,2.042 23,2.526Z"
|
||||
android:fillColor="#364860"/>
|
||||
<path
|
||||
android:pathData="M22,9.389V3.267C22,2.825 21.824,2.401 21.512,2.088C21.199,1.776 20.775,1.6 20.333,1.6H3.667C3.225,1.6 2.801,1.776 2.488,2.088C2.176,2.401 2,2.825 2,3.267V9.389C2,18.723 9.896,21.82 11.479,22.346C11.817,22.461 12.183,22.461 12.521,22.346C14.102,21.82 22,18.723 22,9.389ZM15.885,10.661C16.264,11.197 16.592,11.766 16.867,12.362C17.512,13.795 17.504,14.949 16.841,15.61C16.507,15.944 16.046,16.111 15.487,16.111C14.941,16.111 14.301,15.952 13.593,15.633C12.997,15.359 12.428,15.031 11.892,14.652C11.357,15.031 10.788,15.359 10.192,15.633C9.484,15.952 8.842,16.111 8.297,16.111C7.741,16.111 7.28,15.944 6.946,15.61C6.285,14.949 6.277,13.795 6.922,12.362C7.197,11.766 7.525,11.197 7.903,10.661C7.525,10.126 7.197,9.556 6.922,8.961C6.277,7.527 6.285,6.373 6.946,5.713C7.606,5.052 8.76,5.044 10.194,5.689C10.79,5.964 11.359,6.292 11.894,6.67C12.43,6.292 12.999,5.964 13.595,5.689C15.029,5.044 16.183,5.052 16.843,5.713C17.504,6.373 17.512,7.527 16.867,8.961C16.592,9.556 16.264,10.126 15.885,10.661ZM15.046,9.57C16.015,8.056 16.204,6.926 15.918,6.639V6.638C15.631,6.352 14.501,6.541 12.984,7.512C13.35,7.818 13.711,8.148 14.061,8.498C14.411,8.848 14.74,9.207 15.046,9.57ZM13.133,11.9C13.528,11.507 13.901,11.094 14.251,10.661C13.901,10.229 13.528,9.815 13.133,9.422C12.741,9.028 12.327,8.655 11.894,8.305C11.03,9.007 10.241,9.797 9.538,10.661C9.888,11.094 10.262,11.507 10.656,11.9C11.049,12.294 11.462,12.667 11.894,13.018C12.327,12.667 12.74,12.294 13.133,11.9ZM8.294,6.516C8.095,6.516 7.951,6.559 7.871,6.638C7.585,6.925 7.774,8.055 8.745,9.571C9.051,9.206 9.379,8.847 9.729,8.497C10.079,8.147 10.438,7.818 10.801,7.512C9.707,6.81 8.813,6.516 8.294,6.516ZM8.743,11.753C7.774,13.267 7.585,14.398 7.871,14.684C8.158,14.97 9.288,14.782 10.8,13.81C10.437,13.505 10.078,13.175 9.728,12.825C9.378,12.476 9.049,12.116 8.743,11.753ZM12.987,13.812C14.501,14.782 15.631,14.97 15.918,14.684C16.204,14.398 16.015,13.267 15.043,11.756C14.738,12.119 14.408,12.478 14.059,12.828C13.709,13.177 13.35,13.507 12.987,13.812ZM12.62,11.146C12.715,11.002 12.767,10.834 12.767,10.661C12.767,10.43 12.675,10.208 12.511,10.045C12.347,9.881 12.126,9.789 11.894,9.789C11.722,9.789 11.553,9.84 11.41,9.936C11.267,10.032 11.155,10.168 11.089,10.328C11.023,10.487 11.006,10.662 11.039,10.831C11.073,11 11.156,11.156 11.278,11.278C11.4,11.4 11.555,11.483 11.724,11.517C11.894,11.55 12.069,11.533 12.228,11.467C12.387,11.401 12.524,11.289 12.62,11.146Z"
|
||||
android:fillColor="#4AA8FF"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
||||
|
|
@ -182,7 +182,9 @@
|
|||
android:layout_height="@dimen/call_top_bar_text_height"
|
||||
android:layout_marginStart="5dp"
|
||||
android:visibility="@{viewModel.isPaused || viewModel.isPausedByRemote ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/separator"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_encryption"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
|
|
@ -193,9 +195,23 @@
|
|||
android:layout_marginStart="5dp"
|
||||
android:text="@{viewModel.isPaused ? @string/call_state_paused : @string/call_state_paused_by_remote, default=@string/call_state_paused}"
|
||||
android:visibility="@{viewModel.isPaused || viewModel.isPausedByRemote ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/separator"
|
||||
app:layout_constraintEnd_toStartOf="@id/media_encryption"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_encryption"
|
||||
android:onClick="@{() -> viewModel.showZrtpSasDialogIfPossible()}"
|
||||
android:layout_width="@dimen/call_top_bar_info_height"
|
||||
android:layout_height="@dimen/call_top_bar_info_height"
|
||||
android:padding="10dp"
|
||||
android:src="@{viewModel.isZrtpPq ? @drawable/media_encryption_zrtp_pq : @drawable/media_encryption_srtp, default=@drawable/media_encryption_zrtp_pq}"
|
||||
android:visibility="@{!viewModel.fullScreenMode && !viewModel.pipMode && viewModel.isMediaEncrypted ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"
|
||||
app:layout_constraintBottom_toBottomOf="@id/call_direction_label"
|
||||
app:layout_constraintEnd_toStartOf="@id/switch_camera" />
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{() -> viewModel.switchCamera()}"
|
||||
android:id="@+id/switch_camera"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,17 @@
|
|||
app:layout_constraintStart_toEndOf="@id/separator"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_encryption"
|
||||
android:layout_width="@dimen/call_top_bar_info_height"
|
||||
android:layout_height="@dimen/call_top_bar_info_height"
|
||||
android:padding="10dp"
|
||||
android:src="@{viewModel.isZrtpPq ? @drawable/media_encryption_zrtp_pq : @drawable/media_encryption_srtp, default=@drawable/media_encryption_zrtp_pq}"
|
||||
android:visibility="@{viewModel.isMediaEncrypted ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"
|
||||
app:layout_constraintBottom_toBottomOf="@id/call_direction_label"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/background"
|
||||
android:src="@drawable/shape_round_in_call_gray_background"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,17 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/background"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_encryption"
|
||||
android:layout_width="@dimen/call_top_bar_info_height"
|
||||
android:layout_height="@dimen/call_top_bar_info_height"
|
||||
android:padding="10dp"
|
||||
android:src="@{viewModel.isZrtpPq ? @drawable/media_encryption_zrtp_pq : @drawable/media_encryption_srtp, default=@drawable/media_encryption_zrtp_pq}"
|
||||
android:visibility="@{viewModel.isMediaEncrypted ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"
|
||||
app:layout_constraintBottom_toBottomOf="@id/call_direction_label"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/background"
|
||||
android:src="@drawable/shape_round_in_call_gray_background"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,17 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/background"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/media_encryption"
|
||||
android:layout_width="@dimen/call_top_bar_info_height"
|
||||
android:layout_height="@dimen/call_top_bar_info_height"
|
||||
android:padding="10dp"
|
||||
android:src="@{viewModel.isZrtpPq ? @drawable/media_encryption_zrtp_pq : @drawable/media_encryption_srtp, default=@drawable/media_encryption_zrtp_pq}"
|
||||
android:visibility="@{viewModel.isMediaEncrypted ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="@id/call_direction_label"
|
||||
app:layout_constraintBottom_toBottomOf="@id/call_direction_label"
|
||||
app:layout_constraintEnd_toStartOf="@id/switch_camera" />
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{() -> viewModel.switchCamera()}"
|
||||
android:id="@+id/switch_camera"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue