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

Commit 8c46bba9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "AssistContentRequester move binder call to background thread." into sc-dev

parents 49cb49b1 243fbd3e
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public class AssistContentRequester {
    private final IActivityTaskManager mActivityTaskManager;
    private final String mPackageName;
    private final Executor mCallbackExecutor;
    private final Executor mSystemInteractionExecutor;

    // If system loses the callback, our internal cache of original callback will also get cleared.
    private final Map<Object, Callback> mPendingCallbacks =
@@ -63,6 +64,7 @@ public class AssistContentRequester {
        mActivityTaskManager = ActivityTaskManager.getService();
        mPackageName = context.getApplicationContext().getPackageName();
        mCallbackExecutor = Executors.MAIN_EXECUTOR;
        mSystemInteractionExecutor = Executors.UI_HELPER_EXECUTOR;
    }

    /**
@@ -71,13 +73,16 @@ public class AssistContentRequester {
     * @param taskId to query for the content.
     * @param callback to call when the content is available, called on the main thread.
     */
    public void requestAssistContent(int taskId, Callback callback) {
    public void requestAssistContent(final int taskId, final Callback callback) {
        // ActivityTaskManager interaction here is synchronous, so call off the main thread.
        mSystemInteractionExecutor.execute(() -> {
            try {
                mActivityTaskManager.requestAssistDataForTask(
                        new AssistDataReceiver(callback, this), taskId, mPackageName);
            } catch (RemoteException e) {
                Log.e(TAG, "Requesting assist content failed for task: " + taskId, e);
            }
        });
    }

    private void executeOnMainExecutor(Runnable callback) {