Skip to content

Commit 510c613

Browse files
committed
Merge branch 'master' of github.com:firebase/firebase-android-sdk into fisExceptionFix
2 parents 1d09152 + da5efbf commit 510c613

File tree

33 files changed

+216
-762
lines changed

33 files changed

+216
-762
lines changed

firebase-config/api.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ package com.google.firebase.remoteconfig {
33

44
public class FirebaseRemoteConfig {
55
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Boolean> activate();
6-
method @Deprecated @WorkerThread public boolean activateFetched();
76
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo> ensureInitialized();
87
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> fetch();
98
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> fetch(long);
109
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Boolean> fetchAndActivate();
1110
method @NonNull public java.util.Map<java.lang.String,com.google.firebase.remoteconfig.FirebaseRemoteConfigValue> getAll();
1211
method public boolean getBoolean(@NonNull String);
13-
method @Deprecated @NonNull public byte[] getByteArray(@NonNull String);
1412
method public double getDouble(@NonNull String);
1513
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo getInfo();
1614
method @NonNull public static com.google.firebase.remoteconfig.FirebaseRemoteConfig getInstance();
@@ -20,10 +18,7 @@ package com.google.firebase.remoteconfig {
2018
method @NonNull public String getString(@NonNull String);
2119
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigValue getValue(@NonNull String);
2220
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> reset();
23-
method @Deprecated public void setConfigSettings(@NonNull com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings);
2421
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> setConfigSettingsAsync(@NonNull com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings);
25-
method @Deprecated public void setDefaults(@NonNull java.util.Map<java.lang.String,java.lang.Object>);
26-
method @Deprecated public void setDefaults(@XmlRes int);
2722
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> setDefaultsAsync(@NonNull java.util.Map<java.lang.String,java.lang.Object>);
2823
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> setDefaultsAsync(@XmlRes int);
2924
field public static final boolean DEFAULT_VALUE_FOR_BOOLEAN = false;
@@ -50,12 +45,7 @@ package com.google.firebase.remoteconfig {
5045
ctor public FirebaseRemoteConfigException(@NonNull String, @Nullable Throwable);
5146
}
5247

53-
@Deprecated public class FirebaseRemoteConfigFetchException extends com.google.firebase.remoteconfig.FirebaseRemoteConfigException {
54-
ctor @Deprecated public FirebaseRemoteConfigFetchException(@NonNull String);
55-
ctor @Deprecated public FirebaseRemoteConfigFetchException(@NonNull String, @Nullable Throwable);
56-
}
57-
58-
public class FirebaseRemoteConfigFetchThrottledException extends com.google.firebase.remoteconfig.FirebaseRemoteConfigFetchException {
48+
public class FirebaseRemoteConfigFetchThrottledException extends com.google.firebase.remoteconfig.FirebaseRemoteConfigException {
5949
ctor public FirebaseRemoteConfigFetchThrottledException(long);
6050
method public long getThrottleEndTimeMillis();
6151
}
@@ -75,7 +65,6 @@ package com.google.firebase.remoteconfig {
7565
public class FirebaseRemoteConfigSettings {
7666
method public long getFetchTimeoutInSeconds();
7767
method public long getMinimumFetchIntervalInSeconds();
78-
method @Deprecated public boolean isDeveloperModeEnabled();
7968
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder toBuilder();
8069
}
8170

@@ -84,7 +73,6 @@ package com.google.firebase.remoteconfig {
8473
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings build();
8574
method public long getFetchTimeoutInSeconds();
8675
method public long getMinimumFetchIntervalInSeconds();
87-
method @Deprecated @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder setDeveloperModeEnabled(boolean);
8876
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder setFetchTimeoutInSeconds(long) throws java.lang.IllegalArgumentException;
8977
method @NonNull public com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings.Builder setMinimumFetchIntervalInSeconds(long);
9078
}

firebase-config/bandwagoner/src/androidTest/java/com/googletest/firebase/remoteconfig/bandwagoner/BandwagonerEspressoTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public void activateFetchedWithoutFetching_activateFetchedReturnsFalse()
7474

7575
onView(withId(R.id.activate_fetched_button)).perform(click());
7676
onView(withId(R.id.api_call_results))
77-
.check(
78-
matches(withText(allOf(containsString("activateFetched"), containsString("false!")))));
77+
.check(matches(withText(allOf(containsString("activate"), containsString("false!")))));
7978
}
8079

8180
@Test
@@ -86,14 +85,11 @@ public void fetchAndActivateFetchedTwice_activateFetchedReturnsFalse()
8685

8786
onView(withId(R.id.activate_fetched_button)).perform(click());
8887
onView(withId(R.id.api_call_results))
89-
.check(
90-
matches(
91-
withText(allOf(containsString("activateFetched"), containsString("successful!")))));
88+
.check(matches(withText(allOf(containsString("activate"), containsString("successful!")))));
9289

9390
onView(withId(R.id.activate_fetched_button)).perform(click());
9491
onView(withId(R.id.api_call_results))
95-
.check(
96-
matches(withText(allOf(containsString("activateFetched"), containsString("false!")))));
92+
.check(matches(withText(allOf(containsString("activate"), containsString("false!")))));
9793
}
9894

9995
@Test

firebase-config/bandwagoner/src/main/java/com/googletest/firebase/remoteconfig/bandwagoner/ApiFragment.java

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
package com.googletest.firebase.remoteconfig.bandwagoner;
1818

19-
import static com.googletest.firebase.remoteconfig.bandwagoner.Constants.TAG;
2019
import static com.googletest.firebase.remoteconfig.bandwagoner.TimeFormatHelper.getCurrentTimeString;
2120

2221
import android.app.Activity;
2322
import android.os.Bundle;
23+
import android.text.TextUtils;
2424
import android.util.Log;
2525
import android.view.LayoutInflater;
2626
import android.view.View;
@@ -64,8 +64,8 @@ public void onCreate(Bundle savedInstanceState) {
6464
super.onCreate(savedInstanceState);
6565

6666
frc = FirebaseRemoteConfig.getInstance();
67-
frc.setConfigSettings(
68-
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(true).build());
67+
frc.setConfigSettingsAsync(
68+
new FirebaseRemoteConfigSettings.Builder().setMinimumFetchIntervalInSeconds(0L).build());
6969

7070
firebaseInstallations = FirebaseApp.getInstance().get(FirebaseInstallationsApi.class);
7171
}
@@ -110,7 +110,11 @@ public View onCreateView(
110110
}
111111

112112
if (installationAuthTokenTask.isSuccessful()) {
113-
apiCallResultsText.setText(installationAuthTokenTask.getResult().getToken());
113+
Log.i(
114+
TAG,
115+
String.format(
116+
"Installation authentication token: %s",
117+
installationAuthTokenTask.getResult().getToken()));
114118
} else {
115119
Log.e(
116120
TAG,
@@ -128,12 +132,21 @@ private void addListenerToButton(@IdRes int buttonResourceId, OnClickListener on
128132
}
129133

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

135-
frc.setConfigSettings(
136-
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(isChecked).build());
138+
FirebaseRemoteConfigSettings.Builder settingsBuilder =
139+
new FirebaseRemoteConfigSettings.Builder();
140+
String minimumFetchIntervalString = minimumFetchIntervalText.getText().toString();
141+
142+
if (isChecked || TextUtils.isEmpty(minimumFetchIntervalString)) {
143+
settingsBuilder.setMinimumFetchIntervalInSeconds(0L);
144+
} else {
145+
settingsBuilder.setMinimumFetchIntervalInSeconds(
146+
Integer.parseInt(minimumFetchIntervalString));
147+
}
148+
149+
frc.setConfigSettingsAsync(settingsBuilder.build());
137150
}
138151

139152
/**
@@ -192,11 +205,20 @@ private void onFetch(View unusedView) {
192205
private void onActivateFetched(View unusedView) {
193206
hideSoftKeyboard();
194207

195-
boolean activated = frc.activateFetched();
196-
apiCallResultsText.setText(
197-
String.format(
198-
"%s - activateFetched %s!",
199-
getCurrentTimeString(), activated ? "was successful" : "returned false"));
208+
frc.activate()
209+
.addOnCompleteListener(
210+
activateTask -> {
211+
if (activateTask.isSuccessful()) {
212+
apiCallResultsText.setText(
213+
String.format(
214+
"%s - activate %s!",
215+
getCurrentTimeString(),
216+
activateTask.getResult() ? "was successful" : "returned false"));
217+
} else {
218+
apiCallResultsText.setText(
219+
String.format("%s - activate failed!", getCurrentTimeString()));
220+
}
221+
});
200222
}
201223

202224
/**

firebase-config/src/androidTest/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigIntegrationTest.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.mockito.ArgumentCaptor;
4747
import org.mockito.Mock;
4848
import org.mockito.MockitoAnnotations;
49-
import org.skyscreamer.jsonassert.JSONAssert;
5049

5150
@RunWith(AndroidJUnit4.class)
5251
public class FirebaseRemoteConfigIntegrationTest {
@@ -112,19 +111,6 @@ public void setUp() {
112111
metadataClient);
113112
}
114113

115-
@Test
116-
public void setDefaults_goodXml_setsDefaults() throws Exception {
117-
ConfigContainer goodDefaultsXmlContainer = newDefaultsContainer(DEFAULTS_MAP);
118-
119-
frc.setDefaults(getResourceId("frc_good_defaults"));
120-
121-
ArgumentCaptor<ConfigContainer> captor = ArgumentCaptor.forClass(ConfigContainer.class);
122-
verify(mockDefaultsCache).putWithoutWaitingForDiskWrite(captor.capture());
123-
124-
JSONAssert.assertEquals(
125-
captor.getValue().toString(), goodDefaultsXmlContainer.toString(), false);
126-
}
127-
128114
@Test
129115
public void setDefaultsAsync_goodXml_setsDefaults() throws Exception {
130116
ConfigContainer goodDefaultsXmlContainer = newDefaultsContainer(DEFAULTS_MAP);
@@ -140,27 +126,29 @@ public void setDefaultsAsync_goodXml_setsDefaults() throws Exception {
140126
}
141127

142128
@Test
143-
public void setDefaults_emptyXml_setsEmptyDefaults() throws Exception {
129+
public void setDefaultsAsync_emptyXml_setsEmptyDefaults() throws Exception {
144130
ConfigContainer emptyDefaultsXmlContainer = newDefaultsContainer(ImmutableMap.of());
131+
cachePutReturnsConfig(mockDefaultsCache, emptyDefaultsXmlContainer);
145132

146-
frc.setDefaults(getResourceId("frc_empty_defaults"));
133+
Task<Void> task = frc.setDefaultsAsync(getResourceId("frc_empty_defaults"));
134+
Tasks.await(task);
147135

148136
ArgumentCaptor<ConfigContainer> captor = ArgumentCaptor.forClass(ConfigContainer.class);
149-
verify(mockDefaultsCache).putWithoutWaitingForDiskWrite(captor.capture());
150-
137+
verify(mockDefaultsCache).put(captor.capture());
151138
assertThat(captor.getValue()).isEqualTo(emptyDefaultsXmlContainer);
152139
}
153140

154141
@Test
155-
public void setDefaults_badXml_ignoresBadEntries() throws Exception {
142+
public void setDefaultsAsync_badXml_ignoresBadEntries() throws Exception {
156143
ConfigContainer badDefaultsXmlContainer =
157144
newDefaultsContainer(ImmutableMap.of("second_default_key", "second_default_value"));
145+
cachePutReturnsConfig(mockDefaultsCache, badDefaultsXmlContainer);
158146

159-
frc.setDefaults(getResourceId("frc_bad_defaults"));
147+
Task<Void> task = frc.setDefaultsAsync(getResourceId("frc_bad_defaults"));
148+
Tasks.await(task);
160149

161150
ArgumentCaptor<ConfigContainer> captor = ArgumentCaptor.forClass(ConfigContainer.class);
162-
verify(mockDefaultsCache).putWithoutWaitingForDiskWrite(captor.capture());
163-
151+
verify(mockDefaultsCache).put(captor.capture());
164152
assertThat(captor.getValue()).isEqualTo(badDefaultsXmlContainer);
165153
}
166154

0 commit comments

Comments
 (0)