Merge "Don't log TYPE_DATASET_SELECTED on dataset authentication." into oc-mr1-dev

This commit is contained in:
TreeHugger Robot
2017-09-09 09:04:39 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 16 deletions

View File

@@ -22,8 +22,7 @@ import android.content.IntentSender;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.view.autofill.AutofillId; import android.view.autofill.AutofillManager;
import android.widget.RemoteViews;
import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions;
@@ -81,7 +80,7 @@ public final class FillEventHistory implements Parcelable {
/** /**
* Returns the client state set in the previous {@link FillResponse}. * Returns the client state set in the previous {@link FillResponse}.
* *
* <p><b>NOTE: </b>the state is associated with the app that was autofilled in the previous * <p><b>Note: </b>the state is associated with the app that was autofilled in the previous
* {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)} * {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)}
* , which is not necessary the same app being autofilled now. * , which is not necessary the same app being autofilled now.
*/ */
@@ -148,6 +147,14 @@ public final class FillEventHistory implements Parcelable {
public static final class Event { public static final class Event {
/** /**
* A dataset was selected. The dataset selected can be read from {@link #getDatasetId()}. * A dataset was selected. The dataset selected can be read from {@link #getDatasetId()}.
*
* <p><b>Note: </b>on Android {@link android.os.Build.VERSION_CODES#O}, this event was also
* incorrectly reported after a
* {@link Dataset.Builder#setAuthentication(IntentSender) dataset authentication} was
* selected and the service returned a dataset in the
* {@link AutofillManager#EXTRA_AUTHENTICATION_RESULT} of the activity launched from that
* {@link IntentSender}. This behavior was fixed on Android
* {@link android.os.Build.VERSION_CODES#O_MR1}.
*/ */
public static final int TYPE_DATASET_SELECTED = 0; public static final int TYPE_DATASET_SELECTED = 0;
@@ -158,8 +165,8 @@ public final class FillEventHistory implements Parcelable {
public static final int TYPE_DATASET_AUTHENTICATION_SELECTED = 1; public static final int TYPE_DATASET_AUTHENTICATION_SELECTED = 1;
/** /**
* A {@link FillResponse.Builder#setAuthentication(AutofillId[], IntentSender, RemoteViews) * A {@link FillResponse.Builder#setAuthentication(android.view.autofill.AutofillId[],
* fill response authentication} was selected. * IntentSender, android.widget.RemoteViews) fill response authentication} was selected.
*/ */
public static final int TYPE_AUTHENTICATION_SELECTED = 2; public static final int TYPE_AUTHENTICATION_SELECTED = 2;

View File

@@ -533,9 +533,9 @@ final class AutofillManagerServiceImpl {
/** /**
* Updates the last fill selection when an dataset authentication was selected. * Updates the last fill selection when an dataset authentication was selected.
*/ */
void setDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId) { void logDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId) {
synchronized (mLock) { synchronized (mLock) {
if (isValidEventLocked("setDatasetAuthenticationSelected()", sessionId)) { if (isValidEventLocked("logDatasetAuthenticationSelected()", sessionId)) {
mEventHistory.addEvent( mEventHistory.addEvent(
new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset)); new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset));
} }
@@ -545,9 +545,9 @@ final class AutofillManagerServiceImpl {
/** /**
* Updates the last fill selection when an save Ui is shown. * Updates the last fill selection when an save Ui is shown.
*/ */
void setSaveShown(int sessionId) { void logSaveShown(int sessionId) {
synchronized (mLock) { synchronized (mLock) {
if (isValidEventLocked("setSaveShown()", sessionId)) { if (isValidEventLocked("logSaveShown()", sessionId)) {
mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null)); mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null));
} }
} }
@@ -556,7 +556,7 @@ final class AutofillManagerServiceImpl {
/** /**
* Updates the last fill response when a dataset was selected. * Updates the last fill response when a dataset was selected.
*/ */
void setDatasetSelected(@Nullable String selectedDataset, int sessionId) { void logDatasetSelected(@Nullable String selectedDataset, int sessionId) {
synchronized (mLock) { synchronized (mLock) {
if (isValidEventLocked("setDatasetSelected()", sessionId)) { if (isValidEventLocked("setDatasetSelected()", sessionId)) {
mEventHistory.addEvent(new Event(Event.TYPE_DATASET_SELECTED, selectedDataset)); mEventHistory.addEvent(new Event(Event.TYPE_DATASET_SELECTED, selectedDataset));

View File

@@ -609,7 +609,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return; return;
} }
} }
mHandlerCaller.getHandler().post(() -> autoFill(requestId, datasetIndex, dataset)); mHandlerCaller.getHandler().post(() -> autoFill(requestId, datasetIndex, dataset, true));
} }
// AutoFillUiCallback // AutoFillUiCallback
@@ -747,7 +747,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (datasetIdx != AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED) { if (datasetIdx != AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED) {
final Dataset dataset = (Dataset) result; final Dataset dataset = (Dataset) result;
authenticatedResponse.getDatasets().set(datasetIdx, dataset); authenticatedResponse.getDatasets().set(datasetIdx, dataset);
autoFill(requestId, datasetIdx, dataset); autoFill(requestId, datasetIdx, dataset, false);
} }
} else { } else {
if (result != null) { if (result != null) {
@@ -967,7 +967,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
} }
if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!"); if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!");
mService.setSaveShown(id); mService.logSaveShown(id);
final IAutoFillManagerClient client = getClient(); final IAutoFillManagerClient client = getClient();
mPendingSaveUi = new PendingUi(mActivityToken, id, client); mPendingSaveUi = new PendingUi(mActivityToken, id, client);
getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo, getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo,
@@ -1536,7 +1536,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return viewState; return viewState;
} }
void autoFill(int requestId, int datasetIndex, Dataset dataset) { void autoFill(int requestId, int datasetIndex, Dataset dataset, boolean generateEvent) {
synchronized (mLock) { synchronized (mLock) {
if (mDestroyed) { if (mDestroyed) {
Slog.w(TAG, "Call to Session#autoFill() rejected - session: " Slog.w(TAG, "Call to Session#autoFill() rejected - session: "
@@ -1545,14 +1545,16 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
} }
// Autofill it directly... // Autofill it directly...
if (dataset.getAuthentication() == null) { if (dataset.getAuthentication() == null) {
mService.setDatasetSelected(dataset.getId(), id); if (generateEvent) {
mService.logDatasetSelected(dataset.getId(), id);
}
autoFillApp(dataset); autoFillApp(dataset);
return; return;
} }
// ...or handle authentication. // ...or handle authentication.
mService.setDatasetAuthenticationSelected(dataset.getId(), id); mService.logDatasetAuthenticationSelected(dataset.getId(), id);
setViewStatesLocked(null, dataset, ViewState.STATE_WAITING_DATASET_AUTH, false); setViewStatesLocked(null, dataset, ViewState.STATE_WAITING_DATASET_AUTH, false);
final Intent fillInIntent = createAuthFillInIntentLocked(requestId, mClientState); final Intent fillInIntent = createAuthFillInIntentLocked(requestId, mClientState);