|
30 | 30 | import com.google.android.gms.common.util.VisibleForTesting;
|
31 | 31 | import com.google.firebase.heartbeatinfo.HeartBeatInfo;
|
32 | 32 | import com.google.firebase.heartbeatinfo.HeartBeatInfo.HeartBeat;
|
| 33 | +import com.google.firebase.inject.Provider; |
33 | 34 | import com.google.firebase.installations.FirebaseInstallationsException;
|
34 | 35 | import com.google.firebase.installations.FirebaseInstallationsException.Status;
|
35 | 36 | import com.google.firebase.installations.remote.InstallationResponse.ResponseCode;
|
@@ -101,13 +102,13 @@ public class FirebaseInstallationServiceClient {
|
101 | 102 | static final String PARSING_EXPIRATION_TIME_ERROR_MESSAGE = "Invalid Expiration Timestamp.";
|
102 | 103 |
|
103 | 104 | private final Context context;
|
104 |
| - private final UserAgentPublisher userAgentPublisher; |
105 |
| - private final HeartBeatInfo heartbeatInfo; |
| 105 | + private final Provider<UserAgentPublisher> userAgentPublisher; |
| 106 | + private final Provider<HeartBeatInfo> heartbeatInfo; |
106 | 107 |
|
107 | 108 | public FirebaseInstallationServiceClient(
|
108 | 109 | @NonNull Context context,
|
109 |
| - @Nullable UserAgentPublisher publisher, |
110 |
| - @Nullable HeartBeatInfo heartbeatInfo) { |
| 110 | + @NonNull Provider<UserAgentPublisher> publisher, |
| 111 | + @NonNull Provider<HeartBeatInfo> heartbeatInfo) { |
111 | 112 | this.context = context;
|
112 | 113 | this.userAgentPublisher = publisher;
|
113 | 114 | this.heartbeatInfo = heartbeatInfo;
|
@@ -433,10 +434,12 @@ private HttpURLConnection openHttpURLConnection(URL url, String apiKey)
|
433 | 434 | httpURLConnection.addRequestProperty(CONTENT_ENCODING_HEADER_KEY, GZIP_CONTENT_ENCODING);
|
434 | 435 | httpURLConnection.addRequestProperty(CACHE_CONTROL_HEADER_KEY, CACHE_CONTROL_DIRECTIVE);
|
435 | 436 | httpURLConnection.addRequestProperty(X_ANDROID_PACKAGE_HEADER_KEY, context.getPackageName());
|
436 |
| - if (heartbeatInfo != null && userAgentPublisher != null) { |
437 |
| - HeartBeat heartbeat = heartbeatInfo.getHeartBeatCode(FIREBASE_INSTALLATIONS_ID_HEARTBEAT_TAG); |
| 437 | + if ((heartbeatInfo.get() != null) && (userAgentPublisher.get() != null)) { |
| 438 | + HeartBeat heartbeat = |
| 439 | + heartbeatInfo.get().getHeartBeatCode(FIREBASE_INSTALLATIONS_ID_HEARTBEAT_TAG); |
438 | 440 | if (heartbeat != HeartBeat.NONE) {
|
439 |
| - httpURLConnection.addRequestProperty(USER_AGENT_HEADER, userAgentPublisher.getUserAgent()); |
| 441 | + httpURLConnection.addRequestProperty( |
| 442 | + USER_AGENT_HEADER, userAgentPublisher.get().getUserAgent()); |
440 | 443 | httpURLConnection.addRequestProperty(
|
441 | 444 | HEART_BEAT_HEADER, Integer.toString(heartbeat.getCode()));
|
442 | 445 | }
|
|
0 commit comments