diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 35970bce23..298a4a6fdf 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -635,6 +635,8 @@ code. - Changes - Messaging: Changed SetListener to send the last token received before the listener was set. + - Remote Config: Fixed ConfigInfo fields to default to 0 when + not throttled or having previous fetch data. ### 12.2.0 - Changes diff --git a/remote_config/src/android/remote_config_android.cc b/remote_config/src/android/remote_config_android.cc index 75cf4e208f..df8a7cd3fe 100644 --- a/remote_config/src/android/remote_config_android.cc +++ b/remote_config/src/android/remote_config_android.cc @@ -496,8 +496,14 @@ static void JConfigInfoToConfigInfo(JNIEnv* env, jobject jinfo, ConfigInfo* info) { FIREBASE_DEV_ASSERT(env->IsInstanceOf(jinfo, config_info::GetClass())); - info->fetch_time = env->CallLongMethod( + int64_t fetch_time = env->CallLongMethod( jinfo, config_info::GetMethodId(config_info::kGetFetchTimeMillis)); + // The C++ fetch_time is a uint64_t, so if we are given a negative number, + // use 0 instead, to prevent getting a very large number. + if (fetch_time < 0) { + fetch_time = 0; + } + info->fetch_time = fetch_time; int64_t status_code = env->CallIntMethod( jinfo, config_info::GetMethodId(config_info::kGetLastFetchStatus)); switch (status_code) { diff --git a/remote_config/src/include/firebase/remote_config.h b/remote_config/src/include/firebase/remote_config.h index 940943de29..c3f534a532 100644 --- a/remote_config/src/include/firebase/remote_config.h +++ b/remote_config/src/include/firebase/remote_config.h @@ -94,7 +94,7 @@ struct ConfigUpdate { /// Normally returned as a result of the GetInfo() function. struct ConfigInfo { /// @brief The time (in milliseconds since the epoch) that the last fetch - /// operation completed. + /// operation completed. 0 if no fetch attempt has been made yet. uint64_t fetch_time; /// @brief The status of the last fetch request. diff --git a/remote_config/src/ios/remote_config_ios.mm b/remote_config/src/ios/remote_config_ios.mm index 568b9efd45..647fa2a22b 100644 --- a/remote_config/src/ios/remote_config_ios.mm +++ b/remote_config/src/ios/remote_config_ios.mm @@ -52,10 +52,6 @@ static NSString *true_pattern = @"^(1|true|t|yes|y|on)$"; static NSString *false_pattern = @"^(0|false|f|no|n|off|)$"; -// If a fetch was throttled, this is set to the time when the throttling is -// finished, in milliseconds since epoch. -static NSNumber *g_throttled_end_time = @0; - // Saved default keys. static std::vector *g_default_keys = nullptr; @@ -148,6 +144,11 @@ static void GetInfoFromFIRRemoteConfig(FIRRemoteConfig *rc_instance, ConfigInfo FIREBASE_DEV_ASSERT(out_info != nullptr); out_info->fetch_time = round(rc_instance.lastFetchTime.timeIntervalSince1970 * ::firebase::internal::kMillisecondsPerSecond); + // The C++ throttled_end_time is a uint64_t, so if we are given a negative number, + // use 0 instead, to prevent getting a very large number. + if (throttled_end_time < 0) { + throttled_end_time = 0; + } out_info->throttled_end_time = throttled_end_time * ::firebase::internal::kMillisecondsPerSecond; switch (rc_instance.lastFetchStatus) { case FIRRemoteConfigFetchStatusNoFetchYet: @@ -201,7 +202,7 @@ static ConfigUpdate ConvertConfigUpdateKeys(NSSet *keys) { namespace internal { RemoteConfigInternal::RemoteConfigInternal(const firebase::App &app) - : app_(app), future_impl_(kRemoteConfigFnCount) { + : app_(app), future_impl_(kRemoteConfigFnCount), throttled_end_time_in_sec_(0) { FIRApp *platform_app = app_.GetPlatformApp(); impl_.reset(new FIRRemoteConfigPointer([FIRRemoteConfig remoteConfigWithApp:platform_app])); }