1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Copyright (C) 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 com.android.server.appsearch.visibilitystore;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.appsearch.AppSearchSchema;
import android.app.appsearch.GenericDocument;
/** Holds the visibility settings that apply to a package's databases. */
class VisibilityDocument extends GenericDocument {
/** Schema type for documents that hold AppSearch's metadata, e.g. visibility settings */
public static final String SCHEMA_TYPE = "VisibilityType";
/**
* Property that holds the list of platform-hidden schemas, as part of the visibility settings.
*/
private static final String NOT_PLATFORM_SURFACEABLE_PROPERTY = "notPlatformSurfaceable";
/** Property that holds nested documents of package accessible schemas. */
private static final String PACKAGE_ACCESSIBLE_PROPERTY = "packageAccessible";
/**
* Schema for the VisibilityStore's documents.
*
* <p>NOTE: If you update this, also update
* {@link com.android.server.appsearch.external.localstorage.VisibilityStore#SCHEMA_VERSION}
*/
public static final AppSearchSchema SCHEMA = new AppSearchSchema.Builder(SCHEMA_TYPE)
.addProperty(new AppSearchSchema.StringPropertyConfig.Builder(
NOT_PLATFORM_SURFACEABLE_PROPERTY)
.setCardinality(AppSearchSchema.PropertyConfig.CARDINALITY_REPEATED)
.build())
.addProperty(new AppSearchSchema.DocumentPropertyConfig.Builder(
PACKAGE_ACCESSIBLE_PROPERTY, PackageAccessibleDocument.SCHEMA_TYPE)
.setCardinality(AppSearchSchema.PropertyConfig.CARDINALITY_REPEATED)
.build())
.build();
public VisibilityDocument(@NonNull GenericDocument genericDocument) {
super(genericDocument);
}
@Nullable
public String[] getNotPlatformSurfaceableSchemas() {
return getPropertyStringArray(NOT_PLATFORM_SURFACEABLE_PROPERTY);
}
@Nullable
public GenericDocument[] getPackageAccessibleSchemas() {
return getPropertyDocumentArray(PACKAGE_ACCESSIBLE_PROPERTY);
}
/** Builder for {@link VisibilityDocument}. */
public static class Builder extends GenericDocument.Builder<VisibilityDocument.Builder> {
public Builder(@NonNull String namespace, @NonNull String id) {
super(namespace, id, SCHEMA_TYPE);
}
/** Sets which prefixed schemas have opted out of platform surfacing. */
@NonNull
public Builder setSchemasNotPlatformSurfaceable(
@NonNull String[] notPlatformSurfaceableSchemas) {
return setPropertyString(
NOT_PLATFORM_SURFACEABLE_PROPERTY, notPlatformSurfaceableSchemas);
}
/** Sets which prefixed schemas have configured package access. */
@NonNull
public Builder setPackageAccessibleSchemas(
@NonNull PackageAccessibleDocument[] packageAccessibleSchemas) {
return setPropertyDocument(PACKAGE_ACCESSIBLE_PROPERTY, packageAccessibleSchemas);
}
}
}
|