Change API names and constants by API review

Bug: 179814121
Test: atest FillEventHistoryTest
Test: atest InlineFillEventHistoryTest
Change-Id: Iae9109e57842cda15cc3b11ec3c18e57d6ffea2c
This commit is contained in:
lpeter
2021-04-19 16:57:26 +08:00
parent b1474958c7
commit 13d028d884
4 changed files with 42 additions and 41 deletions

View File

@@ -37754,16 +37754,16 @@ package android.service.autofill {
method @NonNull public java.util.Map<android.view.autofill.AutofillId,android.service.autofill.FieldClassification> getFieldsClassification();
method @NonNull public java.util.Set<java.lang.String> getIgnoredDatasetIds();
method @NonNull public java.util.Map<android.view.autofill.AutofillId,java.util.Set<java.lang.String>> getManuallyEnteredField();
method public int getNoSaveReason();
method public int getNoSaveUiReason();
method @NonNull public java.util.Set<java.lang.String> getSelectedDatasetIds();
method public int getType();
field public static final int NO_SAVE_REASON_DATASET_MATCH = 6; // 0x6
field public static final int NO_SAVE_REASON_FIELD_VALIDATION_FAILED = 5; // 0x5
field public static final int NO_SAVE_REASON_HAS_EMPTY_REQUIRED = 3; // 0x3
field public static final int NO_SAVE_REASON_NONE = 0; // 0x0
field public static final int NO_SAVE_REASON_NO_SAVE_INFO = 1; // 0x1
field public static final int NO_SAVE_REASON_NO_VALUE_CHANGED = 4; // 0x4
field public static final int NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG = 2; // 0x2
field public static final int NO_SAVE_UI_REASON_DATASET_MATCH = 6; // 0x6
field public static final int NO_SAVE_UI_REASON_FIELD_VALIDATION_FAILED = 5; // 0x5
field public static final int NO_SAVE_UI_REASON_HAS_EMPTY_REQUIRED = 3; // 0x3
field public static final int NO_SAVE_UI_REASON_NONE = 0; // 0x0
field public static final int NO_SAVE_UI_REASON_NO_SAVE_INFO = 1; // 0x1
field public static final int NO_SAVE_UI_REASON_NO_VALUE_CHANGED = 4; // 0x4
field public static final int NO_SAVE_UI_REASON_WITH_DELAY_SAVE_FLAG = 2; // 0x2
field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
field public static final int TYPE_CONTEXT_COMMITTED = 4; // 0x4
field public static final int TYPE_DATASETS_SHOWN = 5; // 0x5

View File

@@ -245,35 +245,35 @@ public final class FillEventHistory implements Parcelable {
@interface EventIds{}
/** No reason for save dialog. */
public static final int NO_SAVE_REASON_NONE = 0;
public static final int NO_SAVE_UI_REASON_NONE = 0;
/** The SaveInfo associated with the FillResponse is null. */
public static final int NO_SAVE_REASON_NO_SAVE_INFO = 1;
public static final int NO_SAVE_UI_REASON_NO_SAVE_INFO = 1;
/** The service asked to delay save. */
public static final int NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG = 2;
public static final int NO_SAVE_UI_REASON_WITH_DELAY_SAVE_FLAG = 2;
/** There was empty value for required ids. */
public static final int NO_SAVE_REASON_HAS_EMPTY_REQUIRED = 3;
public static final int NO_SAVE_UI_REASON_HAS_EMPTY_REQUIRED = 3;
/** No value has been changed. */
public static final int NO_SAVE_REASON_NO_VALUE_CHANGED = 4;
public static final int NO_SAVE_UI_REASON_NO_VALUE_CHANGED = 4;
/** Fields failed validation. */
public static final int NO_SAVE_REASON_FIELD_VALIDATION_FAILED = 5;
public static final int NO_SAVE_UI_REASON_FIELD_VALIDATION_FAILED = 5;
/** All fields matched contents of datasets. */
public static final int NO_SAVE_REASON_DATASET_MATCH = 6;
public static final int NO_SAVE_UI_REASON_DATASET_MATCH = 6;
/** @hide */
@IntDef(prefix = { "NO_SAVE_REASON_" }, value = {
NO_SAVE_REASON_NONE,
NO_SAVE_REASON_NO_SAVE_INFO,
NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG,
NO_SAVE_REASON_HAS_EMPTY_REQUIRED,
NO_SAVE_REASON_NO_VALUE_CHANGED,
NO_SAVE_REASON_FIELD_VALIDATION_FAILED,
NO_SAVE_REASON_DATASET_MATCH
@IntDef(prefix = { "NO_SAVE_UI_REASON_" }, value = {
NO_SAVE_UI_REASON_NONE,
NO_SAVE_UI_REASON_NO_SAVE_INFO,
NO_SAVE_UI_REASON_WITH_DELAY_SAVE_FLAG,
NO_SAVE_UI_REASON_HAS_EMPTY_REQUIRED,
NO_SAVE_UI_REASON_NO_VALUE_CHANGED,
NO_SAVE_UI_REASON_FIELD_VALIDATION_FAILED,
NO_SAVE_UI_REASON_DATASET_MATCH
})
@Retention(RetentionPolicy.SOURCE)
public @interface NoSaveReason{}
@@ -488,11 +488,12 @@ public final class FillEventHistory implements Parcelable {
* Returns the reason why a save dialog was not shown.
*
* <p><b>Note: </b>Only set on events of type {@link #TYPE_CONTEXT_COMMITTED}. For the other
* event types, the reason is set to NO_SAVE_REASON_NONE.
* event types, the reason is set to NO_SAVE_UI_REASON_NONE.
*
* @return The reason why a save dialog was not shown.
*/
public int getNoSaveReason() {
@NoSaveReason
public int getNoSaveUiReason() {
return mSaveDialogNotShowReason;
}
@@ -533,7 +534,7 @@ public final class FillEventHistory implements Parcelable {
this(eventType, datasetId, clientState, selectedDatasetIds, ignoredDatasetIds,
changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
manuallyFilledDatasetIds, detectedFieldIds, detectedFieldClassifications,
NO_SAVE_REASON_NONE);
NO_SAVE_UI_REASON_NONE);
}
/**
@@ -599,7 +600,7 @@ public final class FillEventHistory implements Parcelable {
mDetectedFieldClassifications = detectedFieldClassifications;
mSaveDialogNotShowReason = Preconditions.checkArgumentInRange(saveDialogNotShowReason,
NO_SAVE_REASON_NONE, NO_SAVE_REASON_DATASET_MATCH,
NO_SAVE_UI_REASON_NONE, NO_SAVE_UI_REASON_DATASET_MATCH,
"saveDialogNotShowReason");
}

View File

@@ -431,7 +431,7 @@ final class AutofillManagerServiceImpl
final Session.SaveResult saveResult = session.showSaveLocked();
session.logContextCommitted(saveResult.getNoSaveReason());
session.logContextCommitted(saveResult.getNoSaveUiReason());
if (saveResult.isLogSaveShown()) {
session.logSaveUiShown();
@@ -876,7 +876,7 @@ final class AutofillManagerServiceImpl
changedFieldIds, changedDatasetIds, manuallyFilledFieldIds,
manuallyFilledDatasetIds, /* detectedFieldIdsList= */ null,
/* detectedFieldClassificationsList= */ null, appComponentName, compatMode,
Event.NO_SAVE_REASON_NONE);
Event.NO_SAVE_UI_REASON_NONE);
}
@GuardedBy("mLock")

View File

@@ -1772,7 +1772,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
*/
public void logContextCommitted() {
mHandler.sendMessage(obtainMessage(Session::handleLogContextCommitted, this,
Event.NO_SAVE_REASON_NONE));
Event.NO_SAVE_UI_REASON_NONE));
}
/**
@@ -2161,7 +2161,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
Slog.w(TAG, "Call to Session#showSaveLocked() rejected - session: "
+ id + " destroyed");
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ false,
Event.NO_SAVE_REASON_NONE);
Event.NO_SAVE_UI_REASON_NONE);
}
mSessionState = STATE_FINISHED;
final FillResponse response = getLastResponseLocked("showSaveLocked(%s)");
@@ -2180,14 +2180,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (saveInfo == null) {
if (sVerbose) Slog.v(TAG, "showSaveLocked(" + this.id + "): no saveInfo from service");
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
Event.NO_SAVE_REASON_NO_SAVE_INFO);
Event.NO_SAVE_UI_REASON_NO_SAVE_INFO);
}
if ((saveInfo.getFlags() & SaveInfo.FLAG_DELAY_SAVE) != 0) {
// TODO(b/113281366): log metrics
if (sDebug) Slog.v(TAG, "showSaveLocked(" + this.id + "): service asked to delay save");
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ false,
Event.NO_SAVE_REASON_WITH_DELAY_SAVE_FLAG);
Event.NO_SAVE_UI_REASON_WITH_DELAY_SAVE_FLAG);
}
final ArrayMap<AutofillId, InternalSanitizer> sanitizers = createSanitizers(saveInfo);
@@ -2281,7 +2281,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
int saveDialogNotShowReason;
if (!allRequiredAreNotEmpty) {
saveDialogNotShowReason = Event.NO_SAVE_REASON_HAS_EMPTY_REQUIRED;
saveDialogNotShowReason = Event.NO_SAVE_UI_REASON_HAS_EMPTY_REQUIRED;
} else {
// Must look up all optional ids in 2 scenarios:
// - if no required id changed but an optional id did, it should trigger save / update
@@ -2334,7 +2334,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
}
if (!atLeastOneChanged) {
saveDialogNotShowReason = Event.NO_SAVE_REASON_NO_VALUE_CHANGED;
saveDialogNotShowReason = Event.NO_SAVE_UI_REASON_NO_VALUE_CHANGED;
} else {
if (sDebug) {
Slog.d(TAG, "at least one field changed, validate fields for save UI");
@@ -2354,14 +2354,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
log.setType(MetricsEvent.TYPE_FAILURE);
mMetricsLogger.write(log);
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
Event.NO_SAVE_REASON_FIELD_VALIDATION_FAILED);
Event.NO_SAVE_UI_REASON_FIELD_VALIDATION_FAILED);
}
mMetricsLogger.write(log);
if (!isValid) {
Slog.i(TAG, "not showing save UI because fields failed validation");
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
Event.NO_SAVE_REASON_FIELD_VALIDATION_FAILED);
Event.NO_SAVE_UI_REASON_FIELD_VALIDATION_FAILED);
}
}
@@ -2401,7 +2401,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
+ "dataset #" + i + ": " + dataset);
}
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
Event.NO_SAVE_REASON_DATASET_MATCH);
Event.NO_SAVE_UI_REASON_DATASET_MATCH);
}
}
@@ -2422,7 +2422,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (serviceLabel == null || serviceIcon == null) {
wtf(null, "showSaveLocked(): no service label or icon");
return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
Event.NO_SAVE_REASON_NONE);
Event.NO_SAVE_UI_REASON_NONE);
}
getUiForShowing().showSaveUi(serviceLabel, serviceIcon,
@@ -2437,7 +2437,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
mSessionFlags.mShowingSaveUi = true;
return new SaveResult(/* logSaveShown= */ true, /* removeSession= */ false,
Event.NO_SAVE_REASON_NONE);
Event.NO_SAVE_UI_REASON_NONE);
}
}
// Nothing changed...
@@ -3880,7 +3880,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
* @return The reason why a save dialog was not shown.
*/
@NoSaveReason
public int getNoSaveReason() {
public int getNoSaveUiReason() {
return mSaveDialogNotShowReason;
}