Skip to content

Rc realtime #3730

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 31 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
488e8e7
Creates Realtime Http client file. Includes ConfigUpdate Listener & R…
qdpham13 May 13, 2022
fc01819
Creates Realtime Http client file. Includes ConfigUpdate Listener & R…
qdpham13 May 13, 2022
41898e7
Merge remote-tracking branch 'origin/rc-realtime-dev' into rc-realtim…
qdpham13 May 13, 2022
a00ce0c
Update stream name
qdpham13 May 16, 2022
31af37a
Add copyright info to top of file.
qdpham13 May 16, 2022
187864b
Update comments
qdpham13 May 16, 2022
a9d3a97
Format file.
qdpham13 May 17, 2022
3642424
Creates Realtime Http client file. Includes ConfigUpdate Listener & R…
qdpham13 May 13, 2022
19956a8
Update stream name
qdpham13 May 16, 2022
93512af
Add copyright info to top of file.
qdpham13 May 16, 2022
fa56069
Update comments
qdpham13 May 16, 2022
50da87e
Format file.
qdpham13 May 17, 2022
99c166c
Merge remote-tracking branch 'origin/rc-realtime-dev' into rc-realtim…
qdpham13 May 18, 2022
567aa14
Moved ConfigUpdateListener and ConfigUpdateListenerRegistration to pu…
qdpham13 May 18, 2022
4c16e92
Moved ConfigUpdateListener and ConfigUpdateListenerRegistration to pu…
qdpham13 May 18, 2022
e9e28b2
Format and update comments
qdpham13 May 18, 2022
10fefb5
Uodate api.txt
qdpham13 May 18, 2022
31777f5
Add nonnull and nullable to params
qdpham13 May 18, 2022
51bf244
Change registration to interface.
qdpham13 May 18, 2022
b5c4a96
Add author
qdpham13 May 18, 2022
7394492
Update api.txt
qdpham13 May 18, 2022
c35e1bc
Dependabot High severity alerts (#3734)
daymxn May 18, 2022
a4e4d1a
Do not attempt to parse empty json files in MetaDataStore (#3735)
mrober May 18, 2022
3630787
Disable javadoc for undocumented sdks. (#3738)
vkryachko May 19, 2022
83c6d8f
Creates Realtime Http client file. Includes ConfigUpdate Listener & R…
qdpham13 May 13, 2022
4eca1dc
Merge remote-tracking branch 'origin/master' into rc-realtime-dev
qdpham13 May 19, 2022
32e980a
Reupdate files.
qdpham13 May 19, 2022
527ae0c
Make changes based on PR comments;
qdpham13 May 19, 2022
a6f69c2
Remove synchronized set and add explicit synchonized to methods.
qdpham13 May 19, 2022
a22e5d3
Merge remote-tracking branch 'origin/master' into rc-realtime-dev
qdpham13 May 20, 2022
0bd4c2b
Merge remote-tracking branch 'origin/master' into rc-realtime-dev
qdpham13 May 23, 2022
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
9 changes: 9 additions & 0 deletions firebase-config/api.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// Signature format: 2.0
package com.google.firebase.remoteconfig {

public interface ConfigUpdateListener {
method public void onError(Exception);
method public void onEvent();
}

public interface ConfigUpdateListenerRegistration {
method public void remove();
}

public class FirebaseRemoteConfig {
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Boolean> activate();
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.remoteconfig.FirebaseRemoteConfigInfo> ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.remoteconfig;

import javax.annotation.Nonnull;

/**
* Event Listener for Realtime config update callbacks.
*
* @author Quan Pham
*/
public interface ConfigUpdateListener {
/**
* Callback for when a new config has been automatically fetched from the backend. Can be used to
* activate the new config.
*/
void onEvent();

/**
* Call back for when an error occurs during Realtime.
*
* @param error
*/
void onError(@Nonnull Exception error);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.remoteconfig;

/**
* Represents a listener that can be removed by calling remove. This is returned when calling
* addOnConfigUpdateListener and should be used when you no longer want to listen for new config
* updates. If this is the last listener it will close the Realtime stream.
*
* @author Quan Pham
*/
public interface ConfigUpdateListenerRegistration {

/**
* Removes the listener being tracked by this 'ConfigUpdateListenerRegistration`. After the
* initial call, subsequent calls have no effect.
*/
public void remove();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.remoteconfig.internal;

import androidx.annotation.GuardedBy;
import com.google.firebase.remoteconfig.ConfigUpdateListener;
import com.google.firebase.remoteconfig.ConfigUpdateListenerRegistration;
import java.util.LinkedHashSet;
import java.util.Set;

public class ConfigRealtimeHttpClient {

@GuardedBy("this")
private final Set<ConfigUpdateListener> listeners;

public ConfigRealtimeHttpClient() {
listeners = new LinkedHashSet<ConfigUpdateListener>();
}

// Kicks off Http stream listening and autofetch
private void beginRealtime() {}

// Pauses Http stream listening
private void pauseRealtime() {}

public synchronized ConfigUpdateListenerRegistration addRealtimeConfigUpdateListener(
ConfigUpdateListener configUpdateListener) {
listeners.add(configUpdateListener);
beginRealtime();
return new ConfigUpdateListenerRegistrationInternal(configUpdateListener);
}

private synchronized void removeRealtimeConfigUpdateListener(ConfigUpdateListener listener) {
listeners.remove(listener);
if (listeners.isEmpty()) {
pauseRealtime();
}
}

public class ConfigUpdateListenerRegistrationInternal
implements ConfigUpdateListenerRegistration {
private final ConfigUpdateListener listener;

public ConfigUpdateListenerRegistrationInternal(ConfigUpdateListener listener) {
this.listener = listener;
}

public void remove() {
removeRealtimeConfigUpdateListener(listener);
}
}
}