blob: 379b7833150cfd10d312c96f8121de834c4b2eaa [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content.pm;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21import android.os.PatternMatcher;
Jeff Sharkey85f5f812013-10-07 10:16:12 -070022import android.util.Printer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023
24/**
25 * Holds information about a specific
26 * {@link android.content.ContentProvider content provider}. This is returned by
27 * {@link android.content.pm.PackageManager#resolveContentProvider(java.lang.String, int)
28 * PackageManager.resolveContentProvider()}.
29 */
30public final class ProviderInfo extends ComponentInfo
31 implements Parcelable {
Dianne Hackborn2af632f2009-07-08 14:56:37 -070032
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033 /** The name provider is published under content:// */
34 public String authority = null;
35
36 /** Optional permission required for read-only access this content
37 * provider. */
38 public String readPermission = null;
39
40 /** Optional permission required for read/write access this content
41 * provider. */
42 public String writePermission = null;
43
44 /** If true, additional permissions to specific Uris in this content
45 * provider can be granted, as per the
46 * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
47 * grantUriPermissions} attribute.
48 */
49 public boolean grantUriPermissions = false;
50
51 /**
52 * If non-null, these are the patterns that are allowed for granting URI
53 * permissions. Any URI that does not match one of these patterns will not
54 * allowed to be granted. If null, all URIs are allowed. The
55 * {@link PackageManager#GET_URI_PERMISSION_PATTERNS
56 * PackageManager.GET_URI_PERMISSION_PATTERNS} flag must be specified for
57 * this field to be filled in.
58 */
59 public PatternMatcher[] uriPermissionPatterns = null;
60
Dianne Hackborn2af632f2009-07-08 14:56:37 -070061 /**
62 * If non-null, these are path-specific permissions that are allowed for
63 * accessing the provider. Any permissions listed here will allow a
64 * holding client to access the provider, and the provider will check
65 * the URI it provides when making calls against the patterns here.
66 */
67 public PathPermission[] pathPermissions = null;
68
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 /** If true, this content provider allows multiple instances of itself
70 * to run in different process. If false, a single instances is always
71 * run in {@link #processName}. */
72 public boolean multiprocess = false;
73
74 /** Used to control initialization order of single-process providers
75 * running in the same process. Higher goes first. */
76 public int initOrder = 0;
Dianne Hackborn7d19e022012-08-07 19:12:33 -070077
78 /**
Todd Kennedy7bc3a702016-12-08 14:54:48 -080079 * Bit in {@link #flags} indicating if the provider is visible to ephemeral applications.
80 * @hide
81 */
Todd Kennedyc05f5d12017-04-25 11:11:40 -070082 public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000;
Todd Kennedy7bc3a702016-12-08 14:54:48 -080083
84 /**
Dianne Hackborn7d19e022012-08-07 19:12:33 -070085 * Bit in {@link #flags}: If set, a single instance of the provider will
86 * run for all users on the device. Set from the
87 * {@link android.R.attr#singleUser} attribute.
88 */
89 public static final int FLAG_SINGLE_USER = 0x40000000;
90
91 /**
92 * Options that have been set in the provider declaration in the
93 * manifest.
94 * These include: {@link #FLAG_SINGLE_USER}.
95 */
96 public int flags = 0;
97
Fred Quintana718d8a22009-04-29 17:53:20 -070098 /**
99 * Whether or not this provider is syncable.
100 * @deprecated This flag is now being ignored. The current way to make a provider
101 * syncable is to provide a SyncAdapter service for a given provider/account type.
102 */
Dianne Hackborn4a51c202009-08-21 15:14:02 -0700103 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 public boolean isSyncable = false;
105
106 public ProviderInfo() {
107 }
108
109 public ProviderInfo(ProviderInfo orig) {
110 super(orig);
111 authority = orig.authority;
112 readPermission = orig.readPermission;
113 writePermission = orig.writePermission;
114 grantUriPermissions = orig.grantUriPermissions;
115 uriPermissionPatterns = orig.uriPermissionPatterns;
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700116 pathPermissions = orig.pathPermissions;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 multiprocess = orig.multiprocess;
118 initOrder = orig.initOrder;
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700119 flags = orig.flags;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 isSyncable = orig.isSyncable;
121 }
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700122
123 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800124 dump(pw, prefix, DUMP_FLAG_ALL);
125 }
126
127 /** @hide */
Yohei Yukawa8f272172017-08-31 00:26:01 -0700128 public void dump(Printer pw, String prefix, int dumpFlags) {
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700129 super.dumpFront(pw, prefix);
130 pw.println(prefix + "authority=" + authority);
131 pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
Yohei Yukawa8f272172017-08-31 00:26:01 -0700132 super.dumpBack(pw, prefix, dumpFlags);
Jeff Sharkey85f5f812013-10-07 10:16:12 -0700133 }
134
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800135 public int describeContents() {
136 return 0;
137 }
138
139 @Override public void writeToParcel(Parcel out, int parcelableFlags) {
140 super.writeToParcel(out, parcelableFlags);
141 out.writeString(authority);
142 out.writeString(readPermission);
143 out.writeString(writePermission);
144 out.writeInt(grantUriPermissions ? 1 : 0);
145 out.writeTypedArray(uriPermissionPatterns, parcelableFlags);
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700146 out.writeTypedArray(pathPermissions, parcelableFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 out.writeInt(multiprocess ? 1 : 0);
148 out.writeInt(initOrder);
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700149 out.writeInt(flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150 out.writeInt(isSyncable ? 1 : 0);
151 }
152
153 public static final Parcelable.Creator<ProviderInfo> CREATOR
154 = new Parcelable.Creator<ProviderInfo>() {
155 public ProviderInfo createFromParcel(Parcel in) {
156 return new ProviderInfo(in);
157 }
158
159 public ProviderInfo[] newArray(int size) {
160 return new ProviderInfo[size];
161 }
162 };
163
164 public String toString() {
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700165 return "ContentProviderInfo{name=" + authority + " className=" + name + "}";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800166 }
167
168 private ProviderInfo(Parcel in) {
169 super(in);
170 authority = in.readString();
171 readPermission = in.readString();
172 writePermission = in.readString();
173 grantUriPermissions = in.readInt() != 0;
174 uriPermissionPatterns = in.createTypedArray(PatternMatcher.CREATOR);
Dianne Hackborn2af632f2009-07-08 14:56:37 -0700175 pathPermissions = in.createTypedArray(PathPermission.CREATOR);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800176 multiprocess = in.readInt() != 0;
177 initOrder = in.readInt();
Dianne Hackborn7d19e022012-08-07 19:12:33 -0700178 flags = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 isSyncable = in.readInt() != 0;
180 }
181}