Skip to content

Commit

Permalink
Feat[launcher]: update to SDK 34
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Aug 22, 2024
1 parent ae48e8e commit 2d81ff0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ configurations {
android {
namespace 'net.kdt.pojavlaunch'

compileSdk = 33
compileSdk = 34

lintOptions {
abortOnError false
Expand All @@ -114,7 +114,7 @@ android {
defaultConfig {
applicationId "net.kdt.pojavlaunch"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode getDateSeconds()
versionName getVersionName()
multiDexEnabled true //important
Expand Down
8 changes: 6 additions & 2 deletions app_pojavlauncher/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>

<application
android:name=".PojavApplication"
Expand Down Expand Up @@ -119,10 +121,12 @@
</intent-filter>
</provider>

<service android:name=".services.ProgressService" />
<service android:name=".services.ProgressService"
android:foregroundServiceType="dataSync"/>
<service
android:name=".services.GameService"
android:process=":game" />
android:process=":game"
android:foregroundServiceType="mediaPlayback"/>
</application>
<queries>
<package android:name="net.kdt.pojavlaunch.ffmpeg"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package net.kdt.pojavlaunch.services;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
Expand Down Expand Up @@ -43,7 +45,13 @@ public int onStartCommand(Intent intent, int flags, int startId) {
.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.notification_terminate), pendingKillIntent)
.setSmallIcon(R.drawable.notif_icon)
.setNotificationSilent();
startForeground(NotificationUtils.NOTIFICATION_ID_GAME_SERVICE, notificationBuilder.build());

Notification notification = notificationBuilder.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(NotificationUtils.NOTIFICATION_ID_GAME_SERVICE, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
} else {
startForeground(NotificationUtils.NOTIFICATION_ID_GAME_SERVICE, notification);
}
return START_NOT_STICKY; // non-sticky so android wont try restarting the game after the user uses the "Quit" button
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package net.kdt.pojavlaunch.services;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.os.Build;
import android.os.IBinder;
import android.os.Process;
Expand Down Expand Up @@ -64,7 +66,12 @@ public int onStartCommand(Intent intent, int flags, int startId) {
}
Log.d("ProgressService", "Started!");
mNotificationBuilder.setContentText(getString(R.string.progresslayout_tasks_in_progress, ProgressKeeper.getTaskCount()));
startForeground(NotificationUtils.NOTIFICATION_ID_PROGRESS_SERVICE, mNotificationBuilder.build());
Notification notification = mNotificationBuilder.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(NotificationUtils.NOTIFICATION_ID_PROGRESS_SERVICE, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
} else {
startForeground(NotificationUtils.NOTIFICATION_ID_PROGRESS_SERVICE, notification);
}
if(ProgressKeeper.getTaskCount() < 1) stopSelf();
else ProgressKeeper.addTaskCountListener(this, false);

Expand Down

0 comments on commit 2d81ff0

Please sign in to comment.