Skip to content

Commit 91681dd

Browse files
VinayGuthalGoogler
andauthored
Update Fdl Code with tests from piper (#2749)
* Project import generated by Copybara. FolderOrigin-RevId: /google/src/cloud/vguthal/move_stuff/. changes update Hide update update everything update update update * update * update * update * update * update * update Co-authored-by: Googler <[email protected]>
1 parent c7d8a80 commit 91681dd

23 files changed

+473
-87
lines changed

firebase-dynamic-links/firebase-dynamic-links.gradle

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ android {
2929
compileSdkVersion project.targetSdkVersion
3030
defaultConfig {
3131
targetSdkVersion project.targetSdkVersion
32-
minSdkVersion project.minSdkVersion
32+
minSdkVersion 16
3333
versionName version
3434
multiDexEnabled true
3535
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -51,31 +51,34 @@ dependencies {
5151
implementation project(':firebase-common')
5252
implementation project(':firebase-components')
5353

54-
implementation 'androidx.annotation:annotation:1.1.0'
54+
implementation 'androidx.annotation:annotation:1.2.0'
5555

56-
implementation 'com.google.android.gms:play-services-basement:17.0.0'
57-
implementation 'com.google.android.gms:play-services-tasks:17.0.0'
58-
implementation 'com.google.android.gms:play-services-base:17.0.0'
56+
implementation 'com.google.android.gms:play-services-basement:17.6.0'
57+
implementation 'com.google.android.gms:play-services-tasks:17.2.1'
58+
implementation 'com.google.android.gms:play-services-base:17.6.0'
5959

60-
implementation('com.google.firebase:firebase-auth-interop:18.0.0') {
60+
implementation('com.google.firebase:firebase-auth-interop:20.0.0') {
6161
exclude group: "com.google.firebase", module: "firebase-common"
6262
}
63-
implementation('com.google.firebase:firebase-measurement-connector:18.0.0') {
63+
implementation('com.google.firebase:firebase-measurement-connector:19.0.0') {
6464
exclude group: 'com.google.firebase', module: 'firebase-common'
6565
}
66+
testCompileOnly 'com.google.auto.value:auto-value-annotations:1.6.3'
67+
testAnnotationProcessor "com.google.auto.value:auto-value:1.6.3"
6668

6769
javadocClasspath 'com.google.auto.value:auto-value-annotations:1.6.6'
70+
6871
javadocClasspath 'com.google.code.findbugs:jsr305:3.0.2'
6972

70-
testImplementation 'junit:junit:4.12'
71-
testImplementation 'androidx.test:core:1.2.0'
72-
testImplementation 'com.android.support.test:runner:1.0.1'
73-
testImplementation 'org.mockito:mockito-core:2.25.0'
73+
testImplementation 'junit:junit:4.13.2'
74+
testImplementation 'androidx.test:core:1.3.0'
75+
testImplementation 'com.android.support.test:runner:1.0.2'
76+
testImplementation 'org.mockito:mockito-core:3.3.3'
7477
testImplementation "org.robolectric:robolectric:$robolectricVersion"
7578
testImplementation "com.google.truth:truth:$googleTruthVersion"
76-
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
79+
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.10.2'
7780
testImplementation 'com.google.guava:guava-testlib:12.0-rc2'
78-
testImplementation('com.google.android.gms:play-services-appinvite:16.0.0') {
81+
testImplementation('com.google.android.gms:play-services-appinvite:18.0.0') {
7982
exclude group: 'com.google.firebase', module: 'firebase-common'
8083
exclude group: 'com.google.firebase', module: 'firebase-dynamic-links'
8184
}

firebase-dynamic-links/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919

2020
<application>
2121
<service android:name="com.google.firebase.components.ComponentDiscoveryService"
22-
android:exported="false">
22+
android:exported="false">
2323
<meta-data
2424
android:name="com.google.firebase.components:com.google.firebase.dynamiclinks.internal.FirebaseDynamicLinkRegistrar"
2525
android:value="com.google.firebase.components.ComponentRegistrar" />
2626
</service>
2727
</application>
2828
</manifest>
29-

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/DynamicLink.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -94,10 +94,8 @@ public static final class Builder {
9494
public Builder(FirebaseDynamicLinksImpl firebaseDynamicLinks) {
9595
firebaseDynamicLinksImpl = firebaseDynamicLinks;
9696
builderParameters = new Bundle();
97-
if (FirebaseApp.getInstance() != null) {
98-
builderParameters.putString(
99-
KEY_API_KEY, FirebaseApp.getInstance().getOptions().getApiKey());
100-
}
97+
builderParameters.putString(
98+
KEY_API_KEY, firebaseDynamicLinks.getFirebaseApp().getOptions().getApiKey());
10199
fdlParameters = new Bundle();
102100
builderParameters.putBundle(KEY_DYNAMIC_LINK_PARAMETERS, fdlParameters);
103101
}

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/FirebaseDynamicLinks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/PendingDynamicLinkData.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -21,23 +21,25 @@
2121
import android.os.Bundle;
2222
import androidx.annotation.NonNull;
2323
import androidx.annotation.Nullable;
24-
import androidx.annotation.VisibleForTesting;
2524
import com.google.android.gms.common.GooglePlayServicesUtil;
25+
import com.google.android.gms.common.annotation.KeepForSdk;
2626
import com.google.android.gms.common.util.DefaultClock;
27+
import com.google.android.gms.common.util.VisibleForTesting;
2728
import com.google.firebase.dynamiclinks.internal.DynamicLinkData;
2829
import com.google.firebase.dynamiclinks.internal.DynamicLinkUTMParams;
2930

3031
/** Provides accessor methods to dynamic links data. */
3132
public class PendingDynamicLinkData {
3233

33-
private final DynamicLinkData dynamicLinkData;
3434
@Nullable private final DynamicLinkUTMParams dynamicLinkUTMParams;
35+
@Nullable private final DynamicLinkData dynamicLinkData;
3536

3637
/**
3738
* Create a dynamic link from parameters.
3839
*
3940
* @hide
4041
*/
42+
@KeepForSdk
4143
@VisibleForTesting
4244
public PendingDynamicLinkData(DynamicLinkData dynamicLinkData) {
4345
if (dynamicLinkData == null) {
@@ -77,6 +79,7 @@ protected PendingDynamicLinkData(
7779
* @return A bundle will all extension data.
7880
* @hide
7981
*/
82+
@KeepForSdk
8083
@Nullable
8184
public Bundle getExtensions() {
8285
if (dynamicLinkData == null) {
@@ -114,7 +117,7 @@ public Uri getLink() {
114117
@NonNull
115118
public Bundle getUtmParameters() {
116119
if (dynamicLinkUTMParams == null) {
117-
return Bundle.EMPTY;
120+
return new Bundle();
118121
}
119122

120123
return dynamicLinkUTMParams.asBundle();
@@ -156,6 +159,7 @@ public long getClickTimestamp() {
156159
* @hide
157160
*/
158161
@VisibleForTesting
162+
@Nullable
159163
public Uri getRedirectUrl() {
160164
if (dynamicLinkData == null) {
161165
return null;

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/ShortDynamicLink.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/internal/DynamicLinkData.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
import android.net.Uri;
1818
import android.os.Bundle;
1919
import android.os.Parcel;
20+
import androidx.annotation.Nullable;
2021
import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
2122
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
2223

@@ -25,9 +26,11 @@
2526
public class DynamicLinkData extends AbstractSafeParcelable {
2627

2728
@SafeParcelable.Field(id = 1, getter = "getDynamicLink")
29+
@Nullable
2830
private String dynamicLink;
2931

3032
@SafeParcelable.Field(id = 2, getter = "getDeepLink")
33+
@Nullable
3134
private String deepLink;
3235

3336
@SafeParcelable.Field(id = 3, getter = "getMinVersion")
@@ -37,11 +40,14 @@ public class DynamicLinkData extends AbstractSafeParcelable {
3740
private long clickTimestamp = 0L;
3841

3942
@SafeParcelable.Field(id = 5, getter = "getExtensionBundle")
43+
@Nullable
4044
private Bundle extensionBundle = null;
4145

4246
@SafeParcelable.Field(id = 6, getter = "getRedirectUrl")
47+
@Nullable
4348
private Uri redirectUrl;
4449

50+
@Nullable
4551
public String getDynamicLink() {
4652
return dynamicLink;
4753
}
@@ -50,6 +56,7 @@ public void setDynamicLink(String dynamicLink) {
5056
this.dynamicLink = dynamicLink;
5157
}
5258

59+
@Nullable
5360
public String getDeepLink() {
5461
return deepLink;
5562
}
@@ -82,6 +89,7 @@ public void setRedirectUrl(Uri redirectUrl) {
8289
this.redirectUrl = redirectUrl;
8390
}
8491

92+
@Nullable
8593
public Uri getRedirectUrl() {
8694
return redirectUrl;
8795
}
@@ -101,12 +109,12 @@ public void setExtensionData(Bundle bundle) {
101109

102110
@SafeParcelable.Constructor
103111
public DynamicLinkData(
104-
@Param(id = 1) String dynamicLink,
105-
@Param(id = 2) String deepLink,
112+
@Nullable @Param(id = 1) String dynamicLink,
113+
@Nullable @Param(id = 2) String deepLink,
106114
@Param(id = 3) int minVersion,
107115
@Param(id = 4) long clickTimestamp,
108-
@Param(id = 5) Bundle extensions,
109-
@Param(id = 6) Uri redirectUrl) {
116+
@Nullable @Param(id = 5) Bundle extensions,
117+
@Nullable @Param(id = 6) Uri redirectUrl) {
110118
this.dynamicLink = dynamicLink;
111119
this.deepLink = deepLink;
112120
this.minVersion = minVersion;

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/internal/DynamicLinkDataCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/internal/DynamicLinkUTMParams.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,42 +44,44 @@ public class DynamicLinkUTMParams {
4444

4545
public DynamicLinkUTMParams(DynamicLinkData dynamicLinkData) {
4646
this.dynamicLinkData = dynamicLinkData;
47-
this.utmParamsBundle = initUTMParamsBundle();
47+
this.utmParamsBundle = initUTMParamsBundle(dynamicLinkData);
4848
}
4949

5050
@NonNull
5151
public Bundle asBundle() {
5252
return new Bundle(utmParamsBundle);
5353
}
5454

55-
private Bundle initUTMParamsBundle() {
55+
@NonNull
56+
private static Bundle initUTMParamsBundle(DynamicLinkData dynamicLinkData) {
57+
Bundle bundle = new Bundle();
5658
if (dynamicLinkData == null || dynamicLinkData.getExtensionBundle() == null) {
57-
return Bundle.EMPTY;
59+
return bundle;
5860
}
5961

6062
Bundle scionBundle = dynamicLinkData.getExtensionBundle().getBundle(KEY_SCION_DATA_BUNDLE);
6163

6264
if (scionBundle == null) {
63-
return Bundle.EMPTY;
65+
return bundle;
6466
}
6567

6668
Bundle campaignBundle = scionBundle.getBundle(KEY_CAMPAIGN_BUNDLE);
6769
if (campaignBundle == null) {
68-
return Bundle.EMPTY;
70+
return bundle;
6971
}
7072

71-
Bundle bundle = new Bundle();
7273
checkAndAdd(KEY_MEDIUM, KEY_UTM_MEDIUM, campaignBundle, bundle);
7374
checkAndAdd(KEY_SOURCE, KEY_UTM_SOURCE, campaignBundle, bundle);
7475
checkAndAdd(KEY_CAMPAIGN, KEY_UTM_CAMPAIGN, campaignBundle, bundle);
76+
7577
return bundle;
7678
}
7779

7880
/*
7981
* Checks and adds the value from source bundle to the destination bundle based on the source
8082
* key and destination key.
8183
*/
82-
private void checkAndAdd(
84+
private static void checkAndAdd(
8385
@NonNull String sourceKey,
8486
@NonNull String destKey,
8587
@NonNull Bundle source,

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/internal/DynamicLinksApi.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -17,13 +17,14 @@
1717
import android.content.Context;
1818
import android.os.Looper;
1919
import androidx.annotation.NonNull;
20-
import androidx.annotation.VisibleForTesting;
2120
import com.google.android.gms.common.api.Api;
21+
import com.google.android.gms.common.api.Api.ApiOptions;
2222
import com.google.android.gms.common.api.Api.ApiOptions.NoOptions;
2323
import com.google.android.gms.common.api.GoogleApi;
2424
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
2525
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
2626
import com.google.android.gms.common.internal.ClientSettings;
27+
import com.google.android.gms.common.util.VisibleForTesting;
2728

2829
public class DynamicLinksApi extends GoogleApi<NoOptions> {
2930

@@ -63,6 +64,6 @@ public DynamicLinksClient buildClient(
6364
*/
6465
@VisibleForTesting
6566
public DynamicLinksApi(@NonNull Context context) {
66-
super(context, API, null /* options */, Settings.DEFAULT_SETTINGS);
67+
super(context, API, ApiOptions.NO_OPTIONS /* options */, Settings.DEFAULT_SETTINGS);
6768
}
6869
}

firebase-dynamic-links/src/main/java/com/google/firebase/dynamiclinks/internal/DynamicLinksClient.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC
1+
// Copyright 2021 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@ public class DynamicLinksClient extends GmsClient<IDynamicLinksService> {
3232
"com.google.firebase.dynamiclinks.service.START";
3333
public static final String SERVICE_DESCRIPTOR =
3434
"com.google.firebase.dynamiclinks.internal.IDynamicLinksService";
35+
private static final int DYNAMIC_LINKS_API_VALUE = 131;
36+
private static final int V17 = 12451000;
3537

3638
public DynamicLinksClient(
3739
Context context,
@@ -42,8 +44,7 @@ public DynamicLinksClient(
4244
super(
4345
context,
4446
looper,
45-
// ServiceId.DYNAMIC_LINKS_API_VALUE,
46-
131,
47+
DYNAMIC_LINKS_API_VALUE,
4748
clientSettings,
4849
connectedListener,
4950
connectionFailedListener);
@@ -67,7 +68,7 @@ protected IDynamicLinksService createServiceInterface(IBinder binder) {
6768
return IDynamicLinksService.Stub.asInterface(binder);
6869
}
6970

70-
void getDynamicLink(IDynamicLinksCallbacks.Stub callback, String dynamicLink) {
71+
void getDynamicLink(IDynamicLinksCallbacks.Stub callback, @Nullable String dynamicLink) {
7172
try {
7273
getService().getDynamicLink(callback, dynamicLink);
7374
} catch (RemoteException e) {
@@ -89,7 +90,11 @@ public int getMinApkVersion() {
8990
// or an older version is now supported. Do _not_ use JAR_BUILD_VERSION_CODE as long as this
9091
// code is shipped in the 3P SDK (which ships ~from head / dev and would not work with the head
9192
// version of the .apk)..
92-
// return BuildConstants.BaseApkVersion.V17;
93-
return 12451000;
93+
return V17;
94+
}
95+
96+
@Override
97+
public boolean usesClientTelemetry() {
98+
return true;
9499
}
95100
}

0 commit comments

Comments
 (0)