diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 1a8f14d4..a37848a0 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -1,5 +1,5 @@ ext.versions = [ minSdk : 21, - targetSdk : 30, + targetSdk : 31, compileSdk : 31, ] \ No newline at end of file diff --git a/ultrasonic/src/main/AndroidManifest.xml b/ultrasonic/src/main/AndroidManifest.xml index 27946252..78fc9d0f 100644 --- a/ultrasonic/src/main/AndroidManifest.xml +++ b/ultrasonic/src/main/AndroidManifest.xml @@ -40,7 +40,8 @@ + android:launchMode="singleTask" + android:exported="true"> @@ -63,7 +64,7 @@ + android:exported="false"> @@ -71,7 +72,8 @@ - + @@ -85,7 +87,8 @@ + android:label="Ultrasonic (4x1)" + android:exported="false"> @@ -96,7 +99,8 @@ + android:label="Ultrasonic (4x2)" + android:exported="false"> @@ -107,7 +111,8 @@ + android:label="Ultrasonic (4x3)" + android:exported="false"> @@ -118,7 +123,8 @@ + android:label="Ultrasonic (4x4)" + android:exported="false"> @@ -127,14 +133,16 @@ android:name="android.appwidget.provider" android:resource="@xml/appwidget_info_4x4"/> - + + android:authorities="org.moire.ultrasonic.provider.SearchSuggestionProvider" + android:exported="false" /> diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/playback/PlaybackService.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/playback/PlaybackService.kt index f2b56c0a..5c675fbb 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/playback/PlaybackService.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/playback/PlaybackService.kt @@ -15,7 +15,6 @@ */ package org.moire.ultrasonic.playback -import android.annotation.SuppressLint import android.app.PendingIntent import android.content.Intent import androidx.media3.common.AudioAttributes @@ -135,11 +134,14 @@ class PlaybackService : MediaLibraryService(), KoinComponent { .build() } - @SuppressLint("UnspecifiedImmutableFlag") private fun getPendingIntentForContent(): PendingIntent { val intent = Intent(this, NavigationActivity::class.java) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) - val flags = PendingIntent.FLAG_UPDATE_CURRENT + var flags = PendingIntent.FLAG_UPDATE_CURRENT + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + // needed starting Android 12 (S = 31) + flags = flags or PendingIntent.FLAG_IMMUTABLE + } intent.putExtra(Constants.INTENT_SHOW_PLAYER, true) return PendingIntent.getActivity(this, 0, intent, flags) } diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/provider/UltrasonicAppWidgetProvider.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/provider/UltrasonicAppWidgetProvider.kt index 7a12fdfe..79a71759 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/provider/UltrasonicAppWidgetProvider.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/provider/UltrasonicAppWidgetProvider.kt @@ -7,7 +7,6 @@ package org.moire.ultrasonic.provider -import android.annotation.SuppressLint import android.app.PendingIntent import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetProvider @@ -164,7 +163,6 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() { /** * Link up various button actions using [PendingIntent]. */ - @SuppressLint("UnspecifiedImmutableFlag") private fun linkButtons(context: Context, views: RemoteViews, playerActive: Boolean) { var intent = Intent( context, @@ -173,8 +171,13 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() { if (playerActive) intent.putExtra(Constants.INTENT_SHOW_PLAYER, true) intent.action = "android.intent.action.MAIN" intent.addCategory("android.intent.category.LAUNCHER") + var flags = PendingIntent.FLAG_UPDATE_CURRENT + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + // needed starting Android 12 (S = 31) + flags = flags or PendingIntent.FLAG_IMMUTABLE + } var pendingIntent = - PendingIntent.getActivity(context, 10, intent, PendingIntent.FLAG_UPDATE_CURRENT) + PendingIntent.getActivity(context, 10, intent, flags) views.setOnClickPendingIntent(R.id.appwidget_coverart, pendingIntent) views.setOnClickPendingIntent(R.id.appwidget_top, pendingIntent) @@ -185,7 +188,12 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() { Intent.EXTRA_KEY_EVENT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) ) - pendingIntent = PendingIntent.getBroadcast(context, 11, intent, 0) + flags = 0 + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + // needed starting Android 12 (S = 31) + flags = flags or PendingIntent.FLAG_IMMUTABLE + } + pendingIntent = PendingIntent.getBroadcast(context, 11, intent, flags) views.setOnClickPendingIntent(R.id.control_play, pendingIntent) intent = Intent(Constants.CMD_PROCESS_KEYCODE) intent.component = ComponentName(context, MediaButtonIntentReceiver::class.java) @@ -193,7 +201,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() { Intent.EXTRA_KEY_EVENT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT) ) - pendingIntent = PendingIntent.getBroadcast(context, 12, intent, 0) + pendingIntent = PendingIntent.getBroadcast(context, 12, intent, flags) views.setOnClickPendingIntent(R.id.control_next, pendingIntent) intent = Intent(Constants.CMD_PROCESS_KEYCODE) intent.component = ComponentName(context, MediaButtonIntentReceiver::class.java) @@ -201,7 +209,7 @@ open class UltrasonicAppWidgetProvider : AppWidgetProvider() { Intent.EXTRA_KEY_EVENT, KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS) ) - pendingIntent = PendingIntent.getBroadcast(context, 13, intent, 0) + pendingIntent = PendingIntent.getBroadcast(context, 13, intent, flags) views.setOnClickPendingIntent(R.id.control_previous, pendingIntent) } } diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadService.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadService.kt index e9cc351d..5f3fcfe6 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadService.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadService.kt @@ -154,11 +154,14 @@ class DownloadService : Service() { return notificationBuilder.build() } - @SuppressLint("UnspecifiedImmutableFlag") private fun getPendingIntentForContent(): PendingIntent { val intent = Intent(this, NavigationActivity::class.java) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) - val flags = PendingIntent.FLAG_UPDATE_CURRENT + var flags = PendingIntent.FLAG_UPDATE_CURRENT + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { + // needed starting Android 12 (S = 31) + flags = flags or PendingIntent.FLAG_IMMUTABLE + } intent.putExtra(Constants.INTENT_SHOW_PLAYER, true) return PendingIntent.getActivity(this, 0, intent, flags) }