mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Notify when calls start to be routed over cellular data.
Only when the device thinks that it's also connected to a WiFi network.
This commit is contained in:
committed by
Cody Henthorne
parent
e024541b8a
commit
88b895f5ea
@@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.ringrtc.RemotePeer;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.VideoState;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceStateBuilder;
|
||||
import org.webrtc.PeerConnection;
|
||||
import org.webrtc.VideoTrack;
|
||||
import org.whispersystems.signalservice.api.messages.calls.OfferMessage;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
@@ -239,6 +240,17 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
@Override protected @NonNull WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
PeerConnection.AdapterType type = groupCall.getLocalDeviceState().getNetworkRoute().getLocalAdapterType();
|
||||
|
||||
return currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.setNetworkConnectionType(type)
|
||||
.commit()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull WebRtcServiceState handleGroupCallEnded(@NonNull WebRtcServiceState currentState, int groupCallHash, @NonNull GroupCall.GroupCallEndReason groupCallEndReason) {
|
||||
Log.i(tag, "handleGroupCallEnded(): reason: " + groupCallEndReason);
|
||||
|
||||
@@ -49,6 +49,8 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
protected @NonNull WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
|
||||
Log.i(tag, "handleGroupLocalDeviceStateChanged():");
|
||||
|
||||
currentState = super.handleGroupLocalDeviceStateChanged(currentState);
|
||||
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
GroupCall.LocalDeviceState device = groupCall.getLocalDeviceState();
|
||||
GroupCall.ConnectionState connectionState = device.getConnectionState();
|
||||
|
||||
@@ -42,6 +42,8 @@ public class GroupJoiningActionProcessor extends GroupActionProcessor {
|
||||
protected @NonNull WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
|
||||
Log.i(tag, "handleGroupLocalDeviceStateChanged():");
|
||||
|
||||
currentState = super.handleGroupLocalDeviceStateChanged(currentState);
|
||||
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
GroupCall.LocalDeviceState device = groupCall.getLocalDeviceState();
|
||||
|
||||
|
||||
@@ -90,6 +90,8 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
|
||||
protected @NonNull WebRtcServiceState handleGroupLocalDeviceStateChanged(@NonNull WebRtcServiceState currentState) {
|
||||
Log.i(tag, "handleGroupLocalDeviceStateChanged():");
|
||||
|
||||
currentState = super.handleGroupLocalDeviceStateChanged(currentState);
|
||||
|
||||
GroupCall groupCall = currentState.getCallInfoState().requireGroupCall();
|
||||
GroupCall.LocalDeviceState device = groupCall.getLocalDeviceState();
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.thoughtcrime.securesms.service.webrtc.state.WebRtcEphemeralState;
|
||||
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||
import org.thoughtcrime.securesms.util.BubbleUtil;
|
||||
import org.thoughtcrime.securesms.util.NetworkUtil;
|
||||
import org.thoughtcrime.securesms.util.RecipientAccessList;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
@@ -513,12 +512,7 @@ private void processStateless(@NonNull Function1<WebRtcEphemeralState, WebRtcEph
|
||||
}
|
||||
|
||||
@Override public void onNetworkRouteChanged(Remote remote, NetworkRoute networkRoute) {
|
||||
Log.i(TAG, "onNetworkRouteChanged: localAdapterType: " + networkRoute.getLocalAdapterType());
|
||||
try {
|
||||
callManager.updateBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, networkRoute.getLocalAdapterType()));
|
||||
} catch (CallException e) {
|
||||
Log.w(TAG, "Unable to update bandwidth mode on CallManager", e);
|
||||
}
|
||||
process((s, p) -> p.handleNetworkRouteChanged(s, networkRoute));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.signal.ringrtc.CallId;
|
||||
import org.signal.ringrtc.CallManager;
|
||||
import org.signal.ringrtc.CallManager.RingUpdate;
|
||||
import org.signal.ringrtc.GroupCall;
|
||||
import org.signal.ringrtc.NetworkRoute;
|
||||
import org.thoughtcrime.securesms.components.sensors.Orientation;
|
||||
import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink;
|
||||
import org.thoughtcrime.securesms.components.webrtc.EglBaseWrapper;
|
||||
@@ -547,6 +548,22 @@ public abstract class WebRtcActionProcessor {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleNetworkRouteChanged(@NonNull WebRtcServiceState currentState, @NonNull NetworkRoute networkRoute) {
|
||||
Log.i(tag, "onNetworkRouteChanged: localAdapterType: " + networkRoute.getLocalAdapterType());
|
||||
try {
|
||||
webRtcInteractor.getCallManager().updateBandwidthMode(NetworkUtil.getCallingBandwidthMode(context, networkRoute.getLocalAdapterType()));
|
||||
} catch (CallException e) {
|
||||
Log.w(tag, "Unable to update bandwidth mode on CallManager", e);
|
||||
}
|
||||
|
||||
PeerConnection.AdapterType type = networkRoute.getLocalAdapterType();
|
||||
return currentState.builder()
|
||||
.changeLocalDeviceState()
|
||||
.setNetworkConnectionType(type)
|
||||
.commit()
|
||||
.build();
|
||||
}
|
||||
|
||||
protected @NonNull WebRtcServiceState handleBandwidthModeUpdate(@NonNull WebRtcServiceState currentState) {
|
||||
try {
|
||||
webRtcInteractor.getCallManager().updateBandwidthMode(NetworkUtil.getCallingBandwidthMode(context));
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.service.webrtc.state
|
||||
import org.thoughtcrime.securesms.components.sensors.Orientation
|
||||
import org.thoughtcrime.securesms.ringrtc.CameraState
|
||||
import org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager
|
||||
import org.webrtc.PeerConnection
|
||||
|
||||
/**
|
||||
* Local device specific state.
|
||||
@@ -15,7 +16,8 @@ data class LocalDeviceState constructor(
|
||||
var deviceOrientation: Orientation = Orientation.PORTRAIT_BOTTOM_EDGE,
|
||||
var activeDevice: SignalAudioManager.AudioDevice = SignalAudioManager.AudioDevice.NONE,
|
||||
var availableDevices: Set<SignalAudioManager.AudioDevice> = emptySet(),
|
||||
var bluetoothPermissionDenied: Boolean = false
|
||||
var bluetoothPermissionDenied: Boolean = false,
|
||||
var networkConnectionType: PeerConnection.AdapterType = PeerConnection.AdapterType.UNKNOWN,
|
||||
) {
|
||||
|
||||
fun duplicate(): LocalDeviceState {
|
||||
|
||||
@@ -130,6 +130,11 @@ public class WebRtcServiceStateBuilder {
|
||||
toBuild.setBluetoothPermissionDenied(bluetoothPermissionDenied);
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull LocalDeviceStateBuilder setNetworkConnectionType(@NonNull PeerConnection.AdapterType type) {
|
||||
toBuild.setNetworkConnectionType(type);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class CallSetupStateBuilder {
|
||||
|
||||
Reference in New Issue
Block a user