Skip to content

Commit

Permalink
Merge branch 'main' into rl.rename.harm.threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
rlazo committed Sep 30, 2024
2 parents baf177c + e98a4b6 commit 7a9130e
Show file tree
Hide file tree
Showing 273 changed files with 36,248 additions and 567 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void toggleRealtime(View view, Boolean isChecked) {
frc.addOnConfigUpdateListener(
new ConfigUpdateListener() {
@Override
public void onUpdate(ConfigUpdate configUpdate) {
public void onUpdate(@NonNull ConfigUpdate configUpdate) {
Log.d(TAG, String.join(", ", configUpdate.getUpdatedKeys()));
updatedParamsText.setText(String.join(", ", configUpdate.getUpdatedKeys()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.firebase.remoteconfig;

import androidx.annotation.NonNull;
import javax.annotation.Nonnull;

/**
* Event listener interface for real-time Remote Config updates. Implement {@code
Expand All @@ -38,5 +37,5 @@ public interface ConfigUpdateListener {
*
* @param error A {@link FirebaseRemoteConfigException} with information about the error.
*/
void onError(@Nonnull FirebaseRemoteConfigException error);
void onError(@NonNull FirebaseRemoteConfigException error);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import javax.annotation.Nonnull;

/**
* A Firebase Remote Config internal issue caused by an interaction with the Firebase Remote Config
Expand Down Expand Up @@ -46,7 +45,7 @@ public FirebaseRemoteConfigServerException(
* Creates a Firebase Remote Config server exception with the given message and {@code
* FirebaseRemoteConfigException} code.
*/
public FirebaseRemoteConfigServerException(@NonNull String detailMessage, @Nonnull Code code) {
public FirebaseRemoteConfigServerException(@NonNull String detailMessage, @NonNull Code code) {
super(detailMessage, code);
this.httpStatusCode = -1;
}
Expand All @@ -56,7 +55,7 @@ public FirebaseRemoteConfigServerException(@NonNull String detailMessage, @Nonnu
* {@code FirebaseRemoteConfigException} code.
*/
public FirebaseRemoteConfigServerException(
int httpStatusCode, @NonNull String detailMessage, @Nonnull Code code) {
int httpStatusCode, @NonNull String detailMessage, @NonNull Code code) {
super(detailMessage, code);
this.httpStatusCode = httpStatusCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void setUp() throws Exception {
ConfigUpdateListener listener =
new ConfigUpdateListener() {
@Override
public void onUpdate(ConfigUpdate configUpdate) {
public void onUpdate(@NonNull ConfigUpdate configUpdate) {
mockOnUpdateListener.onUpdate(configUpdate);
}

Expand Down Expand Up @@ -1757,7 +1757,7 @@ private void flushScheduledTasks() throws InterruptedException {
private ConfigUpdateListener generateEmptyRealtimeListener() {
return new ConfigUpdateListener() {
@Override
public void onUpdate(ConfigUpdate configUpdate) {}
public void onUpdate(@NonNull ConfigUpdate configUpdate) {}

@Override
public void onError(@NonNull FirebaseRemoteConfigException error) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void registerRolloutsStateSubscriber_firebaseNamespace_callsSubscriptionH
when(mockMetadataClient.getRealtimeBackoffMetadata())
.thenReturn(new ConfigMetadataClient.RealtimeBackoffMetadata(0, new Date()));

RemoteConfigComponent frcComponent = getNewFrcComponent();
RemoteConfigComponent frcComponent = getNewFrcComponentWithoutLoadingDefault();
FirebaseRemoteConfig instance = getFrcInstanceFromComponent(frcComponent, DEFAULT_NAMESPACE);

frcComponent.registerRolloutsStateSubscriber(DEFAULT_NAMESPACE, mockRolloutsStateSubscriber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

Expand Down Expand Up @@ -220,7 +221,7 @@ public void getBlocking_hasCachedValue_returnsCache() throws Exception {

@Test
public void getBlocking_hasNoCachedValueAndFileReadTimesOut_returnsNull() throws Exception {
when(mockStorageClient.read()).thenReturn(configContainer);
when(mockStorageClient.read()).thenAnswer(BLOCK_INDEFINITELY);

ConfigContainer container = cacheClient.getBlocking(/* diskReadTimeoutInSeconds= */ 0L);

Expand Down Expand Up @@ -329,4 +330,18 @@ public void cleanUp() {
cacheThreadPool.shutdownNow();
testingThreadPool.shutdownNow();
}

/**
* A Mockito "answer" that blocks indefinitely. The only way that {@link Answer#answer} will
* return is if its thread is interrupted. This may be useful to cause a method to never return,
* which should result in a timeout waiting for the operation to complete.
* <p>
* Example:
* {@code when(foo.get()).thenAnswer(BLOCK_INDEFINITELY); }
*/
private static final Answer<ConfigContainer> BLOCK_INDEFINITELY =
invocation -> {
Thread.sleep(Long.MAX_VALUE);
throw new RuntimeException("BLOCK_INDEFINITELY.answer() should never get here");
};
}
1 change: 1 addition & 0 deletions firebase-dataconnect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dataconnect.local.properties
19 changes: 19 additions & 0 deletions firebase-dataconnect/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Unreleased
* [feature] Initial release of the Data Connect SDK (public preview). Learn how to
[get started](https://firebase.google.com/docs/data-connect/android-sdk)
with the SDK in your app.
* [feature] Added App Check support.
([#6176](https://github.com/firebase/firebase-android-sdk/pull/6176))
* [feature] Added `AnyValue` to support the `Any` custom GraphQL scalar type.
([#6285](https://github.com/firebase/firebase-android-sdk/pull/6285))
* [feature] Added `OrderDirection` enum support.
([#6307](https://github.com/firebase/firebase-android-sdk/pull/6307))
* [feature] Added ability to specify `SerializersModule` when serializing.
([#6297](https://github.com/firebase/firebase-android-sdk/pull/6297))
* [feature] Added `CallerSdkType`, which enables tracking of the generated SDK usage.
([#6298](https://github.com/firebase/firebase-android-sdk/pull/6298) and
[#6179](https://github.com/firebase/firebase-android-sdk/pull/6179))
* [changed] Changed gRPC proto package to v1beta (was v1alpha).
([#6299](https://github.com/firebase/firebase-android-sdk/pull/6299))
* [changed] Added `equals` and `hashCode` methods to `GeneratedConnector`.
([#6177](https://github.com/firebase/firebase-android-sdk/pull/6177))
110 changes: 110 additions & 0 deletions firebase-dataconnect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# firebase-dataconnect

This is the Firebase Android Data Connect SDK.

## Building

All Gradle commands should be run from the source root (which is one level up
from this folder). See the README.md in the source root for instructions on
publishing/testing Firebase Data Connect.

To build Firebase Data Connect, from the source root run:
```bash
./gradlew :firebase-dataconnect:assembleRelease
```

## Unit Testing

To run unit tests for Firebase Data Connect, from the source root run:
```bash
./gradlew :firebase-dataconnect:check
```

## Integration Testing

Running integration tests requires a Firebase project because they connect to
the Firebase Data Connect backend.

See [here](../README.md#project-setup) for how to setup a project.

Once you setup the project, download `google-services.json` and place it in
the source root.

Make sure you have created a Firebase Data Connect instance for your project,
before you proceed.

By default, integration tests run against the Firebase Data Connect emulator.

### Setting up the Firebase Data Connect Emulator

The integration tests require that the Firebase Data Connect emulator is running
on port 9399, which is default when running it via the Data Connect Toolkit.

* [Install the Firebase CLI](https://firebase.google.com/docs/cli/).
```
npm install -g firebase-tools
```
* [Install the Firebase Data Connect
emulator](https://firebase.google.com/docs/FIX_URL/security/test-rules-emulator#install_the_emulator).
```
firebase setup:emulators:dataconnect
```
* Run the emulator
```
firebase emulators:start --only dataconnect
```
* Select the `Firebase Data Connect Integration Tests (Firebase Data Connect
Emulator)` run configuration to run all integration tests.

To run the integration tests against prod, select
`DataConnectProdIntegrationTest` run configuration.

### Run on Local Android Emulator

Then run:
```bash
./gradlew :firebase-dataconnect:connectedCheck
```

### Run on Firebase Test Lab

You can also test on Firebase Test Lab, which allow you to run the integration
tests on devices hosted in a Google data center.

See [here](../README.md#running-integration-tests-on-firebase-test-lab) for
instructions of how to setup Firebase Test Lab for your project.

Run:
```bash
./gradlew :firebase-dataconnect:deviceCheck
```

## Code Formatting

Run below to format Kotlin and Java code:
```bash
./gradlew :firebase-dataconnect:spotlessApply
```

See [here](../README.md#code-formatting) if you want to be able to format code
from within Android Studio.

## Build Local Jar of Firebase Data Connect SDK

```bash
./gradlew -PprojectsToPublish="firebase-dataconnect" publishReleasingLibrariesToMavenLocal
```

Developers may then take a dependency on these locally published versions by adding
the `mavenLocal()` repository to your [repositories
block](https://docs.gradle.org/current/userguide/declaring_repositories.html) in
your app module's build.gradle.

## Misc
After importing the project into Android Studio and building successfully
for the first time, Android Studio will delete the run configuration xml files
in `./idea/runConfigurations`. Undo these changes with the command:

```
$ git checkout .idea/runConfigurations
```
73 changes: 73 additions & 0 deletions firebase-dataconnect/androidTestutil/androidTestutil.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2024 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.
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("com.android.library")
id("kotlin-android")
alias(libs.plugins.kotlinx.serialization)
}

android {
val compileSdkVersion : Int by rootProject
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject

namespace = "com.google.firebase.dataconnect.androidTestutil"
compileSdk = compileSdkVersion
defaultConfig {
minSdk = minSdkVersion
targetSdk = targetSdkVersion
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions { jvmTarget = "1.8" }

packaging {
resources {
excludes.add("META-INF/LICENSE.md")
excludes.add("META-INF/LICENSE-notice.md")
}
}
}

dependencies {
implementation(project(":firebase-dataconnect"))
implementation(project(":firebase-dataconnect:testutil"))

implementation("com.google.firebase:firebase-auth:22.3.1")
implementation("com.google.firebase:firebase-appcheck:18.0.0")

implementation(libs.androidx.test.core)
implementation(libs.androidx.test.junit)
implementation(libs.auth0.jwt)
implementation(libs.kotest.property)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.truth)
implementation(libs.turbine)
}

tasks.withType<KotlinCompile>().all {
kotlinOptions {
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "prjh5zbv64sv6",
"private_key_id": "abcdef0123456789abcdef0123456789abcdef01",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvfyKRUZMyp1FS\nbL2cZIMNA5AbDHBuZciEZFIbG7rx7d12Lnwz/inBSuhJ2qzmSHvWLQfjV0xsPVEH\nCCQdB7owt8GemvcyrzaW/vQ5WmvN7Wpj7Efz7iEguXQfqa09FklGECfrhgnOdsdd\ntoQW19nzETwepXzBvo6C/etTesUHAjBLUeHoh94vDvMTbp+9Dc48pG+uMhSVItjV\nv32lDRemFcewK33SCYWG2+3CqEQHlFf75pnbMTJr0392KLJtXqv6Kgcd61JXB7l8\nw8G4GPm8o9er0l4j5lB36Az1SmAJM68K7lI98PMrCcSsdwgNT3R16J6y+zMJfc5h\nStGdJP5hAgMBAAECggEARGEtl2CpEYoHEi4jfS3esDHsstVYc3N+OzOZmE1oPH65\nlSRMqbeFDncA5lHpn3qrocp+8dJgiSYlDa/a3mLV5cibjRCFc/64LwJdJ4G3UpAI\nrbFxYbatusH34KRs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AyZjMS6NYLwmZ1M52eeikRWdyO/h\nZ3q6UYLR9K+mhUFgV+X7g15T\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-trn2rx6xed@prjh5zbv64sv6.iam.gserviceaccount.com",
"client_id": "123456789012345678901",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-trn2rx6xed%40prjh5zbv64sv6.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
Loading

0 comments on commit 7a9130e

Please sign in to comment.