From c82c5aeed282c3c21047da76d8f237bbde3da8f5 Mon Sep 17 00:00:00 2001 From: irov Date: Sun, 24 Nov 2024 14:57:21 +0200 Subject: [PATCH] ref-in ADD_MENGINE_DOWNLOAD_SKADNETWORKITEMS_PLIST improve android already create Activity policy add NOTIFICATOR_APPLICATION_DID_RECEIVE_TRIM_MEMORY --- cmake/macro_template.cmake | 22 ++++- cmake/mengine_template.cmake | 2 +- .../org/Mengine/Base/MengineActivity.java | 89 ++++++++++++++----- .../MengineGoogleLicensingPlugin.java | 2 +- .../AndroidApplication/AndroidMain.cpp | 20 +++++ .../SDLApplication/CMakeLists.txt | 8 +- ...ts.py => merge_skadnetworkitems_plists.py} | 19 ++-- ...AndroidPlatformServiceExtensionInterface.h | 1 + src/Interface/NotificatorInterface.h | 1 + .../AndroidPlatformService.cpp | 35 ++++++++ .../AndroidPlatform/AndroidPlatformService.h | 9 ++ .../AppleAppLovinPlugin/CMakeLists.txt | 16 +--- 12 files changed, 171 insertions(+), 53 deletions(-) rename src/Applications/SDLApplication/{merge_plists.py => merge_skadnetworkitems_plists.py} (58%) diff --git a/cmake/macro_template.cmake b/cmake/macro_template.cmake index c9139ec539..eeebb2c8b3 100644 --- a/cmake/macro_template.cmake +++ b/cmake/macro_template.cmake @@ -382,7 +382,7 @@ MACRO(MENGINE_SUBFOLDER) SET(APPLICATION_APPLE_GLOBAL_COCOAPODS ${APPLICATION_APPLE_GLOBAL_COCOAPODS} PARENT_SCOPE) SET(APPLICATION_APPLE_SCRIPT_PHASES ${APPLICATION_APPLE_SCRIPT_PHASES} PARENT_SCOPE) SET(APPLICATION_APPLE_APPLICATION_DELEGATE ${APPLICATION_APPLE_APPLICATION_DELEGATE} PARENT_SCOPE) - SET(APPLICATION_APPLE_PLISTS ${APPLICATION_APPLE_PLISTS} PARENT_SCOPE) + SET(APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS ${APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS} PARENT_SCOPE) SET(APPLICATION_MACOS_DYLIB ${APPLICATION_MACOS_DYLIB} PARENT_SCOPE) SET(APPLICATION_MACOS_DYLIB_WITH_SIGN ${APPLICATION_MACOS_DYLIB_WITH_SIGN} PARENT_SCOPE) @@ -1043,9 +1043,23 @@ MACRO(ADD_MENGINE_SCRIPT_PHASE NAME SCRIPT INPUT_FILES) SET(APPLICATION_APPLE_SCRIPT_PHASES ${APPLICATION_APPLE_SCRIPT_PHASES} PARENT_SCOPE) ENDMACRO() -MACRO(ADD_MENGINE_PLIST PATH) - LIST(APPEND APPLICATION_APPLE_PLISTS ${PATH}) - SET(APPLICATION_APPLE_PLISTS ${APPLICATION_APPLE_PLISTS} PARENT_SCOPE) +MACRO(ADD_MENGINE_DOWNLOAD_SKADNETWORKITEMS_PLIST URL) + get_filename_component(FILENAME ${URL} SKADNETWORKITEMS_PLIST_URL_FILENAME) + + set(SKADNETWORKITEMS_PLIST_DOWNLOAD_FILENAME "${MENGINE_SOLUTIONS_CONFIG_DIR}/downloads/Configuration/${PROJECT_NAME}/${SKADNETWORKITEMS_PLIST_URL_FILENAME}") + + file(DOWNLOAD ${URL} ${SKADNETWORKITEMS_PLIST_DOWNLOAD_FILENAME} STATUS STATUS_DOWNLOAD_SKADNETWORKIDS) + + list(GET STATUS_DOWNLOAD_SKADNETWORKIDS 0 STATUS_DOWNLOAD_SKADNETWORKIDS_CODE) + + if(NOT STATUS_DOWNLOAD_SKADNETWORKIDS_CODE EQUAL 0) + message(FATAL_ERROR "Failed to download file: ${URL}") + else() + message(STATUS "File downloaded successfully: ${URL}") + endif() + + LIST(APPEND APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS ${SKADNETWORKITEMS_PLIST_DOWNLOAD_FILENAME}) + SET(APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS ${APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS} PARENT_SCOPE) ENDMACRO() macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE) diff --git a/cmake/mengine_template.cmake b/cmake/mengine_template.cmake index faf3d3bca7..cf47f22681 100644 --- a/cmake/mengine_template.cmake +++ b/cmake/mengine_template.cmake @@ -8,7 +8,7 @@ SET(APPLICATION_APPLE_GLOBAL_COCOAPODS) SET(APPLICATION_APPLE_SCRIPT_PHASES) SET(APPLICATION_APPLE_APPLICATION_DELEGATE) SET(APPLICATION_APPLE_RESOURCES) -SET(APPLICATION_APPLE_PLISTS) +SET(APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS) SET(APPLICATION_MACOS_DYLIB) SET(APPLICATION_MACOS_DYLIB_WITH_SIGN) diff --git a/gradle/libraries/Mengine/src/main/java/org/Mengine/Base/MengineActivity.java b/gradle/libraries/Mengine/src/main/java/org/Mengine/Base/MengineActivity.java index 3dcc8d1798..4c69c4dcbe 100644 --- a/gradle/libraries/Mengine/src/main/java/org/Mengine/Base/MengineActivity.java +++ b/gradle/libraries/Mengine/src/main/java/org/Mengine/Base/MengineActivity.java @@ -81,10 +81,13 @@ public class MengineActivity extends AppCompatActivity { public static native void AndroidPlatform_windowFocusChangedEvent(boolean focus); public static native void AndroidPlatform_quitEvent(); public static native void AndroidPlatform_lowMemory(); + public static native void AndroidPlatform_trimMemory(int level); public static native void AndroidPlatform_changeLocale(String locale); - private boolean m_initializePython; - private boolean m_destroy; + private static boolean ACTIVITY_CREATED = false; + private static boolean ACTIVITY_DESTROY = false; + + private boolean m_initializePython = false; private Object m_nativeApplication; private Locale m_currentLocale; @@ -174,7 +177,7 @@ protected List getEngineListeners() { @SuppressWarnings("unchecked") public T getPlugin(Class cls) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return null; } @@ -186,7 +189,7 @@ public T getPlugin(Class cls) { } public String getSessionId() { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return ""; } @@ -198,7 +201,7 @@ public String getSessionId() { } public String getVersionName() { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return ""; } @@ -210,7 +213,7 @@ public String getVersionName() { } public void setState(String name, Object value) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return; } @@ -220,7 +223,7 @@ public void setState(String name, Object value) { } public boolean hasMetaData(String name) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return false; } @@ -232,7 +235,7 @@ public boolean hasMetaData(String name) { } public String getMetaDataString(String name) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return null; } @@ -244,7 +247,7 @@ public String getMetaDataString(String name) { } public boolean getMetaDataBoolean(String name) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return false; } @@ -256,7 +259,7 @@ public boolean getMetaDataBoolean(String name) { } public int getMetaDataInteger(String name) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return 0; } @@ -328,6 +331,20 @@ public void checkPermission(String permission, Runnable onSuccess, Runnable onFa protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + MengineLog.logMessageRelease(TAG, "onCreate: %s", savedInstanceState); + + if (MengineActivity.ACTIVITY_CREATED == true) { + MengineAnalytics.buildEvent("mng_activity_create_failed") + .addParameterString("reason", "application already created") + .logAndFlush(); + + this.finishWithAlertDialog("[ERROR] Application already created"); + + return; + } + + MengineActivity.ACTIVITY_CREATED = true; + try { Thread.currentThread().setName("MengineActivity"); } catch (final Exception e) { @@ -339,18 +356,19 @@ protected void onCreate(Bundle savedInstanceState) { MengineApplication application = (MengineApplication)this.getApplication(); if (application.isInvalidInitialize() == true) { + MengineAnalytics.buildEvent("mng_activity_create_failed") + .addParameterString("reason", "application invalid initialize") + .logAndFlush(); + this.finishWithAlertDialog("[ERROR] Application invalid initialize"); return; } - MengineLog.logMessageRelease(TAG, "onCreate: %s", savedInstanceState); - this.setState("activity.lifecycle", "create"); this.setState("activity.init", "begin"); m_initializePython = false; - m_destroy = false; Looper mainLooper = Looper.getMainLooper(); m_commandHandler = new MengineCommandHandler(mainLooper, this); @@ -458,7 +476,19 @@ protected void onCreate(Bundle savedInstanceState) { String[] optionsArgs = options.split(" "); - m_nativeApplication = AndroidMain_bootstrap(nativeLibraryDir, optionsArgs); + Object nativeApplication = AndroidMain_bootstrap(nativeLibraryDir, optionsArgs); + + if (nativeApplication == null) { + MengineAnalytics.buildEvent("mng_activity_create_failed") + .addParameterString("reason", "bootstrap failed") + .logAndFlush(); + + this.finishWithAlertDialog("[ERROR] bootstrap failed"); + + return; + } + + m_nativeApplication = nativeApplication; this.setState("activity.init", "plugin_create"); @@ -484,11 +514,11 @@ protected void onCreate(Bundle savedInstanceState) { } catch (final MenginePluginInvalidInitializeException e) { this.setState("activity.init", "plugin_create_exception." + l.getPluginName()); - MengineAnalytics.buildEvent("mng_activity_init_failed") + MengineAnalytics.buildEvent("mng_activity_create_failed") .addParameterException("reason", e) .logAndFlush(); - this.finishWithAlertDialog("[ERROR] onCreate plugin: %s exception: %s" + this.finishWithAlertDialog("[ERROR] create plugin: %s exception: %s" , l.getPluginName() , e.getMessage() ); @@ -844,7 +874,7 @@ public void onNewIntent(Intent intent) { @Override public void onDestroy() { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { MengineLog.logWarning(TAG, "onDestroy: already destroyed"); super.onDestroy(); @@ -852,7 +882,7 @@ public void onDestroy() { return; } - m_destroy = true; + MengineActivity.ACTIVITY_DESTROY = true; this.setState("activity.lifecycle", "destroy"); @@ -871,7 +901,7 @@ public void onDestroy() { } try { - m_threadMain.join(); + m_threadMain.join(1000); } catch (final InterruptedException e) { MengineLog.logError(TAG, "thread main join exception: %s" , e.getMessage() @@ -941,6 +971,19 @@ public void onLowMemory() { MengineActivity.AndroidPlatform_lowMemory(); } + @Override + public void onTrimMemory(int level) { + super.onTrimMemory(level); + + this.setState("activity.trim_memory", level); + + MengineLog.logMessage(TAG, "onTrimMemory level: %d" + , level + ); + + MengineActivity.AndroidPlatform_trimMemory(level); + } + @Override public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); @@ -1110,7 +1153,7 @@ public void pythonCall(String plugin, String method, Object ... args) { } public void addPythonPlugin(String name, Object plugin) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return; } @@ -1127,7 +1170,7 @@ public void addPythonPlugin(String name, Object plugin) { **********************************************************************************************/ public void activateSemaphore(String name) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return; } @@ -1167,7 +1210,7 @@ public void activateSemaphore(String name) { } public void deactivateSemaphore(String name) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return; } @@ -1181,7 +1224,7 @@ public void deactivateSemaphore(String name) { } public void waitSemaphore(String name, MengineSemaphoreListener cb) { - if (m_destroy == true) { + if (MengineActivity.ACTIVITY_DESTROY == true) { return; } diff --git a/gradle/plugins/GoogleLicensing/src/main/java/org/Mengine/Plugin/GoogleLicensing/MengineGoogleLicensingPlugin.java b/gradle/plugins/GoogleLicensing/src/main/java/org/Mengine/Plugin/GoogleLicensing/MengineGoogleLicensingPlugin.java index 9865246d6d..d171f4e270 100644 --- a/gradle/plugins/GoogleLicensing/src/main/java/org/Mengine/Plugin/GoogleLicensing/MengineGoogleLicensingPlugin.java +++ b/gradle/plugins/GoogleLicensing/src/main/java/org/Mengine/Plugin/GoogleLicensing/MengineGoogleLicensingPlugin.java @@ -10,7 +10,7 @@ import com.google.android.vending.licensing.LicenseChecker; import com.google.android.vending.licensing.LicenseCheckerCallback; -public class MengineGoogleLicensingPlugin extends MenginePlugin implements MenginePluginApplicationListener { +public class MengineGoogleLicensingPlugin extends MenginePlugin implements MenginePluginActivityListener { public static final S tring PLUGIN_NAME = "MengineGLicensing"; @Override diff --git a/src/Applications/AndroidApplication/AndroidMain.cpp b/src/Applications/AndroidApplication/AndroidMain.cpp index 65d68d5f71..c8acc53d35 100644 --- a/src/Applications/AndroidApplication/AndroidMain.cpp +++ b/src/Applications/AndroidApplication/AndroidMain.cpp @@ -8,9 +8,20 @@ extern "C" { + ////////////////////////////////////////////////////////////////////////// + static bool already_bootstrapped = false; ////////////////////////////////////////////////////////////////////////// JNIEXPORT jobject JNICALL MENGINE_ACTIVITY_JAVA_INTERFACE( AndroidMain_1bootstrap )(JNIEnv * _env, jclass _cls, jstring _nativeLibraryDir, jobjectArray _args) { + if( already_bootstrapped == true ) + { + __android_log_print( ANDROID_LOG_ERROR, "Mengine", "Android bootstrap already bootstrapped" ); + + return nullptr; + } + + already_bootstrapped = true; + if( Mengine::Mengine_JNI_Initialize( _env ) == JNI_FALSE ) { __android_log_print( ANDROID_LOG_ERROR, "Mengine", "Android bootstrap JNI initialize failed" ); @@ -57,6 +68,15 @@ extern "C" jobject j_application = _env->NewDirectByteBuffer( application, sizeof(Mengine::AndroidApplication) ); + if ( j_application == nullptr) + { + __android_log_print( ANDROID_LOG_ERROR, "Mengine", "Android bootstrap failed to create direct buffer" ); + + delete application; + + return nullptr; + } + return j_application; } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Applications/SDLApplication/CMakeLists.txt b/src/Applications/SDLApplication/CMakeLists.txt index dcbf35ada1..d5d4757647 100644 --- a/src/Applications/SDLApplication/CMakeLists.txt +++ b/src/Applications/SDLApplication/CMakeLists.txt @@ -181,13 +181,13 @@ if(MENGINE_TARGET_APPLE) set(MENGINE_MERGE_PLIST "${MENGINE_SOLUTIONS_CONFIG_DIR}/res/Configuration/info.plist.in") - if(APPLICATION_APPLE_PLISTS) - MESSAGE("APPLICATION_APPLE_PLISTS: ${APPLICATION_APPLE_PLISTS}") + if(APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS) + MESSAGE("APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS: ${APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS}") - set(PYTHON_MERGE_PLISTS_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/merge_plists.py") + set(PYTHON_MERGE_PLISTS_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/merge_skadnetworkitems_plists.py") execute_process( - COMMAND ${Python3_EXECUTABLE} ${PYTHON_MERGE_PLISTS_SCRIPT} ${MENGINE_DEPLOY_PATH}/${MENGINE_APPLICATION_DEPLOY_PLIST} ${APPLICATION_APPLE_PLISTS} ${MENGINE_MERGE_PLIST} + COMMAND ${Python3_EXECUTABLE} ${PYTHON_MERGE_PLISTS_SCRIPT} ${MENGINE_DEPLOY_PATH}/${MENGINE_APPLICATION_DEPLOY_PLIST} ${APPLICATION_APPLE_SKADNETWORKITEMS_PLISTS} ${MENGINE_MERGE_PLIST} RESULT_VARIABLE MENGINE_PROCESS_MERGE_PLISTS_RESULT OUTPUT_VARIABLE MENGINE_PROCESS_MERGE_PLISTS_OUTPUT ERROR_VARIABLE MENGINE_PROCESS_MERGE_PLISTS_ERROR diff --git a/src/Applications/SDLApplication/merge_plists.py b/src/Applications/SDLApplication/merge_skadnetworkitems_plists.py similarity index 58% rename from src/Applications/SDLApplication/merge_plists.py rename to src/Applications/SDLApplication/merge_skadnetworkitems_plists.py index 7800a466fa..ecd98a25f9 100644 --- a/src/Applications/SDLApplication/merge_plists.py +++ b/src/Applications/SDLApplication/merge_skadnetworkitems_plists.py @@ -9,6 +9,10 @@ def merge_plists(base, patches, output_path): with open(base, 'rb') as f: plist_base = plistlib.load(f) + + if 'SKAdNetworkItems' not in plist_base: + print(f"Base plist file not exist 'SKAdNetworkItems': {base}") + sys.exit(1) for patch in patches: if not os.path.exists(patch): @@ -18,13 +22,14 @@ def merge_plists(base, patches, output_path): with open(patch, 'rb') as f: plist_patch = plistlib.load(f) - plist_base = {**plist_base, **plist_patch} - - if 'SKAdNetworkItems' in plist_base and 'SKAdNetworkItems' in plist_patch: - plist_base['SKAdNetworkItems'] = plist_base['SKAdNetworkItems'] + [ - item for item in plist_patch['SKAdNetworkItems'] - if item not in plist_base['SKAdNetworkItems'] - ] + if isinstance(plist_patch, dict): + if 'SKAdNetworkItems' not in plist_patch: + print(f"Patch plist file not exist 'SKAdNetworkItems': {patch}") + sys.exit(1) + + plist_base['SKAdNetworkItems'] = plist_base['SKAdNetworkItems'] + [item for item in plist_patch['SKAdNetworkItems'] if item not in plist_base['SKAdNetworkItems']] + elif isinstance(plist_patch, list): + plist_base['SKAdNetworkItems'] = plist_base['SKAdNetworkItems'] + [item for item in plist_patch if item not in plist_base['SKAdNetworkItems']] os.makedirs(os.path.dirname(output_path), exist_ok=True) diff --git a/src/Environment/Android/AndroidPlatformServiceExtensionInterface.h b/src/Environment/Android/AndroidPlatformServiceExtensionInterface.h index 8d9f89f02a..77eb7ffe64 100644 --- a/src/Environment/Android/AndroidPlatformServiceExtensionInterface.h +++ b/src/Environment/Android/AndroidPlatformServiceExtensionInterface.h @@ -32,6 +32,7 @@ namespace Mengine public: virtual void androidNativeQuitEvent() = 0; virtual void androidNativeLowMemoryEvent() = 0; + virtual void androidNativeTrimMemoryEvent( jint _level ) = 0; virtual void androidNativeChangeLocale( const Mengine::Char * _language ) = 0; }; } \ No newline at end of file diff --git a/src/Interface/NotificatorInterface.h b/src/Interface/NotificatorInterface.h index 8e4cdab71b..256a2ea39f 100644 --- a/src/Interface/NotificatorInterface.h +++ b/src/Interface/NotificatorInterface.h @@ -156,6 +156,7 @@ namespace Mengine MENGINE_NOTIFICATOR_DECLARE( NOTIFICATOR_APPLICATION_WILL_RESIGN_ACTIVE ); MENGINE_NOTIFICATOR_DECLARE( NOTIFICATOR_APPLICATION_WILL_TERMINATE ); MENGINE_NOTIFICATOR_DECLARE( NOTIFICATOR_APPLICATION_DID_RECEIVE_MEMORY_WARNING ); + MENGINE_NOTIFICATOR_DECLARE( NOTIFICATOR_APPLICATION_DID_RECEIVE_TRIM_MEMORY, int32_t ); ////////////////////////////////////////////////////////////////////////// #endif ////////////////////////////////////////////////////////////////////////// diff --git a/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp b/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp index 30b9ad4c59..a9b11eae7d 100644 --- a/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp +++ b/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp @@ -420,6 +420,14 @@ extern "C" platformExtension->androidNativeLowMemoryEvent(); } /////////////////////////////////////////////////////////////////////// + JNIEXPORT void JNICALL MENGINE_ACTIVITY_JAVA_INTERFACE( AndroidPlatform_1trimMemory )(JNIEnv * env, jclass cls, jint level) + { + Mengine::AndroidPlatformServiceExtensionInterface * platformExtension = PLATFORM_SERVICE() + ->getUnknown(); + + platformExtension->androidNativeTrimMemoryEvent( level ); + } + /////////////////////////////////////////////////////////////////////// JNIEXPORT void JNICALL MENGINE_ACTIVITY_JAVA_INTERFACE( AndroidPlatform_1changeLocale )(JNIEnv * env, jclass cls, jstring _language) { Mengine::AndroidPlatformServiceExtensionInterface * platformExtension = PLATFORM_SERVICE() @@ -1491,6 +1499,10 @@ namespace Mengine { this->lowMemoryEvent_( ev.data.lowMemory ); }break; + case PlatformUnionEvent::PET_TRIM_MEMORY: + { + this->trimMemoryEvent_( ev.data.trimMemory ); + }break; case PlatformUnionEvent::PET_CHANGE_LOCALE: { this->changeLocaleEvent_( ev.data.changeLocale ); @@ -2264,6 +2276,22 @@ namespace Mengine this->pushEvent( event ); } ////////////////////////////////////////////////////////////////////////// + void AndroidPlatformService::androidNativeTrimMemoryEvent(jint _level) + { + MENGINE_THREAD_MUTEX_SCOPE( m_nativeMutex ); + + PlatformUnionEvent event; + event.type = PlatformUnionEvent::PET_TRIM_MEMORY; + + event.data.trimMemory.level = _level; + + LOGGER_INFO( "platform", "trim memory event: %d" + , _level + ); + + this->pushEvent( event ); + } + ////////////////////////////////////////////////////////////////////////// void AndroidPlatformService::androidNativeChangeLocale( const Mengine::Char * _language ) { MENGINE_THREAD_MUTEX_SCOPE( m_nativeMutex ); @@ -2514,6 +2542,13 @@ namespace Mengine NOTIFICATION_NOTIFY( NOTIFICATOR_APPLICATION_DID_RECEIVE_MEMORY_WARNING ); } ////////////////////////////////////////////////////////////////////////// + void AndroidPlatformService::trimMemoryEvent_( const PlatformUnionEvent::PlatformTrimMemoryEvent & _event ) + { + jint level = _event.level; + + NOTIFICATION_NOTIFY( NOTIFICATOR_APPLICATION_DID_RECEIVE_TRIM_MEMORY, level ); + } + ////////////////////////////////////////////////////////////////////////// void AndroidPlatformService::changeLocaleEvent_( const PlatformUnionEvent::PlatformChangeLocale & _event ) { MENGINE_UNUSED( _event ); diff --git a/src/Platforms/AndroidPlatform/AndroidPlatformService.h b/src/Platforms/AndroidPlatform/AndroidPlatformService.h index a0e38df156..706fa993f0 100644 --- a/src/Platforms/AndroidPlatform/AndroidPlatformService.h +++ b/src/Platforms/AndroidPlatform/AndroidPlatformService.h @@ -177,6 +177,7 @@ namespace Mengine void androidNativeWindowFocusChangedEvent( jboolean _focus ) override; void androidNativeQuitEvent() override; void androidNativeLowMemoryEvent() override; + void androidNativeTrimMemoryEvent( jint _level ) override; void androidNativeChangeLocale( const Mengine::Char * _language ) override; protected: @@ -209,6 +210,7 @@ namespace Mengine PET_CLIPBOARD_CHANGED, PET_WINDOW_FOCUS_CHANGED, PET_LOW_MEMORY, + PET_TRIM_MEMORY, PET_CHANGE_LOCALE, } type; @@ -274,6 +276,11 @@ namespace Mengine int32_t dummy; }; + struct PlatformTrimMemoryEvent + { + jint level; + }; + struct PlatformChangeLocale { Char language[MENGINE_LOCALE_LANGUAGE_SIZE + 1]; @@ -292,6 +299,7 @@ namespace Mengine PlatformClipboardChangedEvent clipboardChanged; PlatformWindowFocusChangedEvent windowFocusChanged; PlatformLowMemoryEvent lowMemory; + PlatformTrimMemoryEvent trimMemory; PlatformChangeLocale changeLocale; } data; }; @@ -307,6 +315,7 @@ namespace Mengine void clipboardChangedEvent_( const PlatformUnionEvent::PlatformClipboardChangedEvent & _event ); void windowFocusChangedEvent_( const PlatformUnionEvent::PlatformWindowFocusChangedEvent & _event ); void lowMemoryEvent_( const PlatformUnionEvent::PlatformLowMemoryEvent & _event ); + void trimMemoryEvent_( const PlatformUnionEvent::PlatformTrimMemoryEvent & _event ); void changeLocaleEvent_( const PlatformUnionEvent::PlatformChangeLocale & _event ); protected: diff --git a/src/Plugins/AppleAppLovinPlugin/CMakeLists.txt b/src/Plugins/AppleAppLovinPlugin/CMakeLists.txt index aabfafe362..d6773c9584 100644 --- a/src/Plugins/AppleAppLovinPlugin/CMakeLists.txt +++ b/src/Plugins/AppleAppLovinPlugin/CMakeLists.txt @@ -99,22 +99,12 @@ ADD_APPLOVIN_MEDIATION(VERVE "AppLovinMediationVerveAdapter" "3.1.3.0") ADD_APPLOVIN_MEDIATION(MYTARGET "AppLovinMediationMyTargetAdapter" "5.22.0.0") #VK ADD_APPLOVIN_MEDIATION(YANDEX "AppLovinMediationYandexAdapter" "7.5.0.3") -SET(URL_DOWNLOAD_APPLOVIN_SKADNETWORKIDS "https://skadnetwork-ids.applovin.com/v1/skadnetworkids.xml") +ADD_MENGINE_DOWNLOAD_SKADNETWORKITEMS_PLIST("https://skadnetwork-ids.applovin.com/v1/skadnetworkids.xml") -file(DOWNLOAD ${URL_DOWNLOAD_APPLOVIN_SKADNETWORKIDS} ${MENGINE_SOLUTIONS_CONFIG_DIR}/downloads/Configuration/${PROJECT_NAME}/applovin_skadnetworkids.xml - STATUS STATUS_DOWNLOAD_APPLOVIN_SKADNETWORKIDS -) - -list(GET STATUS_DOWNLOAD_APPLOVIN_SKADNETWORKIDS 0 STATUS_DOWNLOAD_APPLOVIN_SKADNETWORKIDS_CODE) - -if(NOT STATUS_DOWNLOAD_APPLOVIN_SKADNETWORKIDS_CODE EQUAL 0) - message(FATAL_ERROR "Failed to download file: ${URL_DOWNLOAD_APPLOVIN_SKADNETWORKIDS} code: ${STATUS_DOWNLOAD_APPLOVIN_SKADNETWORKIDS_CODE}") -else() - message(STATUS "File downloaded successfully: ${URL_DOWNLOAD_APPLOVIN_SKADNETWORKIDS}") +if(MENGINE_PLUGIN_APPLE_APPLOVIN_MEDIATION_UNITYADS) + ADD_MENGINE_DOWNLOAD_SKADNETWORKITEMS_PLIST("https://skan.mz.unity3d.com/v2/partner/skadnetworks.plist.xml") endif() -ADD_MENGINE_PLIST(${MENGINE_SOLUTIONS_CONFIG_DIR}/downloads/Configuration/${PROJECT_NAME}/applovin_skadnetworkids.xml) - if(MENGINE_PLUGIN_APPLE_APPLOVIN_MEDIATION_UNITYADS) SET(URL_DOWNLOAD_UNITYADS_SKADNETWORKIDS "https://skan.mz.unity3d.com/v2/partner/skadnetworks.plist.xml")