-
Notifications
You must be signed in to change notification settings - Fork 906
Fix crash when starting screen sharing during a call. #9154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,17 +12,18 @@ import android.Manifest | |
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.content.pm.PackageManager | ||
| import android.content.pm.ServiceInfo | ||
| import android.os.Binder | ||
| import android.support.v4.media.session.MediaSessionCompat | ||
| import android.view.KeyEvent | ||
| import androidx.core.app.ActivityCompat | ||
| import androidx.core.app.NotificationManagerCompat | ||
| import androidx.core.app.ServiceCompat | ||
| import androidx.core.content.ContextCompat | ||
| import androidx.media.session.MediaButtonReceiver | ||
| import com.airbnb.mvrx.Mavericks | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import im.vector.app.core.extensions.singletonEntryPoint | ||
| import im.vector.app.core.extensions.startForegroundCompat | ||
| import im.vector.app.features.call.CallArgs | ||
| import im.vector.app.features.call.VectorCallActivity | ||
| import im.vector.app.features.call.audio.MicrophoneAccessService | ||
|
|
@@ -178,7 +179,12 @@ class CallAndroidService : VectorAndroidService() { | |
| fromBg = fromBg | ||
| ) | ||
| if (knownCalls.isEmpty()) { | ||
| startForegroundCompat(callId.hashCode(), notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| callId.hashCode(), | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, | ||
| ) | ||
| } else { | ||
| if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { | ||
| Timber.w("Not allowed to notify.") | ||
|
|
@@ -201,8 +207,12 @@ class CallAndroidService : VectorAndroidService() { | |
| return | ||
| } | ||
| val notification = notificationUtils.buildCallEndedNotification(false) | ||
| val notificationId = callId.hashCode() | ||
| startForegroundCompat(notificationId, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| callId.hashCode(), | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| if (knownCalls.isEmpty()) { | ||
| Timber.tag(loggerTag.value).v("No more call, stop the service") | ||
| stopForegroundCompat() | ||
|
|
@@ -240,7 +250,12 @@ class CallAndroidService : VectorAndroidService() { | |
| title = callInformation.opponentMatrixItem?.getBestName() ?: callInformation.opponentUserId | ||
| ) | ||
| if (knownCalls.isEmpty()) { | ||
| startForegroundCompat(callId.hashCode(), notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| callId.hashCode(), | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } else { | ||
| if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { | ||
| Timber.w("Not allowed to notify.") | ||
|
|
@@ -268,7 +283,12 @@ class CallAndroidService : VectorAndroidService() { | |
| title = callInformation.opponentMatrixItem?.getBestName() ?: callInformation.opponentUserId | ||
| ) | ||
| if (knownCalls.isEmpty()) { | ||
| startForegroundCompat(callId.hashCode(), notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| callId.hashCode(), | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } else { | ||
| if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { | ||
| Timber.w("Not allowed to notify.") | ||
|
|
@@ -285,9 +305,19 @@ class CallAndroidService : VectorAndroidService() { | |
| callRingPlayerOutgoing?.stop() | ||
| val notification = notificationUtils.buildCallEndedNotification(false) | ||
| if (callId != null) { | ||
| startForegroundCompat(callId.hashCode(), notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| callId.hashCode(), | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } else { | ||
| startForegroundCompat(DEFAULT_NOTIFICATION_ID, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| DEFAULT_NOTIFICATION_ID, | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } | ||
| if (knownCalls.isEmpty()) { | ||
| mediaSession?.isActive = false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,9 @@ import android.app.NotificationManager | |
| import android.app.PendingIntent | ||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.content.pm.ServiceInfo | ||
| import android.os.Build | ||
| import androidx.core.app.ServiceCompat | ||
| import androidx.core.content.getSystemService | ||
| import androidx.work.Constraints | ||
| import androidx.work.Data | ||
|
|
@@ -22,7 +24,6 @@ import androidx.work.WorkRequest | |
| import androidx.work.Worker | ||
| import androidx.work.WorkerParameters | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import im.vector.app.core.extensions.startForegroundCompat | ||
| import im.vector.app.core.platform.PendingIntentCompat | ||
| import im.vector.app.features.notifications.NotificationUtils | ||
| import im.vector.app.features.settings.BackgroundSyncMode | ||
|
|
@@ -90,7 +91,12 @@ class VectorSyncAndroidService : SyncAndroidService() { | |
| CommonStrings.notification_listening_for_notifications | ||
| } | ||
| val notification = notificationUtils.buildForegroundServiceNotification(notificationSubtitleRes, false) | ||
| startForegroundCompat(NotificationUtils.NOTIFICATION_ID_FOREGROUND_SERVICE, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| NotificationUtils.NOTIFICATION_ID_FOREGROUND_SERVICE, | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } | ||
|
|
||
| override fun onRescheduleAsked( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,11 @@ | |
| package im.vector.app.features.call.audio | ||
|
|
||
| import android.content.Intent | ||
| import android.content.pm.ServiceInfo | ||
| import android.os.Binder | ||
| import android.os.IBinder | ||
| import androidx.core.app.ServiceCompat | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import im.vector.app.core.extensions.startForegroundCompat | ||
| import im.vector.app.core.services.VectorAndroidService | ||
| import im.vector.app.features.notifications.NotificationUtils | ||
| import im.vector.lib.core.utils.timer.Clock | ||
|
|
@@ -42,7 +43,12 @@ class MicrophoneAccessService : VectorAndroidService() { | |
| private fun showMicrophoneAccessNotification() { | ||
| val notificationId = clock.epochMillis().toInt() | ||
| val notification = notificationUtils.buildMicrophoneAccessNotification() | ||
| startForegroundCompat(notificationId, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| notificationId, | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } | ||
|
|
||
| override fun onBind(intent: Intent?): IBinder { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,11 @@ | |
| package im.vector.app.features.call.webrtc | ||
|
|
||
| import android.content.Intent | ||
| import android.content.pm.ServiceInfo | ||
| import android.os.Binder | ||
| import android.os.IBinder | ||
| import androidx.core.app.ServiceCompat | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import im.vector.app.core.extensions.startForegroundCompat | ||
| import im.vector.app.core.services.VectorAndroidService | ||
| import im.vector.app.features.notifications.NotificationUtils | ||
| import im.vector.lib.core.utils.timer.Clock | ||
|
|
@@ -33,7 +34,12 @@ class ScreenCaptureAndroidService : VectorAndroidService() { | |
| private fun showStickyNotification() { | ||
| val notificationId = clock.epochMillis().toInt() | ||
| val notification = notificationUtils.buildScreenSharingNotification() | ||
| startForegroundCompat(notificationId, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| notificationId, | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } | ||
|
|
||
| override fun onBind(intent: Intent?): IBinder { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,14 @@ package im.vector.app.features.location.live.tracking | |
| import android.Manifest | ||
| import android.content.Intent | ||
| import android.content.pm.PackageManager | ||
| import android.content.pm.ServiceInfo | ||
| import android.os.IBinder | ||
| import android.os.Parcelable | ||
| import androidx.core.app.ActivityCompat | ||
| import androidx.core.app.NotificationManagerCompat | ||
| import androidx.core.app.ServiceCompat | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import im.vector.app.core.di.ActiveSessionHolder | ||
| import im.vector.app.core.extensions.startForegroundCompat | ||
| import im.vector.app.core.services.VectorAndroidService | ||
| import im.vector.app.core.utils.PermissionChecker | ||
| import im.vector.app.features.location.LocationData | ||
|
|
@@ -114,7 +115,12 @@ class LocationSharingAndroidService : VectorAndroidService(), LocationTracker.Ca | |
| NotificationManagerCompat.from(this).notify(FOREGROUND_SERVICE_NOTIFICATION_ID, notification) | ||
| } | ||
| } else { | ||
| startForegroundCompat(FOREGROUND_SERVICE_NOTIFICATION_ID, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| FOREGROUND_SERVICE_NOTIFICATION_ID, | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| foregroundModeStarted = true | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,11 @@ | |
| package im.vector.app.features.start | ||
|
|
||
| import android.content.Intent | ||
| import android.content.pm.ServiceInfo | ||
| import androidx.core.app.ServiceCompat | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import im.vector.app.core.di.ActiveSessionHolder | ||
| import im.vector.app.core.di.NamedGlobalScope | ||
| import im.vector.app.core.extensions.startForegroundCompat | ||
| import im.vector.app.core.services.VectorAndroidService | ||
| import im.vector.app.features.notifications.NotificationUtils | ||
| import kotlinx.coroutines.CoroutineScope | ||
|
|
@@ -50,6 +51,11 @@ class StartAppAndroidService : VectorAndroidService() { | |
| private fun showStickyNotification() { | ||
| val notificationId = Random.nextInt() | ||
| val notification = notificationUtils.buildStartAppNotification() | ||
| startForegroundCompat(notificationId, notification) | ||
| ServiceCompat.startForeground( | ||
| this, | ||
| notificationId, | ||
| notification, | ||
| ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_PHONE_CALLandroid.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_PHONE_CALL