mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Only use startForegroundService for initial service construction
This commit is contained in:
parent
71727e1474
commit
4de14a5dc1
@ -256,8 +256,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_ADDRESS, Address.fromExternal(context, envelope.getSource()));
|
||||
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_DESCRIPTION, message.getDescription());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(intent);
|
||||
else context.startService(intent);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
private void handleCallIceUpdateMessage(@NonNull SignalServiceEnvelope envelope,
|
||||
@ -273,8 +272,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
intent.putExtra(WebRtcCallService.EXTRA_ICE_SDP_MID, message.getSdpMid());
|
||||
intent.putExtra(WebRtcCallService.EXTRA_ICE_SDP_LINE_INDEX, message.getSdpMLineIndex());
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(intent);
|
||||
else context.startService(intent);
|
||||
context.startService(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,8 +289,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId());
|
||||
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_ADDRESS, Address.fromExternal(context, envelope.getSource()));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(intent);
|
||||
else context.startService(intent);
|
||||
context.startService(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,8 +301,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
intent.putExtra(WebRtcCallService.EXTRA_CALL_ID, message.getId());
|
||||
intent.putExtra(WebRtcCallService.EXTRA_REMOTE_ADDRESS, Address.fromExternal(context, envelope.getSource()));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(intent);
|
||||
else context.startService(intent);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
private void handleEndSessionMessage(@NonNull MasterSecretUnion masterSecret,
|
||||
|
@ -194,9 +194,7 @@ public class WebRtcCallService extends Service implements InjectableType, PeerCo
|
||||
Log.w(TAG, "onStartCommand...");
|
||||
if (intent == null || intent.getAction() == null) return START_NOT_STICKY;
|
||||
|
||||
serviceExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
serviceExecutor.execute(() -> {
|
||||
if (intent.getAction().equals(ACTION_INCOMING_CALL) && isBusy()) handleBusyCall(intent);
|
||||
else if (intent.getAction().equals(ACTION_REMOTE_BUSY)) handleBusyMessage(intent);
|
||||
else if (intent.getAction().equals(ACTION_INCOMING_CALL)) handleIncomingCall(intent);
|
||||
@ -218,7 +216,6 @@ public class WebRtcCallService extends Service implements InjectableType, PeerCo
|
||||
else if (intent.getAction().equals(ACTION_CALL_CONNECTED)) handleCallConnected(intent);
|
||||
else if (intent.getAction().equals(ACTION_CHECK_TIMEOUT)) handleCheckTimeout(intent);
|
||||
else if (intent.getAction().equals(ACTION_IS_IN_CALL_QUERY)) handleIsInCallQuery(intent);
|
||||
}
|
||||
});
|
||||
|
||||
return START_NOT_STICKY;
|
||||
@ -601,6 +598,17 @@ public class WebRtcCallService extends Service implements InjectableType, PeerCo
|
||||
Recipient recipient = getRemoteRecipient(intent);
|
||||
long callId = getCallId(intent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
switch (callState) {
|
||||
case STATE_DIALING:
|
||||
case STATE_REMOTE_RINGING: setCallInProgressNotification(TYPE_OUTGOING_RINGING, this.recipient); break;
|
||||
case STATE_ANSWERING: setCallInProgressNotification(TYPE_INCOMING_CONNECTING, this.recipient); break;
|
||||
case STATE_LOCAL_RINGING: setCallInProgressNotification(TYPE_INCOMING_RINGING, this.recipient); break;
|
||||
case STATE_CONNECTED: setCallInProgressNotification(TYPE_ESTABLISHED, this.recipient); break;
|
||||
default: throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(recipient, SignalServiceCallMessage.forBusy(new BusyMessage(callId)));
|
||||
insertMissedCall(getRemoteRecipient(intent), false);
|
||||
}
|
||||
@ -1109,9 +1117,7 @@ public class WebRtcCallService extends Service implements InjectableType, PeerCo
|
||||
}
|
||||
|
||||
private ListenableFutureTask<List<PeerConnection.IceServer>> retrieveTurnServers() {
|
||||
Callable<List<PeerConnection.IceServer>> callable = new Callable<List<PeerConnection.IceServer>>() {
|
||||
@Override
|
||||
public List<PeerConnection.IceServer> call() {
|
||||
Callable<List<PeerConnection.IceServer>> callable = () -> {
|
||||
LinkedList<PeerConnection.IceServer> results = new LinkedList<>();
|
||||
|
||||
try {
|
||||
@ -1130,7 +1136,6 @@ public class WebRtcCallService extends Service implements InjectableType, PeerCo
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
ListenableFutureTask<List<PeerConnection.IceServer>> futureTask = new ListenableFutureTask<>(callable, null, serviceExecutor);
|
||||
|
Loading…
x
Reference in New Issue
Block a user