Merge "Autofill: Fix unsafe usages of mCurrentViewId related to Inline UI." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
87935f64d4
@@ -717,10 +717,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestConsumer =
|
Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestConsumer =
|
||||||
mAssistReceiver.newAutofillRequestLocked(/*isInlineRequest=*/ true);
|
mAssistReceiver.newAutofillRequestLocked(/*isInlineRequest=*/ true);
|
||||||
if (inlineSuggestionsRequestConsumer != null) {
|
if (inlineSuggestionsRequestConsumer != null) {
|
||||||
|
final AutofillId focusedId = mCurrentViewId;
|
||||||
remoteRenderService.getInlineSuggestionsRendererInfo(
|
remoteRenderService.getInlineSuggestionsRendererInfo(
|
||||||
new RemoteCallback((extras) -> {
|
new RemoteCallback((extras) -> {
|
||||||
mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
|
mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
|
||||||
mCurrentViewId, inlineSuggestionsRequestConsumer, extras);
|
focusedId, inlineSuggestionsRequestConsumer, extras);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -2786,6 +2787,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
*/
|
*/
|
||||||
private boolean requestShowInlineSuggestionsLocked(@NonNull FillResponse response,
|
private boolean requestShowInlineSuggestionsLocked(@NonNull FillResponse response,
|
||||||
@Nullable String filterText) {
|
@Nullable String filterText) {
|
||||||
|
if (mCurrentViewId == null) {
|
||||||
|
Log.w(TAG, "requestShowInlineSuggestionsLocked(): no view currently focused");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final AutofillId focusedId = mCurrentViewId;
|
||||||
|
|
||||||
final Optional<InlineSuggestionsRequest> inlineSuggestionsRequest =
|
final Optional<InlineSuggestionsRequest> inlineSuggestionsRequest =
|
||||||
mInlineSessionController.getInlineSuggestionsRequestLocked();
|
mInlineSessionController.getInlineSuggestionsRequestLocked();
|
||||||
if (!inlineSuggestionsRequest.isPresent()) {
|
if (!inlineSuggestionsRequest.isPresent()) {
|
||||||
@@ -2800,17 +2807,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ViewState currentView = mViewStates.get(mCurrentViewId);
|
final ViewState currentView = mViewStates.get(focusedId);
|
||||||
if ((currentView.getState() & ViewState.STATE_INLINE_DISABLED) != 0) {
|
if ((currentView.getState() & ViewState.STATE_INLINE_DISABLED) != 0) {
|
||||||
response.getDatasets().clear();
|
response.getDatasets().clear();
|
||||||
}
|
}
|
||||||
InlineSuggestionsResponse inlineSuggestionsResponse =
|
InlineSuggestionsResponse inlineSuggestionsResponse =
|
||||||
InlineSuggestionFactory.createInlineSuggestionsResponse(
|
InlineSuggestionFactory.createInlineSuggestionsResponse(
|
||||||
inlineSuggestionsRequest.get(), response, filterText, mCurrentViewId,
|
inlineSuggestionsRequest.get(), response, filterText, focusedId,
|
||||||
this, () -> {
|
this, () -> {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mInlineSessionController.hideInlineSuggestionsUiLocked(
|
mInlineSessionController.hideInlineSuggestionsUiLocked(
|
||||||
mCurrentViewId);
|
focusedId);
|
||||||
}
|
}
|
||||||
}, remoteRenderService);
|
}, remoteRenderService);
|
||||||
if (inlineSuggestionsResponse == null) {
|
if (inlineSuggestionsResponse == null) {
|
||||||
@@ -2818,7 +2825,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mInlineSessionController.onInlineSuggestionsResponseLocked(mCurrentViewId,
|
return mInlineSessionController.onInlineSuggestionsResponseLocked(focusedId,
|
||||||
inlineSuggestionsResponse);
|
inlineSuggestionsResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3107,19 +3114,19 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
remoteService.getComponentName().getPackageName());
|
remoteService.getComponentName().getPackageName());
|
||||||
mAugmentedRequestsLogs.add(log);
|
mAugmentedRequestsLogs.add(log);
|
||||||
|
|
||||||
final AutofillId focusedId = AutofillId.withoutSession(mCurrentViewId);
|
final AutofillId focusedId = mCurrentViewId;
|
||||||
|
|
||||||
final Consumer<InlineSuggestionsRequest> requestAugmentedAutofill =
|
final Consumer<InlineSuggestionsRequest> requestAugmentedAutofill =
|
||||||
(inlineSuggestionsRequest) -> {
|
(inlineSuggestionsRequest) -> {
|
||||||
remoteService.onRequestAutofillLocked(id, mClient, taskId, mComponentName,
|
remoteService.onRequestAutofillLocked(id, mClient, taskId, mComponentName,
|
||||||
focusedId,
|
AutofillId.withoutSession(focusedId),
|
||||||
currentValue, inlineSuggestionsRequest,
|
currentValue, inlineSuggestionsRequest,
|
||||||
/*inlineSuggestionsCallback=*/
|
/*inlineSuggestionsCallback=*/
|
||||||
response -> {
|
response -> {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
return mInlineSessionController
|
return mInlineSessionController
|
||||||
.onInlineSuggestionsResponseLocked(
|
.onInlineSuggestionsResponseLocked(
|
||||||
mCurrentViewId, response);
|
focusedId, response);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/*onErrorCallback=*/ () -> {
|
/*onErrorCallback=*/ () -> {
|
||||||
@@ -3144,7 +3151,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
remoteRenderService.getInlineSuggestionsRendererInfo(new RemoteCallback(
|
remoteRenderService.getInlineSuggestionsRendererInfo(new RemoteCallback(
|
||||||
(extras) -> {
|
(extras) -> {
|
||||||
mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
|
mInlineSessionController.onCreateInlineSuggestionsRequestLocked(
|
||||||
mCurrentViewId, /*requestConsumer=*/ requestAugmentedAutofill,
|
focusedId, /*requestConsumer=*/ requestAugmentedAutofill,
|
||||||
extras);
|
extras);
|
||||||
}, mHandler));
|
}, mHandler));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user