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

Commit 1b7a0d33 authored by Utkarsh Nigam's avatar Utkarsh Nigam Committed by Android (Google) Code Review
Browse files

Merge "Stop using thread pool for observing document changes." into main

parents 8b7bfe3c 2d480944
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@ import java.util.Objects;
import java.util.WeakHashMap;
import java.util.concurrent.CompletionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/** Implementation of the AppFunctionManagerService. */
public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
@@ -592,7 +593,9 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
                        .registerObserverCallbackAsync(
                                "android",
                                new ObserverSpec.Builder().build(),
                                THREAD_POOL_EXECUTOR,
                                // AppFunctionMetadataObserver implements a simple callback that
                                // does not block and should be safe to run on any thread.
                                Runnable::run,
                                appFunctionMetadataObserver)
                        .whenComplete(
                                (voidResult, ex) -> {
+14 −10
Original line number Diff line number Diff line
@@ -99,26 +99,30 @@ public class MetadataSyncAdapter {
     *     synchronization was successful.
     */
    public AndroidFuture<Boolean> submitSyncRequest() {
        AndroidFuture<Boolean> settableSyncStatus = new AndroidFuture<>();
        Runnable runnable =
                () -> {
                    SearchContext staticMetadataSearchContext =
                            new SearchContext.Builder(
                                AppFunctionStaticMetadataHelper.APP_FUNCTION_STATIC_METADATA_DB)
                                            AppFunctionStaticMetadataHelper
                                                    .APP_FUNCTION_STATIC_METADATA_DB)
                                    .build();
                    SearchContext runtimeMetadataSearchContext =
                            new SearchContext.Builder(
                                AppFunctionRuntimeMetadata.APP_FUNCTION_RUNTIME_METADATA_DB)
                                            AppFunctionRuntimeMetadata
                                                    .APP_FUNCTION_RUNTIME_METADATA_DB)
                                    .build();
        AndroidFuture<Boolean> settableSyncStatus = new AndroidFuture<>();
        Runnable runnable =
                () -> {
                    try (FutureAppSearchSession staticMetadataSearchSession =
                                    new FutureAppSearchSessionImpl(
                                            mAppSearchManager,
                                            AppFunctionExecutors.THREAD_POOL_EXECUTOR,
                                            // Fine to use Runnable::run as all the callback does is
                                            // set the result in the future.
                                            Runnable::run,
                                            staticMetadataSearchContext);
                            FutureAppSearchSession runtimeMetadataSearchSession =
                                    new FutureAppSearchSessionImpl(
                                            mAppSearchManager,
                                            AppFunctionExecutors.THREAD_POOL_EXECUTOR,
                                            Runnable::run,
                                            runtimeMetadataSearchContext)) {

                        trySyncAppFunctionMetadataBlocking(