Merge "Fixed Cancellation for PendingAutofillRequest." into qt-dev

am: 99885212fa

Change-Id: Ifc84c7c92b4ea9690499c808945fbc3cb7f96792
This commit is contained in:
Adam He
2019-05-22 15:16:01 -07:00
committed by android-build-merger
2 changed files with 14 additions and 14 deletions

View File

@@ -228,7 +228,7 @@ public abstract class AugmentedAutofillService extends Service {
} else { } else {
// TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging // TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging
if (sDebug) Log.d(TAG, "Reusing proxy for session " + sessionId); if (sDebug) Log.d(TAG, "Reusing proxy for session " + sessionId);
proxy.update(focusedId, focusedValue, callback); proxy.update(focusedId, focusedValue, callback, cancellationSignal);
} }
try { try {
@@ -252,6 +252,15 @@ public abstract class AugmentedAutofillService extends Service {
Log.w(TAG, "No proxy for session " + sessionId); Log.w(TAG, "No proxy for session " + sessionId);
return; return;
} }
if (proxy.mCallback != null) {
try {
if (!proxy.mCallback.isCompleted()) {
proxy.mCallback.cancel();
}
} catch (Exception e) {
Log.e(TAG, "failed to check current pending request status", e);
}
}
proxy.destroy(); proxy.destroy();
} }
mAutofillProxies.clear(); mAutofillProxies.clear();
@@ -442,7 +451,7 @@ public abstract class AugmentedAutofillService extends Service {
} }
private void update(@NonNull AutofillId focusedId, @NonNull AutofillValue focusedValue, private void update(@NonNull AutofillId focusedId, @NonNull AutofillValue focusedValue,
@NonNull IFillCallback callback) { @NonNull IFillCallback callback, @NonNull CancellationSignal cancellationSignal) {
synchronized (mLock) { synchronized (mLock) {
mFocusedId = focusedId; mFocusedId = focusedId;
mFocusedValue = focusedValue; mFocusedValue = focusedValue;
@@ -457,6 +466,7 @@ public abstract class AugmentedAutofillService extends Service {
Log.d(TAG, "mCallback is updated."); Log.d(TAG, "mCallback is updated.");
} }
mCallback = callback; mCallback = callback;
mCancellationSignal = cancellationSignal;
} }
} }

View File

@@ -225,17 +225,7 @@ final class RemoteAugmentedAutofillService
@Override @Override
public void cancel() { public void cancel() {
synchronized (mLock) { PendingAutofillRequest.this.cancel();
final boolean cancelled = isCancelledLocked();
final ICancellationSignal cancellation = mCancellation;
if (!cancelled) {
try {
cancellation.cancel();
} catch (RemoteException e) {
Slog.e(mTag, "Error requesting a cancellation", e);
}
}
}
} }
}; };
} }
@@ -304,7 +294,7 @@ final class RemoteAugmentedAutofillService
try { try {
cancellation.cancel(); cancellation.cancel();
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(mTag, "Error cancelling a fill request", e); Slog.e(mTag, "Error cancelling an augmented fill request", e);
} }
} }
return true; return true;