From 51be8b933256cdf36e92bfb9a18c689f09149c3b Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 17 Mar 2025 14:53:10 +0000 Subject: [PATCH] Android: Remove unnecessary SDK version checks --- .../native/juce_Audio_android.cpp | 3 +- .../native/juce_Midi_android.cpp | 32 +-- .../native/juce_Oboe_android.cpp | 3 +- .../native/juce_OpenSL_android.cpp | 38 ++- ...toothMidiDevicePairingDialogue_android.cpp | 10 +- .../native/juce_AndroidDocument_android.cpp | 148 +++--------- .../juce_core/native/juce_Files_android.cpp | 28 +-- .../native/juce_JNIHelpers_android.h | 25 +- .../juce_RuntimePermissions_android.cpp | 4 +- .../juce_Accessibility_android.cpp | 17 +- .../native/juce_ContentSharer_android.cpp | 12 +- .../native/juce_Windowing_android.cpp | 4 +- .../native/juce_PushNotifications_android.cpp | 227 +++++++----------- .../native/juce_CameraDevice_android.h | 42 ++-- .../juce_video/native/juce_Video_android.h | 22 +- 15 files changed, 210 insertions(+), 405 deletions(-) diff --git a/modules/juce_audio_devices/native/juce_Audio_android.cpp b/modules/juce_audio_devices/native/juce_Audio_android.cpp index 4f9a41db96..3747bac7dd 100644 --- a/modules/juce_audio_devices/native/juce_Audio_android.cpp +++ b/modules/juce_audio_devices/native/juce_Audio_android.cpp @@ -207,8 +207,7 @@ public: STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT, (jint) (minBufferSizeOut * numDeviceOutputChannels * static_cast (sizeof (int16))), MODE_STREAM))); - const bool supportsUnderrunCount = (getAndroidSDKVersion() >= 24); - getUnderrunCount = supportsUnderrunCount ? env->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : nullptr; + getUnderrunCount = env->GetMethodID (AudioTrack, "getUnderrunCount", "()I"); int outputDeviceState = env->CallIntMethod (outputDevice, AudioTrack.getState); if (outputDeviceState > 0) diff --git a/modules/juce_audio_devices/native/juce_Midi_android.cpp b/modules/juce_audio_devices/native/juce_Midi_android.cpp index 8d301d0f18..66767100d0 100644 --- a/modules/juce_audio_devices/native/juce_Midi_android.cpp +++ b/modules/juce_audio_devices/native/juce_Midi_android.cpp @@ -798,7 +798,7 @@ constexpr unsigned char javaMidiByteCode[] METHOD (openMidiInputPortWithID, "openMidiInputPortWithID", "(IJ)Lcom/rmsl/juce/JuceMidiSupport$JuceMidiPort;") \ METHOD (openMidiOutputPortWithID, "openMidiOutputPortWithID", "(I)Lcom/rmsl/juce/JuceMidiSupport$JuceMidiPort;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (MidiDeviceManager, "com/rmsl/juce/JuceMidiSupport$MidiDeviceManager", 23) +DECLARE_JNI_CLASS (MidiDeviceManager, "com/rmsl/juce/JuceMidiSupport$MidiDeviceManager") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -808,7 +808,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (MidiDeviceManager, "com/rmsl/juce/JuceMidiSuppor METHOD (sendMidi, "sendMidi", "([BII)V") \ METHOD (getName, "getName", "()Ljava/lang/String;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (JuceMidiPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiPort", 23) +DECLARE_JNI_CLASS (JuceMidiPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiPort") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -928,7 +928,7 @@ private: #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ CALLBACK (generatedCallback<&MidiInput::Pimpl::handleReceive>, "handleReceive", "(J[BIIJ)V" ) -DECLARE_JNI_CLASS_WITH_MIN_SDK (JuceMidiInputPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiInputPort", 23) +DECLARE_JNI_CLASS (JuceMidiInputPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiInputPort") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -1014,24 +1014,18 @@ private: //============================================================================== Array MidiInput::getAvailableDevices() { - if (getAndroidSDKVersion() < 23) - return {}; - AndroidMidiDeviceManager manager; return manager.getDevices (true); } MidiDeviceInfo MidiInput::getDefaultDevice() { - if (getAndroidSDKVersion() < 23) - return {}; - return getAvailableDevices().getFirst(); } std::unique_ptr MidiInput::openDevice (const String& deviceIdentifier, MidiInputCallback* callback) { - if (getAndroidSDKVersion() < 23 || deviceIdentifier.isEmpty()) + if (deviceIdentifier.isEmpty()) return {}; AndroidMidiDeviceManager manager; @@ -1051,9 +1045,6 @@ std::unique_ptr MidiInput::openDevice (const String& deviceIdentifier StringArray MidiInput::getDevices() { - if (getAndroidSDKVersion() < 23) - return {}; - StringArray deviceNames; for (auto& d : getAvailableDevices()) @@ -1064,7 +1055,7 @@ StringArray MidiInput::getDevices() int MidiInput::getDefaultDeviceIndex() { - return (getAndroidSDKVersion() < 23 ? -1 : 0); + return 0; } std::unique_ptr MidiInput::openDevice (int index, MidiInputCallback* callback) @@ -1094,24 +1085,18 @@ void MidiInput::stop() //============================================================================== Array MidiOutput::getAvailableDevices() { - if (getAndroidSDKVersion() < 23) - return {}; - AndroidMidiDeviceManager manager; return manager.getDevices (false); } MidiDeviceInfo MidiOutput::getDefaultDevice() { - if (getAndroidSDKVersion() < 23) - return {}; - return getAvailableDevices().getFirst(); } std::unique_ptr MidiOutput::openDevice (const String& deviceIdentifier) { - if (getAndroidSDKVersion() < 23 || deviceIdentifier.isEmpty()) + if (deviceIdentifier.isEmpty()) return {}; AndroidMidiDeviceManager manager; @@ -1130,9 +1115,6 @@ std::unique_ptr MidiOutput::openDevice (const String& deviceIdentifi StringArray MidiOutput::getDevices() { - if (getAndroidSDKVersion() < 23) - return {}; - StringArray deviceNames; for (auto& d : getAvailableDevices()) @@ -1143,7 +1125,7 @@ StringArray MidiOutput::getDevices() int MidiOutput::getDefaultDeviceIndex() { - return (getAndroidSDKVersion() < 23 ? -1 : 0); + return 0; } std::unique_ptr MidiOutput::openDevice (int index) diff --git a/modules/juce_audio_devices/native/juce_Oboe_android.cpp b/modules/juce_audio_devices/native/juce_Oboe_android.cpp index f624d7f0c1..08d868ea0f 100644 --- a/modules/juce_audio_devices/native/juce_Oboe_android.cpp +++ b/modules/juce_audio_devices/native/juce_Oboe_android.cpp @@ -1196,8 +1196,7 @@ public: bool supportsDevicesInfo() const { - static auto result = getAndroidSDKVersion() >= 23; - return result; + return true; } void addDevice (const LocalRef& device, JNIEnv* env) diff --git a/modules/juce_audio_devices/native/juce_OpenSL_android.cpp b/modules/juce_audio_devices/native/juce_OpenSL_android.cpp index 831fdacd79..410dae8e70 100644 --- a/modules/juce_audio_devices/native/juce_OpenSL_android.cpp +++ b/modules/juce_audio_devices/native/juce_OpenSL_android.cpp @@ -360,22 +360,17 @@ public: if (runner == nullptr) return false; - const bool supportsJavaProxy = (getAndroidSDKVersion() >= 24); + // may return nullptr on some platforms - that's ok + config = SlRef::cast (runner); - if (supportsJavaProxy) + if (config != nullptr) { - // may return nullptr on some platforms - that's ok - config = SlRef::cast (runner); + jobject audioRoutingJni; + auto status = (*config)->AcquireJavaProxy (config, /*SL_ANDROID_JAVA_PROXY_ROUTING*/1, + &audioRoutingJni); - if (config != nullptr) - { - jobject audioRoutingJni; - auto status = (*config)->AcquireJavaProxy (config, /*SL_ANDROID_JAVA_PROXY_ROUTING*/1, - &audioRoutingJni); - - if (status == SL_RESULT_SUCCESS && audioRoutingJni != nullptr) - javaProxy = GlobalRef (LocalRef (getEnv()->NewLocalRef (audioRoutingJni))); - } + if (status == SL_RESULT_SUCCESS && audioRoutingJni != nullptr) + javaProxy = GlobalRef (LocalRef (getEnv()->NewLocalRef (audioRoutingJni))); } queue = SlRef::cast (runner); @@ -677,8 +672,7 @@ public: return; } - const bool supportsUnderrunCount = (getAndroidSDKVersion() >= 24); - getUnderrunCount = supportsUnderrunCount ? getEnv()->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : nullptr; + getUnderrunCount = getEnv()->GetMethodID (AudioTrack, "getUnderrunCount", "()I"); } } } @@ -1054,18 +1048,14 @@ OpenSLAudioIODevice::OpenSLSession* OpenSLAudioIODevice::OpenSLSession::create ( int numBuffersToUse) { std::unique_ptr retval; - auto sdkVersion = getAndroidSDKVersion(); // SDK versions 21 and higher should natively support floating point... - if (sdkVersion >= 21) - { - retval.reset (new OpenSLSessionT (numInputChannels, numOutputChannels, samleRateToUse, - bufferSizeToUse, numBuffersToUse)); + retval.reset (new OpenSLSessionT (numInputChannels, numOutputChannels, samleRateToUse, + bufferSizeToUse, numBuffersToUse)); - // ...however, some devices lie so re-try without floating point - if (retval != nullptr && (! retval->openedOK())) - retval = nullptr; - } + // ...however, some devices lie so re-try without floating point + if (retval != nullptr && (! retval->openedOK())) + retval = nullptr; if (retval == nullptr) { diff --git a/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_android.cpp b/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_android.cpp index 5b6398cb8a..ebba727092 100644 --- a/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_android.cpp +++ b/modules/juce_audio_utils/native/juce_BluetoothMidiDevicePairingDialogue_android.cpp @@ -38,7 +38,7 @@ namespace juce #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (getAndroidBluetoothManager, "getAndroidBluetoothManager", "(Landroid/content/Context;)Lcom/rmsl/juce/JuceMidiSupport$BluetoothMidiManager;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidJuceMidiSupport, "com/rmsl/juce/JuceMidiSupport", 23) +DECLARE_JNI_CLASS (AndroidJuceMidiSupport, "com/rmsl/juce/JuceMidiSupport") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -49,7 +49,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidJuceMidiSupport, "com/rmsl/juce/JuceMidiS METHOD (getBluetoothDeviceStatus, "getBluetoothDeviceStatus", "(Ljava/lang/String;)I") \ METHOD (startStopScan, "startStopScan", "(Z)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidBluetoothManager, "com/rmsl/juce/JuceMidiSupport$BluetoothMidiManager", 23) +DECLARE_JNI_CLASS (AndroidBluetoothManager, "com/rmsl/juce/JuceMidiSupport$BluetoothMidiManager") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -501,9 +501,6 @@ bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* { std::unique_ptr exitCallback (exitCallbackPtr); - if (getAndroidSDKVersion() < 23) - return false; - auto boundsToUse = (btBounds != nullptr ? *btBounds : Rectangle {}); if (! RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi)) @@ -521,9 +518,6 @@ bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* bool BluetoothMidiDevicePairingDialogue::isAvailable() { - if (getAndroidSDKVersion() < 23) - return false; - auto* env = getEnv(); LocalRef btManager (env->CallStaticObjectMethod (AndroidJuceMidiSupport, AndroidJuceMidiSupport.getAndroidBluetoothManager, getAppContext().get())); diff --git a/modules/juce_core/native/juce_AndroidDocument_android.cpp b/modules/juce_core/native/juce_AndroidDocument_android.cpp index fd8e7cabb4..4d60d2935e 100644 --- a/modules/juce_core/native/juce_AndroidDocument_android.cpp +++ b/modules/juce_core/native/juce_AndroidDocument_android.cpp @@ -150,8 +150,8 @@ struct AndroidDocumentDetail return LocalRef{}; LocalRef documentId { (jstring) env->CallObjectMethod (cursor, AndroidCursor.getString, idColumnIndex) }; - return LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract21, - DocumentsContract21.buildDocumentUriUsingTree, + return LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.buildDocumentUriUsingTree, treeUri.get(), documentId.get()) }; }(); @@ -164,11 +164,11 @@ struct AndroidDocumentDetail static DocumentsContractIteratorEngine makeDocumentsContractIteratorEngine (const GlobalRef& uri) { - const LocalRef documentId { getEnv()->CallStaticObjectMethod (DocumentsContract19, - DocumentsContract19.getDocumentId, + const LocalRef documentId { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.getDocumentId, uri.get()) }; - const LocalRef childrenUri { getEnv()->CallStaticObjectMethod (DocumentsContract21, - DocumentsContract21.buildChildDocumentsUriUsingTree, + const LocalRef childrenUri { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.buildChildDocumentsUriUsingTree, uri.get(), documentId.get()) }; @@ -329,34 +329,10 @@ public: virtual AndroidDocumentInfo getInfo() const = 0; virtual URL getUrl() const = 0; virtual NativeInfo getNativeInfo() const = 0; - - virtual std::unique_ptr copyDocumentToParentDocument (const Pimpl&) const - { - // This function is not supported on the current platform. - jassertfalse; - return {}; - } - - virtual std::unique_ptr moveDocumentFromParentToParent (const Pimpl&, const Pimpl&) const - { - // This function is not supported on the current platform. - jassertfalse; - return {}; - } - - virtual std::unique_ptr renameTo (const String&) const - { - // This function is not supported on the current platform. - jassertfalse; - return {}; - } - - virtual std::unique_ptr createChildDocumentWithTypeAndName (const String&, const String&) const - { - // This function is not supported on the current platform. - jassertfalse; - return {}; - } + virtual std::unique_ptr copyDocumentToParentDocument (const Pimpl&) const = 0; + virtual std::unique_ptr moveDocumentFromParentToParent (const Pimpl&, const Pimpl&) const = 0; + virtual std::unique_ptr renameTo (const String&) const = 0; + virtual std::unique_ptr createChildDocumentWithTypeAndName (const String&, const String&) const = 0; File getFile() const { return getUrl().getLocalFile(); } @@ -398,23 +374,23 @@ struct AndroidDocument::Utils }; //============================================================================== - class AndroidDocumentPimplApi21 : public Pimpl + class AndroidDocumentPimpl : public Pimpl { public: - AndroidDocumentPimplApi21() = default; + AndroidDocumentPimpl() = default; - explicit AndroidDocumentPimplApi21 (const URL& uriIn) - : AndroidDocumentPimplApi21 (urlToUri (uriIn)) {} + explicit AndroidDocumentPimpl (const URL& uriIn) + : AndroidDocumentPimpl (urlToUri (uriIn)) {} - explicit AndroidDocumentPimplApi21 (const LocalRef& uriIn) + explicit AndroidDocumentPimpl (const LocalRef& uriIn) : uri (uriIn) {} bool deleteDocument() const override { if (const auto resolver = AndroidContentUriResolver::getContentResolver()) { - return getEnv()->CallStaticBooleanMethod (DocumentsContract19, - DocumentsContract19.deleteDocument, + return getEnv()->CallStaticBooleanMethod (DocumentsContract, + DocumentsContract.deleteDocument, resolver.get(), uri.get()); } @@ -517,12 +493,10 @@ struct AndroidDocument::Utils NativeInfo getNativeInfo() const override { return { uri }; } - std::unique_ptr clone() const override { return std::make_unique (*this); } - std::unique_ptr createChildDocumentWithTypeAndName (const String& type, const String& name) const override { - return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract21, - DocumentsContract21.createDocument, + return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.createDocument, AndroidContentUriResolver::getContentResolver().get(), getNativeInfo().uri.get(), javaString (type).get(), @@ -533,8 +507,8 @@ struct AndroidDocument::Utils { if (const auto resolver = AndroidContentUriResolver::getContentResolver()) { - return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract21, - DocumentsContract21.renameDocument, + return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.renameDocument, resolver.get(), getNativeInfo().uri.get(), javaString (name).get()) }); @@ -543,17 +517,7 @@ struct AndroidDocument::Utils return nullptr; } - private: - GlobalRef uri; - }; - - //============================================================================== - class AndroidDocumentPimplApi24 final : public AndroidDocumentPimplApi21 - { - public: - using AndroidDocumentPimplApi21::AndroidDocumentPimplApi21; - - std::unique_ptr clone() const override { return std::make_unique (*this); } + std::unique_ptr clone() const override { return std::make_unique (*this); } std::unique_ptr copyDocumentToParentDocument (const Pimpl& target) const override { @@ -563,8 +527,8 @@ struct AndroidDocument::Utils return {}; } - return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract24, - DocumentsContract24.copyDocument, + return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.copyDocument, AndroidContentUriResolver::getContentResolver().get(), getNativeInfo().uri.get(), target.getNativeInfo().uri.get()) }); @@ -578,41 +542,25 @@ struct AndroidDocument::Utils return {}; } - return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract24, - DocumentsContract24.moveDocument, + return Utils::createPimplForSdk (LocalRef { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.moveDocument, AndroidContentUriResolver::getContentResolver().get(), getNativeInfo().uri.get(), currentParent.getNativeInfo().uri.get(), newParent.getNativeInfo().uri.get()) }); } + + private: + GlobalRef uri; }; + //============================================================================== static std::unique_ptr createPimplForSdk (const LocalRef& uri) { if (jniCheckHasExceptionOccurredAndClear()) return nullptr; - return createPimplForSdkImpl (uri, - VersionTag { 24 }, - VersionTag { 21 }); - } - - static std::unique_ptr createPimplForSdkImpl (const LocalRef&) - { - // Failed to find a suitable implementation for this platform - jassertfalse; - return nullptr; - } - - template - static std::unique_ptr createPimplForSdkImpl (const LocalRef& uri, - VersionTag head, - VersionTag... tail) - { - if (head.version <= getAndroidSDKVersion()) - return std::make_unique (uri); - - return createPimplForSdkImpl (uri, tail...); + return std::make_unique (uri); } #else @@ -747,14 +695,14 @@ struct AndroidDocument::Utils void AndroidDocumentPermission::takePersistentReadWriteAccess ([[maybe_unused]] const URL& url) { #if JUCE_ANDROID - AndroidDocumentDetail::setPermissions (url, ContentResolver19.takePersistableUriPermission); + AndroidDocumentDetail::setPermissions (url, ContentResolver.takePersistableUriPermission); #endif } void AndroidDocumentPermission::releasePersistentReadWriteAccess ([[maybe_unused]] const URL& url) { #if JUCE_ANDROID - AndroidDocumentDetail::setPermissions (url, ContentResolver19.releasePersistableUriPermission); + AndroidDocumentDetail::setPermissions (url, ContentResolver.releasePersistableUriPermission); #endif } @@ -765,7 +713,7 @@ std::vector AndroidDocumentPermission::getPersistedPe #else auto* env = getEnv(); const LocalRef permissions { env->CallObjectMethod (AndroidContentUriResolver::getContentResolver().get(), - ContentResolver19.getPersistedUriPermissions) }; + ContentResolver.getPersistedUriPermissions) }; if (permissions == nullptr) return {}; @@ -814,8 +762,8 @@ AndroidDocument AndroidDocument::fromDocument ([[maybe_unused]] const URL& docum #if JUCE_ANDROID const auto javaUri = urlToUri (documentUrl); - if (! getEnv()->CallStaticBooleanMethod (DocumentsContract19, - DocumentsContract19.isDocumentUri, + if (! getEnv()->CallStaticBooleanMethod (DocumentsContract, + DocumentsContract.isDocumentUri, getAppContext().get(), javaUri.get())) { @@ -832,8 +780,8 @@ AndroidDocument AndroidDocument::fromTree ([[maybe_unused]] const URL& treeUrl) { #if JUCE_ANDROID const auto javaUri = urlToUri (treeUrl); - LocalRef treeDocumentId { getEnv()->CallStaticObjectMethod (DocumentsContract21, - DocumentsContract21.getTreeDocumentId, + LocalRef treeDocumentId { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.getTreeDocumentId, javaUri.get()) }; jniCheckHasExceptionOccurredAndClear(); @@ -844,8 +792,8 @@ AndroidDocument AndroidDocument::fromTree ([[maybe_unused]] const URL& treeUrl) return AndroidDocument{}; } - LocalRef documentUri { getEnv()->CallStaticObjectMethod (DocumentsContract21, - DocumentsContract21.buildDocumentUriUsingTree, + LocalRef documentUri { getEnv()->CallStaticObjectMethod (DocumentsContract, + DocumentsContract.buildDocumentUriUsingTree, javaUri.get(), treeDocumentId.get()) }; @@ -1010,14 +958,6 @@ AndroidDocumentIterator AndroidDocumentIterator::makeNonRecursive (const Android using Detail = AndroidDocumentDetail; - #if JUCE_ANDROID - if (getAndroidSDKVersion() == 21) - { - if (auto uri = dir.getNativeInfo().uri) - return Utils::makeWithEngine (Detail::makeDocumentsContractIteratorEngine (uri)); - } - #endif - return Utils::makeWithEngineInplace (dir.getUrl().getLocalFile(), false); } @@ -1028,14 +968,6 @@ AndroidDocumentIterator AndroidDocumentIterator::makeRecursive (const AndroidDoc using Detail = AndroidDocumentDetail; - #if JUCE_ANDROID - if (getAndroidSDKVersion() == 21) - { - if (auto uri = dir.getNativeInfo().uri) - return Utils::makeWithEngine (Detail::RecursiveEngine { uri }); - } - #endif - return Utils::makeWithEngineInplace (dir.getUrl().getLocalFile(), true); } diff --git a/modules/juce_core/native/juce_Files_android.cpp b/modules/juce_core/native/juce_Files_android.cpp index 3941a79881..51ed65decc 100644 --- a/modules/juce_core/native/juce_Files_android.cpp +++ b/modules/juce_core/native/juce_Files_android.cpp @@ -47,17 +47,12 @@ DECLARE_JNI_CLASS (MediaScannerConnection, "android/media/MediaScannerConnection #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (query, "query", "(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;") \ METHOD (openInputStream, "openInputStream", "(Landroid/net/Uri;)Ljava/io/InputStream;") \ - METHOD (openOutputStream, "openOutputStream", "(Landroid/net/Uri;)Ljava/io/OutputStream;") - -DECLARE_JNI_CLASS (ContentResolver, "android/content/ContentResolver") -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ + METHOD (openOutputStream, "openOutputStream", "(Landroid/net/Uri;)Ljava/io/OutputStream;") \ METHOD (takePersistableUriPermission, "takePersistableUriPermission", "(Landroid/net/Uri;I)V") \ METHOD (releasePersistableUriPermission, "releasePersistableUriPermission", "(Landroid/net/Uri;I)V") \ METHOD (getPersistedUriPermissions, "getPersistedUriPermissions", "()Ljava/util/List;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (ContentResolver19, "android/content/ContentResolver", 19) +DECLARE_JNI_CLASS (ContentResolver, "android/content/ContentResolver") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -105,6 +100,7 @@ DECLARE_JNI_CLASS (AndroidInputStream, "java/io/InputStream") DECLARE_JNI_CLASS (AndroidApplicationInfo, "android/content/pm/ApplicationInfo") #undef JNI_CLASS_MEMBERS + #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (buildChildDocumentsUri, "buildChildDocumentsUri", "(Ljava/lang/String;Ljava/lang/String;)Landroid/net/Uri;") \ STATICMETHOD (buildDocumentUri, "buildDocumentUri", "(Ljava/lang/String;Ljava/lang/String;)Landroid/net/Uri;") \ @@ -115,28 +111,18 @@ DECLARE_JNI_CLASS (AndroidApplicationInfo, "android/content/pm/ApplicationInfo") STATICMETHOD (deleteDocument, "deleteDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;)Z") \ STATICMETHOD (getDocumentId, "getDocumentId", "(Landroid/net/Uri;)Ljava/lang/String;") \ STATICMETHOD (getRootId, "getRootId", "(Landroid/net/Uri;)Ljava/lang/String;") \ - STATICMETHOD (isDocumentUri, "isDocumentUri", "(Landroid/content/Context;Landroid/net/Uri;)Z") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (DocumentsContract19, "android/provider/DocumentsContract", 19) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ + STATICMETHOD (isDocumentUri, "isDocumentUri", "(Landroid/content/Context;Landroid/net/Uri;)Z") \ STATICMETHOD (buildChildDocumentsUriUsingTree, "buildChildDocumentsUriUsingTree", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/net/Uri;") \ STATICMETHOD (buildDocumentUriUsingTree, "buildDocumentUriUsingTree", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/net/Uri;") \ STATICMETHOD (buildTreeDocumentUri, "buildTreeDocumentUri", "(Ljava/lang/String;Ljava/lang/String;)Landroid/net/Uri;") \ STATICMETHOD (createDocument, "createDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;Ljava/lang/String;)Landroid/net/Uri;") \ STATICMETHOD (getTreeDocumentId, "getTreeDocumentId", "(Landroid/net/Uri;)Ljava/lang/String;") \ - STATICMETHOD (renameDocument, "renameDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;)Landroid/net/Uri;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (DocumentsContract21, "android/provider/DocumentsContract", 21) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ + STATICMETHOD (renameDocument, "renameDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;Ljava/lang/String;)Landroid/net/Uri;") \ STATICMETHOD (copyDocument, "copyDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/net/Uri;)Landroid/net/Uri;") \ STATICMETHOD (moveDocument, "moveDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/net/Uri;Landroid/net/Uri;)Landroid/net/Uri;") \ STATICMETHOD (removeDocument, "removeDocument", "(Landroid/content/ContentResolver;Landroid/net/Uri;Landroid/net/Uri;)Z") -DECLARE_JNI_CLASS_WITH_MIN_SDK (DocumentsContract24, "android/provider/DocumentsContract", 24) +DECLARE_JNI_CLASS (DocumentsContract, "android/provider/DocumentsContract") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -153,7 +139,7 @@ DECLARE_JNI_CLASS (AndroidMimeTypeMap, "android/webkit/MimeTypeMap") METHOD (isReadPermission, "isReadPermission", "()Z") \ METHOD (isWritePermission, "isWritePermission", "()Z") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidUriPermission, "android/content/UriPermission", 19) +DECLARE_JNI_CLASS (AndroidUriPermission, "android/content/UriPermission") #undef JNI_CLASS_MEMBERS //============================================================================== diff --git a/modules/juce_core/native/juce_JNIHelpers_android.h b/modules/juce_core/native/juce_JNIHelpers_android.h index a3e061f827..924b27970b 100644 --- a/modules/juce_core/native/juce_JNIHelpers_android.h +++ b/modules/juce_core/native/juce_JNIHelpers_android.h @@ -312,11 +312,12 @@ template constexpr auto numBytes (const T (&) [N]) { retu //============================================================================== #define DECLARE_JNI_CLASS_WITH_MIN_SDK(CppClassName, javaPath, minSDK) \ + static_assert (minSDK >= 24, "There's no need to supply a min SDK lower than JUCE's minimum requirement"); \ DECLARE_JNI_CLASS_WITH_BYTECODE (CppClassName, javaPath, minSDK, nullptr) //============================================================================== #define DECLARE_JNI_CLASS(CppClassName, javaPath) \ - DECLARE_JNI_CLASS_WITH_MIN_SDK (CppClassName, javaPath, 16) + DECLARE_JNI_CLASS_WITH_MIN_SDK (CppClassName, javaPath, 24) //============================================================================== #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -359,7 +360,7 @@ DECLARE_JNI_CLASS (AndroidActivity, "android/app/Activity") METHOD (startActivityForResult, "startActivityForResult", "(Landroid/content/Intent;I)V") \ METHOD (setArguments, "setArguments", "(Landroid/os/Bundle;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidFragment, "android/app/Fragment", 11) +DECLARE_JNI_CLASS (AndroidFragment, "android/app/Fragment") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -369,7 +370,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidFragment, "android/app/Fragment", 11) METHOD (setContentType, "setContentType", "(I)Landroid/media/AudioAttributes$Builder;") \ METHOD (setUsage, "setUsage", "(I)Landroid/media/AudioAttributes$Builder;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidAudioAttributesBuilder, "android/media/AudioAttributes$Builder", 21) +DECLARE_JNI_CLASS (AndroidAudioAttributesBuilder, "android/media/AudioAttributes$Builder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -472,6 +473,7 @@ DECLARE_JNI_CLASS (AndroidHandlerThread, "android/os/HandlerThread") #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (createChooser, "createChooser", "(Landroid/content/Intent;Ljava/lang/CharSequence;)Landroid/content/Intent;") \ + STATICMETHOD (createChooserWithSender, "createChooser", "(Landroid/content/Intent;Ljava/lang/CharSequence;Landroid/content/IntentSender;)Landroid/content/Intent;") \ METHOD (addCategory, "addCategory", "(Ljava/lang/String;)Landroid/content/Intent;") \ METHOD (constructor, "", "()V") \ METHOD (constructorWithContextAndClass, "", "(Landroid/content/Context;Ljava/lang/Class;)V") \ @@ -500,12 +502,6 @@ DECLARE_JNI_CLASS (AndroidHandlerThread, "android/os/HandlerThread") DECLARE_JNI_CLASS (AndroidIntent, "android/content/Intent") #undef JNI_CLASS_MEMBERS -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - STATICMETHOD (createChooser, "createChooser", "(Landroid/content/Intent;Ljava/lang/CharSequence;Landroid/content/IntentSender;)Landroid/content/Intent;") \ - -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidIntent22, "android/content/Intent", 22) -#undef JNI_CLASS_MEMBERS - #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (constructor, "", "()V") \ METHOD (postRotate, "postRotate", "(FFF)Z") \ @@ -578,7 +574,7 @@ DECLARE_JNI_CLASS (AndroidPendingIntent, "android/app/PendingIntent") #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (toString, "toString", "()Ljava/lang/String;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidRange, "android/util/Range", 21) +DECLARE_JNI_CLASS (AndroidRange, "android/util/Range") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -617,7 +613,7 @@ DECLARE_JNI_CLASS (AndroidConfiguration, "android/content/res/Configuration") METHOD (getHeight, "getHeight", "()I") \ METHOD (getWidth, "getWidth", "()I") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidSize, "android/util/Size", 21) +DECLARE_JNI_CLASS (AndroidSize, "android/util/Size") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -647,15 +643,10 @@ DECLARE_JNI_CLASS (AndroidUri, "android/net/Uri") METHOD (getRootView, "getRootView", "()Landroid/view/View;") \ METHOD (addOnLayoutChangeListener, "addOnLayoutChangeListener", "(Landroid/view/View$OnLayoutChangeListener;)V") \ METHOD (announceForAccessibility, "announceForAccessibility", "(Ljava/lang/CharSequence;)V") \ - -DECLARE_JNI_CLASS (AndroidView, "android/view/View") -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (setOnApplyWindowInsetsListener, "setOnApplyWindowInsetsListener", "(Landroid/view/View$OnApplyWindowInsetsListener;)V") \ METHOD (getRootWindowInsets, "getRootWindowInsets", "()Landroid/view/WindowInsets;") - DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidView23, "android/view/View", 23) +DECLARE_JNI_CLASS (AndroidView, "android/view/View") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ diff --git a/modules/juce_core/native/juce_RuntimePermissions_android.cpp b/modules/juce_core/native/juce_RuntimePermissions_android.cpp index 867bd2129c..6a6c3c1712 100644 --- a/modules/juce_core/native/juce_RuntimePermissions_android.cpp +++ b/modules/juce_core/native/juce_RuntimePermissions_android.cpp @@ -247,7 +247,7 @@ void RuntimePermissions::request (PermissionID permission, Callback callback) auto alreadyGranted = isGranted (permission); - if (alreadyGranted || getAndroidSDKVersion() < 23) + if (alreadyGranted) { callback (alreadyGranted); return; @@ -276,7 +276,7 @@ void RuntimePermissions::request (PermissionID permission, Callback callback) bool RuntimePermissions::isRequired (PermissionID /*permission*/) { - return getAndroidSDKVersion() >= 23; + return true; } bool RuntimePermissions::isGranted (PermissionID permission) diff --git a/modules/juce_gui_basics/native/accessibility/juce_Accessibility_android.cpp b/modules/juce_gui_basics/native/accessibility/juce_Accessibility_android.cpp index 418eba3108..e4badb82bb 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_Accessibility_android.cpp +++ b/modules/juce_gui_basics/native/accessibility/juce_Accessibility_android.cpp @@ -60,27 +60,22 @@ namespace juce METHOD (setText, "setText", "(Ljava/lang/CharSequence;)V") \ METHOD (setMovementGranularities, "setMovementGranularities", "(I)V") \ METHOD (addAction, "addAction", "(I)V") \ + METHOD (setCollectionInfo, "setCollectionInfo", "(Landroid/view/accessibility/AccessibilityNodeInfo$CollectionInfo;)V") \ + METHOD (setCollectionItemInfo, "setCollectionItemInfo", "(Landroid/view/accessibility/AccessibilityNodeInfo$CollectionItemInfo;)V") DECLARE_JNI_CLASS (AndroidAccessibilityNodeInfo, "android/view/accessibility/AccessibilityNodeInfo") #undef JNI_CLASS_MEMBERS -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (setCollectionInfo, "setCollectionInfo", "(Landroid/view/accessibility/AccessibilityNodeInfo$CollectionInfo;)V") \ - METHOD (setCollectionItemInfo, "setCollectionItemInfo", "(Landroid/view/accessibility/AccessibilityNodeInfo$CollectionItemInfo;)V") - - DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidAccessibilityNodeInfo19, "android/view/accessibility/AccessibilityNodeInfo", 19) -#undef JNI_CLASS_MEMBERS - #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (obtain, "obtain", "(IIZ)Landroid/view/accessibility/AccessibilityNodeInfo$CollectionInfo;") - DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidAccessibilityNodeInfoCollectionInfo, "android/view/accessibility/AccessibilityNodeInfo$CollectionInfo", 19) + DECLARE_JNI_CLASS (AndroidAccessibilityNodeInfoCollectionInfo, "android/view/accessibility/AccessibilityNodeInfo$CollectionInfo") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (obtain, "obtain", "(IIIIZ)Landroid/view/accessibility/AccessibilityNodeInfo$CollectionItemInfo;") - DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidAccessibilityNodeInfoCollectionItemInfo, "android/view/accessibility/AccessibilityNodeInfo$CollectionItemInfo", 19) + DECLARE_JNI_CLASS (AndroidAccessibilityNodeInfoCollectionItemInfo, "android/view/accessibility/AccessibilityNodeInfo$CollectionItemInfo") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -500,7 +495,7 @@ public: (jint) rows, (jint) columns, (jboolean) false) }; - env->CallVoidMethod (info, AndroidAccessibilityNodeInfo19.setCollectionInfo, collectionInfo.get()); + env->CallVoidMethod (info, AndroidAccessibilityNodeInfo.setCollectionInfo, collectionInfo.get()); } if (auto* enclosingTableHandler = detail::AccessibilityHelpers::getEnclosingHandlerWithInterface (&accessibilityHandler, &AccessibilityHandler::getTableInterface)) @@ -521,7 +516,7 @@ public: (jint) columns.begin, (jint) columns.num, (jboolean) (header == IsHeader::yes)) }; - env->CallVoidMethod (info, AndroidAccessibilityNodeInfo19.setCollectionItemInfo, collectionItemInfo.get()); + env->CallVoidMethod (info, AndroidAccessibilityNodeInfo.setCollectionItemInfo, collectionItemInfo.get()); }; if (rowSpan.hasValue() && columnSpan.hasValue()) diff --git a/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp b/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp index c126366628..a3f43788d0 100644 --- a/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp +++ b/modules/juce_gui_basics/native/juce_ContentSharer_android.cpp @@ -370,12 +370,6 @@ private: const auto text = javaString ("Choose share target"); - if (getAndroidSDKVersion() < 22) - return LocalRef (env->CallStaticObjectMethod (AndroidIntent, - AndroidIntent.createChooser, - intent.get(), - text.get())); - constexpr jint FLAG_UPDATE_CURRENT = 0x08000000; constexpr jint FLAG_IMMUTABLE = 0x04000000; @@ -385,7 +379,7 @@ private: const LocalRef replyIntent (env->NewObject (AndroidIntent, AndroidIntent.constructorWithContextAndClass, context.get(), klass)); getEnv()->CallObjectMethod (replyIntent, AndroidIntent.putExtraInt, javaString ("com.rmsl.juce.JUCE_REQUEST_CODE").get(), request); - const auto flags = FLAG_UPDATE_CURRENT | (getAndroidSDKVersion() <= 23 ? 0 : FLAG_IMMUTABLE); + const auto flags = FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE; const LocalRef pendingIntent (env->CallStaticObjectMethod (AndroidPendingIntent, AndroidPendingIntent.getBroadcast, context.get(), @@ -393,8 +387,8 @@ private: replyIntent.get(), flags)); - return LocalRef (env->CallStaticObjectMethod (AndroidIntent22, - AndroidIntent22.createChooser, + return LocalRef (env->CallStaticObjectMethod (AndroidIntent, + AndroidIntent.createChooserWithSender, intent.get(), text.get(), env->CallObjectMethod (pendingIntent, diff --git a/modules/juce_gui_basics/native/juce_Windowing_android.cpp b/modules/juce_gui_basics/native/juce_Windowing_android.cpp index 33bd0a3aa6..f06feb916a 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_android.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_android.cpp @@ -1316,7 +1316,7 @@ public: if (supportsDisplayCutout()) { - if (const auto methodID = AndroidView23.setOnApplyWindowInsetsListener) + if (const auto methodID = AndroidView.setOnApplyWindowInsetsListener) { env->CallVoidMethod (view, methodID, @@ -2700,7 +2700,7 @@ void Displays::findDisplays (float masterScale) if (! activityArea.isEmpty()) d.userArea = activityArea / d.scale; - if (const auto getRootWindowInsetsMethodId = AndroidView23.getRootWindowInsets) + if (const auto getRootWindowInsetsMethodId = AndroidView.getRootWindowInsets) { LocalRef insets (env->CallObjectMethod (contentView.get(), getRootWindowInsetsMethodId)); JuceInsets::tie (d) = getInsetsFromAndroidWindowInsets (insets, d.scale).tie(); diff --git a/modules/juce_gui_extra/native/juce_PushNotifications_android.cpp b/modules/juce_gui_extra/native/juce_PushNotifications_android.cpp index 25dd16027f..c3b5146ae3 100644 --- a/modules/juce_gui_extra/native/juce_PushNotifications_android.cpp +++ b/modules/juce_gui_extra/native/juce_PushNotifications_android.cpp @@ -63,7 +63,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationChannelGroup, "android/app/Notificat #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ FIELD (extras, "extras", "Landroid/os/Bundle;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidNotification, "android/app/Notification", 19) +DECLARE_JNI_CLASS (AndroidNotification, "android/app/Notification") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -72,74 +72,48 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidNotification, "android/app/Notification", METHOD (constructor, "", "(ILjava/lang/CharSequence;Landroid/app/PendingIntent;)V") \ METHOD (build, "build", "()Landroid/app/Notification$Action;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationActionBuilder, "android/app/Notification$Action$Builder", 20) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (getNotification, "getNotification", "()Landroid/app/Notification;") \ - METHOD (setAutoCancel, "setAutoCancel", "(Z)Landroid/app/Notification$Builder;") \ - METHOD (setContentInfo, "setContentInfo", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ - METHOD (setContentIntent, "setContentIntent", "(Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;") \ - METHOD (setContentText, "setContentText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ - METHOD (setContentTitle, "setContentTitle", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ - METHOD (setDefaults, "setDefaults", "(I)Landroid/app/Notification$Builder;") \ - METHOD (setDeleteIntent, "setDeleteIntent", "(Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;") \ - METHOD (setLargeIcon, "setLargeIcon", "(Landroid/graphics/Bitmap;)Landroid/app/Notification$Builder;") \ - METHOD (setLights, "setLights", "(III)Landroid/app/Notification$Builder;") \ - METHOD (setNumber, "setNumber", "(I)Landroid/app/Notification$Builder;") \ - METHOD (setOngoing, "setOngoing", "(Z)Landroid/app/Notification$Builder;") \ - METHOD (setOnlyAlertOnce, "setOnlyAlertOnce", "(Z)Landroid/app/Notification$Builder;") \ - METHOD (setProgress, "setProgress", "(IIZ)Landroid/app/Notification$Builder;") \ - METHOD (setSmallIcon, "setSmallIcon", "(I)Landroid/app/Notification$Builder;") \ - METHOD (setSound, "setSound", "(Landroid/net/Uri;)Landroid/app/Notification$Builder;") \ - METHOD (setTicker, "setTicker", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ - METHOD (setVibrate, "setVibrate", "([J)Landroid/app/Notification$Builder;") \ - METHOD (setWhen, "setWhen", "(J)Landroid/app/Notification$Builder;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderBase, "android/app/Notification$Builder", 11) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (addAction, "addAction", "(ILjava/lang/CharSequence;Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;") \ - METHOD (build, "build", "()Landroid/app/Notification;") \ - METHOD (setPriority, "setPriority", "(I)Landroid/app/Notification$Builder;") \ - METHOD (setSubText, "setSubText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ - METHOD (setUsesChronometer, "setUsesChronometer", "(Z)Landroid/app/Notification$Builder;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderApi16, "android/app/Notification$Builder", 16) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (setShowWhen, "setShowWhen", "(Z)Landroid/app/Notification$Builder;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderApi17, "android/app/Notification$Builder", 17) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (addAction, "addAction", "(Landroid/app/Notification$Action;)Landroid/app/Notification$Builder;") \ - METHOD (addExtras, "addExtras", "(Landroid/os/Bundle;)Landroid/app/Notification$Builder;") \ - METHOD (setLocalOnly, "setLocalOnly", "(Z)Landroid/app/Notification$Builder;") \ - METHOD (setGroup, "setGroup", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ - METHOD (setGroupSummary, "setGroupSummary", "(Z)Landroid/app/Notification$Builder;") \ - METHOD (setSortKey, "setSortKey", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderApi20, "android/app/Notification$Builder", 20) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (addPerson, "addPerson", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ - METHOD (setCategory, "setCategory", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ - METHOD (setColor, "setColor", "(I)Landroid/app/Notification$Builder;") \ - METHOD (setPublicVersion, "setPublicVersion", "(Landroid/app/Notification;)Landroid/app/Notification$Builder;") \ - METHOD (setVisibility, "setVisibility", "(I)Landroid/app/Notification$Builder;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderApi21, "android/app/Notification$Builder", 21) +DECLARE_JNI_CLASS (NotificationActionBuilder, "android/app/Notification$Action$Builder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ + METHOD (getNotification, "getNotification", "()Landroid/app/Notification;") \ + METHOD (setAutoCancel, "setAutoCancel", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (setContentInfo, "setContentInfo", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ + METHOD (setContentIntent, "setContentIntent", "(Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;") \ + METHOD (setContentText, "setContentText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ + METHOD (setContentTitle, "setContentTitle", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ + METHOD (setDefaults, "setDefaults", "(I)Landroid/app/Notification$Builder;") \ + METHOD (setDeleteIntent, "setDeleteIntent", "(Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;") \ + METHOD (setLargeIcon, "setLargeIcon", "(Landroid/graphics/Bitmap;)Landroid/app/Notification$Builder;") \ + METHOD (setLights, "setLights", "(III)Landroid/app/Notification$Builder;") \ + METHOD (setNumber, "setNumber", "(I)Landroid/app/Notification$Builder;") \ + METHOD (setOngoing, "setOngoing", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (setOnlyAlertOnce, "setOnlyAlertOnce", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (setProgress, "setProgress", "(IIZ)Landroid/app/Notification$Builder;") \ + METHOD (setSmallIcon, "setSmallIcon", "(I)Landroid/app/Notification$Builder;") \ + METHOD (setSound, "setSound", "(Landroid/net/Uri;)Landroid/app/Notification$Builder;") \ + METHOD (setTicker, "setTicker", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ + METHOD (setVibrate, "setVibrate", "([J)Landroid/app/Notification$Builder;") \ + METHOD (setWhen, "setWhen", "(J)Landroid/app/Notification$Builder;") \ + METHOD (build, "build", "()Landroid/app/Notification;") \ + METHOD (setPriority, "setPriority", "(I)Landroid/app/Notification$Builder;") \ + METHOD (setSubText, "setSubText", "(Ljava/lang/CharSequence;)Landroid/app/Notification$Builder;") \ + METHOD (setUsesChronometer, "setUsesChronometer", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (setShowWhen, "setShowWhen", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (addAction, "addAction", "(Landroid/app/Notification$Action;)Landroid/app/Notification$Builder;") \ + METHOD (addExtras, "addExtras", "(Landroid/os/Bundle;)Landroid/app/Notification$Builder;") \ + METHOD (setLocalOnly, "setLocalOnly", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (setGroup, "setGroup", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ + METHOD (setGroupSummary, "setGroupSummary", "(Z)Landroid/app/Notification$Builder;") \ + METHOD (setSortKey, "setSortKey", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ + METHOD (addPerson, "addPerson", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ + METHOD (setCategory, "setCategory", "(Ljava/lang/String;)Landroid/app/Notification$Builder;") \ + METHOD (setColor, "setColor", "(I)Landroid/app/Notification$Builder;") \ + METHOD (setPublicVersion, "setPublicVersion", "(Landroid/app/Notification;)Landroid/app/Notification$Builder;") \ + METHOD (setVisibility, "setVisibility", "(I)Landroid/app/Notification$Builder;") \ METHOD (setChronometerCountDown, "setChronometerCountDown", "(Z)Landroid/app/Notification$Builder;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderApi24, "android/app/Notification$Builder", 24) +DECLARE_JNI_CLASS (NotificationBuilderBase, "android/app/Notification$Builder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -153,21 +127,11 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationBuilderApi26, "android/app/Notificat #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (cancel, "cancel", "(Ljava/lang/String;I)V") \ METHOD (cancelAll, "cancelAll", "()V") \ - METHOD (notify, "notify", "(Ljava/lang/String;ILandroid/app/Notification;)V") - -DECLARE_JNI_CLASS (NotificationManagerBase, "android/app/NotificationManager") -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ - METHOD (getActiveNotifications, "getActiveNotifications", "()[Landroid/service/notification/StatusBarNotification;") - -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationManagerApi23, "android/app/NotificationManager", 23) -#undef JNI_CLASS_MEMBERS - -#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ + METHOD (notify, "notify", "(Ljava/lang/String;ILandroid/app/Notification;)V") \ + METHOD (getActiveNotifications, "getActiveNotifications", "()[Landroid/service/notification/StatusBarNotification;") \ METHOD (areNotificationsEnabled, "areNotificationsEnabled", "()Z") -DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationManagerApi24, "android/app/NotificationManager", 24) +DECLARE_JNI_CLASS (NotificationManagerBase, "android/app/NotificationManager") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -180,7 +144,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (NotificationManagerApi26, "android/app/Notificat #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (getResultsFromIntent, "getResultsFromIntent", "(Landroid/content/Intent;)Landroid/os/Bundle;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInput, "android/app/RemoteInput", 20) +DECLARE_JNI_CLASS (RemoteInput, "android/app/RemoteInput") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -190,13 +154,13 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInput, "android/app/RemoteInput", 20) METHOD (setChoices, "setChoices", "([Ljava/lang/CharSequence;)Landroid/app/RemoteInput$Builder;") \ METHOD (setLabel, "setLabel", "(Ljava/lang/CharSequence;)Landroid/app/RemoteInput$Builder;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (RemoteInputBuilder, "android/app/RemoteInput$Builder", 20) +DECLARE_JNI_CLASS (RemoteInputBuilder, "android/app/RemoteInput$Builder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (getNotification, "getNotification", "()Landroid/app/Notification;") - DECLARE_JNI_CLASS_WITH_MIN_SDK (StatusBarNotification, "android/service/notification/StatusBarNotification", 23) + DECLARE_JNI_CLASS (StatusBarNotification, "android/service/notification/StatusBarNotification") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -287,15 +251,12 @@ struct PushNotifications::Impl if (getAndroidSDKVersion() >= 33 && ! RuntimePermissions::isGranted (RuntimePermissions::postNotification)) return false; - if (getAndroidSDKVersion() >= 24) - { - auto* env = getEnv(); + auto* env = getEnv(); - auto notificationManager = getNotificationManager(); + auto notificationManager = getNotificationManager(); - if (notificationManager.get() != nullptr) - return env->CallBooleanMethod (notificationManager, NotificationManagerApi24.areNotificationsEnabled); - } + if (notificationManager.get() != nullptr) + return env->CallBooleanMethod (notificationManager, NotificationManagerBase.areNotificationsEnabled); return true; } @@ -347,39 +308,30 @@ struct PushNotifications::Impl void getDeliveredNotifications() const { - if (getAndroidSDKVersion() >= 23) + auto* env = getEnv(); + + Array notifications; + + auto notificationManager = getNotificationManager(); + jassert (notificationManager != nullptr); + + if (notificationManager.get() != nullptr) { - auto* env = getEnv(); + auto statusBarNotifications = LocalRef ((jobjectArray)env->CallObjectMethod (notificationManager, + NotificationManagerBase.getActiveNotifications)); - Array notifications; + const int numNotifications = env->GetArrayLength (statusBarNotifications.get()); - auto notificationManager = getNotificationManager(); - jassert (notificationManager != nullptr); - - if (notificationManager.get() != nullptr) + for (int i = 0; i < numNotifications; ++i) { - auto statusBarNotifications = LocalRef ((jobjectArray)env->CallObjectMethod (notificationManager, - NotificationManagerApi23.getActiveNotifications)); + auto statusBarNotification = LocalRef (env->GetObjectArrayElement (statusBarNotifications.get(), (jsize) i)); + auto notification = LocalRef (env->CallObjectMethod (statusBarNotification, StatusBarNotification.getNotification)); - const int numNotifications = env->GetArrayLength (statusBarNotifications.get()); - - for (int i = 0; i < numNotifications; ++i) - { - auto statusBarNotification = LocalRef (env->GetObjectArrayElement (statusBarNotifications.get(), (jsize) i)); - auto notification = LocalRef (env->CallObjectMethod (statusBarNotification, StatusBarNotification.getNotification)); - - notifications.add (javaNotificationToJuceNotification (notification)); - } + notifications.add (javaNotificationToJuceNotification (notification)); } + } - owner.listeners.call ([&] (Listener& l) { l.deliveredNotificationsListReceived (notifications); }); - } - else - { - // Not supported on this platform - jassertfalse; - owner.listeners.call ([] (Listener& l) { l.deliveredNotificationsListReceived ({}); }); - } + owner.listeners.call ([&] (Listener& l) { l.deliveredNotificationsListReceived (notifications); }); } void notifyListenersAboutLocalNotification (const LocalRef& intent) @@ -643,7 +595,7 @@ struct PushNotifications::Impl if (notificationBuilder == nullptr) return notificationBuilder; - return LocalRef (env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.build)); + return LocalRef (env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.build)); } static LocalRef createNotificationBuilder (const Notification& n) @@ -737,8 +689,8 @@ struct PushNotifications::Impl if (publicNotificationBuilder == nullptr) return {}; - auto publicVersion = LocalRef (env->CallObjectMethod (publicNotificationBuilder, NotificationBuilderApi16.build)); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setPublicVersion, publicVersion.get()); + auto publicVersion = LocalRef (env->CallObjectMethod (publicNotificationBuilder, NotificationBuilderBase.build)); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setPublicVersion, publicVersion.get()); } return notificationBuilder; @@ -863,57 +815,48 @@ struct PushNotifications::Impl env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setOnlyAlertOnce, n.alertOnlyOnce); if (n.subtitle.isNotEmpty()) - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setSubText, javaString (n.subtitle).get()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setSubText, javaString (n.subtitle).get()); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setPriority, n.priority); - - if (getAndroidSDKVersion() < 24) - { - const bool useChronometer = n.timestampVisibility == Notification::chronometer; - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setUsesChronometer, useChronometer); - } + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setPriority, n.priority); const bool showTimeStamp = n.timestampVisibility != Notification::off; - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi17.setShowWhen, showTimeStamp); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setShowWhen, showTimeStamp); if (n.groupId.isNotEmpty()) { - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setGroup, javaString (n.groupId).get()); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setGroupSummary, n.groupSummary); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setGroup, javaString (n.groupId).get()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setGroupSummary, n.groupSummary); } if (n.groupSortKey.isNotEmpty()) - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setSortKey, javaString (n.groupSortKey).get()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setSortKey, javaString (n.groupSortKey).get()); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.setLocalOnly, n.localOnly); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setLocalOnly, n.localOnly); auto extras = LocalRef (env->NewObject (AndroidBundle, AndroidBundle.constructor)); env->CallVoidMethod (extras, AndroidBundle.putBundle, javaString ("notificationData").get(), juceNotificationToBundle (n).get()); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addExtras, extras.get()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.addExtras, extras.get()); if (n.person.isNotEmpty()) - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.addPerson, javaString (n.person).get()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.addPerson, javaString (n.person).get()); auto categoryString = typeToCategory (n.type); if (categoryString.isNotEmpty()) - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setCategory, javaString (categoryString).get()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setCategory, javaString (categoryString).get()); if (n.accentColour != Colour()) - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setColor, n.accentColour.getARGB()); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setColor, n.accentColour.getARGB()); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi21.setVisibility, n.lockScreenAppearance); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setVisibility, n.lockScreenAppearance); - if (getAndroidSDKVersion() >= 24) - { - const bool useChronometer = n.timestampVisibility == Notification::chronometer; - const bool useCountDownChronometer = n.timestampVisibility == Notification::countDownChronometer; + const bool useChronometer = n.timestampVisibility == Notification::chronometer; + const bool useCountDownChronometer = n.timestampVisibility == Notification::countDownChronometer; - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi24.setChronometerCountDown, useCountDownChronometer); - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi16.setUsesChronometer, useChronometer | useCountDownChronometer); - } + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setChronometerCountDown, useCountDownChronometer); + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.setUsesChronometer, useChronometer | useCountDownChronometer); if (getAndroidSDKVersion() >= 26) { @@ -1045,7 +988,7 @@ struct PushNotifications::Impl env->CallObjectMethod (remoteInputBuilder, RemoteInputBuilder.build)); } - env->CallObjectMethod (notificationBuilder, NotificationBuilderApi20.addAction, + env->CallObjectMethod (notificationBuilder, NotificationBuilderBase.addAction, env->CallObjectMethod (actionBuilder, NotificationActionBuilder.build)); } diff --git a/modules/juce_video/native/juce_CameraDevice_android.h b/modules/juce_video/native/juce_CameraDevice_android.h index f1b1303424..125a2c1ec7 100644 --- a/modules/juce_video/native/juce_CameraDevice_android.h +++ b/modules/juce_video/native/juce_CameraDevice_android.h @@ -103,7 +103,7 @@ static const uint8 CameraSupportByteCode[] = #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ STATICMETHOD (valueOf, "valueOf", "(Ljava/lang/String;)Landroid/graphics/Bitmap$CompressFormat;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidBitmapCompressFormat, "android/graphics/Bitmap$CompressFormat", 21) +DECLARE_JNI_CLASS (AndroidBitmapCompressFormat, "android/graphics/Bitmap$CompressFormat") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -111,20 +111,20 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidBitmapCompressFormat, "android/graphics/B METHOD (createCaptureRequest, "createCaptureRequest", "(I)Landroid/hardware/camera2/CaptureRequest$Builder;") \ METHOD (createCaptureSession, "createCaptureSession", "(Ljava/util/List;Landroid/hardware/camera2/CameraCaptureSession$StateCallback;Landroid/os/Handler;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidCameraDevice, "android/hardware/camera2/CameraDevice", 21) +DECLARE_JNI_CLASS (AndroidCameraDevice, "android/hardware/camera2/CameraDevice") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (close, "close", "()V") \ METHOD (getPlanes, "getPlanes", "()[Landroid/media/Image$Plane;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidImage, "android/media/Image", 21) +DECLARE_JNI_CLASS (AndroidImage, "android/media/Image") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (getBuffer, "getBuffer", "()Ljava/nio/ByteBuffer;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidImagePlane, "android/media/Image$Plane", 21) +DECLARE_JNI_CLASS (AndroidImagePlane, "android/media/Image$Plane") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -134,7 +134,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidImagePlane, "android/media/Image$Plane", METHOD (setOnImageAvailableListener, "setOnImageAvailableListener", "(Landroid/media/ImageReader$OnImageAvailableListener;Landroid/os/Handler;)V") \ STATICMETHOD (newInstance, "newInstance", "(IIII)Landroid/media/ImageReader;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidImageReader, "android/media/ImageReader", 21) +DECLARE_JNI_CLASS (AndroidImageReader, "android/media/ImageReader") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -157,7 +157,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidImageReader, "android/media/ImageReader", METHOD (start, "start", "()V") \ METHOD (stop, "stop", "()V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaRecorder, "android/media/MediaRecorder", 21) +DECLARE_JNI_CLASS (AndroidMediaRecorder, "android/media/MediaRecorder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -167,19 +167,19 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaRecorder, "android/media/MediaRecord METHOD (setSurfaceTextureListener, "setSurfaceTextureListener", "(Landroid/view/TextureView$SurfaceTextureListener;)V") \ METHOD (setTransform, "setTransform", "(Landroid/graphics/Matrix;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidTextureView, "android/view/TextureView", 21) +DECLARE_JNI_CLASS (AndroidTextureView, "android/view/TextureView") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (constructor, "", "(Landroid/graphics/SurfaceTexture;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidSurface, "android/view/Surface", 21) +DECLARE_JNI_CLASS (AndroidSurface, "android/view/Surface") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (setDefaultBufferSize, "setDefaultBufferSize", "(II)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidSurfaceTexture, "android/graphics/SurfaceTexture", 21) +DECLARE_JNI_CLASS (AndroidSurfaceTexture, "android/graphics/SurfaceTexture") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -188,7 +188,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidSurfaceTexture, "android/graphics/Surface METHOD (isOutputSupportedFor, "isOutputSupportedFor", "(I)Z") \ METHOD (isOutputSupportedForSurface, "isOutputSupportedFor", "(Landroid/view/Surface;)Z") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidStreamConfigurationMap, "android/hardware/camera2/params/StreamConfigurationMap", 21) +DECLARE_JNI_CLASS (AndroidStreamConfigurationMap, "android/hardware/camera2/params/StreamConfigurationMap") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -196,7 +196,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidStreamConfigurationMap, "android/hardware METHOD (toByteArray, "toByteArray", "()[B") \ METHOD (size, "size", "()I") -DECLARE_JNI_CLASS_WITH_MIN_SDK (ByteArrayOutputStream, "java/io/ByteArrayOutputStream", 21) +DECLARE_JNI_CLASS (ByteArrayOutputStream, "java/io/ByteArrayOutputStream") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -206,7 +206,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (ByteArrayOutputStream, "java/io/ByteArrayOutputS METHOD (setRepeatingRequest, "setRepeatingRequest", "(Landroid/hardware/camera2/CaptureRequest;Landroid/hardware/camera2/CameraCaptureSession$CaptureCallback;Landroid/os/Handler;)I") \ METHOD (stopRepeating, "stopRepeating", "()V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraCaptureSession, "android/hardware/camera2/CameraCaptureSession", 21) +DECLARE_JNI_CLASS (CameraCaptureSession, "android/hardware/camera2/CameraCaptureSession") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -217,13 +217,13 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraCaptureSession, "android/hardware/camera2/ STATICFIELD (SCALER_STREAM_CONFIGURATION_MAP, "SCALER_STREAM_CONFIGURATION_MAP", "Landroid/hardware/camera2/CameraCharacteristics$Key;") \ STATICFIELD (SENSOR_ORIENTATION, "SENSOR_ORIENTATION", "Landroid/hardware/camera2/CameraCharacteristics$Key;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraCharacteristics, "android/hardware/camera2/CameraCharacteristics", 21) +DECLARE_JNI_CLASS (CameraCharacteristics, "android/hardware/camera2/CameraCharacteristics") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (getName, "getName", "()Ljava/lang/String;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraCharacteristicsKey, "android/hardware/camera2/CameraCharacteristics$Key", 21) +DECLARE_JNI_CLASS (CameraCharacteristicsKey, "android/hardware/camera2/CameraCharacteristics$Key") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -231,7 +231,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraCharacteristicsKey, "android/hardware/came METHOD (getCameraIdList, "getCameraIdList", "()[Ljava/lang/String;") \ METHOD (openCamera, "openCamera", "(Ljava/lang/String;Landroid/hardware/camera2/CameraDevice$StateCallback;Landroid/os/Handler;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraManager, "android/hardware/camera2/CameraManager", 21) +DECLARE_JNI_CLASS (CameraManager, "android/hardware/camera2/CameraManager") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -240,7 +240,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraManager, "android/hardware/camera2/CameraM STATICFIELD (CONTROL_AF_TRIGGER, "CONTROL_AF_TRIGGER", "Landroid/hardware/camera2/CaptureRequest$Key;") \ STATICFIELD (CONTROL_MODE, "CONTROL_MODE", "Landroid/hardware/camera2/CaptureRequest$Key;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CaptureRequest, "android/hardware/camera2/CaptureRequest", 21) +DECLARE_JNI_CLASS (CaptureRequest, "android/hardware/camera2/CaptureRequest") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -248,7 +248,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (CaptureRequest, "android/hardware/camera2/Captur METHOD (build, "build", "()Landroid/hardware/camera2/CaptureRequest;") \ METHOD (set, "set", "(Landroid/hardware/camera2/CaptureRequest$Key;Ljava/lang/Object;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CaptureRequestBuilder, "android/hardware/camera2/CaptureRequest$Builder", 21) +DECLARE_JNI_CLASS (CaptureRequestBuilder, "android/hardware/camera2/CaptureRequest$Builder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -256,7 +256,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (CaptureRequestBuilder, "android/hardware/camera2 STATICFIELD (CONTROL_AE_STATE, "CONTROL_AE_STATE", "Landroid/hardware/camera2/CaptureResult$Key;") \ STATICFIELD (CONTROL_AF_STATE, "CONTROL_AF_STATE", "Landroid/hardware/camera2/CaptureResult$Key;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (CaptureResult, "android/hardware/camera2/CaptureResult", 21) +DECLARE_JNI_CLASS (CaptureResult, "android/hardware/camera2/CaptureResult") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -2101,7 +2101,7 @@ private: CALLBACK (generatedCallback<&CaptureSession::cameraCaptureSessionConfiguredCallback>, "cameraCaptureSessionConfigured", "(JLandroid/hardware/camera2/CameraCaptureSession;)V") \ CALLBACK (generatedCallback<&CaptureSession::cameraCaptureSessionReadyCallback>, "cameraCaptureSessionReady", "(JLandroid/hardware/camera2/CameraCaptureSession;)V") - DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraCaptureSessionStateCallback, "com/rmsl/juce/CameraCaptureSessionStateCallback", 21) + DECLARE_JNI_CLASS (CameraCaptureSessionStateCallback, "com/rmsl/juce/CameraCaptureSessionStateCallback") #undef JNI_CLASS_MEMBERS @@ -2318,7 +2318,7 @@ private: CALLBACK (generatedCallback<&ScopedCameraDevice::cameraDeviceStateErrorCallback>, "cameraDeviceStateError", "(JLandroid/hardware/camera2/CameraDevice;I)V") \ CALLBACK (generatedCallback<&ScopedCameraDevice::cameraDeviceStateOpenedCallback>, "cameraDeviceStateOpened", "(JLandroid/hardware/camera2/CameraDevice;)V") - DECLARE_JNI_CLASS_WITH_MIN_SDK (CameraDeviceStateCallback, "com/rmsl/juce/CameraDeviceStateCallback", 21) + DECLARE_JNI_CLASS (CameraDeviceStateCallback, "com/rmsl/juce/CameraDeviceStateCallback") #undef JNI_CLASS_MEMBERS LocalRef createCameraStateCallbackObject() @@ -2730,7 +2730,7 @@ private: METHOD (enable, "enable", "()V") \ CALLBACK (generatedCallback<&DeviceOrientationChangeListener::orientationChanged>, "deviceOrientationChanged", "(JI)V") - DECLARE_JNI_CLASS_WITH_MIN_SDK (OrientationEventListener, "com/rmsl/juce/JuceOrientationEventListener", 21) + DECLARE_JNI_CLASS (OrientationEventListener, "com/rmsl/juce/JuceOrientationEventListener") #undef JNI_CLASS_MEMBERS LocalRef createOrientationEventListener() diff --git a/modules/juce_video/native/juce_Video_android.h b/modules/juce_video/native/juce_Video_android.h index 18f9b69e2b..4c3e386b99 100644 --- a/modules/juce_video/native/juce_Video_android.h +++ b/modules/juce_video/native/juce_Video_android.h @@ -112,7 +112,7 @@ static const uint8 MediaSessionByteCode[] = METHOD (setVolumeTo, "setVolumeTo", "(II)V") \ METHOD (unregisterCallback, "unregisterCallback", "(Landroid/media/session/MediaController$Callback;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaController, "android/media/session/MediaController", 21) +DECLARE_JNI_CLASS (AndroidMediaController, "android/media/session/MediaController") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -120,7 +120,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaController, "android/media/session/M METHOD (getCurrentVolume, "getCurrentVolume", "()I") \ METHOD (getMaxVolume, "getMaxVolume", "()I") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaControllerPlaybackInfo, "android/media/session/MediaController$PlaybackInfo", 21) +DECLARE_JNI_CLASS (AndroidMediaControllerPlaybackInfo, "android/media/session/MediaController$PlaybackInfo") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -130,7 +130,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaControllerPlaybackInfo, "android/med METHOD (seekTo, "seekTo", "(J)V") \ METHOD (stop, "stop", "()V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaControllerTransportControls, "android/media/session/MediaController$TransportControls", 21) +DECLARE_JNI_CLASS (AndroidMediaControllerTransportControls, "android/media/session/MediaController$TransportControls") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -159,7 +159,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaControllerTransportControls, "androi METHOD (start, "start", "()V") \ METHOD (stop, "stop", "()V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaPlayer, "android/media/MediaPlayer", 21) +DECLARE_JNI_CLASS (AndroidMediaPlayer, "android/media/MediaPlayer") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -174,7 +174,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaPlayer, "android/media/MediaPlayer", METHOD (setPlaybackState, "setPlaybackState", "(Landroid/media/session/PlaybackState;)V") \ METHOD (setPlaybackToLocal, "setPlaybackToLocal", "(Landroid/media/AudioAttributes;)V") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaSession, "android/media/session/MediaSession", 21) +DECLARE_JNI_CLASS (AndroidMediaSession, "android/media/session/MediaSession") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -182,14 +182,14 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaSession, "android/media/session/Medi METHOD (constructor, "", "()V") \ METHOD (putLong, "putLong", "(Ljava/lang/String;J)Landroid/media/MediaMetadata$Builder;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaMetadataBuilder, "android/media/MediaMetadata$Builder", 21) +DECLARE_JNI_CLASS (AndroidMediaMetadataBuilder, "android/media/MediaMetadata$Builder") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ METHOD (getSpeed, "getSpeed", "()F") \ METHOD (setSpeed, "setSpeed", "(F)Landroid/media/PlaybackParams;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidPlaybackParams, "android/media/PlaybackParams", 21) +DECLARE_JNI_CLASS (AndroidPlaybackParams, "android/media/PlaybackParams") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -199,7 +199,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidPlaybackParams, "android/media/PlaybackPa METHOD (getPosition, "getPosition", "()J") \ METHOD (getState, "getState", "()I") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidPlaybackState, "android/media/session/PlaybackState", 21) +DECLARE_JNI_CLASS (AndroidPlaybackState, "android/media/session/PlaybackState") #undef JNI_CLASS_MEMBERS #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \ @@ -209,7 +209,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidPlaybackState, "android/media/session/Pla METHOD (setErrorMessage, "setErrorMessage", "(Ljava/lang/CharSequence;)Landroid/media/session/PlaybackState$Builder;") \ METHOD (setState, "setState", "(IJF)Landroid/media/session/PlaybackState$Builder;") -DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidPlaybackStateBuilder, "android/media/session/PlaybackState$Builder", 21) +DECLARE_JNI_CLASS (AndroidPlaybackStateBuilder, "android/media/session/PlaybackState$Builder") #undef JNI_CLASS_MEMBERS //============================================================================== @@ -1283,7 +1283,7 @@ private: CALLBACK (generatedCallback<&MediaSession::seekToCallback>, "mediaSessionSeekTo", "(JJ)V") \ CALLBACK (generatedCallback<&MediaSession::stopCallback>, "mediaSessionStop", "(J)V") - DECLARE_JNI_CLASS_WITH_MIN_SDK (AndroidMediaSessionCallback, "com/rmsl/juce/MediaSessionCallback", 21) + DECLARE_JNI_CLASS (AndroidMediaSessionCallback, "com/rmsl/juce/MediaSessionCallback") #undef JNI_CLASS_MEMBERS LocalRef createCallbackObject() @@ -1654,7 +1654,7 @@ private: METHOD (setEnabled, "setEnabled", "(Z)V") \ CALLBACK (generatedCallback<&SystemVolumeListener::systemVolumeChanged>, "mediaSessionSystemVolumeChanged", "(J)V") - DECLARE_JNI_CLASS_WITH_MIN_SDK (SystemVolumeObserver, "com/rmsl/juce/SystemVolumeObserver", 21) + DECLARE_JNI_CLASS (SystemVolumeObserver, "com/rmsl/juce/SystemVolumeObserver") #undef JNI_CLASS_MEMBERS