Fix crash in call stats view

This commit is contained in:
Erwan Croze 2016-10-24 11:29:15 +02:00
parent f8d6499b2e
commit 9d7df73d9f
7 changed files with 41 additions and 35 deletions

View file

@ -14,6 +14,7 @@
android:text="@string/assistant_create_account" android:text="@string/assistant_create_account"
style="@style/font6" style="@style/font6"
android:textAllCaps="true" android:textAllCaps="true"
android:gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/title_account_activation" /> android:id="@+id/title_account_activation" />

View file

@ -14,6 +14,7 @@
android:text="@string/assistant_create_account" android:text="@string/assistant_create_account"
style="@style/font6" style="@style/font6"
android:textAllCaps="true" android:textAllCaps="true"
android:gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
@ -21,7 +22,7 @@
android:text="@string/assistant_validate_account_1" android:text="@string/assistant_validate_account_1"
style="@style/font11" style="@style/font11"
android:paddingTop="10dp" android:paddingTop="10dp"
android:gravity="center" android:gravity="center_horizontal"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View file

@ -22,6 +22,7 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.linphone.assistant.AssistantActivity; import org.linphone.assistant.AssistantActivity;
import org.linphone.core.LinphoneAccountCreator;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallParams; import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCallStats; import org.linphone.core.LinphoneCallStats;
@ -450,6 +451,7 @@ public class StatusFragment extends Fragment {
, TextView ul, TextView ice, TextView ip, TextView senderLossRate , TextView ul, TextView ice, TextView ip, TextView senderLossRate
, TextView receiverLossRate, TextView enc, TextView dec, TextView videoResolutionSent , TextView receiverLossRate, TextView enc, TextView dec, TextView videoResolutionSent
, TextView videoResolutionReceived, boolean isVideo) { , TextView videoResolutionReceived, boolean isVideo) {
Context ctxt = LinphoneActivity.instance();
if (stats != null) { if (stats != null) {
layout.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE);
title.setVisibility(TextView.VISIBLE); title.setVisibility(TextView.VISIBLE);
@ -460,33 +462,33 @@ public class StatusFragment extends Fragment {
LinphoneManager.getInstance().getOpenH264DownloadHelper().isCodecFound()) { LinphoneManager.getInstance().getOpenH264DownloadHelper().isCodecFound()) {
mime = "OpenH264"; mime = "OpenH264";
} }
formatText(codec, getString(R.string.call_stats_codec), formatText(codec, ctxt.getString(R.string.call_stats_codec),
mime + " / " + (media.getRate() / 1000) + "kHz"); mime + " / " + (media.getRate() / 1000) + "kHz");
} }
formatText(enc, getString(R.string.call_stats_encoder_name), formatText(enc, ctxt.getString(R.string.call_stats_encoder_name),
stats.getEncoderName(media)); stats.getEncoderName(media));
formatText(dec, getString(R.string.call_stats_decoder_name), formatText(dec, ctxt.getString(R.string.call_stats_decoder_name),
stats.getDecoderName(media)); stats.getDecoderName(media));
formatText(dl, getString(R.string.call_stats_download), formatText(dl, ctxt.getString(R.string.call_stats_download),
String.valueOf((int) stats.getDownloadBandwidth()) + " kbits/s"); String.valueOf((int) stats.getDownloadBandwidth()) + " kbits/s");
formatText(ul, getString(R.string.call_stats_upload), formatText(ul, ctxt.getString(R.string.call_stats_upload),
String.valueOf((int) stats.getUploadBandwidth()) + " kbits/s"); String.valueOf((int) stats.getUploadBandwidth()) + " kbits/s");
formatText(ice, getString(R.string.call_stats_ice), formatText(ice, ctxt.getString(R.string.call_stats_ice),
stats.getIceState().toString()); stats.getIceState().toString());
formatText(ip, getString(R.string.call_stats_ip), formatText(ip, ctxt.getString(R.string.call_stats_ip),
(stats.getIpFamilyOfRemote() == LinphoneAddressFamily.INET_6.getInt()) ? (stats.getIpFamilyOfRemote() == LinphoneAddressFamily.INET_6.getInt()) ?
"IpV6" : (stats.getIpFamilyOfRemote() == LinphoneAddressFamily.INET.getInt()) ? "IpV6" : (stats.getIpFamilyOfRemote() == LinphoneAddressFamily.INET.getInt()) ?
"IpV4" : "Unknown"); "IpV4" : "Unknown");
formatText(senderLossRate, getString(R.string.call_stats_sender_loss_rate), formatText(senderLossRate, ctxt.getString(R.string.call_stats_sender_loss_rate),
new DecimalFormat("##.##").format(stats.getSenderLossRate()) + "%"); new DecimalFormat("##.##").format(stats.getSenderLossRate()) + "%");
formatText(receiverLossRate, getString(R.string.call_stats_receiver_loss_rate), formatText(receiverLossRate, ctxt.getString(R.string.call_stats_receiver_loss_rate),
new DecimalFormat("##.##").format(stats.getReceiverLossRate())+ "%"); new DecimalFormat("##.##").format(stats.getReceiverLossRate())+ "%");
if (isVideo) { if (isVideo) {
formatText(videoResolutionSent, formatText(videoResolutionSent,
getString(R.string.call_stats_video_resolution_sent), ctxt.getString(R.string.call_stats_video_resolution_sent),
"\u2191 " + params.getSentVideoSize().toDisplayableString()); "\u2191 " + params.getSentVideoSize().toDisplayableString());
formatText(videoResolutionReceived, formatText(videoResolutionReceived,
getString(R.string.call_stats_video_resolution_received), ctxt.getString(R.string.call_stats_video_resolution_received),
"\u2193 " + params.getReceivedVideoSize().toDisplayableString()); "\u2193 " + params.getReceivedVideoSize().toDisplayableString());
} }
} else { } else {
@ -547,29 +549,31 @@ public class StatusFragment extends Fragment {
@Override @Override
public void run() { public void run() {
synchronized(LinphoneManager.getLc()) { synchronized(LinphoneManager.getLc()) {
LinphoneCallParams params = call.getCurrentParamsCopy(); if (LinphoneActivity.isInstanciated()) {
if (params != null) { LinphoneCallParams params = call.getCurrentParamsCopy();
LinphoneCallStats audioStats = call.getAudioStats(); if (params != null) {
LinphoneCallStats videoStats = null; LinphoneCallStats audioStats = call.getAudioStats();
LinphoneCallStats videoStats = null;
if (params.getVideoEnabled()) if (params.getVideoEnabled())
videoStats = call.getVideoStats(); videoStats = call.getVideoStats();
PayloadType payloadAudio = params.getUsedAudioCodec(); PayloadType payloadAudio = params.getUsedAudioCodec();
PayloadType payloadVideo = params.getUsedVideoCodec(); PayloadType payloadVideo = params.getUsedVideoCodec();
displayMediaStats(params, audioStats, payloadAudio, audioLayout displayMediaStats(params, audioStats, payloadAudio, audioLayout
, titleAudio, codecAudio, dlAudio, ulAudio, iceAudio , titleAudio, codecAudio, dlAudio, ulAudio, iceAudio
,ipAudio, senderLossRateAudio, receiverLossRateAudio , ipAudio, senderLossRateAudio, receiverLossRateAudio
, encoderAudio, decoderAudio, null, null , encoderAudio, decoderAudio, null, null
, false); , false);
displayMediaStats(params, videoStats, payloadVideo, videoLayout displayMediaStats(params, videoStats, payloadVideo, videoLayout
, titleVideo, codecVideo, dlVideo, ulVideo, iceVideo , titleVideo, codecVideo, dlVideo, ulVideo, iceVideo
, ipVideo, senderLossRateVideo, receiverLossRateVideo , ipVideo, senderLossRateVideo, receiverLossRateVideo
, encoderVideo, decoderVideo , encoderVideo, decoderVideo
, videoResolutionSent, videoResolutionReceived , videoResolutionSent, videoResolutionReceived
, true); , true);
}
} }
} }
} }

@ -1 +1 @@
Subproject commit f0c669c4c2155518d71e03b3312fa601336c27d9 Subproject commit 29c556fa8ac1ab21fba1291231ffa8dea43cf32a

@ -1 +1 @@
Subproject commit 8fbc0d7ff00a97bc07ab7a867e55195a0bc07a62 Subproject commit 63e61b0ae0f20e6d9f790335184fa4a0fc2a90ab

@ -1 +1 @@
Subproject commit 7de31a427206079fd715dc6f427b675471e65fd7 Subproject commit 8a7f0868a7d35f86ff5fa422c7333f113d935e0f

@ -1 +1 @@
Subproject commit ed8748422bdb0c8c3790ce6fea0b6e894d8adea4 Subproject commit 31722cf5b86b71c58a442d7cd420c23130ea74e0