blob: 2a13c7198b3fdcbf30213eca3ecf363f90ff6d49 [file] [log] [blame]
Sudheer Shankafc46e9b2016-10-21 17:55:27 -07001/*
2 * Copyright (C) 2016 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.app;
18
Mathew Inwood61e8ae62018-08-14 14:17:44 +010019import android.annotation.UnsupportedAppUsage;
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070020import android.content.ContentProviderNative;
21import android.content.IContentProvider;
22import android.content.pm.ProviderInfo;
Mathew Inwood8c854f82018-09-14 12:35:36 +010023import android.os.Build;
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070024import android.os.IBinder;
25import android.os.Parcel;
26import android.os.Parcelable;
27
28/**
29 * Information you can retrieve about a particular application.
30 *
31 * @hide
32 */
33public class ContentProviderHolder implements Parcelable {
Mathew Inwood61e8ae62018-08-14 14:17:44 +010034 @UnsupportedAppUsage
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070035 public final ProviderInfo info;
Mathew Inwood61e8ae62018-08-14 14:17:44 +010036 @UnsupportedAppUsage
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070037 public IContentProvider provider;
38 public IBinder connection;
Mathew Inwood8c854f82018-09-14 12:35:36 +010039 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070040 public boolean noReleaseNeeded;
41
Mathew Inwood61e8ae62018-08-14 14:17:44 +010042 @UnsupportedAppUsage
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070043 public ContentProviderHolder(ProviderInfo _info) {
44 info = _info;
45 }
46
47 @Override
48 public int describeContents() {
49 return 0;
50 }
51
52 @Override
53 public void writeToParcel(Parcel dest, int flags) {
54 info.writeToParcel(dest, 0);
55 if (provider != null) {
56 dest.writeStrongBinder(provider.asBinder());
57 } else {
58 dest.writeStrongBinder(null);
59 }
60 dest.writeStrongBinder(connection);
61 dest.writeInt(noReleaseNeeded ? 1 : 0);
62 }
63
64 public static final Parcelable.Creator<ContentProviderHolder> CREATOR
65 = new Parcelable.Creator<ContentProviderHolder>() {
66 @Override
67 public ContentProviderHolder createFromParcel(Parcel source) {
68 return new ContentProviderHolder(source);
69 }
70
71 @Override
72 public ContentProviderHolder[] newArray(int size) {
73 return new ContentProviderHolder[size];
74 }
75 };
76
Mathew Inwood61e8ae62018-08-14 14:17:44 +010077 @UnsupportedAppUsage
Sudheer Shankafc46e9b2016-10-21 17:55:27 -070078 private ContentProviderHolder(Parcel source) {
79 info = ProviderInfo.CREATOR.createFromParcel(source);
80 provider = ContentProviderNative.asInterface(
81 source.readStrongBinder());
82 connection = source.readStrongBinder();
83 noReleaseNeeded = source.readInt() != 0;
84 }
85}