The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.content.pm; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | import android.os.PatternMatcher; |
Jeff Sharkey | 85f5f81 | 2013-10-07 10:16:12 -0700 | [diff] [blame] | 22 | import android.util.Printer; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 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 | */ |
| 30 | public final class ProviderInfo extends ComponentInfo |
| 31 | implements Parcelable { |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 32 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | /** 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; |
Dianne Hackborn | 52e42a4 | 2019-02-05 16:10:50 -0800 | [diff] [blame] | 50 | |
| 51 | /** If true, always apply URI permission grants, as per the |
| 52 | * {@link android.R.styleable#AndroidManifestProvider_forceUriPermissions |
| 53 | * forceUriPermissions} attribute. |
| 54 | */ |
| 55 | public boolean forceUriPermissions = false; |
| 56 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | /** |
| 58 | * If non-null, these are the patterns that are allowed for granting URI |
| 59 | * permissions. Any URI that does not match one of these patterns will not |
| 60 | * allowed to be granted. If null, all URIs are allowed. The |
| 61 | * {@link PackageManager#GET_URI_PERMISSION_PATTERNS |
| 62 | * PackageManager.GET_URI_PERMISSION_PATTERNS} flag must be specified for |
| 63 | * this field to be filled in. |
| 64 | */ |
| 65 | public PatternMatcher[] uriPermissionPatterns = null; |
| 66 | |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 67 | /** |
| 68 | * If non-null, these are path-specific permissions that are allowed for |
| 69 | * accessing the provider. Any permissions listed here will allow a |
| 70 | * holding client to access the provider, and the provider will check |
| 71 | * the URI it provides when making calls against the patterns here. |
| 72 | */ |
| 73 | public PathPermission[] pathPermissions = null; |
| 74 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | /** If true, this content provider allows multiple instances of itself |
| 76 | * to run in different process. If false, a single instances is always |
| 77 | * run in {@link #processName}. */ |
| 78 | public boolean multiprocess = false; |
| 79 | |
| 80 | /** Used to control initialization order of single-process providers |
| 81 | * running in the same process. Higher goes first. */ |
| 82 | public int initOrder = 0; |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
Todd Kennedy | 7bc3a70 | 2016-12-08 14:54:48 -0800 | [diff] [blame] | 85 | * Bit in {@link #flags} indicating if the provider is visible to ephemeral applications. |
| 86 | * @hide |
| 87 | */ |
Todd Kennedy | c05f5d1 | 2017-04-25 11:11:40 -0700 | [diff] [blame] | 88 | public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000; |
Todd Kennedy | 7bc3a70 | 2016-12-08 14:54:48 -0800 | [diff] [blame] | 89 | |
| 90 | /** |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 91 | * Bit in {@link #flags}: If set, a single instance of the provider will |
| 92 | * run for all users on the device. Set from the |
| 93 | * {@link android.R.attr#singleUser} attribute. |
| 94 | */ |
| 95 | public static final int FLAG_SINGLE_USER = 0x40000000; |
| 96 | |
| 97 | /** |
| 98 | * Options that have been set in the provider declaration in the |
| 99 | * manifest. |
| 100 | * These include: {@link #FLAG_SINGLE_USER}. |
| 101 | */ |
| 102 | public int flags = 0; |
| 103 | |
Fred Quintana | 718d8a2 | 2009-04-29 17:53:20 -0700 | [diff] [blame] | 104 | /** |
| 105 | * Whether or not this provider is syncable. |
| 106 | * @deprecated This flag is now being ignored. The current way to make a provider |
| 107 | * syncable is to provide a SyncAdapter service for a given provider/account type. |
| 108 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 109 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | public boolean isSyncable = false; |
| 111 | |
| 112 | public ProviderInfo() { |
| 113 | } |
| 114 | |
| 115 | public ProviderInfo(ProviderInfo orig) { |
| 116 | super(orig); |
| 117 | authority = orig.authority; |
| 118 | readPermission = orig.readPermission; |
| 119 | writePermission = orig.writePermission; |
| 120 | grantUriPermissions = orig.grantUriPermissions; |
Dianne Hackborn | 52e42a4 | 2019-02-05 16:10:50 -0800 | [diff] [blame] | 121 | forceUriPermissions = orig.forceUriPermissions; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | uriPermissionPatterns = orig.uriPermissionPatterns; |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 123 | pathPermissions = orig.pathPermissions; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 124 | multiprocess = orig.multiprocess; |
| 125 | initOrder = orig.initOrder; |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 126 | flags = orig.flags; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | isSyncable = orig.isSyncable; |
| 128 | } |
Jeff Sharkey | 85f5f81 | 2013-10-07 10:16:12 -0700 | [diff] [blame] | 129 | |
| 130 | public void dump(Printer pw, String prefix) { |
Dianne Hackborn | 6ac42ae | 2015-12-08 17:22:10 -0800 | [diff] [blame] | 131 | dump(pw, prefix, DUMP_FLAG_ALL); |
| 132 | } |
| 133 | |
| 134 | /** @hide */ |
Yohei Yukawa | 8f27217 | 2017-08-31 00:26:01 -0700 | [diff] [blame] | 135 | public void dump(Printer pw, String prefix, int dumpFlags) { |
Jeff Sharkey | 85f5f81 | 2013-10-07 10:16:12 -0700 | [diff] [blame] | 136 | super.dumpFront(pw, prefix); |
| 137 | pw.println(prefix + "authority=" + authority); |
| 138 | pw.println(prefix + "flags=0x" + Integer.toHexString(flags)); |
Yohei Yukawa | 8f27217 | 2017-08-31 00:26:01 -0700 | [diff] [blame] | 139 | super.dumpBack(pw, prefix, dumpFlags); |
Jeff Sharkey | 85f5f81 | 2013-10-07 10:16:12 -0700 | [diff] [blame] | 140 | } |
| 141 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | public int describeContents() { |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | @Override public void writeToParcel(Parcel out, int parcelableFlags) { |
| 147 | super.writeToParcel(out, parcelableFlags); |
| 148 | out.writeString(authority); |
| 149 | out.writeString(readPermission); |
| 150 | out.writeString(writePermission); |
| 151 | out.writeInt(grantUriPermissions ? 1 : 0); |
Dianne Hackborn | 52e42a4 | 2019-02-05 16:10:50 -0800 | [diff] [blame] | 152 | out.writeInt(forceUriPermissions ? 1 : 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | out.writeTypedArray(uriPermissionPatterns, parcelableFlags); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 154 | out.writeTypedArray(pathPermissions, parcelableFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | out.writeInt(multiprocess ? 1 : 0); |
| 156 | out.writeInt(initOrder); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 157 | out.writeInt(flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | out.writeInt(isSyncable ? 1 : 0); |
| 159 | } |
| 160 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 161 | public static final @android.annotation.NonNull Parcelable.Creator<ProviderInfo> CREATOR |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | = new Parcelable.Creator<ProviderInfo>() { |
| 163 | public ProviderInfo createFromParcel(Parcel in) { |
| 164 | return new ProviderInfo(in); |
| 165 | } |
| 166 | |
| 167 | public ProviderInfo[] newArray(int size) { |
| 168 | return new ProviderInfo[size]; |
| 169 | } |
| 170 | }; |
| 171 | |
| 172 | public String toString() { |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 173 | return "ContentProviderInfo{name=" + authority + " className=" + name + "}"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | private ProviderInfo(Parcel in) { |
| 177 | super(in); |
| 178 | authority = in.readString(); |
| 179 | readPermission = in.readString(); |
| 180 | writePermission = in.readString(); |
| 181 | grantUriPermissions = in.readInt() != 0; |
Dianne Hackborn | 52e42a4 | 2019-02-05 16:10:50 -0800 | [diff] [blame] | 182 | forceUriPermissions = in.readInt() != 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 183 | uriPermissionPatterns = in.createTypedArray(PatternMatcher.CREATOR); |
Dianne Hackborn | 2af632f | 2009-07-08 14:56:37 -0700 | [diff] [blame] | 184 | pathPermissions = in.createTypedArray(PathPermission.CREATOR); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 185 | multiprocess = in.readInt() != 0; |
| 186 | initOrder = in.readInt(); |
Dianne Hackborn | 7d19e02 | 2012-08-07 19:12:33 -0700 | [diff] [blame] | 187 | flags = in.readInt(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 188 | isSyncable = in.readInt() != 0; |
| 189 | } |
| 190 | } |