31
31
import androidx .annotation .VisibleForTesting ;
32
32
import androidx .browser .customtabs .CustomTabsIntent ;
33
33
import com .google .android .gms .common .internal .Preconditions ;
34
+ import com .google .android .gms .tasks .CancellationToken ;
35
+ import com .google .android .gms .tasks .CancellationTokenSource ;
34
36
import com .google .android .gms .tasks .OnFailureListener ;
35
37
import com .google .android .gms .tasks .OnSuccessListener ;
36
38
import com .google .android .gms .tasks .Task ;
@@ -50,6 +52,7 @@ public class FirebaseAppDistribution implements Application.ActivityLifecycleCal
50
52
private Activity currentActivity ;
51
53
@ VisibleForTesting private boolean currentlySigningIn = false ;
52
54
private TaskCompletionSource <Void > signInTaskCompletionSource = null ;
55
+ private CancellationTokenSource signInCancellationSource ;
53
56
54
57
/** Constructor for FirebaseAppDistribution */
55
58
public FirebaseAppDistribution (
@@ -177,9 +180,11 @@ public void onSuccess(String fid) {
177
180
Uri uri =
178
181
Uri .parse (
179
182
String .format (
180
- "https://appdistribution.firebase.dev/nba/pub/apps/"
181
- + "%s/installations/%s/buildalerts?appName=%s" ,
182
- firebaseApp .getOptions ().getApplicationId (), fid , getApplicationName (context )));
183
+ "https://appdistribution.firebase.google.com/pub/apps/%s/installations/%s/buildalerts?appName=%s&packageName=%s" ,
184
+ firebaseApp .getOptions ().getApplicationId (),
185
+ fid ,
186
+ getApplicationName (context ),
187
+ context .getPackageName ()));
183
188
openSignInFlowInBrowser (uri );
184
189
}
185
190
};
@@ -225,8 +230,13 @@ public void onClick(DialogInterface dialogInterface, int i) {
225
230
/** Signs in the App Distribution tester. Presents the tester with a Google sign in UI */
226
231
@ NonNull
227
232
public Task <Void > signInTester () {
233
+ if (signInTaskCompletionSource != null && !signInTaskCompletionSource .getTask ().isComplete ()) {
234
+ signInCancellationSource .cancel ();
235
+ }
236
+
237
+ signInCancellationSource = new CancellationTokenSource ();
238
+ signInTaskCompletionSource = new TaskCompletionSource <>(signInCancellationSource .getToken ());
228
239
229
- this .signInTaskCompletionSource = new TaskCompletionSource <>();
230
240
Context context = firebaseApp .getApplicationContext ();
231
241
AlertDialog alertDialog = getSignInAlertDialog (context );
232
242
alertDialog .show ();
@@ -236,7 +246,7 @@ public Task<Void> signInTester() {
236
246
237
247
private void setSignInTaskCompletionError (FirebaseAppDistributionException e ) {
238
248
if (signInTaskCompletionSource != null && !signInTaskCompletionSource .getTask ().isComplete ()) {
239
- this . signInTaskCompletionSource .setException (e );
249
+ signInTaskCompletionSource .setException (e );
240
250
}
241
251
}
242
252
0 commit comments