public interface

VisibilityStore

 androidx.appsearch.localstorage.visibilitystore.VisibilityStore

Gradle dependencies

compile group: 'androidx.appsearch', name: 'appsearch-local-storage', version: '1.0.0-alpha04'

  • groupId: androidx.appsearch
  • artifactId: appsearch-local-storage
  • version: 1.0.0-alpha04

Artifact androidx.appsearch:appsearch-local-storage:1.0.0-alpha04 it located at Google repository (https://maven.google.com/)

Overview

An interface for classes that store and validate document visibility data.

Summary

Fields
public static final java.lang.StringDATABASE_NAME

public static final java.lang.StringPACKAGE_NAME

These cannot have any of the special characters used by AppSearchImpl (e.g.

Methods
public booleanisSchemaSearchableByCaller(java.lang.String packageName, java.lang.String databaseName, java.lang.String prefixedSchema, int callerUid, boolean callerHasSystemAccess)

Checks whether the given package has access to system-surfaceable schemas.

public voidsetVisibility(java.lang.String packageName, java.lang.String databaseName, java.util.Set<java.lang.String> schemasNotDisplayedBySystem, java.util.Map<java.lang.String, java.util.List> schemasVisibleToPackages)

Sets visibility settings for the given database.

Fields

public static final java.lang.String PACKAGE_NAME

These cannot have any of the special characters used by AppSearchImpl (e.g. AppSearchImpl#PACKAGE_DELIMITER or AppSearchImpl#DATABASE_DELIMITER.

public static final java.lang.String DATABASE_NAME

Methods

public void setVisibility(java.lang.String packageName, java.lang.String databaseName, java.util.Set<java.lang.String> schemasNotDisplayedBySystem, java.util.Map<java.lang.String, java.util.List> schemasVisibleToPackages)

Sets visibility settings for the given database. Any previous visibility settings will be overwritten.

Parameters:

packageName: Package of app that owns the schemas.
databaseName: Database that owns the schemas.
schemasNotDisplayedBySystem: Set of prefixed schemas that should be hidden from platform surfaces.
schemasVisibleToPackages: Map of prefixed schemas to a list of package identifiers that have access to the schema.

public boolean isSchemaSearchableByCaller(java.lang.String packageName, java.lang.String databaseName, java.lang.String prefixedSchema, int callerUid, boolean callerHasSystemAccess)

Checks whether the given package has access to system-surfaceable schemas.

Parameters:

callerUid: UID of the app that wants to see the data.

Source

/*
 * Copyright 2021 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.localstorage.visibilitystore;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.appsearch.app.PackageIdentifier;
import androidx.appsearch.exceptions.AppSearchException;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * An interface for classes that store and validate document visibility data.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public interface VisibilityStore {
    /**
     * These cannot have any of the special characters used by AppSearchImpl (e.g. {@code
     * AppSearchImpl#PACKAGE_DELIMITER} or {@code AppSearchImpl#DATABASE_DELIMITER}.
     */
    String PACKAGE_NAME = "VS#Pkg";

    @VisibleForTesting
    String DATABASE_NAME = "VS#Db";

    /**
     * Sets visibility settings for the given database. Any previous visibility settings will be
     * overwritten.
     *
     * @param packageName Package of app that owns the schemas.
     * @param databaseName Database that owns the schemas.
     * @param schemasNotDisplayedBySystem Set of prefixed schemas that should be hidden from
     *     platform surfaces.
     * @param schemasVisibleToPackages Map of prefixed schemas to a list of package identifiers that
     *     have access to the schema.
     * @throws AppSearchException on AppSearchImpl error.
     */
    void setVisibility(
            @NonNull String packageName,
            @NonNull String databaseName,
            @NonNull Set<String> schemasNotDisplayedBySystem,
            @NonNull Map<String, List<PackageIdentifier>> schemasVisibleToPackages)
            throws AppSearchException;

    /**
     * Checks whether the given package has access to system-surfaceable schemas.
     *
     * @param callerUid UID of the app that wants to see the data.
     */
    boolean isSchemaSearchableByCaller(
            @NonNull String packageName,
            @NonNull String databaseName,
            @NonNull String prefixedSchema,
            int callerUid,
            boolean callerHasSystemAccess);
}