diff --git a/.idea/compiler.xml b/.idea/compiler.xml index fb7f4a8..b589d56 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..bab4a3a --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index e256cef..a42a30b 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -5,10 +5,8 @@ diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index b91a976..c20ca1a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..4604c44 --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,252 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 66366b5..4cafef3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,14 +4,14 @@ plugins { android { namespace 'marto.rtl_tcp_andro' - compileSdk 33 + compileSdk 34 defaultConfig { applicationId "marto.rtl_tcp_andro" - minSdk 16 - targetSdk 33 - versionCode 30 - versionName "3.15" + minSdk 21 + targetSdk 34 + versionCode 31 + versionName "3.151" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b6478c1..3a0c54c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,6 +26,7 @@ + @@ -89,7 +90,7 @@ \ No newline at end of file diff --git a/app/src/main/java/com/sdrtouch/rtlsdr/BinaryRunnerService.java b/app/src/main/java/com/sdrtouch/rtlsdr/BinaryRunnerService.java index 82b5521..b175a28 100644 --- a/app/src/main/java/com/sdrtouch/rtlsdr/BinaryRunnerService.java +++ b/app/src/main/java/com/sdrtouch/rtlsdr/BinaryRunnerService.java @@ -26,6 +26,7 @@ import android.app.Service; import android.content.Context; import android.content.Intent; +import android.content.pm.ServiceInfo; import android.os.Binder; import android.os.Build; import android.os.IBinder; @@ -127,12 +128,16 @@ private void startForeground() { .setOngoing(true) .setContentTitle(getText(R.string.app_name)); - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { builder = builder .setPriority(Notification.PRIORITY_MAX); } - startForeground(ONGOING_NOTIFICATION_ID, builder.build()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + startForeground(ONGOING_NOTIFICATION_ID, builder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK); + } else { + startForeground(ONGOING_NOTIFICATION_ID, builder.build()); + } } private final OnStatusListener onStatusListener = new OnStatusListener() { diff --git a/build.gradle b/build.gradle index 9d6e350..62623aa 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,6 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '7.3.0' apply false - id 'com.android.library' version '7.3.0' apply false + id 'com.android.application' version '8.5.2' apply false + id 'com.android.library' version '8.5.2' apply false } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3e927b1..3a131ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,6 @@ android.useAndroidX=true # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true +android.defaults.buildfeatures.buildconfig=true +android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a67dcbd..46a251b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Oct 04 18:55:38 BST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/hackrf/build.gradle b/hackrf/build.gradle index b9e9cde..cee47b1 100644 --- a/hackrf/build.gradle +++ b/hackrf/build.gradle @@ -4,11 +4,11 @@ plugins { android { namespace 'info.martinmarinov.hackrf' - compileSdk 33 + compileSdk 34 defaultConfig { - minSdk 16 - targetSdk 33 + minSdk 21 + targetSdk 34 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" diff --git a/hackrf/src/main/AndroidManifest.xml b/hackrf/src/main/AndroidManifest.xml index 97ee047..f81a084 100644 --- a/hackrf/src/main/AndroidManifest.xml +++ b/hackrf/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + obtainFdFor(Context ctx, UsbDevice usbDevice) { + public static Future obtainFdFor(Context context, UsbDevice usbDevice) { int flags = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - flags = PendingIntent.FLAG_MUTABLE; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + flags = FLAG_MUTABLE | FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT; + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + flags = FLAG_MUTABLE; } - UsbManager manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE); + UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); if (!manager.hasPermission(usbDevice)) { AsyncFuture task = new AsyncFuture<>(); - registerNewBroadcastReceiver(ctx, usbDevice, task); - manager.requestPermission(usbDevice, PendingIntent.getBroadcast(ctx, 0, new Intent(ACTION_USB_PERMISSION), flags)); + registerNewBroadcastReceiver(context, usbDevice, task); + manager.requestPermission(usbDevice, PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), flags)); return task; } else { return new CompletedFuture<>(manager.openDevice(usbDevice)); } } - private static void registerNewBroadcastReceiver(final Context ctx, final UsbDevice usbDevice, final AsyncFuture task) { - ctx.registerReceiver(new BroadcastReceiver() { + private static void registerNewBroadcastReceiver(final Context context, final UsbDevice usbDevice, final AsyncFuture task) { + BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); @@ -62,9 +69,9 @@ public void onReceive(Context context, Intent intent) { Log.appendLine("Permission already should be processed, ignoring."); return; } - UsbManager manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE); + UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); - if (device != null && device.equals(usbDevice)) { + if (device.equals(usbDevice)) { if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { if (!manager.hasPermission(device)) { Log.appendLine("Permissions were granted but can't access the device"); @@ -79,7 +86,7 @@ public void onReceive(Context context, Intent intent) { } context.unregisterReceiver(this); } else { - Log.appendLine("Got a permission for an unexpected device %s. Expected %s.", device == null ? "NULL" : device, usbDevice); + Log.appendLine("Got a permission for an unexpected device"); task.setDone(null); } } @@ -88,9 +95,13 @@ public void onReceive(Context context, Intent intent) { task.setDone(null); } } - }, new IntentFilter(ACTION_USB_PERMISSION)); + }; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.registerReceiver(broadcastReceiver, new IntentFilter(ACTION_USB_PERMISSION), RECEIVER_EXPORTED); + } else { + context.registerReceiver(broadcastReceiver, new IntentFilter(ACTION_USB_PERMISSION)); + } } - private UsbPermissionObtainer() { - } -} + private UsbPermissionObtainer() {} +} \ No newline at end of file