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

Commit 5f46e0ff authored by Shashwat Razdan's avatar Shashwat Razdan Committed by Android (Google) Code Review
Browse files

Merge "Callback screenshot to getContextualSearchState if token refresh is enabled." into main

parents 2a506a65 291b5d66
Loading
Loading
Loading
Loading
+18 −5
Original line number Original line Diff line number Diff line
@@ -466,12 +466,25 @@ public class ContextualSearchManagerService extends SystemService {
                issueToken();
                issueToken();
                Bundle bundle = new Bundle();
                Bundle bundle = new Bundle();
                bundle.putParcelable(ContextualSearchManager.EXTRA_TOKEN, mToken);
                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 {
                    try {
                        callback.onResult(
                        callback.onResult(
                            new ContextualSearchState(null, null, bundle));
                            new ContextualSearchState(null, null, bundle));
                    } catch (RemoteException e) {
                    } catch (RemoteException e) {
                        Log.e(TAG, "Error invoking ContextualSearchCallback", e);
                        Log.e(TAG, "Error invoking ContextualSearchCallback", e);
                    }
                    }
                });
            }
            }
            synchronized (mLock) {
            synchronized (mLock) {
                mStateCallback = callback;
                mStateCallback = callback;