|
46 | 46 | import com.google.firebase.appdistribution.UpdateStatus;
|
47 | 47 | import com.google.firebase.appdistribution.UpdateTask;
|
48 | 48 | import java.util.concurrent.Executor;
|
| 49 | +import java.util.concurrent.atomic.AtomicBoolean; |
49 | 50 |
|
50 | 51 | /**
|
51 | 52 | * This class is the "real" implementation of the Firebase App Distribution API which should only be
|
@@ -87,6 +88,8 @@ class FirebaseAppDistributionImpl implements FirebaseAppDistribution {
|
87 | 88 | private TaskCompletionSource<Void> showSignInDialogTask = null;
|
88 | 89 | private TaskCompletionSource<Void> showUpdateDialogTask = null;
|
89 | 90 |
|
| 91 | + private AtomicBoolean feedbackInProgress = new AtomicBoolean(false); |
| 92 | + |
90 | 93 | @VisibleForTesting
|
91 | 94 | FirebaseAppDistributionImpl(
|
92 | 95 | @NonNull FirebaseApp firebaseApp,
|
@@ -318,6 +321,12 @@ public void startFeedback(int infoTextResourceId) {
|
318 | 321 |
|
319 | 322 | @Override
|
320 | 323 | public void startFeedback(@NonNull CharSequence infoText) {
|
| 324 | + if (!feedbackInProgress.compareAndSet(/* expect= */ false, /* update= */ true)) { |
| 325 | + LogWrapper.getInstance() |
| 326 | + .i("Ignoring startFeedback() call because feedback is already in progress"); |
| 327 | + return; |
| 328 | + } |
| 329 | + LogWrapper.getInstance().i("Starting feedback"); |
321 | 330 | screenshotTaker
|
322 | 331 | .takeScreenshot()
|
323 | 332 | .addOnFailureListener(
|
@@ -349,7 +358,10 @@ public void startFeedback(@NonNull CharSequence infoText, @Nullable Uri screensh
|
349 | 358 | taskExecutor,
|
350 | 359 | releaseName -> launchFeedbackActivity(releaseName, infoText, screenshotUri))
|
351 | 360 | .addOnFailureListener(
|
352 |
| - taskExecutor, e -> LogWrapper.getInstance().e("Failed to launch feedback flow", e)); |
| 361 | + e -> { |
| 362 | + LogWrapper.getInstance().e("Failed to launch feedback flow", e); |
| 363 | + feedbackInProgress.set(false); |
| 364 | + }); |
353 | 365 | }
|
354 | 366 |
|
355 | 367 | private Task<Void> launchFeedbackActivity(
|
@@ -412,10 +424,13 @@ void onActivityDestroyed(@NonNull Activity activity) {
|
412 | 424 | dialogHostActivity = null;
|
413 | 425 | }
|
414 | 426 |
|
415 |
| - // If the feedback activity finishes, clean up the screenshot that was taken before starting |
416 |
| - // the activity. If this does not happen for some reason it will be cleaned up the next time |
417 |
| - // before taking a new screenshot. |
418 | 427 | if (activity instanceof FeedbackActivity) {
|
| 428 | + LogWrapper.getInstance().i("FeedbackActivity destroyed"); |
| 429 | + feedbackInProgress.set(false); |
| 430 | + |
| 431 | + // If the feedback activity finishes, clean up the screenshot that was taken before starting |
| 432 | + // the activity. If this does not happen for some reason it will be cleaned up the next time |
| 433 | + // before taking a new screenshot. |
419 | 434 | screenshotTaker.deleteScreenshot();
|
420 | 435 | }
|
421 | 436 | }
|
|
0 commit comments