Skip to content

Commit 4748715

Browse files
authored
Un-hide EmulatorSettings API (#1712)
1 parent 751684d commit 4748715

File tree

17 files changed

+53
-48
lines changed

17 files changed

+53
-48
lines changed

firebase-common/api.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
package com.google.firebase {
33

44
public class FirebaseApp {
5+
method public void enableEmulators(@NonNull com.google.firebase.emulators.EmulatorSettings);
56
method @NonNull public android.content.Context getApplicationContext();
67
method @NonNull public static java.util.List<com.google.firebase.FirebaseApp> getApps(@NonNull android.content.Context);
8+
method @NonNull public com.google.firebase.emulators.EmulatorSettings getEmulatorSettings();
79
method @NonNull public static com.google.firebase.FirebaseApp getInstance();
810
method @NonNull public static com.google.firebase.FirebaseApp getInstance(@NonNull String);
911
method @NonNull public String getName();
@@ -47,6 +49,30 @@ package com.google.firebase {
4749

4850
}
4951

52+
package com.google.firebase.emulators {
53+
54+
public final class EmulatedServiceSettings {
55+
ctor public EmulatedServiceSettings(@NonNull String, int);
56+
method @NonNull public String getHost();
57+
method public int getPort();
58+
}
59+
60+
public final class EmulatorSettings {
61+
field public static final com.google.firebase.emulators.EmulatorSettings DEFAULT;
62+
}
63+
64+
public static final class EmulatorSettings.Builder {
65+
ctor public EmulatorSettings.Builder();
66+
method @NonNull public com.google.firebase.emulators.EmulatorSettings.Builder addEmulatedService(@NonNull com.google.firebase.emulators.FirebaseEmulator, @NonNull com.google.firebase.emulators.EmulatedServiceSettings);
67+
method @NonNull public com.google.firebase.emulators.EmulatorSettings build();
68+
}
69+
70+
public final class FirebaseEmulator {
71+
method @NonNull public String getName();
72+
}
73+
74+
}
75+
5076
package com.google.firebase.provider {
5177

5278
public class FirebaseInitProvider extends android.content.ContentProvider {

firebase-common/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=19.3.1
1+
version=19.4.0
22
latestReleasedVersion=19.3.0
33
android.enableUnitTestBinaryResources=true

firebase-common/src/main/java/com/google/firebase/FirebaseApp.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ public FirebaseOptions getOptions() {
149149
/**
150150
* Returns the specified {@link EmulatorSettings} or a default.
151151
*
152-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
153-
*
154-
* @hide
152+
* <p>Calling this method "freezes" the emulator settings and future calls to enableEmulators on
153+
* the same FirebaseApp instance will fail.
155154
*/
156155
@NonNull
157156
public EmulatorSettings getEmulatorSettings() {
@@ -330,10 +329,7 @@ public static FirebaseApp initializeApp(
330329
* com.google.firebase.emulators.EmulatedServiceSettings} for {@link FirebaseDatabase#EMULATOR},
331330
* then calls to Cloud Firestore will communicate with the emulator rather than production.
332331
*
333-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
334-
*
335332
* @param emulatorSettings the emulator settings for all services.
336-
* @hide
337333
*/
338334
public void enableEmulators(@NonNull EmulatorSettings emulatorSettings) {
339335
checkNotDeleted();

firebase-common/src/main/java/com/google/firebase/emulators/EmulatedServiceSettings.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
/**
2020
* Settings to connect a single Firebase service to a local emulator.
2121
*
22-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
23-
*
2422
* @see EmulatorSettings
25-
* @hide
2623
*/
2724
public final class EmulatedServiceSettings {
2825

@@ -34,6 +31,7 @@ public EmulatedServiceSettings(@NonNull String host, int port) {
3431
this.port = port;
3532
}
3633

34+
@NonNull
3735
public String getHost() {
3836
return host;
3937
}

firebase-common/src/main/java/com/google/firebase/emulators/EmulatorSettings.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
* Settings that control which Firebase services should access a local emulator, rather than
2626
* production.
2727
*
28-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
29-
*
3028
* @see com.google.firebase.FirebaseApp#enableEmulators(EmulatorSettings)
31-
* @hide
3229
*/
3330
public final class EmulatorSettings {
3431

firebase-common/src/main/java/com/google/firebase/emulators/FirebaseEmulator.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@
1919
/**
2020
* Identifier Firebase services that can be emulated using the Firebase Emulator Suite.
2121
*
22-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
23-
*
2422
* @see com.google.firebase.FirebaseApp#enableEmulators(EmulatorSettings)
2523
* @see EmulatorSettings
2624
* @see EmulatedServiceSettings
27-
* @hide
2825
*/
2926
public final class FirebaseEmulator {
3027

@@ -36,14 +33,15 @@ public final class FirebaseEmulator {
3633
* @hide
3734
*/
3835
@NonNull
39-
public static FirebaseEmulator forName(String name) {
36+
public static FirebaseEmulator forName(@NonNull String name) {
4037
return new FirebaseEmulator(name);
4138
}
4239

43-
private FirebaseEmulator(String name) {
40+
private FirebaseEmulator(@NonNull String name) {
4441
this.name = name;
4542
}
4643

44+
@NonNull
4745
public String getName() {
4846
return name;
4947
}

firebase-database/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Unreleased
22

33
- [changed] Added internal HTTP header to the WebChannel connection.
4+
- [feature] Realtime Database now supports connecting to a local emulator via
5+
`FirebaseApp.enableEmulators()`
46

57
# 19.3.0
68
- [feature] Added ServerValue.increment() to support atomic field value increments

firebase-database/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ package com.google.firebase.database {
9696
method public void setLogLevel(@NonNull com.google.firebase.database.Logger.Level);
9797
method public void setPersistenceCacheSizeBytes(long);
9898
method public void setPersistenceEnabled(boolean);
99+
field @NonNull public static final com.google.firebase.emulators.FirebaseEmulator EMULATOR;
99100
}
100101

101102
public abstract class GenericTypeIndicator<T> {

firebase-database/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version=19.3.1
15+
version=19.4.0
1616
latestReleasedVersion=19.3.0
1717
android.enableUnitTestBinaryResources=true

firebase-database/src/main/java/com/google/firebase/database/FirebaseDatabase.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,8 @@
4040
*/
4141
public class FirebaseDatabase {
4242

43-
/**
44-
* Emulator identifier. See {@link FirebaseApp#enableEmulators(EmulatorSettings)}
45-
*
46-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
47-
*
48-
* @hide
49-
*/
50-
public static final FirebaseEmulator EMULATOR = FirebaseEmulator.forName("database");
43+
/** Emulator identifier. See {@link FirebaseApp#enableEmulators(EmulatorSettings)} */
44+
@NonNull public static final FirebaseEmulator EMULATOR = FirebaseEmulator.forName("database");
5145

5246
private static final String SDK_VERSION = BuildConfig.VERSION_NAME;
5347

firebase-firestore/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
the app was in the background.
55
- [fixed] Fixed an issue that may have prevented the client from connecting
66
to the backend immediately after a user signed in.
7+
- [feature] Firestore now supports connecting to a local emulator via
8+
`FirebaseApp.enableEmulators()`.
79

810
# 21.4.3
911
- [changed] Firestore now limits the number of concurrent document lookups it

firebase-firestore/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ package com.google.firebase.firestore {
152152
method public static void setLoggingEnabled(boolean);
153153
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> terminate();
154154
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> waitForPendingWrites();
155+
field @NonNull public static final com.google.firebase.emulators.FirebaseEmulator EMULATOR;
155156
}
156157

157158
public class FirebaseFirestoreException extends com.google.firebase.FirebaseException {

firebase-firestore/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=21.4.4
1+
version=21.5.0
22
latestReleasedVersion=21.4.3

firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,8 @@
5858
*/
5959
public class FirebaseFirestore {
6060

61-
/**
62-
* Emulator identifier. See {@link FirebaseApp#enableEmulators(EmulatorSettings)}
63-
*
64-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
65-
*
66-
* @hide
67-
*/
68-
public static FirebaseEmulator EMULATOR = FirebaseEmulator.forName("firestore");
61+
/** Emulator identifier. See {@link FirebaseApp#enableEmulators(EmulatorSettings)} */
62+
@NonNull public static final FirebaseEmulator EMULATOR = FirebaseEmulator.forName("firestore");
6963

7064
/**
7165
* Provides a registry management interface for {@code FirebaseFirestore} instances.

firebase-functions/api.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ package com.google.firebase.functions {
77
method @NonNull public static com.google.firebase.functions.FirebaseFunctions getInstance(@NonNull com.google.firebase.FirebaseApp);
88
method @NonNull public static com.google.firebase.functions.FirebaseFunctions getInstance(@NonNull String);
99
method @NonNull public static com.google.firebase.functions.FirebaseFunctions getInstance();
10-
method public void useFunctionsEmulator(@NonNull String);
10+
method @Deprecated public void useFunctionsEmulator(@NonNull String);
11+
field @NonNull public static final com.google.firebase.emulators.FirebaseEmulator EMULATOR;
1112
}
1213

1314
public class FirebaseFunctionsException extends com.google.firebase.FirebaseException {

firebase-functions/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=19.0.3
1+
version=19.1.0
22
latestReleasedVersion=19.0.2
33
android.enableUnitTestBinaryResources=true

firebase-functions/src/main/java/com/google/firebase/functions/FirebaseFunctions.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.google.android.gms.tasks.Tasks;
2929
import com.google.firebase.FirebaseApp;
3030
import com.google.firebase.emulators.EmulatedServiceSettings;
31+
import com.google.firebase.emulators.EmulatorSettings;
3132
import com.google.firebase.emulators.FirebaseEmulator;
3233
import com.google.firebase.functions.FirebaseFunctionsException.Code;
3334
import java.io.IOException;
@@ -49,16 +50,8 @@
4950
/** FirebaseFunctions lets you call Cloud Functions for Firebase. */
5051
public class FirebaseFunctions {
5152

52-
/**
53-
* Emulator identifier, see {@link
54-
* com.google.firebase.emulators.EmulatorSettings.Builder#addEmulatedService(FirebaseEmulator,
55-
* EmulatedServiceSettings)}
56-
*
57-
* <p>TODO(samstern): Un-hide this once Firestore, Database, and Functions are implemented
58-
*
59-
* @hide
60-
*/
61-
public static final FirebaseEmulator EMULATOR = FirebaseEmulator.forName("functions");
53+
/** Emulator identifier. See {@link FirebaseApp#enableEmulators(EmulatorSettings)} */
54+
@NonNull public static final FirebaseEmulator EMULATOR = FirebaseEmulator.forName("functions");
6255

6356
/** A task that will be resolved once ProviderInstaller has installed what it needs to. */
6457
private static final TaskCompletionSource<Void> providerInstalled = new TaskCompletionSource<>();
@@ -218,7 +211,9 @@ URL getURL(String function) {
218211
* https://firebase.google.com/docs/functions/local-emulator
219212
*
220213
* @param origin The origin of the local emulator, such as "http://10.0.2.2:5005".
214+
* @deprecated use {@link FirebaseApp#enableEmulators(EmulatorSettings)}.
221215
*/
216+
@Deprecated
222217
public void useFunctionsEmulator(@NonNull String origin) {
223218
Preconditions.checkNotNull(origin, "origin cannot be null");
224219
urlFormat = origin + "/%2$s/%1$s/%3$s";

0 commit comments

Comments
 (0)