OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / frameworks / base / core / java / android / content / pm / ProviderInfo.java
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;
22
23 /**
24  * Holds information about a specific
25  * {@link android.content.ContentProvider content provider}. This is returned by
26  * {@link android.content.pm.PackageManager#resolveContentProvider(java.lang.String, int)
27  * PackageManager.resolveContentProvider()}.
28  */
29 public final class ProviderInfo extends ComponentInfo
30         implements Parcelable {
31     
32     /** The name provider is published under content:// */
33     public String authority = null;
34     
35     /** Optional permission required for read-only access this content
36      * provider. */
37     public String readPermission = null;
38     
39     /** Optional permission required for read/write access this content
40      * provider. */
41     public String writePermission = null;
42     
43     /** If true, additional permissions to specific Uris in this content
44      * provider can be granted, as per the
45      * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
46      * grantUriPermissions} attribute.
47      */
48     public boolean grantUriPermissions = false;
49     
50     /**
51      * If non-null, these are the patterns that are allowed for granting URI
52      * permissions.  Any URI that does not match one of these patterns will not
53      * allowed to be granted.  If null, all URIs are allowed.  The
54      * {@link PackageManager#GET_URI_PERMISSION_PATTERNS
55      * PackageManager.GET_URI_PERMISSION_PATTERNS} flag must be specified for
56      * this field to be filled in.
57      */
58     public PatternMatcher[] uriPermissionPatterns = null;
59     
60     /**
61      * If non-null, these are path-specific permissions that are allowed for
62      * accessing the provider.  Any permissions listed here will allow a
63      * holding client to access the provider, and the provider will check
64      * the URI it provides when making calls against the patterns here.
65      */
66     public PathPermission[] pathPermissions = null;
67     
68     /** If true, this content provider allows multiple instances of itself
69      *  to run in different process.  If false, a single instances is always
70      *  run in {@link #processName}. */
71     public boolean multiprocess = false;
72     
73     /** Used to control initialization order of single-process providers
74      *  running in the same process.  Higher goes first. */
75     public int initOrder = 0;
76     
77     /**
78      * Whether or not this provider is syncable.
79      * @deprecated This flag is now being ignored. The current way to make a provider
80      * syncable is to provide a SyncAdapter service for a given provider/account type. 
81      */
82     @Deprecated
83     public boolean isSyncable = false;
84
85     public ProviderInfo() {
86     }
87
88     public ProviderInfo(ProviderInfo orig) {
89         super(orig);
90         authority = orig.authority;
91         readPermission = orig.readPermission;
92         writePermission = orig.writePermission;
93         grantUriPermissions = orig.grantUriPermissions;
94         uriPermissionPatterns = orig.uriPermissionPatterns;
95         pathPermissions = orig.pathPermissions;
96         multiprocess = orig.multiprocess;
97         initOrder = orig.initOrder;
98         isSyncable = orig.isSyncable;
99     }
100     
101     public int describeContents() {
102         return 0;
103     }
104
105     @Override public void writeToParcel(Parcel out, int parcelableFlags) {
106         super.writeToParcel(out, parcelableFlags);
107         out.writeString(authority);
108         out.writeString(readPermission);
109         out.writeString(writePermission);
110         out.writeInt(grantUriPermissions ? 1 : 0);
111         out.writeTypedArray(uriPermissionPatterns, parcelableFlags);
112         out.writeTypedArray(pathPermissions, parcelableFlags);
113         out.writeInt(multiprocess ? 1 : 0);
114         out.writeInt(initOrder);
115         out.writeInt(isSyncable ? 1 : 0);
116     }
117
118     public static final Parcelable.Creator<ProviderInfo> CREATOR
119             = new Parcelable.Creator<ProviderInfo>() {
120         public ProviderInfo createFromParcel(Parcel in) {
121             return new ProviderInfo(in);
122         }
123
124         public ProviderInfo[] newArray(int size) {
125             return new ProviderInfo[size];
126         }
127     };
128
129     public String toString() {
130         return "ContentProviderInfo{name=" + authority + " className=" + name
131             + " isSyncable=" + (isSyncable ? "true" : "false") + "}";
132     }
133
134     private ProviderInfo(Parcel in) {
135         super(in);
136         authority = in.readString();
137         readPermission = in.readString();
138         writePermission = in.readString();
139         grantUriPermissions = in.readInt() != 0;
140         uriPermissionPatterns = in.createTypedArray(PatternMatcher.CREATOR);
141         pathPermissions = in.createTypedArray(PathPermission.CREATOR);
142         multiprocess = in.readInt() != 0;
143         initOrder = in.readInt();
144         isSyncable = in.readInt() != 0;
145     }
146 }