Skip to content

Commit c27ba1d

Browse files
authored
Remove the Deprecated Remote Config Impl (#402)
Changes: - Removed the Remote Config static API. - Update the integration test to remove deprecated API tests. - Added readme.md notes. Additionally added notes for the Instance ID removal. - Ran the quick Integration Tests for sanity.
1 parent 3fefe0e commit c27ba1d

File tree

5 files changed

+7
-718
lines changed

5 files changed

+7
-718
lines changed

release_build_files/readme.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,13 @@ code.
553553

554554
## Release Notes
555555

556-
### TBD
556+
### 8.0.0
557+
557558
- Changes
559+
- Instance Id: Removed support for the previously-deprecated Instance ID SDK.
560+
- Remote Config: The previously-deprecated static methods have been removed.
561+
Please use the new instance-based `firebase::remote_config::RemoteConfig`
562+
API.
558563
- Remote Config(Android): Fix for getting Remote Config instance for a
559564
specific app object.
560565
([#991](https://github.com/firebase/quickstart-unity/issues/991).

remote_config/integration_test/src/integration_test.cc

Lines changed: 0 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
#define FIREBASE_CONFIG_STRING ""
4040
#endif // FIREBASE_CONFIG
4141

42-
// If 1, will test the deprecating module functions. 0 will test RemoteConfig
43-
// instance functions.
44-
// TODO(b/178658613) clean up when remove deprecated V1 code
45-
#define TEST_DEPRECATED 0
46-
4742
namespace firebase_testapp_automated {
4843

4944
using app_framework::LogDebug;
@@ -64,23 +59,13 @@ class FirebaseRemoteConfigTest : public FirebaseTest {
6459
void TearDown() override;
6560

6661
protected:
67-
#if TEST_DEPRECATED
68-
// Initialize Firebase App and Firebase Remote Config.
69-
void InitializeDeprecated();
70-
// Shut down Firebase Remote Config and Firebase App.
71-
void TerminateDeprecated();
72-
73-
bool initialized_deprecated_ = false;
74-
75-
#else
7662
// Initialize Firebase App and Firebase Remote Config.
7763
void Initialize();
7864
// Shut down Firebase Remote Config and Firebase App.
7965
void Terminate();
8066

8167
bool initialized_ = false;
8268
RemoteConfig* rc_ = nullptr;
83-
#endif // TEST_DEPRECATED
8469
};
8570

8671
FirebaseRemoteConfigTest::FirebaseRemoteConfigTest() : initialized_(false) {
@@ -95,66 +80,15 @@ FirebaseRemoteConfigTest::~FirebaseRemoteConfigTest() {
9580

9681
void FirebaseRemoteConfigTest::SetUp() {
9782
FirebaseTest::SetUp();
98-
#if TEST_DEPRECATED
99-
InitializeDeprecated();
100-
#else
10183
Initialize();
102-
#endif // TEST_DEPRECATED
10384
}
10485

10586
void FirebaseRemoteConfigTest::TearDown() {
10687
// Delete the shared path, if there is one.
107-
#if TEST_DEPRECATED
108-
TerminateDeprecated();
109-
#else
11088
Terminate();
111-
#endif // TEST_DEPRECATED
11289
FirebaseTest::TearDown();
11390
}
11491

115-
#if TEST_DEPRECATED
116-
117-
void FirebaseRemoteConfigTest::InitializeDeprecated() {
118-
if (initialized_deprecated_) return;
119-
SetLogLevel(app_framework::kDebug);
120-
121-
InitializeApp();
122-
123-
LogDebug("Initializing Firebase Remote Config - DEPRECATED.");
124-
125-
::firebase::ModuleInitializer initializer;
126-
127-
initializer.Initialize(app_, nullptr, [](::firebase::App* app, void* target) {
128-
LogDebug("Try to initialize Firebase RemoteConfig - DEPRECATED.");
129-
return firebase::remote_config::Initialize(*app);
130-
});
131-
132-
WaitForCompletion(initializer.InitializeLastResult(), "InitializeDeprecated");
133-
134-
ASSERT_EQ(initializer.InitializeLastResult().error(), 0)
135-
<< initializer.InitializeLastResult().error_message();
136-
137-
LogDebug("Successfully initialized Firebase RemoteConfig - DEPRECATED.");
138-
139-
initialized_deprecated_ = true;
140-
}
141-
142-
void FirebaseRemoteConfigTest::TerminateDeprecated() {
143-
if (!initialized_deprecated_) return;
144-
145-
LogDebug("Shutdown the Remote Config library - DEPRECATED.");
146-
147-
LogDebug("Terminating - DEPRECATED.");
148-
firebase::remote_config::Terminate();
149-
TerminateApp();
150-
151-
initialized_deprecated_ = false;
152-
153-
ProcessEvents(100);
154-
}
155-
156-
#else // !TEST_DEPRECATED
157-
15892
void FirebaseRemoteConfigTest::Initialize() {
15993
if (initialized_) return;
16094
SetLogLevel(app_framework::kDebug);
@@ -199,7 +133,6 @@ void FirebaseRemoteConfigTest::Terminate() {
199133

200134
ProcessEvents(100);
201135
}
202-
#endif // TEST_DEPRECATED
203136

204137
static const char* ValueSourceToString(
205138
firebase::remote_config::ValueSource source) {
@@ -237,167 +170,17 @@ static const firebase::remote_config::ConfigKeyValueVariant kServerValue[] = {
237170
{"TestDefaultOnly", firebase::Variant::FromMutableString(
238171
"Default value that won't be overridden")}};
239172

240-
#if TEST_DEPRECATED
241-
static void SetDefaults() {
242-
size_t default_count = FIREBASE_ARRAYSIZE(defaults);
243-
firebase::remote_config::SetDefaults(defaults, default_count);
244-
}
245-
#else // !TEST_DEPRECATED
246173
static Future<void> SetDefaultsV2(RemoteConfig* rc) {
247174
size_t default_count = FIREBASE_ARRAYSIZE(defaults);
248175
return rc->SetDefaults(defaults, default_count);
249176
}
250-
#endif // TEST_DEPRECATED
251177

252178
// Test cases below.
253179

254180
TEST_F(FirebaseRemoteConfigTest, TestInitializeAndTerminate) {
255181
// Already tested via SetUp() and TearDown().
256182
}
257183

258-
#if TEST_DEPRECATED
259-
TEST_F(FirebaseRemoteConfigTest, TestSetDefaults) {
260-
SetDefaults();
261-
262-
bool validated_defaults = true;
263-
firebase::remote_config::ValueInfo value_info;
264-
bool bool_value =
265-
firebase::remote_config::GetBoolean("TestBoolean", &value_info);
266-
if (value_info.source == firebase::remote_config::kValueSourceDefaultValue) {
267-
EXPECT_FALSE(bool_value);
268-
} else {
269-
validated_defaults = false;
270-
}
271-
int64_t int64_value =
272-
firebase::remote_config::GetLong("TestLong", &value_info);
273-
if (value_info.source == firebase::remote_config::kValueSourceDefaultValue) {
274-
EXPECT_EQ(int64_value, 42);
275-
} else {
276-
validated_defaults = false;
277-
}
278-
double double_value =
279-
firebase::remote_config::GetDouble("TestDouble", &value_info);
280-
if (value_info.source == firebase::remote_config::kValueSourceDefaultValue) {
281-
EXPECT_NEAR(double_value, 3.14, 0.0001);
282-
} else {
283-
validated_defaults = false;
284-
}
285-
std::string string_value =
286-
firebase::remote_config::GetString("TestString", &value_info);
287-
if (value_info.source == firebase::remote_config::kValueSourceDefaultValue) {
288-
EXPECT_EQ(string_value, "Hello World");
289-
} else {
290-
validated_defaults = false;
291-
}
292-
std::vector<unsigned char> blob_value =
293-
firebase::remote_config::GetData("TestData"); //, &value_info);
294-
if (value_info.source == firebase::remote_config::kValueSourceDefaultValue) {
295-
EXPECT_THAT(blob_value, testing::ElementsAreArray(kBinaryDefaults,
296-
sizeof(kBinaryDefaults)));
297-
} else {
298-
validated_defaults = false;
299-
}
300-
301-
if (!validated_defaults) {
302-
LogWarning(
303-
"Can't validate defaults, they've been overridden by server values.\n"
304-
#if defined(__ANDROID__)
305-
"Delete the app's data and run this test again to test SetDefaults:\n"
306-
" adb shell pm clear [bundle ID]"
307-
#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
308-
"Uninstall and re-install the app and run this again to test "
309-
"SetDefaults."
310-
#else // Desktop
311-
"Delete the Remote Config cache and run this test again to test "
312-
"SetDefaults:\n"
313-
#if defined(_WIN32)
314-
" del remote_config_data"
315-
#else
316-
" rm remote_config_data"
317-
#endif // defined(_WIN32)
318-
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
319-
);
320-
}
321-
}
322-
323-
/* The following test expects that you have your server values set to:
324-
TestData 4321
325-
TestDouble 625.63
326-
TestLong 119
327-
TestBoolean true
328-
TestString This is a string
329-
*/
330-
331-
TEST_F(FirebaseRemoteConfigTest, TestFetchAndActivate) {
332-
SetDefaults();
333-
334-
WaitForCompletion(firebase::remote_config::Fetch(0), "Fetch");
335-
336-
#if defined(__ANDROID__)
337-
// TODO(b/178386092) not activate for android, need to verify android native
338-
// behavior
339-
#else
340-
EXPECT_TRUE(firebase::remote_config::ActivateFetched());
341-
#endif // defined(__ANDROID__)
342-
const firebase::remote_config::ConfigInfo& info =
343-
firebase::remote_config::GetInfo();
344-
LogDebug("Fetch time: %lld", info.fetch_time);
345-
firebase::remote_config::ValueInfo value_info;
346-
bool bool_value =
347-
firebase::remote_config::GetBoolean("TestBoolean", &value_info);
348-
EXPECT_EQ(value_info.source, firebase::remote_config::kValueSourceRemoteValue)
349-
<< "TestBoolean source is " << ValueSourceToString(value_info.source)
350-
<< ", expected Remote";
351-
EXPECT_TRUE(bool_value);
352-
353-
int64_t int64_value =
354-
firebase::remote_config::GetLong("TestLong", &value_info);
355-
EXPECT_EQ(value_info.source, firebase::remote_config::kValueSourceRemoteValue)
356-
<< "TestLong source is " << ValueSourceToString(value_info.source)
357-
<< ", expected Remote";
358-
EXPECT_EQ(int64_value, 119);
359-
360-
double double_value =
361-
firebase::remote_config::GetDouble("TestDouble", &value_info);
362-
EXPECT_EQ(value_info.source, firebase::remote_config::kValueSourceRemoteValue)
363-
<< "TestDouble source is " << ValueSourceToString(value_info.source)
364-
<< ", expected Remote";
365-
EXPECT_NEAR(double_value, 625.63, 0.0001);
366-
367-
std::string string_value =
368-
firebase::remote_config::GetString("TestString", &value_info);
369-
EXPECT_EQ(value_info.source, firebase::remote_config::kValueSourceRemoteValue)
370-
<< "TestString source is " << ValueSourceToString(value_info.source)
371-
<< ", expected Remote";
372-
EXPECT_EQ(string_value, "This is a string");
373-
374-
std::vector<unsigned char> blob_value =
375-
firebase::remote_config::GetData("TestData"); //, &value_info);
376-
EXPECT_EQ(value_info.source, firebase::remote_config::kValueSourceRemoteValue)
377-
<< "TestData source is " << ValueSourceToString(value_info.source)
378-
<< ", expected Remote";
379-
380-
const unsigned char kExpectedBlobServerValue[] = {'4', '3', '2', '1'};
381-
EXPECT_THAT(blob_value,
382-
testing::ElementsAreArray(kExpectedBlobServerValue,
383-
sizeof(kExpectedBlobServerValue)));
384-
}
385-
386-
TEST_F(FirebaseRemoteConfigTest, TestGetKeys) {
387-
SetDefaults();
388-
389-
std::vector<std::string> keys = firebase::remote_config::GetKeys();
390-
EXPECT_THAT(
391-
keys, UnorderedElementsAre("TestBoolean", "TestLong", "TestDouble",
392-
"TestString", "TestData", "TestDefaultOnly"));
393-
std::vector<std::string> keys_subset =
394-
firebase::remote_config::GetKeysByPrefix("TestD");
395-
EXPECT_THAT(keys_subset, UnorderedElementsAre("TestDouble", "TestData",
396-
"TestDefaultOnly"));
397-
}
398-
399-
#else // !TEST_DEPRECATED
400-
401184
TEST_F(FirebaseRemoteConfigTest, TestSetDefaultsV2) {
402185
ASSERT_NE(rc_, nullptr);
403186

@@ -550,6 +333,5 @@ TEST_F(FirebaseRemoteConfigTest, TestFetchV2) {
550333
testing::ElementsAreArray(kExpectedBlobServerValue,
551334
sizeof(kExpectedBlobServerValue)));
552335
}
553-
#endif // TEST_DEPRECATED
554336

555337
} // namespace firebase_testapp_automated

remote_config/src/android/remote_config_android.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@ RemoteConfigInternal::RemoteConfigInternal(const firebase::App& app)
457457
jclass config_class = config::GetClass();
458458
jobject platform_app = app_.GetPlatformApp();
459459
jobject config_instance_local = env->CallStaticObjectMethod(
460-
config_class,
461-
config::GetMethodId(config::kGetInstance),
462-
platform_app);
460+
config_class, config::GetMethodId(config::kGetInstance), platform_app);
463461
env->DeleteLocalRef(platform_app);
464462
if (util::CheckAndClearJniExceptions(env)) config_instance_local = nullptr;
465463
FIREBASE_ASSERT(config_instance_local);

0 commit comments

Comments
 (0)