Skip to content
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

Upgrade to Android 14, Sdk Version 34 #986

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
defaultConfig {
applicationId "org.xbmc.kore"
minSdkVersion 24
targetSdkVersion 33
targetSdkVersion 34
versionCode 31
versionName = getVersionName()
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<!--
Added notification permission so that code in MediaSessionService doesn't show errors.
This is not really necessary, given that notifications are sent via MediaService, and those
Expand All @@ -31,8 +32,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="n">
android:networkSecurityConfig="@xml/network_security_config">

<!-- Activities -->
<activity
Expand Down Expand Up @@ -195,6 +195,7 @@
android:exported="false" />
<service
android:name=".service.MediaSessionService"
android:foregroundServiceType="mediaPlayback"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -200,7 +201,11 @@ public int onStartCommand(Intent intent, int flags, int startId) {
}

// Request foreground and show default notification, will update later
startForeground(NOTIFICATION_ID, nothingPlayingNotification);
if (Utils.isUpsideDownCakeOrLater()) {
startForeground(NOTIFICATION_ID, nothingPlayingNotification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
} else {
startForeground(NOTIFICATION_ID, nothingPlayingNotification);
}

HostConnectionObserver connectionObserver = HostManager.getInstance(this).getHostConnectionObserver();
if (hostConnectionObserver == null || hostConnectionObserver != connectionObserver) {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/xbmc/kore/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public static boolean isTiramisuOrLater() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU;
}

public static boolean isUpsideDownCakeOrLater() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
}

/**
* Concats a list of strings
* @param list List to concatenate
Expand Down
Loading