Skip to content

Remove deprecated methods from RC. #2042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions firebase-config/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package com.google.firebase.remoteconfig {

public class FirebaseRemoteConfig {
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Boolean> activate();
method @Deprecated @WorkerThread public boolean activateFetched();
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo> ensureInitialized();
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> fetch();
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> fetch(long);
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Boolean> fetchAndActivate();
method @NonNull public java.util.Map<java.lang.String,com.google.firebase.remoteconfig.FirebaseRemoteConfigValue> getAll();
method public boolean getBoolean(@NonNull String);
method @Deprecated @NonNull public byte[] getByteArray(@NonNull String);
method public double getDouble(@NonNull String);
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo getInfo();
method @NonNull public static com.google.firebase.remoteconfig.FirebaseRemoteConfig getInstance();
Expand All @@ -20,10 +18,7 @@ package com.google.firebase.remoteconfig {
method @NonNull public String getString(@NonNull String);
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigValue getValue(@NonNull String);
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> reset();
method @Deprecated public void setConfigSettings(@NonNull com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings);
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> setConfigSettingsAsync(@NonNull com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings);
method @Deprecated public void setDefaults(@NonNull java.util.Map<java.lang.String,java.lang.Object>);
method @Deprecated public void setDefaults(@XmlRes int);
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> setDefaultsAsync(@NonNull java.util.Map<java.lang.String,java.lang.Object>);
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> setDefaultsAsync(@XmlRes int);
field public static final boolean DEFAULT_VALUE_FOR_BOOLEAN = false;
Expand All @@ -50,12 +45,7 @@ package com.google.firebase.remoteconfig {
ctor public FirebaseRemoteConfigException(@NonNull String, @Nullable Throwable);
}

@Deprecated public class FirebaseRemoteConfigFetchException extends com.google.firebase.remoteconfig.FirebaseRemoteConfigException {
ctor @Deprecated public FirebaseRemoteConfigFetchException(@NonNull String);
ctor @Deprecated public FirebaseRemoteConfigFetchException(@NonNull String, @Nullable Throwable);
}

public class FirebaseRemoteConfigFetchThrottledException extends com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchException {
public class FirebaseRemoteConfigFetchThrottledException extends com.google.firebase.remoteconfig.FirebaseRemoteConfigException {
ctor public FirebaseRemoteConfigFetchThrottledException(long);
method public long getThrottleEndTimeMillis();
}
Expand All @@ -75,7 +65,6 @@ package com.google.firebase.remoteconfig {
public class FirebaseRemoteConfigSettings {
method public long getFetchTimeoutInSeconds();
method public long getMinimumFetchIntervalInSeconds();
method @Deprecated public boolean isDeveloperModeEnabled();
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder toBuilder();
}

Expand All @@ -84,7 +73,6 @@ package com.google.firebase.remoteconfig {
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings build();
method public long getFetchTimeoutInSeconds();
method public long getMinimumFetchIntervalInSeconds();
method @Deprecated @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder setDeveloperModeEnabled(boolean);
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder setFetchTimeoutInSeconds(long) throws java.lang.IllegalArgumentException;
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder setMinimumFetchIntervalInSeconds(long);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public void activateFetchedWithoutFetching_activateFetchedReturnsFalse()

onView(withId(R.id.activate_fetched_button)).perform(click());
onView(withId(R.id.api_call_results))
.check(
matches(withText(allOf(containsString("activateFetched"), containsString("false!")))));
.check(matches(withText(allOf(containsString("activate"), containsString("false!")))));
}

@Test
Expand All @@ -86,14 +85,11 @@ public void fetchAndActivateFetchedTwice_activateFetchedReturnsFalse()

onView(withId(R.id.activate_fetched_button)).perform(click());
onView(withId(R.id.api_call_results))
.check(
matches(
withText(allOf(containsString("activateFetched"), containsString("successful!")))));
.check(matches(withText(allOf(containsString("activate"), containsString("successful!")))));

onView(withId(R.id.activate_fetched_button)).perform(click());
onView(withId(R.id.api_call_results))
.check(
matches(withText(allOf(containsString("activateFetched"), containsString("false!")))));
.check(matches(withText(allOf(containsString("activate"), containsString("false!")))));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package com.googletest.firebase.remoteconfig.bandwagoner;

import static com.googletest.firebase.remoteconfig.bandwagoner.Constants.TAG;
import static com.googletest.firebase.remoteconfig.bandwagoner.TimeFormatHelper.getCurrentTimeString;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -64,8 +64,8 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

frc = FirebaseRemoteConfig.getInstance();
frc.setConfigSettings(
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(true).build());
frc.setConfigSettingsAsync(
new FirebaseRemoteConfigSettings.Builder().setMinimumFetchIntervalInSeconds(0L).build());

firebaseInstallations = FirebaseApp.getInstance().get(FirebaseInstallationsApi.class);
}
Expand Down Expand Up @@ -132,12 +132,21 @@ private void addListenerToButton(@IdRes int buttonResourceId, OnClickListener on
}

/** Sets the version of the FRC server the SDK fetches from. */
@SuppressWarnings("FirebaseUseExplicitDependencies")
private void onDevModeToggle(boolean isChecked) {
hideSoftKeyboard();

frc.setConfigSettings(
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(isChecked).build());
FirebaseRemoteConfigSettings.Builder settingsBuilder =
new FirebaseRemoteConfigSettings.Builder();
String minimumFetchIntervalString = minimumFetchIntervalText.getText().toString();

if (isChecked || TextUtils.isEmpty(minimumFetchIntervalString)) {
settingsBuilder.setMinimumFetchIntervalInSeconds(0L);
} else {
settingsBuilder.setMinimumFetchIntervalInSeconds(
Integer.parseInt(minimumFetchIntervalString));
}

frc.setConfigSettingsAsync(settingsBuilder.build());
}

/**
Expand Down Expand Up @@ -196,11 +205,20 @@ private void onFetch(View unusedView) {
private void onActivateFetched(View unusedView) {
hideSoftKeyboard();

boolean activated = frc.activateFetched();
apiCallResultsText.setText(
String.format(
"%s - activateFetched %s!",
getCurrentTimeString(), activated ? "was successful" : "returned false"));
frc.activate()
.addOnCompleteListener(
activateTask -> {
if (activateTask.isSuccessful()) {
apiCallResultsText.setText(
String.format(
"%s - activate %s!",
getCurrentTimeString(),
activateTask.getResult() ? "was successful" : "returned false"));
} else {
apiCallResultsText.setText(
String.format("%s - activate failed!", getCurrentTimeString()));
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.skyscreamer.jsonassert.JSONAssert;

@RunWith(AndroidJUnit4.class)
public class FirebaseRemoteConfigIntegrationTest {
Expand Down Expand Up @@ -112,19 +111,6 @@ public void setUp() {
metadataClient);
}

@Test
public void setDefaults_goodXml_setsDefaults() throws Exception {
ConfigContainer goodDefaultsXmlContainer = newDefaultsContainer(DEFAULTS_MAP);

frc.setDefaults(getResourceId("frc_good_defaults"));

ArgumentCaptor<ConfigContainer> captor = ArgumentCaptor.forClass(ConfigContainer.class);
verify(mockDefaultsCache).putWithoutWaitingForDiskWrite(captor.capture());

JSONAssert.assertEquals(
captor.getValue().toString(), goodDefaultsXmlContainer.toString(), false);
}

@Test
public void setDefaultsAsync_goodXml_setsDefaults() throws Exception {
ConfigContainer goodDefaultsXmlContainer = newDefaultsContainer(DEFAULTS_MAP);
Expand All @@ -140,27 +126,29 @@ public void setDefaultsAsync_goodXml_setsDefaults() throws Exception {
}

@Test
public void setDefaults_emptyXml_setsEmptyDefaults() throws Exception {
public void setDefaultsAsync_emptyXml_setsEmptyDefaults() throws Exception {
ConfigContainer emptyDefaultsXmlContainer = newDefaultsContainer(ImmutableMap.of());
cachePutReturnsConfig(mockDefaultsCache, emptyDefaultsXmlContainer);

frc.setDefaults(getResourceId("frc_empty_defaults"));
Task<Void> task = frc.setDefaultsAsync(getResourceId("frc_empty_defaults"));
Tasks.await(task);

ArgumentCaptor<ConfigContainer> captor = ArgumentCaptor.forClass(ConfigContainer.class);
verify(mockDefaultsCache).putWithoutWaitingForDiskWrite(captor.capture());

verify(mockDefaultsCache).put(captor.capture());
assertThat(captor.getValue()).isEqualTo(emptyDefaultsXmlContainer);
}

@Test
public void setDefaults_badXml_ignoresBadEntries() throws Exception {
public void setDefaultsAsync_badXml_ignoresBadEntries() throws Exception {
ConfigContainer badDefaultsXmlContainer =
newDefaultsContainer(ImmutableMap.of("second_default_key", "second_default_value"));
cachePutReturnsConfig(mockDefaultsCache, badDefaultsXmlContainer);

frc.setDefaults(getResourceId("frc_bad_defaults"));
Task<Void> task = frc.setDefaultsAsync(getResourceId("frc_bad_defaults"));
Tasks.await(task);

ArgumentCaptor<ConfigContainer> captor = ArgumentCaptor.forClass(ConfigContainer.class);
verify(mockDefaultsCache).putWithoutWaitingForDiskWrite(captor.capture());

verify(mockDefaultsCache).put(captor.capture());
assertThat(captor.getValue()).isEqualTo(badDefaultsXmlContainer);
}

Expand Down
Loading