diff options
| author | 2020-02-13 16:00:52 -0800 | |
|---|---|---|
| committer | 2020-02-13 17:15:56 -0800 | |
| commit | b5d87a86957bf8db38255036f1c6b2701707861c (patch) | |
| tree | 64fc8e8c2e116881bef236e3864223bd1c0e4816 | |
| parent | 6988e11c8d131ae3fc006cde016a37e39645b4c0 (diff) | |
Pass Activity LocusContext to the Content Capture.
Bug: 147750355
Test: manual
Change-Id: Ic739318ac5a38f5c251da433ffc054a57e4123c1
| -rw-r--r-- | core/java/android/app/Activity.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 2319dd2c168f..395a196420fa 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -126,6 +126,7 @@ import android.view.autofill.AutofillManager; import android.view.autofill.AutofillManager.AutofillClient; import android.view.autofill.AutofillPopupWindow; import android.view.autofill.IAutofillWindowPresenter; +import android.view.contentcapture.ContentCaptureContext; import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient; import android.widget.AdapterView; @@ -1056,7 +1057,10 @@ public class Activity extends ContextThemeWrapper } catch (RemoteException re) { re.rethrowFromSystemServer(); } - // TODO(b/147750355): Pass locusId and bundle to the Content Capture. + // If locusId is not null pass it to the Content Capture. + if (locusId != null) { + setLocusContextToContentCapture(locusId, bundle); + } } /** Return the application that owns this activity. */ @@ -1209,6 +1213,19 @@ public class Activity extends ContextThemeWrapper } } + private void setLocusContextToContentCapture(LocusId locusId, @Nullable Bundle bundle) { + final ContentCaptureManager cm = getContentCaptureManager(); + if (cm == null) return; + + ContentCaptureContext.Builder contentCaptureContextBuilder = + new ContentCaptureContext.Builder(locusId); + if (bundle != null) { + contentCaptureContextBuilder.setExtras(bundle); + } + cm.getMainContentCaptureSession().setContentCaptureContext( + contentCaptureContextBuilder.build()); + } + @Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(newBase); |