Reduce verbosity of WebRtcViewModel event logging during calls.

This commit is contained in:
Cody Henthorne
2024-04-04 11:53:05 -04:00
committed by Greyson Parrelli
parent dbf8a7ca87
commit 16588c401e
4 changed files with 48 additions and 1 deletions

View File

@@ -162,6 +162,7 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
private ControlsAndInfoController controlsAndInfo;
private boolean enterPipOnResume;
private long lastProcessedIntentTimestamp;
private WebRtcViewModel previousEvent = null;
private Disposable ephemeralStateDisposable = Disposable.empty();
@@ -885,7 +886,8 @@ public class WebRtcCallActivity extends BaseActivity implements SafetyNumberChan
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(@NonNull WebRtcViewModel event) {
Log.i(TAG, "Got message from service: " + event);
Log.i(TAG, "Got message from service: " + event.describeDifference(previousEvent));
previousEvent = event;
viewModel.setRecipient(event.getRecipient());
callScreen.setRecipient(event.getRecipient());

View File

@@ -79,6 +79,10 @@ data class CallParticipant(
return copy(handRaisedTimestamp = timestamp)
}
override fun toString(): String {
return "CallParticipant(callParticipantId=$callParticipantId, isForwardingVideo=$isForwardingVideo, isVideoEnabled=$isVideoEnabled, isMicrophoneEnabled=$isMicrophoneEnabled, handRaisedTimestamp=$handRaisedTimestamp, isMediaKeysReceived=$isMediaKeysReceived, isScreenSharing=$isScreenSharing)"
}
enum class DeviceOrdinal {
PRIMARY, SECONDARY
}

View File

@@ -64,6 +64,11 @@ public final class CallParticipantId implements Parcelable {
dest.writeParcelable(recipientId, flags);
}
@Override
public @NonNull String toString() {
return "CallParticipantId(demuxId=" + demuxId + ", recipientId=" + recipientId + ')';
}
public static final Parcelable.Creator<CallParticipantId> CREATOR = new Parcelable.Creator<CallParticipantId>() {
@Override
public CallParticipantId createFromParcel(Parcel in) {

View File

@@ -124,6 +124,7 @@ class WebRtcViewModel(state: WebRtcServiceState) {
PeerConnection.AdapterType.VPN,
PeerConnection.AdapterType.LOOPBACK,
PeerConnection.AdapterType.ADAPTER_TYPE_ANY -> false
PeerConnection.AdapterType.CELLULAR,
PeerConnection.AdapterType.CELLULAR_2G,
PeerConnection.AdapterType.CELLULAR_3G,
@@ -157,4 +158,39 @@ class WebRtcViewModel(state: WebRtcServiceState) {
}
""".trimIndent()
}
fun describeDifference(previousEvent: WebRtcViewModel?): String {
return if (previousEvent == null) {
this.toString()
} else if (previousEvent == this) {
"<no change>"
} else {
val builder = StringBuilder()
if (state != previousEvent.state) builder.append(" state=$state\n")
if (recipient.id != previousEvent.recipient.id) builder.append(" recipient=${recipient.id}\n")
if (isRemoteVideoOffer != previousEvent.isRemoteVideoOffer) builder.append(" isRemoteVideoOffer=$isRemoteVideoOffer\n")
if (callConnectedTime != previousEvent.callConnectedTime) builder.append(" callConnectedTime=$callConnectedTime\n")
if (localParticipant != previousEvent.localParticipant) builder.append(" localParticipant=$localParticipant\n")
if (remoteParticipants != previousEvent.remoteParticipants) {
if (remoteParticipants.size <= 8) {
builder.append(" remoteParticipants=$remoteParticipants\n")
} else {
builder.append(" remoteParticipants=<Too many:${remoteParticipants.size}>\n")
}
}
if (identityChangedParticipants != previousEvent.identityChangedParticipants) builder.append(" identityChangedParticipants=$identityChangedParticipants\n")
if (remoteDevicesCount != previousEvent.remoteDevicesCount) builder.append(" remoteDevicesCount=$remoteDevicesCount\n")
if (participantLimit != previousEvent.participantLimit) builder.append(" participantLimit=$participantLimit\n")
if (activeDevice != previousEvent.activeDevice) builder.append(" activeDevice=$activeDevice\n")
if (availableDevices != previousEvent.availableDevices) builder.append(" availableDevices=$availableDevices\n")
if (bluetoothPermissionDenied != previousEvent.bluetoothPermissionDenied) builder.append(" bluetoothPermissionDenied=$bluetoothPermissionDenied\n")
if (ringGroup != previousEvent.ringGroup) builder.append(" ringGroup=$ringGroup\n")
if (builder.isEmpty()) {
"<no change>"
} else {
"WebRtcViewModel {\n$builder}"
}
}
}
}