Skip to content

Commit f52051e

Browse files
committed
Raise target SDK to 33 for PdCore and PdTest
Target SDK for other apps was raised to the minimum SDK which is 28.
1 parent ead6dad commit f52051e

File tree

11 files changed

+59
-27
lines changed

11 files changed

+59
-27
lines changed

CircleOfFifths/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
package="org.puredata.android.fifths" >
44
<application android:icon="@drawable/icon" android:label="@string/app_name">
55
<activity android:name=".CircleOfFifths" android:label="@string/app_name"
6-
android:screenOrientation="portrait" android:theme="@style/DisableSoundEffects">
6+
android:screenOrientation="portrait" android:theme="@style/DisableSoundEffects"
7+
android:exported="true">
78
<intent-filter>
89
<action android:name="android.intent.action.MAIN" />
910
<category android:name="android.intent.category.LAUNCHER" />

CircleOfFifths/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android {
1313
defaultConfig {
1414
applicationId "org.puredata.android.fifths"
1515
minSdkVersion rootProject.minSdkVersion
16-
targetSdkVersion 22
16+
targetSdkVersion 28
1717
versionCode 3
1818
versionName "0.3"
1919
}

PdCore/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ android {
2222

2323
defaultConfig {
2424
minSdkVersion rootProject.minSdkVersion
25-
targetSdkVersion 30
25+
targetSdkVersion 33
2626
versionCode 1
2727
versionName version
2828
}

PdCore/src/main/java/org/puredata/android/service/PdService.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.app.Service;
2020
import android.content.Intent;
2121
import android.content.SharedPreferences;
22+
import android.content.pm.ServiceInfo;
2223
import android.content.res.Resources;
2324
import android.os.Binder;
2425
import android.os.Build;
@@ -232,17 +233,15 @@ public void onDestroy() {
232233
}
233234

234235
private Notification makeNotification(Intent intent, int icon, String title, String description) {
235-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
236-
NotificationManager notificationManager =
237-
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
238-
NotificationChannel channel =
239-
new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW);
240-
if (notificationManager != null) {
241-
notificationManager.createNotificationChannel(channel);
242-
}
236+
NotificationManager notificationManager =
237+
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
238+
NotificationChannel channel =
239+
new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW);
240+
if (notificationManager != null) {
241+
notificationManager.createNotificationChannel(channel);
243242
}
244243

245-
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
244+
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_IMMUTABLE);
246245
return new NotificationCompat.Builder(PdService.this, TAG)
247246
.setSmallIcon(icon)
248247
.setContentTitle(title)
@@ -256,7 +255,15 @@ private Notification makeNotification(Intent intent, int icon, String title, Str
256255

257256
private void startForeground(Notification notification) {
258257
stopForeground();
259-
startForeground(NOTIFICATION_ID, notification);
258+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
259+
int foregroundServiceTypes = ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK;
260+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
261+
foregroundServiceTypes |= ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE;
262+
}
263+
startForeground(NOTIFICATION_ID, notification, foregroundServiceTypes);
264+
} else {
265+
startForeground(NOTIFICATION_ID, notification);
266+
}
260267
hasForeground = true;
261268
}
262269

PdTest/AndroidManifest.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
package="org.puredata.android.test">
44
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/DisableSoundEffects">
55
<activity android:label="@string/app_name" android:name=".PdTest"
6-
android:screenOrientation="portrait" android:launchMode="singleTask">
6+
android:screenOrientation="portrait" android:launchMode="singleTask"
7+
android:exported="true">
78
<intent-filter>
89
<action android:name="android.intent.action.MAIN" />
910
<category android:name="android.intent.category.LAUNCHER" />
1011
</intent-filter>
1112
</activity>
12-
<service android:name="org.puredata.android.service.PdService" />
13+
<service android:name="org.puredata.android.service.PdService"
14+
android:foregroundServiceType="mediaPlayback|microphone"/>
1315
<activity android:label="Pure Data Preferences"
1416
android:name="org.puredata.android.service.PdPreferences"
1517
android:screenOrientation="portrait" />
1618
</application>
1719
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
1820
<uses-permission android:name="android.permission.RECORD_AUDIO" />
21+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
22+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
23+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
1924
<uses-permission android:name="android.permission.BLUETOOTH" />
20-
</manifest>
25+
</manifest>

PdTest/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ android {
1515

1616
defaultConfig {
1717
minSdkVersion rootProject.minSdkVersion
18-
targetSdkVersion 30
18+
targetSdkVersion 33
1919
versionCode 1
2020
versionName '1.0'
2121

PdTest/src/org/puredata/android/test/PdTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.content.SharedPreferences;
2828
import android.content.pm.PackageManager;
2929
import android.content.res.Resources;
30+
import android.os.Build;
3031
import android.os.IBinder;
3132
import android.preference.PreferenceManager;
3233
import androidx.annotation.NonNull;
@@ -245,7 +246,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
245246
@Override
246247
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
247248
@NonNull int[] grantResults) {
248-
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
249+
if (recordAudioPermissionGranted()) {
249250
startAudio();
250251
} else {
251252
toast("Can't start audio - microphone permission required!");
@@ -261,7 +262,7 @@ public void onClick(View v) {
261262
} else if (recordAudioPermissionGranted()) {
262263
startAudio();
263264
} else {
264-
requestAudioPermission();
265+
requestPermissions();
265266
}
266267

267268
PdBase.sendFloat("left", left.isChecked() ? 1 : 0);
@@ -335,7 +336,13 @@ private boolean recordAudioPermissionGranted() {
335336
return permissionResult == PackageManager.PERMISSION_GRANTED;
336337
}
337338

338-
private void requestAudioPermission() {
339-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, 0);
339+
private void requestPermissions() {
340+
String[] permissions;
341+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
342+
permissions = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.POST_NOTIFICATIONS};
343+
} else {
344+
permissions = new String[]{Manifest.permission.RECORD_AUDIO};
345+
}
346+
ActivityCompat.requestPermissions(this, permissions, 0);
340347
}
341348
}

ScenePlayer/AndroidManifest.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<uses-permission android:name="android.permission.RECORD_AUDIO" />
88
<uses-permission android:name="android.permission.INTERNET" />
99
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
10+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
11+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
13+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
1014

1115
<supports-screens android:smallScreens="false" />
1216

@@ -18,7 +22,8 @@
1822
<activity
1923
android:label="@string/app_name"
2024
android:name=".SceneTabs"
21-
android:screenOrientation="portrait" >
25+
android:screenOrientation="portrait"
26+
android:exported="true">
2227
<intent-filter >
2328
<action android:name="android.intent.action.MAIN" />
2429

@@ -57,6 +62,7 @@
5762
android:screenOrientation="portrait"
5863
android:theme="@style/FullScreen.DisableSoundEffects" />
5964

60-
<service android:name="org.puredata.android.service.PdService" />
65+
<service android:name="org.puredata.android.service.PdService"
66+
android:foregroundServiceType="mediaPlayback|microphone"/>
6167
</application>
6268
</manifest>

ScenePlayer/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414

1515
defaultConfig {
1616
minSdkVersion rootProject.minSdkVersion
17-
targetSdkVersion 22
17+
targetSdkVersion 28
1818
versionCode 11
1919
versionName "0.9.2"
2020
}

Voice-O-Rama/AndroidManifest.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="at.or.at.voiceorama">
4+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
45
<uses-permission android:name="android.permission.RECORD_AUDIO" />
6+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
7+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
8+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/>
59
<application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="true">
610
<activity android:label="@string/app_name" android:name=".VoiceORama"
7-
android:configChanges="orientation" android:launchMode="singleTask">
11+
android:configChanges="orientation" android:launchMode="singleTask"
12+
android:exported="true">
813
<intent-filter>
914
<action android:name="android.intent.action.MAIN" />
1015
<category android:name="android.intent.category.LAUNCHER" />
1116
</intent-filter>
1217
</activity>
13-
<service android:name="org.puredata.android.service.PdService" />
18+
<service android:name="org.puredata.android.service.PdService"
19+
android:foregroundServiceType="mediaPlayback|microphone"/>
1420
<activity android:label="Pure Data Preferences"
1521
android:name="org.puredata.android.service.PdPreferences"
1622
android:configChanges="orientation">

0 commit comments

Comments
 (0)