Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion firebase-common/firebase-common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ android {
targetSdk = targetSdkVersion
unitTests { isIncludeAndroidResources = true }
}
lint { targetSdk = targetSdkVersion }
lint {
targetSdk = targetSdkVersion
baseline = file("lint-baseline.xml")
}
}

kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_1_8 } }
Expand Down
114 changes: 114 additions & 0 deletions firebase-common/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.6.1" type="baseline" client="gradle" dependencies="false" name="AGP (8.6.1)" variant="all" version="8.6.1">

<issue
id="UnusedAttribute"
message="Attribute `directBootAware` is only used in API level 24 and higher (current min is 23)"
errorLine1=" android:directBootAware=&quot;true&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/AndroidManifest.xml"
line="25"
column="13"/>
</issue>

<issue
id="DiscouragedApi"
message="Use of `scheduleAtFixedRate` is strongly discouraged because it can lead to unexpected behavior when Android processes become cached (tasks may unexpectedly execute hundreds or thousands of times in quick succession when a process changes from cached to uncached); prefer using `scheduleWithFixedDelay`"
errorLine1=" scheduler.scheduleAtFixedRate("
errorLine2=" ^">
<location
file="src/main/java/com/google/firebase/concurrent/DelegatingScheduledExecutorService.java"
line="151"
column="13"/>
</issue>

<issue
id="UnclosedTrace"
message="The `beginSection()` call is not always closed with a matching `endSection()` because the code in between may return early"
errorLine1=" Trace.beginSection(name);"
errorLine2=" ~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/tracing/FirebaseTrace.java"
line="27"
column="13"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 23"
errorLine1=" if (Build.VERSION.SDK_INT >= 23) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/concurrent/ExecutorsRegistrar.java"
line="114"
column="9"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 14"
errorLine1=" @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/FirebaseApp.java"
line="683"
column="3"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 23"
errorLine1=" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/FirebaseCommonRegistrar.java"
line="77"
column="19"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 23"
errorLine1=" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/FirebaseCommonRegistrar.java"
line="81"
column="19"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 23"
errorLine1=" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/FirebaseCommonRegistrar.java"
line="85"
column="19"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 23"
errorLine1=" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/tracing/FirebaseTrace.java"
line="26"
column="9"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 23"
errorLine1=" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/com/google/firebase/tracing/FirebaseTrace.java"
line="32"
column="9"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class FirebaseOptionsTest {
private static final String GA_TRACKING_ID = "UA-123456-2";
private static final String GCM_SENDER_ID = "309678045053";
private static final String STORAGE_BUCKET = "ghconfigtest-644f2";
private static final String RECAPTCHA_SITE_KEY = "6L00000sAAAAAAaaaaaAAaa00000_AAAaAaaAa00";
private static final String GCP_PROJECT_ID = "test-product-id";

private static final FirebaseOptions ALL_VALUES_OPTIONS =
Expand All @@ -40,6 +41,7 @@ public class FirebaseOptionsTest {
.setGaTrackingId(GA_TRACKING_ID)
.setGcmSenderId(GCM_SENDER_ID)
.setStorageBucket(STORAGE_BUCKET)
.set
Comment thread
rlazo marked this conversation as resolved.
Outdated
.setProjectId(GCP_PROJECT_ID)
.build();

Expand All @@ -53,6 +55,7 @@ public void createOptionsWithAllValuesSet() {
.setGaTrackingId(GA_TRACKING_ID)
.setGcmSenderId(GCM_SENDER_ID)
.setStorageBucket(STORAGE_BUCKET)
.setRecaptchaSiteKey(RECAPTCHA_SITE_KEY)
.setProjectId(GCP_PROJECT_ID)
.build();
assertThat(firebaseOptions.getApplicationId()).isEqualTo(GOOGLE_APP_ID);
Expand All @@ -61,6 +64,7 @@ public void createOptionsWithAllValuesSet() {
assertThat(firebaseOptions.getGaTrackingId()).isEqualTo(GA_TRACKING_ID);
assertThat(firebaseOptions.getGcmSenderId()).isEqualTo(GCM_SENDER_ID);
assertThat(firebaseOptions.getStorageBucket()).isEqualTo(STORAGE_BUCKET);
assertThat(firebaseOptions.getRecaptchaSiteKey()).isEqualTo(RECAPTCHA_SITE_KEY);
assertThat(firebaseOptions.getProjectId()).isEqualTo(GCP_PROJECT_ID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ public final class FirebaseOptions {
private static final String DATABASE_URL_RESOURCE_NAME = "firebase_database_url";
private static final String GA_TRACKING_ID_RESOURCE_NAME = "ga_trackingId";
private static final String GCM_SENDER_ID_RESOURCE_NAME = "gcm_defaultSenderId";
private static final String STORAGE_BUCKET_RESOURCE_NAME = "google_storage_bucket";
private static final String PROJECT_ID_RESOURCE_NAME = "project_id";
private static final String RECAPTCHA_SITE_KEY_RESOURCE_NAME = "recaptcha_site_key";
private static final String STORAGE_BUCKET_RESOURCE_NAME = "google_storage_bucket";

private final String apiKey;
private final String applicationId;
private final String databaseUrl;
private final String gaTrackingId;
private final String gcmSenderId;
private final String storageBucket;
private final String recaptchaSiteKey;
private final String projectId;

/** Builder for constructing FirebaseOptions. */
Expand All @@ -55,6 +57,7 @@ public static final class Builder {
private String gaTrackingId;
private String gcmSenderId;
private String storageBucket;
private String recaptchaSiteKey;
private String projectId;

/** Constructs an empty builder. */
Expand All @@ -73,6 +76,7 @@ public Builder(@NonNull FirebaseOptions options) {
gaTrackingId = options.gaTrackingId;
gcmSenderId = options.gcmSenderId;
storageBucket = options.storageBucket;
recaptchaSiteKey = options.recaptchaSiteKey;
projectId = options.projectId;
}

Expand Down Expand Up @@ -115,6 +119,12 @@ public Builder setStorageBucket(@Nullable String storageBucket) {
return this;
}

@NonNull
public Builder setRecaptchaSiteKey(@Nullable String recaptchaSiteKey) {
this.recaptchaSiteKey = recaptchaSiteKey;
return this;
}

@NonNull
public Builder setProjectId(@Nullable String projectId) {
this.projectId = projectId;
Expand All @@ -124,7 +134,14 @@ public Builder setProjectId(@Nullable String projectId) {
@NonNull
public FirebaseOptions build() {
return new FirebaseOptions(
applicationId, apiKey, databaseUrl, gaTrackingId, gcmSenderId, storageBucket, projectId);
applicationId,
apiKey,
databaseUrl,
gaTrackingId,
gcmSenderId,
storageBucket,
recaptchaSiteKey,
projectId);
}
}

Expand All @@ -135,6 +152,7 @@ private FirebaseOptions(
@Nullable String gaTrackingId,
@Nullable String gcmSenderId,
@Nullable String storageBucket,
@Nullable String recaptchaSiteKey,
@Nullable String projectId) {
Preconditions.checkState(!isEmptyOrWhitespace(applicationId), "ApplicationId must be set.");
this.applicationId = applicationId;
Expand All @@ -143,6 +161,7 @@ private FirebaseOptions(
this.gaTrackingId = gaTrackingId;
this.gcmSenderId = gcmSenderId;
this.storageBucket = storageBucket;
this.recaptchaSiteKey = recaptchaSiteKey;
this.projectId = projectId;
}

Expand All @@ -165,6 +184,7 @@ public static FirebaseOptions fromResource(@NonNull Context context) {
reader.getString(GA_TRACKING_ID_RESOURCE_NAME),
reader.getString(GCM_SENDER_ID_RESOURCE_NAME),
reader.getString(STORAGE_BUCKET_RESOURCE_NAME),
reader.getString(RECAPTCHA_SITE_KEY_RESOURCE_NAME),
reader.getString(PROJECT_ID_RESOURCE_NAME));
}

Expand Down Expand Up @@ -216,6 +236,12 @@ public String getStorageBucket() {
return storageBucket;
}

/** The Google Cloud Storage bucket name, e.g. abc-xyz-123.storage.firebase.com. */
Comment thread
rlazo marked this conversation as resolved.
@Nullable
public String getRecaptchaSiteKey() {
return recaptchaSiteKey;
}

/** The Google Cloud project ID, e.g. my-project-1234 */
@Nullable
public String getProjectId() {
Expand All @@ -234,13 +260,21 @@ public boolean equals(Object o) {
&& Objects.equal(gaTrackingId, other.gaTrackingId)
&& Objects.equal(gcmSenderId, other.gcmSenderId)
&& Objects.equal(storageBucket, other.storageBucket)
&& Objects.equal(recaptchaSiteKey, other.recaptchaSiteKey)
&& Objects.equal(projectId, other.projectId);
}

@Override
public int hashCode() {
return Objects.hashCode(
applicationId, apiKey, databaseUrl, gaTrackingId, gcmSenderId, storageBucket, projectId);
applicationId,
apiKey,
databaseUrl,
gaTrackingId,
gcmSenderId,
storageBucket,
recaptchaSiteKey,
projectId);
}

@Override
Expand All @@ -251,6 +285,7 @@ public String toString() {
.add("databaseUrl", databaseUrl)
.add("gcmSenderId", gcmSenderId)
.add("storageBucket", storageBucket)
.add("recaptchaSiteKey", recaptchaSiteKey)
.add("projectId", projectId)
.toString();
}
Expand Down
Loading