kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add foreground service type to WebRtcCallService.
rodzic
e0f3e34899
commit
652d0d46ed
|
@ -659,7 +659,7 @@
|
|||
android:theme="@style/Theme.Signal.DayNight.NoActionBar"
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
|
||||
|
||||
<service android:enabled="true" android:name=".service.webrtc.WebRtcCallService"/>
|
||||
<service android:enabled="true" android:name=".service.webrtc.WebRtcCallService" android:foregroundServiceType="camera|microphone"/>
|
||||
<service android:enabled="true" android:name=".service.ApplicationMigrationService"/>
|
||||
<service android:enabled="true" android:exported="false" android:name=".service.KeyCachingService"/>
|
||||
<service android:enabled="true" android:name=".messages.IncomingMessageObserver$ForegroundService"/>
|
||||
|
|
|
@ -6,8 +6,10 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
@ -18,8 +20,6 @@ import androidx.core.content.ContextCompat;
|
|||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraintObserver;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
||||
|
@ -200,10 +200,10 @@ public final class WebRtcCallService extends Service implements SignalAudioManag
|
|||
|
||||
private void setCallNotification() {
|
||||
if (lastNotificationId != INVALID_NOTIFICATION_ID) {
|
||||
startForeground(lastNotificationId, lastNotification);
|
||||
startForegroundCompat(lastNotificationId, lastNotification);
|
||||
} else {
|
||||
Log.w(TAG, "Service running without having called start first, show temp notification and terminate service.");
|
||||
startForeground(CallNotificationBuilder.getStoppingNotificationId(), CallNotificationBuilder.getStoppingNotification(this));
|
||||
startForegroundCompat(CallNotificationBuilder.getStoppingNotificationId(), CallNotificationBuilder.getStoppingNotification(this));
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,15 @@ public final class WebRtcCallService extends Service implements SignalAudioManag
|
|||
lastNotificationId = CallNotificationBuilder.getNotificationId(type);
|
||||
lastNotification = CallNotificationBuilder.getCallInProgressNotification(this, type, Recipient.resolved(id));
|
||||
|
||||
startForeground(lastNotificationId, lastNotification);
|
||||
startForegroundCompat(lastNotificationId, lastNotification);
|
||||
}
|
||||
|
||||
private void startForegroundCompat(int notificationId, Notification notification) {
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE);
|
||||
} else {
|
||||
startForeground(notificationId, notification);
|
||||
}
|
||||
}
|
||||
|
||||
private void stop() {
|
||||
|
|
Ładowanie…
Reference in New Issue