From 0bc09ca2eea11c3b74ae3e2bf37aa72924eaa09d Mon Sep 17 00:00:00 2001 From: Tal Kirshboim Date: Thu, 15 Jun 2023 21:40:19 +0200 Subject: [PATCH] Raise target SDK to 33 for PdCore and PdTest Target SDK for other apps was raised to the minimum SDK which is 28. --- CircleOfFifths/AndroidManifest.xml | 3 ++- CircleOfFifths/build.gradle | 2 +- PdCore/build.gradle | 2 +- .../puredata/android/service/PdService.java | 27 ++++++++++++------- PdTest/AndroidManifest.xml | 11 +++++--- PdTest/build.gradle | 2 +- .../src/org/puredata/android/test/PdTest.java | 15 ++++++++--- ScenePlayer/AndroidManifest.xml | 10 +++++-- ScenePlayer/build.gradle | 2 +- Voice-O-Rama/AndroidManifest.xml | 10 +++++-- Voice-O-Rama/build.gradle | 2 +- 11 files changed, 59 insertions(+), 27 deletions(-) diff --git a/CircleOfFifths/AndroidManifest.xml b/CircleOfFifths/AndroidManifest.xml index ce495dd1..3bf9cb6b 100644 --- a/CircleOfFifths/AndroidManifest.xml +++ b/CircleOfFifths/AndroidManifest.xml @@ -3,7 +3,8 @@ package="org.puredata.android.fifths" > + android:screenOrientation="portrait" android:theme="@style/DisableSoundEffects" + android:exported="true"> diff --git a/CircleOfFifths/build.gradle b/CircleOfFifths/build.gradle index 7d5aa71d..ddc476dd 100644 --- a/CircleOfFifths/build.gradle +++ b/CircleOfFifths/build.gradle @@ -13,7 +13,7 @@ android { defaultConfig { applicationId "org.puredata.android.fifths" minSdkVersion rootProject.minSdkVersion - targetSdkVersion 22 + targetSdkVersion 28 versionCode 3 versionName "0.3" } diff --git a/PdCore/build.gradle b/PdCore/build.gradle index da56a750..feb45c59 100644 --- a/PdCore/build.gradle +++ b/PdCore/build.gradle @@ -22,7 +22,7 @@ android { defaultConfig { minSdkVersion rootProject.minSdkVersion - targetSdkVersion 30 + targetSdkVersion 33 versionCode 1 versionName version } diff --git a/PdCore/src/main/java/org/puredata/android/service/PdService.java b/PdCore/src/main/java/org/puredata/android/service/PdService.java index fbab2d03..db52ca02 100644 --- a/PdCore/src/main/java/org/puredata/android/service/PdService.java +++ b/PdCore/src/main/java/org/puredata/android/service/PdService.java @@ -19,6 +19,7 @@ import android.app.Service; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.os.Binder; import android.os.Build; @@ -232,17 +233,15 @@ public void onDestroy() { } private Notification makeNotification(Intent intent, int icon, String title, String description) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationManager notificationManager = - (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - NotificationChannel channel = - new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW); - if (notificationManager != null) { - notificationManager.createNotificationChannel(channel); - } + NotificationManager notificationManager = + (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + NotificationChannel channel = + new NotificationChannel(TAG, TAG, NotificationManager.IMPORTANCE_LOW); + if (notificationManager != null) { + notificationManager.createNotificationChannel(channel); } - PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); + PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_IMMUTABLE); return new NotificationCompat.Builder(PdService.this, TAG) .setSmallIcon(icon) .setContentTitle(title) @@ -256,7 +255,15 @@ private Notification makeNotification(Intent intent, int icon, String title, Str private void startForeground(Notification notification) { stopForeground(); - startForeground(NOTIFICATION_ID, notification); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) { + int foregroundServiceTypes = ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) { + foregroundServiceTypes |= ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE; + } + startForeground(NOTIFICATION_ID, notification, foregroundServiceTypes); + } else { + startForeground(NOTIFICATION_ID, notification); + } hasForeground = true; } diff --git a/PdTest/AndroidManifest.xml b/PdTest/AndroidManifest.xml index 378997a0..cc9ebc4b 100644 --- a/PdTest/AndroidManifest.xml +++ b/PdTest/AndroidManifest.xml @@ -3,18 +3,23 @@ package="org.puredata.android.test"> + android:screenOrientation="portrait" android:launchMode="singleTask" + android:exported="true"> - + + + + - + diff --git a/PdTest/build.gradle b/PdTest/build.gradle index 93fd9b36..eac38f5d 100644 --- a/PdTest/build.gradle +++ b/PdTest/build.gradle @@ -15,7 +15,7 @@ android { defaultConfig { minSdkVersion rootProject.minSdkVersion - targetSdkVersion 30 + targetSdkVersion 33 versionCode 1 versionName '1.0' diff --git a/PdTest/src/org/puredata/android/test/PdTest.java b/PdTest/src/org/puredata/android/test/PdTest.java index 5e522abd..2d83ccc2 100644 --- a/PdTest/src/org/puredata/android/test/PdTest.java +++ b/PdTest/src/org/puredata/android/test/PdTest.java @@ -27,6 +27,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Resources; +import android.os.Build; import android.os.IBinder; import android.preference.PreferenceManager; import androidx.annotation.NonNull; @@ -245,7 +246,7 @@ public boolean onOptionsItemSelected(MenuItem item) { @Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + if (recordAudioPermissionGranted()) { startAudio(); } else { toast("Can't start audio - microphone permission required!"); @@ -261,7 +262,7 @@ public void onClick(View v) { } else if (recordAudioPermissionGranted()) { startAudio(); } else { - requestAudioPermission(); + requestPermissions(); } PdBase.sendFloat("left", left.isChecked() ? 1 : 0); @@ -335,7 +336,13 @@ private boolean recordAudioPermissionGranted() { return permissionResult == PackageManager.PERMISSION_GRANTED; } - private void requestAudioPermission() { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, 0); + private void requestPermissions() { + String[] permissions; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + permissions = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.POST_NOTIFICATIONS}; + } else { + permissions = new String[]{Manifest.permission.RECORD_AUDIO}; + } + ActivityCompat.requestPermissions(this, permissions, 0); } } diff --git a/ScenePlayer/AndroidManifest.xml b/ScenePlayer/AndroidManifest.xml index acc89ab6..26f39164 100644 --- a/ScenePlayer/AndroidManifest.xml +++ b/ScenePlayer/AndroidManifest.xml @@ -7,6 +7,10 @@ + + + + @@ -18,7 +22,8 @@ + android:screenOrientation="portrait" + android:exported="true"> @@ -57,6 +62,7 @@ android:screenOrientation="portrait" android:theme="@style/FullScreen.DisableSoundEffects" /> - + \ No newline at end of file diff --git a/ScenePlayer/build.gradle b/ScenePlayer/build.gradle index f460107e..e40a7727 100644 --- a/ScenePlayer/build.gradle +++ b/ScenePlayer/build.gradle @@ -14,7 +14,7 @@ android { defaultConfig { minSdkVersion rootProject.minSdkVersion - targetSdkVersion 22 + targetSdkVersion 28 versionCode 11 versionName "0.9.2" } diff --git a/Voice-O-Rama/AndroidManifest.xml b/Voice-O-Rama/AndroidManifest.xml index 6bb203cc..c748143c 100644 --- a/Voice-O-Rama/AndroidManifest.xml +++ b/Voice-O-Rama/AndroidManifest.xml @@ -1,16 +1,22 @@ + + + + + android:configChanges="orientation" android:launchMode="singleTask" + android:exported="true"> - + diff --git a/Voice-O-Rama/build.gradle b/Voice-O-Rama/build.gradle index 7b5f221a..e1b50fe7 100644 --- a/Voice-O-Rama/build.gradle +++ b/Voice-O-Rama/build.gradle @@ -11,7 +11,7 @@ android { defaultConfig { minSdkVersion rootProject.minSdkVersion - targetSdkVersion 22 + targetSdkVersion 28 versionCode 11 versionName "1.0" }