mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
ipc,t/oxr_android: Add FLAG_IMMUTABLE for PendingIntent from S+
Signed-off-by: utzcoz <utzcoz@outlook.com>
This commit is contained in:
parent
62c87d27d6
commit
34c97c48ef
|
@ -82,11 +82,16 @@ class MonadoService : Service(), Watchdog.ShutdownListener {
|
|||
}
|
||||
|
||||
private fun handleStart() {
|
||||
var flags = 0
|
||||
// From targeting S+, the PendingIntent needs one of FLAG_IMMUTABLE and FLAG_MUTABLE
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
flags = PendingIntent.FLAG_IMMUTABLE
|
||||
}
|
||||
val pendingShutdownIntent = PendingIntent.getForegroundService(
|
||||
this,
|
||||
0,
|
||||
Intent(BuildConfig.SHUTDOWN_ACTION).setPackage(packageName),
|
||||
0
|
||||
flags
|
||||
)
|
||||
|
||||
val notification = serviceNotification.buildNotification(this, pendingShutdownIntent)
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.content.ComponentName
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import org.freedesktop.monado.android_common.AboutActivity
|
||||
import org.freedesktop.monado.auxiliary.UiProvider
|
||||
|
@ -29,14 +30,22 @@ class MonadoOpenXrUiProvider @Inject constructor(@ApplicationContext val context
|
|||
/**
|
||||
* Make a {@code PendingIntent} to launch an "About" activity for the runtime/target.
|
||||
*/
|
||||
override fun makeAboutActivityPendingIntent(): PendingIntent =
|
||||
PendingIntent.getActivity(context,
|
||||
0,
|
||||
Intent.makeMainActivity(
|
||||
ComponentName.createRelative(context,
|
||||
AboutActivity::class.qualifiedName!!)),
|
||||
0
|
||||
)
|
||||
|
||||
override fun makeAboutActivityPendingIntent(): PendingIntent {
|
||||
var flags = 0
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
flags = PendingIntent.FLAG_IMMUTABLE
|
||||
}
|
||||
return PendingIntent.getActivity(
|
||||
context,
|
||||
0,
|
||||
Intent.makeMainActivity(
|
||||
ComponentName.createRelative(
|
||||
context,
|
||||
AboutActivity::class.qualifiedName!!
|
||||
)
|
||||
),
|
||||
flags
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue