From 99994e60fc0e66a784dfe9fa90594f5ae40b06f7 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Wed, 22 Feb 2023 11:55:33 -0800 Subject: [PATCH 1/9] Change user-agent register timing in C++ Change to register user-agents before platform App creation so that the new user-agents can be captured and logged at iOS/Android level. --- app/src/app_android.cc | 14 +++++++--- app/src/app_common.cc | 38 ++++++++++++++++------------ app/src/app_common.h | 4 +++ app/src/app_desktop.cc | 6 ++++- app/src/app_ios.mm | 6 ++++- app/src/include/firebase/app.h | 4 ++- app/tests/app_test.cc | 7 ++++- firestore/src/main/firestore_main.cc | 6 ++++- 8 files changed, 61 insertions(+), 24 deletions(-) diff --git a/app/src/app_android.cc b/app/src/app_android.cc index 17b8e7a34f..fb0a94b677 100644 --- a/app/src/app_android.cc +++ b/app/src/app_android.cc @@ -479,6 +479,9 @@ App* App::Create(const AppOptions& options, const char* name, JNIEnv* jni_env, } LogDebug("Creating Firebase App %s for %s", name, kFirebaseVersionString); if (CacheMethods(jni_env, activity)) { + // Register C++ user-agents before creating Android app. + app_common::RegisterSdkUsage(jni_env); + // Try to get or create a new FirebaseApp object. jobject platform_app = CreateOrGetPlatformApp(jni_env, options, name, activity); @@ -526,9 +529,14 @@ static void RegisterLibraryWithVersionRegistrar(JNIEnv* env, env->DeleteLocalRef(registrar); } -void App::RegisterLibrary(const char* library, const char* version) { - RegisterLibraryWithVersionRegistrar(util::GetJNIEnvFromApp(), library, - version); +void App::RegisterLibrary(const char* library, const char* version, + void* platform_resource) { + FIREBASE_ASSERT(platform_resource); + + // Always relies on platform_resource to get reference to JNIEnv* to reduce + // complexity. + RegisterLibraryWithVersionRegistrar( + reinterpret_cast(platform_resource), library, version); app_common::RegisterLibrary(library, version); } diff --git a/app/src/app_common.cc b/app/src/app_common.cc index 77934bf9cf..cc25a0df25 100644 --- a/app/src/app_common.cc +++ b/app/src/app_common.cc @@ -261,7 +261,7 @@ class LibraryRegistry { // Guards g_apps and g_default_app. static Mutex* g_app_mutex = new Mutex(); -static std::map>* g_apps; +static std::map>* g_apps = nullptr; static App* g_default_app = nullptr; LibraryRegistry* LibraryRegistry::library_registry_ = nullptr; @@ -294,21 +294,6 @@ App* AddApp(App* app, std::map* results) { app_options.storage_bucket(), app_options.project_id(), static_cast(reinterpret_cast(app))); } - LibraryRegistry::Initialize(); - if (created_first_app) { - // This calls the platform specific method to propagate the registration to - // any SDKs in use by this library. - App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX, - FIREBASE_VERSION_NUMBER_STRING); - App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-os", - kOperatingSystem); - App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-arch", - kCpuArchitecture); - App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-stl", - kCppRuntimeOrStl); - App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-buildsrc", - kBuildSource); - } callback::Initialize(); AppCallback::NotifyAllAppCreated(app, results); return app; @@ -433,6 +418,27 @@ void RegisterLibrariesFromUserAgent(const char* user_agent) { if (changed) registry->UpdateUserAgent(); } +void RegisterSdkUsage(void* platform_resource) { + MutexLock lock(*g_app_mutex); + + // Only register libraries when no C++ apps was created before. + if (g_apps == nullptr) { + LibraryRegistry::Initialize(); + // This calls the platform specific method to propagate the registration to + // any SDKs in use by this library. + App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX, + FIREBASE_VERSION_NUMBER_STRING, platform_resource); + App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-os", kOperatingSystem, + platform_resource); + App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-arch", + kCpuArchitecture, platform_resource); + App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-stl", + kCppRuntimeOrStl, platform_resource); + App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-buildsrc", + kBuildSource, platform_resource); + } +} + const char* GetUserAgent() { MutexLock lock(*g_app_mutex); return LibraryRegistry::Initialize()->GetUserAgent(); diff --git a/app/src/app_common.h b/app/src/app_common.h index a2fbc0eed4..5873b040ee 100644 --- a/app/src/app_common.h +++ b/app/src/app_common.h @@ -80,6 +80,10 @@ void RegisterLibrary(const char* library, const char* version); // This is useful when this SDK wraps other SDKs. void RegisterLibrariesFromUserAgent(const char* user_agent); +// Register all user-agents related to C++ SDK usages. +// platform_resource currently is only used for passing JNIEnv on Android +void RegisterSdkUsage(void* platform_resource); + // Get the user agent string for all registered libraries. // This is not thread safe w.r.t RegisterLibrary(). // NOTE: This is an internal method, use App::UserAgent() instead. diff --git a/app/src/app_desktop.cc b/app/src/app_desktop.cc index 0276c163c9..b2373ff5d8 100644 --- a/app/src/app_desktop.cc +++ b/app/src/app_desktop.cc @@ -137,6 +137,9 @@ App* App::Create(const AppOptions& options, const char* name) { // NOLINT AppOptions options_with_defaults = options; if (options_with_defaults.PopulateRequiredWithDefaults()) { + // Register C++/Unity user-agents + app_common::RegisterSdkUsage(nullptr); + app = new App(); app->name_ = name; app->options_ = options_with_defaults; @@ -168,7 +171,8 @@ internal::FunctionRegistry* App::function_registry() { } #endif // INTERNAL_EXPERIMENTAL -void App::RegisterLibrary(const char* library, const char* version) { +void App::RegisterLibrary(const char* library, const char* version, + void* platform_resource) { app_common::RegisterLibrary(library, version); } diff --git a/app/src/app_ios.mm b/app/src/app_ios.mm index e218b1d0f8..93a2d0ba14 100644 --- a/app/src/app_ios.mm +++ b/app/src/app_ios.mm @@ -252,6 +252,10 @@ static void PlatformOptionsToAppOptions(FIROptions* platform_options, AppOptions LogError("App %s already created, options will not be applied.", name); return app; } + + // Register C++/Unity user-agents before creating iOS app. + app_common::RegisterSdkUsage(nullptr); + LogDebug("Creating Firebase App %s for %s", name, kFirebaseVersionString); app = new App(); app->options_ = options; @@ -277,7 +281,7 @@ static void PlatformOptionsToAppOptions(FIROptions* platform_options, AppOptions App* App::GetInstance(const char* name) { return app_common::FindAppByName(name); } -void App::RegisterLibrary(const char* library, const char* version) { +void App::RegisterLibrary(const char* library, const char* version, void* platform_resource) { [FIRApp registerLibrary:@(library) withVersion:@(version)]; app_common::RegisterLibrariesFromUserAgent( util::NSStringToString([FIRApp firebaseUserAgent]).c_str()); diff --git a/app/src/include/firebase/app.h b/app/src/include/firebase/app.h index 0501f38ac0..daaba09890 100644 --- a/app/src/include/firebase/app.h +++ b/app/src/include/firebase/app.h @@ -697,7 +697,9 @@ class App { /// @param library Name of the library to register as a user of the Firebase /// C++ SDK. /// @param version Version of the library being registered. - static void RegisterLibrary(const char* library, const char* version); + /// @param context Platform specific resource. Ex. for Android, this is JNIEnv + static void RegisterLibrary(const char* library, const char* version, + void* platform_resource); // Internal method to retrieve the combined string of registered libraries. static const char* GetUserAgent(); diff --git a/app/tests/app_test.cc b/app/tests/app_test.cc index ad60202f22..95502c86e0 100644 --- a/app/tests/app_test.cc +++ b/app/tests/app_test.cc @@ -498,7 +498,12 @@ TEST_F(AppTest, TestRegisterLibrary) { ContainsRegex("fire-cpp-arch/[^ ]+")); EXPECT_THAT(std::string(App::GetUserAgent()), ContainsRegex("fire-cpp-stl/[^ ]+")); - App::RegisterLibrary("fire-testing", "1.2.3"); +#if FIREBASE_PLATFORM_ANDROID + App::RegisterLibrary("fire-testing", "1.2.3", + firebase_app_default->GetJNIEnv()); +#else + App::RegisterLibrary("fire-testing", "1.2.3", nullptr); +#endif EXPECT_THAT(std::string(App::GetUserAgent()), HasSubstr("fire-testing/1.2.3")); firebase_app_default.reset(nullptr); diff --git a/firestore/src/main/firestore_main.cc b/firestore/src/main/firestore_main.cc index 9174665b7c..fc1d73806e 100644 --- a/firestore/src/main/firestore_main.cc +++ b/firestore/src/main/firestore_main.cc @@ -110,7 +110,11 @@ FirestoreInternal::FirestoreInternal( "com.google.firebase.firestore.transaction", /*threads=*/5))) { ApplyDefaultSettings(); - App::RegisterLibrary("fire-fst", kFirestoreVersionString); +#if FIREBASE_PLATFORM_ANDROID + App::RegisterLibrary("fire-fst", kFirestoreVersionString, app->GetJNIEnv()); +#else + App::RegisterLibrary("fire-fst", kFirestoreVersionString, nullptr); +#endif } FirestoreInternal::~FirestoreInternal() { From 06bd6a2348de6f751c2d272a63e6351dfcb395e9 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Wed, 22 Feb 2023 11:58:31 -0800 Subject: [PATCH 2/9] Add Android utility `CallAfterEnsureMethodsCached` This utility function is used internally to ensure the callback is triggered when all necessary Java classes and methods are cached. --- app/src/app_android.cc | 8 ++++++++ app/src/util_android.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/app/src/app_android.cc b/app/src/app_android.cc index fb0a94b677..5827fada9d 100644 --- a/app/src/app_android.cc +++ b/app/src/app_android.cc @@ -573,6 +573,14 @@ bool App::IsDataCollectionDefaultEnabled() const { const char* App::GetUserAgent() { return app_common::GetUserAgent(); } +void util::CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, + std::function callback) { + if (CacheMethods(env, activity)) { + callback(); + ReleaseClasses(env); + } +} + JavaVM* App::java_vm() const { return internal_->java_vm(); } jobject App::GetPlatformApp() const { return internal_->GetLocalRef(); } diff --git a/app/src/util_android.h b/app/src/util_android.h index 734a6003d8..c850f5ad34 100644 --- a/app/src/util_android.h +++ b/app/src/util_android.h @@ -1127,6 +1127,12 @@ jint AttachCurrentThread(JavaVM* java_vm, JNIEnv** env); // App. If there is no instantiated App, returns nullptr. JNIEnv* GetJNIEnvFromApp(); +// Make sure the Java classes and methods are cached before triggering the +// the callback. Can be slow if this is called BEFORE any Firebase App is +// created. +void CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, + std::function callback); + } // namespace util // NOLINTNEXTLINE - allow namespace overridden } // namespace firebase From 141c3e18d964b953e0e91022451821b339008674 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Thu, 2 Mar 2023 18:24:58 -0800 Subject: [PATCH 3/9] Update according to the review feedback --- app/src/app_common.cc | 4 +++- app/src/include/firebase/app.h | 3 ++- app/src/util_android.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/app_common.cc b/app/src/app_common.cc index cc25a0df25..0db042c1aa 100644 --- a/app/src/app_common.cc +++ b/app/src/app_common.cc @@ -264,6 +264,7 @@ static Mutex* g_app_mutex = new Mutex(); static std::map>* g_apps = nullptr; static App* g_default_app = nullptr; LibraryRegistry* LibraryRegistry::library_registry_ = nullptr; +static bool g_is_user_agent_registered = false; App* AddApp(App* app, std::map* results) { bool created_first_app = false; @@ -422,7 +423,8 @@ void RegisterSdkUsage(void* platform_resource) { MutexLock lock(*g_app_mutex); // Only register libraries when no C++ apps was created before. - if (g_apps == nullptr) { + if (!g_is_user_agent_registered) { + g_is_user_agent_registered = true; LibraryRegistry::Initialize(); // This calls the platform specific method to propagate the registration to // any SDKs in use by this library. diff --git a/app/src/include/firebase/app.h b/app/src/include/firebase/app.h index daaba09890..5e7399f8e4 100644 --- a/app/src/include/firebase/app.h +++ b/app/src/include/firebase/app.h @@ -697,7 +697,8 @@ class App { /// @param library Name of the library to register as a user of the Firebase /// C++ SDK. /// @param version Version of the library being registered. - /// @param context Platform specific resource. Ex. for Android, this is JNIEnv + /// @param platform_resource Platform specific resource. Ex. for Android, this + /// is JNIEnv. static void RegisterLibrary(const char* library, const char* version, void* platform_resource); diff --git a/app/src/util_android.h b/app/src/util_android.h index c850f5ad34..f562e4a81a 100644 --- a/app/src/util_android.h +++ b/app/src/util_android.h @@ -1129,7 +1129,7 @@ JNIEnv* GetJNIEnvFromApp(); // Make sure the Java classes and methods are cached before triggering the // the callback. Can be slow if this is called BEFORE any Firebase App is -// created. +// created. This is currently used by Unity SDK. void CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, std::function callback); From 783bd65d315eff0f7d9d699596fa246f46e62a48 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Fri, 3 Mar 2023 17:58:34 -0800 Subject: [PATCH 4/9] Fix test fail The desktop test fail because the user-agent does not get registered again after the app is deleted an created again. Move the boolean to LibraryRegistry instance so that it can reset when the app is deleted. --- app/src/app_common.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/app_common.cc b/app/src/app_common.cc index 0db042c1aa..ca94070e10 100644 --- a/app/src/app_common.cc +++ b/app/src/app_common.cc @@ -190,7 +190,7 @@ struct AppData { // Tracks library registrations. class LibraryRegistry { private: - LibraryRegistry() {} + LibraryRegistry() : is_common_libraries_registered(false) {} public: // Register a library, returns true if the library version changed. @@ -252,9 +252,23 @@ class LibraryRegistry { } } + static bool GetCommonLibrariesRegistered() { + if (library_registry_) { + return library_registry_->is_common_libraries_registered; + } + return false; + } + + static void SetCommonLibrariesRegistered() { + if (library_registry_) { + library_registry_->is_common_libraries_registered = true; + } + } + private: std::map library_to_version_; std::string user_agent_; + bool is_common_libraries_registered; static LibraryRegistry* library_registry_; }; @@ -264,7 +278,6 @@ static Mutex* g_app_mutex = new Mutex(); static std::map>* g_apps = nullptr; static App* g_default_app = nullptr; LibraryRegistry* LibraryRegistry::library_registry_ = nullptr; -static bool g_is_user_agent_registered = false; App* AddApp(App* app, std::map* results) { bool created_first_app = false; @@ -423,8 +436,7 @@ void RegisterSdkUsage(void* platform_resource) { MutexLock lock(*g_app_mutex); // Only register libraries when no C++ apps was created before. - if (!g_is_user_agent_registered) { - g_is_user_agent_registered = true; + if (!LibraryRegistry::GetCommonLibrariesRegistered()) { LibraryRegistry::Initialize(); // This calls the platform specific method to propagate the registration to // any SDKs in use by this library. @@ -438,6 +450,7 @@ void RegisterSdkUsage(void* platform_resource) { kCppRuntimeOrStl, platform_resource); App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-buildsrc", kBuildSource, platform_resource); + LibraryRegistry::SetCommonLibrariesRegistered(); } } From 4e00f8203bcd036d80a33a865564b61c21224077 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Fri, 3 Mar 2023 18:02:28 -0800 Subject: [PATCH 5/9] rename the function --- app/src/app_common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/app_common.cc b/app/src/app_common.cc index ca94070e10..85921da314 100644 --- a/app/src/app_common.cc +++ b/app/src/app_common.cc @@ -252,7 +252,7 @@ class LibraryRegistry { } } - static bool GetCommonLibrariesRegistered() { + static bool IsCommonLibrariesRegistered() { if (library_registry_) { return library_registry_->is_common_libraries_registered; } @@ -436,7 +436,7 @@ void RegisterSdkUsage(void* platform_resource) { MutexLock lock(*g_app_mutex); // Only register libraries when no C++ apps was created before. - if (!LibraryRegistry::GetCommonLibrariesRegistered()) { + if (!LibraryRegistry::IsCommonLibrariesRegistered()) { LibraryRegistry::Initialize(); // This calls the platform specific method to propagate the registration to // any SDKs in use by this library. From d6c682ba10ecb03d7dc9ffc39efb3a206a9fe7f1 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Fri, 3 Mar 2023 19:47:56 -0800 Subject: [PATCH 6/9] format code --- app/src/app_common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/app_common.cc b/app/src/app_common.cc index 85921da314..76f494503e 100644 --- a/app/src/app_common.cc +++ b/app/src/app_common.cc @@ -254,14 +254,14 @@ class LibraryRegistry { static bool IsCommonLibrariesRegistered() { if (library_registry_) { - return library_registry_->is_common_libraries_registered; + return library_registry_->is_common_libraries_registered; } return false; } static void SetCommonLibrariesRegistered() { if (library_registry_) { - library_registry_->is_common_libraries_registered = true; + library_registry_->is_common_libraries_registered = true; } } From f5435d8231fe26d0e9ca824afd8b010b1d55784a Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Mon, 6 Mar 2023 11:34:47 -0800 Subject: [PATCH 7/9] Update according to the comments - Rename `IsCommonLibrariesRegistered` to `IsCommonLibraryRegistered`, and similar changes. - Change function parameter `/* platform_resource */` for platforms which are not using this parameter - Move `CallAfterEnsureMethodsCached()` declaration to `app_android.h` --- app/src/app_android.cc | 12 ++++++------ app/src/app_android.h | 32 ++++++++++++++++++++++++++++++++ app/src/app_common.cc | 16 ++++++++-------- app/src/app_desktop.cc | 2 +- app/src/app_ios.mm | 4 +++- app/src/app_stub.cc | 4 +++- app/src/util_android.h | 7 ------- 7 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 app/src/app_android.h diff --git a/app/src/app_android.cc b/app/src/app_android.cc index 9be6b34d7e..112c05e3f6 100644 --- a/app/src/app_android.cc +++ b/app/src/app_android.cc @@ -574,16 +574,16 @@ bool App::IsDataCollectionDefaultEnabled() const { const char* App::GetUserAgent() { return app_common::GetUserAgent(); } -void util::CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, - std::function callback) { +JavaVM* App::java_vm() const { return internal_->java_vm(); } + +jobject App::GetPlatformApp() const { return internal_->GetLocalRef(); } + +void CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, + std::function callback) { if (CacheMethods(env, activity)) { callback(); ReleaseClasses(env); } } -JavaVM* App::java_vm() const { return internal_->java_vm(); } - -jobject App::GetPlatformApp() const { return internal_->GetLocalRef(); } - } // namespace firebase diff --git a/app/src/app_android.h b/app/src/app_android.h new file mode 100644 index 0000000000..d4c641168f --- /dev/null +++ b/app/src/app_android.h @@ -0,0 +1,32 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FIREBASE_APP_SRC_APP_ANDROID_H_ +#define FIREBASE_APP_SRC_APP_ANDROID_H_ + +#include + +#include + +namespace firebase { +// Make sure the Java classes and methods are cached before triggering the +// the callback. Can be slow if this is called BEFORE any Firebase App is +// created. This is currently used by Unity SDK. +void CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, + std::function callback); +} // namespace firebase + +#endif // FIREBASE_APP_SRC_APP_ANDROID_H_ diff --git a/app/src/app_common.cc b/app/src/app_common.cc index 76f494503e..935d018b2d 100644 --- a/app/src/app_common.cc +++ b/app/src/app_common.cc @@ -190,7 +190,7 @@ struct AppData { // Tracks library registrations. class LibraryRegistry { private: - LibraryRegistry() : is_common_libraries_registered(false) {} + LibraryRegistry() : is_common_library_registered(false) {} public: // Register a library, returns true if the library version changed. @@ -252,23 +252,23 @@ class LibraryRegistry { } } - static bool IsCommonLibrariesRegistered() { + static bool IsCommonLibraryRegistered() { if (library_registry_) { - return library_registry_->is_common_libraries_registered; + return library_registry_->is_common_library_registered; } return false; } - static void SetCommonLibrariesRegistered() { + static void SetCommonLibraryRegistered() { if (library_registry_) { - library_registry_->is_common_libraries_registered = true; + library_registry_->is_common_library_registered = true; } } private: std::map library_to_version_; std::string user_agent_; - bool is_common_libraries_registered; + bool is_common_library_registered; static LibraryRegistry* library_registry_; }; @@ -436,7 +436,7 @@ void RegisterSdkUsage(void* platform_resource) { MutexLock lock(*g_app_mutex); // Only register libraries when no C++ apps was created before. - if (!LibraryRegistry::IsCommonLibrariesRegistered()) { + if (!LibraryRegistry::IsCommonLibraryRegistered()) { LibraryRegistry::Initialize(); // This calls the platform specific method to propagate the registration to // any SDKs in use by this library. @@ -450,7 +450,7 @@ void RegisterSdkUsage(void* platform_resource) { kCppRuntimeOrStl, platform_resource); App::RegisterLibrary(FIREBASE_CPP_USER_AGENT_PREFIX "-buildsrc", kBuildSource, platform_resource); - LibraryRegistry::SetCommonLibrariesRegistered(); + LibraryRegistry::SetCommonLibraryRegistered(); } } diff --git a/app/src/app_desktop.cc b/app/src/app_desktop.cc index b2373ff5d8..3ca7b61557 100644 --- a/app/src/app_desktop.cc +++ b/app/src/app_desktop.cc @@ -172,7 +172,7 @@ internal::FunctionRegistry* App::function_registry() { #endif // INTERNAL_EXPERIMENTAL void App::RegisterLibrary(const char* library, const char* version, - void* platform_resource) { + void* /* platform_resource */) { app_common::RegisterLibrary(library, version); } diff --git a/app/src/app_ios.mm b/app/src/app_ios.mm index 93a2d0ba14..b997e76657 100644 --- a/app/src/app_ios.mm +++ b/app/src/app_ios.mm @@ -281,7 +281,9 @@ static void PlatformOptionsToAppOptions(FIROptions* platform_options, AppOptions App* App::GetInstance(const char* name) { return app_common::FindAppByName(name); } -void App::RegisterLibrary(const char* library, const char* version, void* platform_resource) { +void App::RegisterLibrary(const char* library, + const char* version, + void* /* platform_resource */) { [FIRApp registerLibrary:@(library) withVersion:@(version)]; app_common::RegisterLibrariesFromUserAgent( util::NSStringToString([FIRApp firebaseUserAgent]).c_str()); diff --git a/app/src/app_stub.cc b/app/src/app_stub.cc index a60e61144e..240d3b940e 100644 --- a/app/src/app_stub.cc +++ b/app/src/app_stub.cc @@ -72,7 +72,9 @@ internal::FunctionRegistry* App::function_registry() { } #endif -void App::RegisterLibrary(const char* library, const char* version) { +void App::RegisterLibrary(const char* library, + const char* version, + void* /* platform_resource */) { app_common::RegisterLibrary(library, version); } diff --git a/app/src/util_android.h b/app/src/util_android.h index f562e4a81a..d5305e2693 100644 --- a/app/src/util_android.h +++ b/app/src/util_android.h @@ -1126,13 +1126,6 @@ jint AttachCurrentThread(JavaVM* java_vm, JNIEnv** env); // firebase::App, either the default App (if it exists) or any valid // App. If there is no instantiated App, returns nullptr. JNIEnv* GetJNIEnvFromApp(); - -// Make sure the Java classes and methods are cached before triggering the -// the callback. Can be slow if this is called BEFORE any Firebase App is -// created. This is currently used by Unity SDK. -void CallAfterEnsureMethodsCached(JNIEnv* env, jobject activity, - std::function callback); - } // namespace util // NOLINTNEXTLINE - allow namespace overridden } // namespace firebase From 4aa4f4029823e59a38d3ce27de50b6ef2857e399 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Mon, 6 Mar 2023 11:43:16 -0800 Subject: [PATCH 8/9] fix lint --- app/src/app_android.cc | 2 ++ app/src/app_android.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/app_android.cc b/app/src/app_android.cc index 112c05e3f6..7402e79d50 100644 --- a/app/src/app_android.cc +++ b/app/src/app_android.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include "app/src/app_android.h" + #include #include diff --git a/app/src/app_android.h b/app/src/app_android.h index d4c641168f..9889e15f61 100644 --- a/app/src/app_android.h +++ b/app/src/app_android.h @@ -17,10 +17,10 @@ #ifndef FIREBASE_APP_SRC_APP_ANDROID_H_ #define FIREBASE_APP_SRC_APP_ANDROID_H_ -#include - #include +#include + namespace firebase { // Make sure the Java classes and methods are cached before triggering the // the callback. Can be slow if this is called BEFORE any Firebase App is From 3e68401ddeb9cf2ed9e433e17e86e913ac808f19 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Mon, 6 Mar 2023 11:45:16 -0800 Subject: [PATCH 9/9] format_code --- app/src/app_ios.mm | 4 +--- app/src/app_stub.cc | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/app_ios.mm b/app/src/app_ios.mm index b997e76657..f7a4b32fea 100644 --- a/app/src/app_ios.mm +++ b/app/src/app_ios.mm @@ -281,9 +281,7 @@ static void PlatformOptionsToAppOptions(FIROptions* platform_options, AppOptions App* App::GetInstance(const char* name) { return app_common::FindAppByName(name); } -void App::RegisterLibrary(const char* library, - const char* version, - void* /* platform_resource */) { +void App::RegisterLibrary(const char* library, const char* version, void* /* platform_resource */) { [FIRApp registerLibrary:@(library) withVersion:@(version)]; app_common::RegisterLibrariesFromUserAgent( util::NSStringToString([FIRApp firebaseUserAgent]).c_str()); diff --git a/app/src/app_stub.cc b/app/src/app_stub.cc index 240d3b940e..1c2c6c28e6 100644 --- a/app/src/app_stub.cc +++ b/app/src/app_stub.cc @@ -72,8 +72,7 @@ internal::FunctionRegistry* App::function_registry() { } #endif -void App::RegisterLibrary(const char* library, - const char* version, +void App::RegisterLibrary(const char* library, const char* version, void* /* platform_resource */) { app_common::RegisterLibrary(library, version); }