public interface

AppSearchEnvironment

 androidx.appsearch.app.AppSearchEnvironment

Subclasses:

JetpackAppSearchEnvironment

Gradle dependencies

compile group: 'androidx.appsearch', name: 'appsearch', version: '1.1.0-alpha05'

  • groupId: androidx.appsearch
  • artifactId: appsearch
  • version: 1.1.0-alpha05

Artifact androidx.appsearch:appsearch:1.1.0-alpha05 it located at Google repository (https://maven.google.com/)

Overview

An interface which exposes environment specific methods for AppSearch.

Summary

Methods
public java.util.concurrent.ExecutorServicecreateCachedThreadPoolExecutor()

Creates and returns an Executor with cached thread pools.

public ContextcreateContextAsUser(Context context, UserHandle userHandle)

Returns the correct context for the user based on the environment.

public java.util.concurrent.ExecutorServicecreateExecutorService(int corePoolSize, int maxConcurrency, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, int priority)

Returns an ExecutorService based on given parameters.

public java.util.concurrent.ExecutorServicecreateSingleThreadExecutor()

Returns an ExecutorService with a single thread.

public java.io.FilegetAppSearchDir(Context context, UserHandle userHandle)

Returns the directory to initialize appsearch based on the environment.

public java.io.FilegetCacheDir(Context context)

Returns a cache directory for creating temporary files like in case of migrating documents.

public booleanisInfoLoggingEnabled()

Returns if we can log INFO level logs.

Methods

public java.io.File getAppSearchDir(Context context, UserHandle userHandle)

Returns the directory to initialize appsearch based on the environment.

public Context createContextAsUser(Context context, UserHandle userHandle)

Returns the correct context for the user based on the environment.

public java.util.concurrent.ExecutorService createExecutorService(int corePoolSize, int maxConcurrency, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, int priority)

Returns an ExecutorService based on given parameters.

public java.util.concurrent.ExecutorService createSingleThreadExecutor()

Returns an ExecutorService with a single thread.

public java.util.concurrent.ExecutorService createCachedThreadPoolExecutor()

Creates and returns an Executor with cached thread pools.

public java.io.File getCacheDir(Context context)

Returns a cache directory for creating temporary files like in case of migrating documents.

public boolean isInfoLoggingEnabled()

Returns if we can log INFO level logs.

Source

/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.appsearch.app;

import android.content.Context;
import android.os.UserHandle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

import java.io.File;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * An interface which exposes environment specific methods for AppSearch.
 *
 * @exportToFramework:hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public interface AppSearchEnvironment {

    /** Returns the directory to initialize appsearch based on the environment. */
    @NonNull
    File getAppSearchDir(@NonNull Context context, @Nullable UserHandle userHandle);

    /** Returns the correct context for the user based on the environment. */
    @NonNull
    Context createContextAsUser(@NonNull Context context, @NonNull UserHandle userHandle);

    /** Returns an ExecutorService based on given parameters. */
    @NonNull
    ExecutorService createExecutorService(
            int corePoolSize,
            int maxConcurrency,
            long keepAliveTime,
            @NonNull TimeUnit unit,
            @NonNull BlockingQueue<Runnable> workQueue,
            int priority);

    /** Returns an ExecutorService with a single thread. */
    @NonNull
    ExecutorService createSingleThreadExecutor();

    /** Creates and returns an Executor with cached thread pools. */
    @NonNull
    ExecutorService createCachedThreadPoolExecutor();

    /**
     * Returns a cache directory for creating temporary files like in case of migrating documents.
     */
    @Nullable
    File getCacheDir(@NonNull Context context);

    /** Returns if we can log INFO level logs. */
    boolean isInfoLoggingEnabled();
}