File tree Expand file tree Collapse file tree 7 files changed +37
-0
lines changed Expand file tree Collapse file tree 7 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1515#include " installations/src/android/installations_android.h"
1616
1717#include " app/src/util.h"
18+ #include " app/src/util_android.h"
1819#include " installations/src/common.h"
1920
2021namespace firebase {
@@ -186,6 +187,19 @@ void InstallationsInternal::Cleanup() {
186187 }
187188}
188189
190+ void InstallationsInternal::LogHeartbeat (const firebase::App& app) {
191+ // Calling the native getter is sufficient to cause a Heartbeat to be logged.
192+ JNIEnv* env = app.GetJNIEnv ();
193+ jobject platform_app = app.GetPlatformApp ();
194+ jclass installations_class = installations::GetClass ();
195+ jobject installations_instance_local = env->CallStaticObjectMethod (
196+ installations_class,
197+ installations::GetMethodId (installations::kGetInstance ), platform_app);
198+ firebase::util::CheckAndClearJniExceptions (env);
199+ env->DeleteLocalRef (installations_instance_local);
200+ env->DeleteLocalRef (platform_app);
201+ }
202+
189203Future<std::string> InstallationsInternal::GetId () {
190204 const auto handle =
191205 future_impl_.SafeAlloc <std::string>(kInstallationsFnGetId );
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ class InstallationsInternal {
3434 explicit InstallationsInternal (const firebase::App& app);
3535 ~InstallationsInternal ();
3636
37+ // Platform-specific method that causes a heartbeat to be logged.
38+ // See go/firebase-platform-logging-design for more information.
39+ static void LogHeartbeat (const firebase::App& app);
40+
3741 Future<std::string> GetId ();
3842 Future<std::string> GetIdLastResult ();
3943
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ Installations* Installations::GetInstance(App* app) {
3232 // Return the Installations if it already exists.
3333 Installations* existing_installations = FindInstallations (app);
3434 if (existing_installations) {
35+ // Log heartbeat data when instance getters are called.
36+ // See go/firebase-platform-logging-design for more information.
37+ InstallationsInternal::LogHeartbeat (*app);
3538 return existing_installations;
3639 }
3740
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ class InstallationsInternal {
4242 explicit InstallationsInternal (const firebase::App& app);
4343 ~InstallationsInternal ();
4444
45+ // Platform-specific method that causes a heartbeat to be logged.
46+ // See go/firebase-platform-logging-design for more information.
47+ static void LogHeartbeat (const firebase::App& app);
48+
4549 Future<std::string> GetId ();
4650 Future<std::string> GetIdLastResult ();
4751
Original file line number Diff line number Diff line change 4040 // Destructor is necessary for ARC garbage collection.
4141}
4242
43+ void InstallationsInternal::LogHeartbeat (const firebase::App& app) {
44+ // Calling the native getter is sufficient to cause a Heartbeat to be logged.
45+ FIRApp *platform_app = app.GetPlatformApp ();
46+ [FIRInstallations installationsWithApp: platform_app];
47+ }
48+
4349bool InstallationsInternal::Initialized () const {
4450 return true ;
4551}
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ InstallationsInternal::InstallationsInternal(const firebase::App& app)
2626
2727InstallationsInternal::~InstallationsInternal () {}
2828
29+ void InstallationsInternal::LogHeartbeat (const firebase::App& app) {}
30+
2931bool InstallationsInternal::Initialized () const { return true ; }
3032
3133void InstallationsInternal::Cleanup () {}
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ class InstallationsInternal {
3131 explicit InstallationsInternal (const firebase::App& app);
3232 ~InstallationsInternal ();
3333
34+ // Platform-specific method that causes a heartbeat to be logged.
35+ // See go/firebase-platform-logging-design for more information.
36+ static void LogHeartbeat (const firebase::App& app);
37+
3438 Future<std::string> GetId ();
3539 Future<std::string> GetIdLastResult ();
3640
You can’t perform that action at this time.
0 commit comments