Merge "Fix package access bug." into sc-dev

This commit is contained in:
Cassie Wang
2021-02-10 23:12:43 +00:00
committed by Android (Google) Code Review
3 changed files with 12 additions and 6 deletions

View File

@@ -108,7 +108,7 @@ public class AppSearchManagerService extends SystemService {
schemasPackageAccessibleBundles.entrySet()) {
List<PackageIdentifier> packageIdentifiers =
new ArrayList<>(entry.getValue().size());
for (int i = 0; i < packageIdentifiers.size(); i++) {
for (int i = 0; i < entry.getValue().size(); i++) {
packageIdentifiers.add(new PackageIdentifier(entry.getValue().get(i)));
}
schemasPackageAccessible.put(entry.getKey(), packageIdentifiers);

View File

@@ -317,7 +317,7 @@ public final class AppSearchImpl {
}
Map<String, List<PackageIdentifier>> prefixedSchemasPackageAccessible =
new ArrayMap<>(schemasNotPlatformSurfaceable.size());
new ArrayMap<>(schemasPackageAccessible.size());
for (Map.Entry<String, List<PackageIdentifier>> entry :
schemasPackageAccessible.entrySet()) {
prefixedSchemasPackageAccessible.put(prefix + entry.getKey(), entry.getValue());

View File

@@ -37,8 +37,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* This test class adapts the AppSearch Framework API to ListenableFuture, so it can be tested via
* a consistent interface.
* This test class adapts the AppSearch Framework API to ListenableFuture, so it can be tested via a
* consistent interface.
*
* @hide
*/
public class GlobalSearchSessionShimImpl implements GlobalSearchSessionShim {
@@ -47,7 +48,13 @@ public class GlobalSearchSessionShimImpl implements GlobalSearchSessionShim {
@NonNull
public static ListenableFuture<GlobalSearchSessionShim> createGlobalSearchSession() {
Context context = ApplicationProvider.getApplicationContext();
return createGlobalSearchSession(ApplicationProvider.getApplicationContext());
}
/** Only for use when called from a non-instrumented context. */
@NonNull
public static ListenableFuture<GlobalSearchSessionShim> createGlobalSearchSession(
@NonNull Context context) {
AppSearchManager appSearchManager = context.getSystemService(AppSearchManager.class);
SettableFuture<AppSearchResult<GlobalSearchSession>> future = SettableFuture.create();
ExecutorService executor = Executors.newCachedThreadPool();
@@ -62,7 +69,6 @@ public class GlobalSearchSessionShimImpl implements GlobalSearchSessionShim {
@NonNull GlobalSearchSession session, @NonNull ExecutorService executor) {
mGlobalSearchSession = Preconditions.checkNotNull(session);
mExecutor = Preconditions.checkNotNull(executor);
}
@NonNull