Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 291b5d66 authored by Connie Huang's avatar Connie Huang
Browse files

Callback screenshot to getContextualSearchState if token refresh is enabled.

As proposed in go/l2a-css, return the screenshot to the
getContextualSearchState callback. This is gated by the
token refresh flag in preparation for merging to mainline.

Flag: EXEMPT Rewrite.
Bug: 338598282
Test: Tested on device and with CTS
Change-Id: I715fa72e7058223f10bc4f67cb95ff3459671a3e
parent 89d2efd2
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -466,12 +466,25 @@ public class ContextualSearchManagerService extends SystemService {
                issueToken();
                Bundle bundle = new Bundle();
                bundle.putParcelable(ContextualSearchManager.EXTRA_TOKEN, mToken);
                // We get take the screenshot with the system server's identity because the system
                // server has READ_FRAME_BUFFER permission to get the screenshot.
                Binder.withCleanCallingIdentity(() -> {
                    if (mWmInternal != null) {
                        bundle.putParcelable(ContextualSearchManager.EXTRA_SCREENSHOT,
                                mWmInternal.takeAssistScreenshot(Set.of(
                                        TYPE_STATUS_BAR,
                                        TYPE_NAVIGATION_BAR,
                                        TYPE_NAVIGATION_BAR_PANEL,
                                        TYPE_POINTER))
                                .asBitmap().asShared());
                    }
                    try {
                        callback.onResult(
                            new ContextualSearchState(null, null, bundle));
                    } catch (RemoteException e) {
                        Log.e(TAG, "Error invoking ContextualSearchCallback", e);
                    }
                });
            }
            synchronized (mLock) {
                mStateCallback = callback;