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.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 @UnsupportedAppUsage ContentProviderHolder(ProviderInfo _info)43 public ContentProviderHolder(ProviderInfo _info) { 44 info = _info; 45 } 46 47 @Override describeContents()48 public int describeContents() { 49 return 0; 50 } 51 52 @Override writeToParcel(Parcel dest, int flags)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 @android.annotation.NonNull 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 77 @UnsupportedAppUsage ContentProviderHolder(Parcel source)78 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 }