Skip to content

Commit b4b848f

Browse files
committed
Remove unnecessary class field from SafetyNetAppCheckProvider.
1 parent 1de82ee commit b4b848f

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

appcheck/firebase-appcheck-safetynet/src/main/java/com/google/firebase/appcheck/safetynet/internal/SafetyNetAppCheckProvider.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ public class SafetyNetAppCheckProvider implements AppCheckProvider {
4949
private static final String NONCE = "";
5050
private static final String UTF_8 = "UTF-8";
5151

52-
private final Context context;
5352
private final Task<SafetyNetClient> safetyNetClientTask;
5453
private final NetworkClient networkClient;
55-
private final Executor backgroundExecutor;
5654
private final Executor blockingExecutor;
5755
private final RetryManager retryManager;
5856
private final String apiKey;
@@ -81,12 +79,11 @@ public SafetyNetAppCheckProvider(
8179
checkNotNull(networkClient);
8280
checkNotNull(googleApiAvailability);
8381
checkNotNull(backgroundExecutor);
84-
this.context = firebaseApp.getApplicationContext();
8582
this.apiKey = firebaseApp.getOptions().getApiKey();
86-
this.backgroundExecutor = backgroundExecutor;
8783
this.blockingExecutor = blockingExecutor;
8884
this.safetyNetClientTask =
89-
initSafetyNetClient(this.context, googleApiAvailability, this.backgroundExecutor);
85+
initSafetyNetClient(
86+
firebaseApp.getApplicationContext(), googleApiAvailability, backgroundExecutor);
9087
this.networkClient = networkClient;
9188
this.retryManager = new RetryManager();
9289
}
@@ -96,14 +93,11 @@ public SafetyNetAppCheckProvider(
9693
@NonNull FirebaseApp firebaseApp,
9794
@NonNull SafetyNetClient safetyNetClient,
9895
@NonNull NetworkClient networkClient,
99-
@NonNull Executor backgroundExecutor,
10096
@NonNull Executor blockingExecutor,
10197
@NonNull RetryManager retryManager) {
102-
this.context = firebaseApp.getApplicationContext();
10398
this.apiKey = firebaseApp.getOptions().getApiKey();
10499
this.safetyNetClientTask = Tasks.forResult(safetyNetClient);
105100
this.networkClient = networkClient;
106-
this.backgroundExecutor = backgroundExecutor;
107101
this.blockingExecutor = blockingExecutor;
108102
this.retryManager = retryManager;
109103
}

appcheck/firebase-appcheck-safetynet/src/test/java/com/google/firebase/appcheck/safetynet/internal/SafetyNetAppCheckProviderTest.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ public void testGetToken_nonNullSafetyNetClient_expectCallsSafetyNetForAttestati
128128
firebaseApp,
129129
mockSafetyNetClient,
130130
mockNetworkClient,
131-
TestOnlyExecutors.background(),
132131
TestOnlyExecutors.blocking(),
133132
mockRetryManager);
134133
assertThat(provider.getSafetyNetClientTask().getResult()).isEqualTo(mockSafetyNetClient);
@@ -151,7 +150,6 @@ public void testExchangeSafetyNetJwsForToken_nullAttestationResponse_expectThrow
151150
firebaseApp,
152151
mockSafetyNetClient,
153152
mockNetworkClient,
154-
TestOnlyExecutors.background(),
155153
TestOnlyExecutors.blocking(),
156154
mockRetryManager);
157155
assertThrows(
@@ -170,7 +168,6 @@ public void testExchangeSafetyNetJwsForToken_emptySafetyNetJwsResult_expectThrow
170168
firebaseApp,
171169
mockSafetyNetClient,
172170
mockNetworkClient,
173-
TestOnlyExecutors.background(),
174171
TestOnlyExecutors.blocking(),
175172
mockRetryManager);
176173
assertThrows(
@@ -188,7 +185,6 @@ public void testExchangeSafetyNetJwsForToken_validFields_expectReturnsTask() {
188185
firebaseApp,
189186
mockSafetyNetClient,
190187
mockNetworkClient,
191-
TestOnlyExecutors.background(),
192188
TestOnlyExecutors.blocking(),
193189
mockRetryManager);
194190
Task<AppCheckToken> task =
@@ -212,7 +208,6 @@ public void exchangeSafetyNetJwsForToken_onSuccess_setsTaskResult() throws Excep
212208
mockSafetyNetClient,
213209
mockNetworkClient,
214210
MoreExecutors.directExecutor(),
215-
MoreExecutors.directExecutor(),
216211
mockRetryManager);
217212
Task<AppCheckToken> task =
218213
provider.exchangeSafetyNetAttestationResponseForToken(mockSafetyNetAttestationResponse);
@@ -240,7 +235,6 @@ public void exchangeSafetyNetJwsForToken_onFailure_setsTaskException() throws Ex
240235
mockSafetyNetClient,
241236
mockNetworkClient,
242237
MoreExecutors.directExecutor(),
243-
MoreExecutors.directExecutor(),
244238
mockRetryManager);
245239
Task<AppCheckToken> task =
246240
provider.exchangeSafetyNetAttestationResponseForToken(mockSafetyNetAttestationResponse);

0 commit comments

Comments
 (0)