Fixed OneTimeListener so AUTOFILL_SAVE_UI metric is properly saved.

Test: adb shell logcat -b events | grep sysui
Test: atest CtsAutoFillServiceTestCases # to make sure it didn't break anything

Fixes: 112315388

Change-Id: Iecf374578b33a4fcfa84fe4f07613e05c9777fa9
(cherry picked from commit 373d49ebe8)
This commit is contained in:
Felipe Leme
2018-08-07 12:36:35 -07:00
parent 726df7efc9
commit fcb10a09da

View File

@@ -81,6 +81,13 @@ final class SaveUi {
void onDestroy();
}
/**
* Wrapper that guarantees that only one callback is triggered by ignoring further calls after
* it's destroyed.
*
* <p>It's needed becase {@link #onCancel(IntentSender)} is always called when the Save UI
* dialog is dismissed.
*/
private class OneTimeListener implements OnSaveListener {
private final OnSaveListener mRealListener;
@@ -96,7 +103,6 @@ final class SaveUi {
if (mDone) {
return;
}
mDone = true;
mRealListener.onSave();
}
@@ -106,7 +112,6 @@ final class SaveUi {
if (mDone) {
return;
}
mDone = true;
mRealListener.onCancel(listener);
}