1 /* 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 17 package android.app; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.content.ContentProviderNative; 21 import android.content.IContentProvider; 22 import android.content.pm.ProviderInfo; 23 import android.os.Build; 24 import android.os.IBinder; 25 import android.os.Parcel; 26 import android.os.Parcelable; 27 28 /** 29 * Information you can retrieve about a particular application. 30 * 31 * @hide 32 */ 33 public class ContentProviderHolder implements Parcelable { 34 @UnsupportedAppUsage 35 public final ProviderInfo info; 36 @UnsupportedAppUsage 37 public IContentProvider provider; 38 public IBinder connection; 39 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) 40 public boolean noReleaseNeeded; 41 42 /** 43 * Whether the provider here is a local provider or not. 44 */ 45 public boolean mLocal; 46 47 @UnsupportedAppUsage ContentProviderHolder(ProviderInfo _info)48 public ContentProviderHolder(ProviderInfo _info) { 49 info = _info; 50 } 51 52 @Override describeContents()53 public int describeContents() { 54 return 0; 55 } 56 57 @Override writeToParcel(Parcel dest, int flags)58 public void writeToParcel(Parcel dest, int flags) { 59 info.writeToParcel(dest, 0); 60 if (provider != null) { 61 dest.writeStrongBinder(provider.asBinder()); 62 } else { 63 dest.writeStrongBinder(null); 64 } 65 dest.writeStrongBinder(connection); 66 dest.writeInt(noReleaseNeeded ? 1 : 0); 67 dest.writeInt(mLocal ? 1 : 0); 68 } 69 70 public static final @android.annotation.NonNull Parcelable.Creator<ContentProviderHolder> CREATOR 71 = new Parcelable.Creator<ContentProviderHolder>() { 72 @Override 73 public ContentProviderHolder createFromParcel(Parcel source) { 74 return new ContentProviderHolder(source); 75 } 76 77 @Override 78 public ContentProviderHolder[] newArray(int size) { 79 return new ContentProviderHolder[size]; 80 } 81 }; 82 83 @UnsupportedAppUsage ContentProviderHolder(Parcel source)84 private ContentProviderHolder(Parcel source) { 85 info = ProviderInfo.CREATOR.createFromParcel(source); 86 provider = ContentProviderNative.asInterface( 87 source.readStrongBinder()); 88 connection = source.readStrongBinder(); 89 noReleaseNeeded = source.readInt() != 0; 90 mLocal = source.readInt() != 0; 91 } 92 } 93