diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java index 4357905f03714..0089c6dc8d2e1 100644 --- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java +++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java @@ -30,8 +30,6 @@ import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.util.ArraySet; -import com.android.internal.infra.AndroidFuture; - import java.io.Closeable; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -43,6 +41,7 @@ import java.io.IOException; import java.util.List; import java.util.Objects; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; /** @@ -95,7 +94,7 @@ public class AppSearchMigrationHelper implements Closeable { File queryFile = File.createTempFile(/*prefix=*/"appsearch", /*suffix=*/null); try (ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(queryFile, MODE_WRITE_ONLY)) { - AndroidFuture> androidFuture = new AndroidFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); mService.writeQueryResultsToFile(mPackageName, mDatabaseName, fileDescriptor, /*queryExpression=*/ "", @@ -106,11 +105,11 @@ public class AppSearchMigrationHelper implements Closeable { mUserId, new IAppSearchResultCallback.Stub() { @Override - public void onResult(AppSearchResult result) throws RemoteException { - androidFuture.complete(result); + public void onResult(AppSearchResult result) { + future.complete(result); } }); - AppSearchResult result = androidFuture.get(); + AppSearchResult result = future.get(); if (!result.isSuccess()) { throw new AppSearchException(result.getResultCode(), result.getErrorMessage()); } @@ -142,15 +141,15 @@ public class AppSearchMigrationHelper implements Closeable { } try (ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(mMigratedFile, MODE_READ_ONLY)) { - AndroidFuture>> androidFuture = new AndroidFuture<>(); + CompletableFuture>> future = new CompletableFuture<>(); mService.putDocumentsFromFile(mPackageName, mDatabaseName, fileDescriptor, mUserId, new IAppSearchResultCallback.Stub() { @Override - public void onResult(AppSearchResult result) throws RemoteException { - androidFuture.complete(result); + public void onResult(AppSearchResult result) { + future.complete(result); } }); - AppSearchResult> result = androidFuture.get(); + AppSearchResult> result = future.get(); if (!result.isSuccess()) { return AppSearchResult.newFailedResult(result); } diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java index 1e0d205230ca3..64ac63c2b8499 100644 --- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java +++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java @@ -28,7 +28,6 @@ import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; -import com.android.internal.infra.AndroidFuture; import com.android.internal.util.Preconditions; import java.io.Closeable; @@ -37,6 +36,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; @@ -708,8 +708,8 @@ public final class AppSearchSession implements Closeable { try { // Migration process // 1. Validate and retrieve all active migrators. - AndroidFuture> getSchemaFuture = - new AndroidFuture<>(); + CompletableFuture> getSchemaFuture = + new CompletableFuture<>(); getSchema(callbackExecutor, getSchemaFuture::complete); AppSearchResult getSchemaResult = getSchemaFuture.get(); if (!getSchemaResult.isSuccess()) { @@ -733,7 +733,8 @@ public final class AppSearchSession implements Closeable { // 2. SetSchema with forceOverride=false, to retrieve the list of // incompatible/deleted types. - AndroidFuture> setSchemaFuture = new AndroidFuture<>(); + CompletableFuture> setSchemaFuture = + new CompletableFuture<>(); mService.setSchema( mPackageName, mDatabaseName, @@ -781,8 +782,8 @@ public final class AppSearchSession implements Closeable { // failed. if (!setSchemaResponse.getIncompatibleTypes().isEmpty() || !setSchemaResponse.getDeletedTypes().isEmpty()) { - AndroidFuture> setSchema2Future = - new AndroidFuture<>(); + CompletableFuture> setSchema2Future = + new CompletableFuture<>(); // only trigger second setSchema() call if the first one is fail. mService.setSchema( mPackageName, diff --git a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl b/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl index 17f724b3a6f5a..507bd6884cde7 100644 --- a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl +++ b/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl @@ -17,14 +17,9 @@ package android.app.appsearch; import android.os.Bundle; -import android.app.appsearch.AppSearchBatchResult; -import android.app.appsearch.AppSearchResult; import android.app.appsearch.IAppSearchBatchResultCallback; import android.app.appsearch.IAppSearchResultCallback; import android.os.ParcelFileDescriptor; -import com.android.internal.infra.AndroidFuture; - -parcelable SearchResults; /** {@hide} */ interface IAppSearchManager {