diff --git a/play-services-auth-api-phone/core/src/main/kotlin/org/microg/gms/auth/phone/SmsRetrieverCore.kt b/play-services-auth-api-phone/core/src/main/kotlin/org/microg/gms/auth/phone/SmsRetrieverCore.kt index c0c70b4945..14096e4ed1 100644 --- a/play-services-auth-api-phone/core/src/main/kotlin/org/microg/gms/auth/phone/SmsRetrieverCore.kt +++ b/play-services-auth-api-phone/core/src/main/kotlin/org/microg/gms/auth/phone/SmsRetrieverCore.kt @@ -25,6 +25,7 @@ import android.telephony.SmsMessage import android.text.TextUtils import android.util.Base64 import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.core.content.ContextCompat import androidx.core.os.bundleOf import androidx.lifecycle.DefaultLifecycleObserver @@ -160,7 +161,7 @@ class SmsRetrieverCore(private val context: Context, override val lifecycle: Lif private fun getTimeoutPendingIntent(context: Context, packageName: String): PendingIntent { val intent = Intent(ACTION_SMS_RETRIEVE_TIMEOUT) intent.setPackage(packageName) - return PendingIntent.getBroadcast(context, ++requestCode, intent, PendingIntent.FLAG_IMMUTABLE) + return PendingIntentCompat.getBroadcast(context, ++requestCode, intent, 0, false)!! } private fun tryHandleIncomingMessageAsRetrieverMessage(message: SmsMessage): Boolean { diff --git a/play-services-base/core/build.gradle b/play-services-base/core/build.gradle index 055c85b381..96ace60ae2 100644 --- a/play-services-base/core/build.gradle +++ b/play-services-base/core/build.gradle @@ -13,6 +13,7 @@ dependencies { implementation "androidx.annotation:annotation:$annotationVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" + implementation "androidx.core:core-ktx:$coreVersion" implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion" implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion" implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion" diff --git a/play-services-base/core/src/main/kotlin/org/microg/gms/utils/IntentCacheManager.kt b/play-services-base/core/src/main/kotlin/org/microg/gms/utils/IntentCacheManager.kt index fc57ced6f4..4a5e55be9d 100644 --- a/play-services-base/core/src/main/kotlin/org/microg/gms/utils/IntentCacheManager.kt +++ b/play-services-base/core/src/main/kotlin/org/microg/gms/utils/IntentCacheManager.kt @@ -7,9 +7,7 @@ package org.microg.gms.utils import android.app.AlarmManager import android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP -import android.app.PendingIntent import android.app.PendingIntent.FLAG_NO_CREATE -import android.app.PendingIntent.FLAG_MUTABLE import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.app.Service import android.content.Context @@ -18,6 +16,7 @@ import android.os.Build.VERSION.SDK_INT import android.os.Parcelable import android.os.SystemClock import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.core.content.getSystemService import java.util.UUID @@ -29,7 +28,7 @@ class IntentCacheManager(private val context: Conte private val pendingActions: MutableList<() -> Unit> = arrayListOf() init { - val pendingIntent = PendingIntent.getService(context, type, getIntent(), if (SDK_INT >= 31) FLAG_MUTABLE else 0) + val pendingIntent = PendingIntentCompat.getService(context, type, getIntent(), 0, true)!! val alarmManager = context.getSystemService() if (SDK_INT >= 19) { alarmManager?.setWindow(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + TEN_YEARS, -1, pendingIntent) @@ -116,7 +115,7 @@ class IntentCacheManager(private val context: Conte putExtra(EXTRA_ID, id) putParcelableArrayListExtra(EXTRA_DATA, content) } - val pendingIntent = PendingIntent.getService(context, type, intent, FLAG_NO_CREATE or FLAG_UPDATE_CURRENT or if (SDK_INT >= 31) FLAG_MUTABLE else 0) + val pendingIntent = PendingIntentCompat.getService(context, type, intent, FLAG_NO_CREATE or FLAG_UPDATE_CURRENT, true) if (pendingIntent == null) { Log.w(TAG, "Failed to update existing pending intent, will likely have a loss of information") } diff --git a/play-services-core/src/main/kotlin/org/microg/gms/games/GamesConnectService.kt b/play-services-core/src/main/kotlin/org/microg/gms/games/GamesConnectService.kt index e5f7486a63..34810ef768 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/games/GamesConnectService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/games/GamesConnectService.kt @@ -11,6 +11,7 @@ import android.content.Context import android.content.Intent import android.os.Parcel import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope @@ -51,10 +52,10 @@ class GamesConnectServiceImpl(val context: Context, override val lifecycle: Life override fun signIn(callback: IGamesConnectCallbacks?, request: GamesSignInRequest?) { Log.d(TAG, "signIn($request)") fun sendSignInRequired() { - val resolution = PendingIntent.getActivity(context, packageName.hashCode(), Intent(context, GamesSignInActivity::class.java).apply { + val resolution = PendingIntentCompat.getActivity(context, packageName.hashCode(), Intent(context, GamesSignInActivity::class.java).apply { putExtra(EXTRA_GAME_PACKAGE_NAME, packageName) putExtra(EXTRA_SCOPES, arrayOf(Scopes.GAMES_LITE)) - }, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + }, PendingIntent.FLAG_UPDATE_CURRENT, false) when (request?.signInType) { 0 -> { // Manual sign in, provide resolution callback?.onSignIn(Status(CommonStatusCodes.SIGN_IN_REQUIRED, null, resolution), null) diff --git a/play-services-core/src/main/kotlin/org/microg/gms/games/GamesService.kt b/play-services-core/src/main/kotlin/org/microg/gms/games/GamesService.kt index d6b3e96e8f..13e37a41ab 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/games/GamesService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/games/GamesService.kt @@ -14,6 +14,7 @@ import android.os.Bundle import android.os.IBinder import android.os.Parcel import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.core.os.bundleOf import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner @@ -55,7 +56,7 @@ class GamesService : BaseService(TAG, GmsService.GAMES) { Log.d(TAG, "Sending SIGN_IN_REQUIRED to $packageName") callback.onPostInitCompleteWithConnectionInfo(ConnectionResult.SIGN_IN_REQUIRED, null, ConnectionInfo().apply { params = bundleOf( - "pendingIntent" to PendingIntent.getActivity( + "pendingIntent" to PendingIntentCompat.getActivity( this@GamesService, packageName.hashCode(), Intent(this@GamesService, GamesSignInActivity::class.java).apply { @@ -63,7 +64,8 @@ class GamesService : BaseService(TAG, GmsService.GAMES) { putExtra(EXTRA_ACCOUNT, request.account) putExtra(EXTRA_SCOPES, request.scopes) }, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + PendingIntent.FLAG_UPDATE_CURRENT, + false ) ) }) diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt index 007450891e..0ac84f8fec 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt @@ -6,14 +6,13 @@ package org.microg.gms.fido.core.privileged import android.app.KeyguardManager -import android.app.PendingIntent -import android.app.PendingIntent.FLAG_IMMUTABLE import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.content.Context import android.content.Context.KEYGUARD_SERVICE import android.content.Intent import android.os.Build.VERSION.SDK_INT import android.os.Parcel +import androidx.core.app.PendingIntentCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.lifecycleScope @@ -70,7 +69,7 @@ class Fido2PrivilegedServiceImpl(private val context: Context, override val life .putExtra(KEY_OPTIONS, options.serializeToBytes()) val pendingIntent = - PendingIntent.getActivity(context, options.hashCode(), intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE) + PendingIntentCompat.getActivity(context, options.hashCode(), intent, FLAG_UPDATE_CURRENT, false) callbacks.onPendingIntent(Status.SUCCESS, pendingIntent) } } @@ -84,7 +83,7 @@ class Fido2PrivilegedServiceImpl(private val context: Context, override val life .putExtra(KEY_OPTIONS, options.serializeToBytes()) val pendingIntent = - PendingIntent.getActivity(context, options.hashCode(), intent, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE) + PendingIntentCompat.getActivity(context, options.hashCode(), intent, FLAG_UPDATE_CURRENT, false) callbacks.onPendingIntent(Status.SUCCESS, pendingIntent) } } diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/nfc/NfcTransportHandler.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/nfc/NfcTransportHandler.kt index b6d2f8ec8c..3d49cf895d 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/nfc/NfcTransportHandler.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/nfc/NfcTransportHandler.kt @@ -14,6 +14,7 @@ import android.nfc.Tag import android.nfc.tech.IsoDep import android.util.Log import androidx.core.app.OnNewIntentProvider +import androidx.core.app.PendingIntentCompat import androidx.core.util.Consumer import com.google.android.gms.fido.fido2.api.common.AuthenticatorAssertionResponse import com.google.android.gms.fido.fido2.api.common.AuthenticatorAttestationResponse @@ -36,7 +37,7 @@ class NfcTransportHandler(private val activity: Activity, callback: TransportHan private suspend fun waitForNewNfcTag(adapter: NfcAdapter): Tag { val intent = Intent(activity, activity.javaClass).apply { addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) } - val pendingIntent: PendingIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_MUTABLE) + val pendingIntent: PendingIntent = PendingIntentCompat.getActivity(activity, 0, intent, 0, true)!! adapter.enableForegroundDispatch( activity, pendingIntent, diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/usb/UsbDevicePermissionManager.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/usb/UsbDevicePermissionManager.kt index 1a9d1503c2..ef3c4098f1 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/usb/UsbDevicePermissionManager.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/usb/UsbDevicePermissionManager.kt @@ -13,6 +13,7 @@ import android.content.IntentFilter import android.hardware.usb.UsbDevice import android.hardware.usb.UsbManager import android.os.Build.VERSION.SDK_INT +import androidx.core.app.PendingIntentCompat import kotlinx.coroutines.CompletableDeferred private val Context.usbPermissionCallbackAction @@ -75,7 +76,7 @@ class UsbDevicePermissionManager(private val context: Context) { val res = CompletableDeferred() if (UsbDevicePermissionReceiver.addDeferred(device, res)) { UsbDevicePermissionReceiver.register(context) - val intent = PendingIntent.getBroadcast(context, 0, Intent(context.usbPermissionCallbackAction).apply { `package` = context.packageName }, if (SDK_INT >= 31) PendingIntent.FLAG_MUTABLE else 0) + val intent = PendingIntentCompat.getBroadcast(context, 0, Intent(context.usbPermissionCallbackAction).apply { `package` = context.packageName }, 0, true) context.usbManager?.requestPermission(device, intent) } return res.await() diff --git a/play-services-location/core/provider/build.gradle b/play-services-location/core/provider/build.gradle index 3f8087be64..5eac582349 100644 --- a/play-services-location/core/provider/build.gradle +++ b/play-services-location/core/provider/build.gradle @@ -12,6 +12,7 @@ dependencies { implementation project(':play-services-base-core') implementation project(':play-services-location-core-base') + implementation "androidx.core:core-ktx:$coreVersion" implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" diff --git a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/provider/NetworkLocationProviderPreTiramisu.kt b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/provider/NetworkLocationProviderPreTiramisu.kt index 40972f4efb..f2a4001ce2 100644 --- a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/provider/NetworkLocationProviderPreTiramisu.kt +++ b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/provider/NetworkLocationProviderPreTiramisu.kt @@ -6,7 +6,6 @@ package org.microg.gms.location.provider import android.app.PendingIntent -import android.app.PendingIntent.FLAG_MUTABLE import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.content.Context import android.content.Intent @@ -15,6 +14,7 @@ import android.location.Location import android.os.Build.VERSION.SDK_INT import android.os.WorkSource import androidx.annotation.RequiresApi +import androidx.core.app.PendingIntentCompat import com.android.location.provider.ProviderPropertiesUnbundled import com.android.location.provider.ProviderRequestUnbundled import org.microg.gms.location.* @@ -86,7 +86,7 @@ class NetworkLocationProviderPreTiramisu : AbstractLocationProviderPreTiramisu { if (enabled) throw IllegalStateException() val intent = Intent(context, NetworkLocationProviderService::class.java) intent.action = ACTION_REPORT_LOCATION - pendingIntent = PendingIntent.getService(context, 0, intent, (if (SDK_INT >= 31) FLAG_MUTABLE else 0) or FLAG_UPDATE_CURRENT) + pendingIntent = PendingIntentCompat.getService(context, 0, intent, FLAG_UPDATE_CURRENT, true) currentRequest = null enabled = true when { diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt index bdd3701873..09a0af4ef3 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt @@ -8,8 +8,6 @@ package org.microg.gms.nearby.exposurenotification import android.annotation.SuppressLint import android.annotation.TargetApi import android.app.AlarmManager -import android.app.PendingIntent -import android.app.PendingIntent.FLAG_IMMUTABLE import android.app.PendingIntent.FLAG_ONE_SHOT import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.bluetooth.BluetoothAdapter.* @@ -24,6 +22,7 @@ import android.os.Handler import android.os.Looper import android.os.SystemClock import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import kotlinx.coroutines.Dispatchers @@ -199,7 +198,7 @@ class AdvertiserService : LifecycleService() { private fun scheduleRestartAdvertising(nextSend: Long) { val intent = Intent(this, AdvertiserService::class.java).apply { action = ACTION_RESTART_ADVERTISING } - val pendingIntent = PendingIntent.getService(this, ACTION_RESTART_ADVERTISING.hashCode(), intent, FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE) + val pendingIntent = PendingIntentCompat.getService(this, ACTION_RESTART_ADVERTISING.hashCode(), intent, FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT, false)!! when { SDK_INT >= 23 -> alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + nextSend, pendingIntent) diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/CleanupService.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/CleanupService.kt index c313e91ff4..ba842d3aa5 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/CleanupService.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/CleanupService.kt @@ -6,13 +6,12 @@ package org.microg.gms.nearby.exposurenotification import android.app.AlarmManager -import android.app.PendingIntent -import android.app.PendingIntent.FLAG_IMMUTABLE import android.app.PendingIntent.FLAG_ONE_SHOT import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.content.Context import android.content.Intent import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import kotlinx.coroutines.Dispatchers @@ -50,7 +49,7 @@ class CleanupService : LifecycleService() { fun stop() { val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager - val pendingIntent = PendingIntent.getService(applicationContext, CleanupService::class.java.name.hashCode(), Intent(applicationContext, CleanupService::class.java), FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE) + val pendingIntent = PendingIntentCompat.getService(applicationContext, CleanupService::class.java.name.hashCode(), Intent(applicationContext, CleanupService::class.java), FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT, false)!! alarmManager.set(AlarmManager.RTC, ExposurePreferences(this).lastCleanup + CLEANUP_INTERVAL, pendingIntent) stopSelf() } diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt index 122414935b..e31eeb73a4 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt @@ -16,6 +16,7 @@ import android.location.LocationManager import android.os.* import android.util.Base64 import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.core.location.LocationManagerCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleCoroutineScope @@ -113,7 +114,7 @@ class ExposureNotificationServiceImpl(private val context: Context, override val Log.w(TAG, e) } Log.d(TAG, "Pending: $intent") - val pi = PendingIntent.getActivity(context, permission.hashCode(), intent, PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE) + val pi = PendingIntentCompat.getActivity(context, permission.hashCode(), intent, PendingIntent.FLAG_ONE_SHOT, false)!! Log.d(TAG, "Pending: $pi") return pi } diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt index 6207db6ee8..8adec59159 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt @@ -7,7 +7,6 @@ package org.microg.gms.nearby.exposurenotification import android.annotation.TargetApi import android.app.* -import android.app.PendingIntent.FLAG_IMMUTABLE import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.bluetooth.BluetoothAdapter import android.content.BroadcastReceiver @@ -22,6 +21,7 @@ import android.util.Log import android.util.TypedValue import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import androidx.core.app.PendingIntentCompat import androidx.core.content.ContextCompat import androidx.core.location.LocationManagerCompat import androidx.lifecycle.LifecycleService @@ -99,7 +99,7 @@ class NotifyService : LifecycleService() { try { val intent = Intent(ExposureNotificationClient.ACTION_EXPOSURE_NOTIFICATION_SETTINGS).apply { `package` = packageName } intent.resolveActivity(packageManager) - setContentIntent(PendingIntent.getActivity(this@NotifyService, notificationId, Intent(ExposureNotificationClient.ACTION_EXPOSURE_NOTIFICATION_SETTINGS).apply { `package` = packageName }, FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE)) + setContentIntent(PendingIntentCompat.getActivity(this@NotifyService, notificationId, Intent(ExposureNotificationClient.ACTION_EXPOSURE_NOTIFICATION_SETTINGS).apply { `package` = packageName }, FLAG_UPDATE_CURRENT, false)) } catch (e: Exception) { // Ignore } diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ScannerService.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ScannerService.kt index 0d4b5cb9dc..f363737c00 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ScannerService.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ScannerService.kt @@ -8,8 +8,6 @@ package org.microg.gms.nearby.exposurenotification import android.annotation.SuppressLint import android.annotation.TargetApi import android.app.AlarmManager -import android.app.PendingIntent -import android.app.PendingIntent.FLAG_IMMUTABLE import android.app.PendingIntent.FLAG_ONE_SHOT import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.bluetooth.BluetoothAdapter.* @@ -20,6 +18,7 @@ import android.content.Intent import android.content.IntentFilter import android.os.* import android.util.Log +import androidx.core.app.PendingIntentCompat import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import org.microg.gms.common.ForegroundServiceContext @@ -161,7 +160,7 @@ class ScannerService : LifecycleService() { private fun scheduleStartScan(nextScan: Long) { val intent = Intent(this, ScannerService::class.java) - val pendingIntent = PendingIntent.getService(this, ScannerService::class.java.hashCode(), intent, FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE) + val pendingIntent = PendingIntentCompat.getService(this, ScannerService::class.java.hashCode(), intent, FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT, false)!! if (Build.VERSION.SDK_INT >= 23) { // Note: there is no setWindowAndAllowWhileIdle() alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + nextScan, pendingIntent) diff --git a/play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java b/play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java index 7cf3947799..9d27a77370 100644 --- a/play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java +++ b/play-services-tasks/src/main/java/com/google/android/gms/tasks/Task.java @@ -114,7 +114,7 @@ public Task addOnCompleteListener(Executor executor, OnCompleteListener public abstract Task addOnFailureListener(Activity activity, OnFailureListener listener); /** - * Adds an Activity-scoped listener that is called if the Task fails. + * Adds a listener that is called if the Task fails. *

* The listener will be called on main application thread. If the Task has already failed, a * call to the listener will be immediately scheduled. If multiple listeners are added, they