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.content.ContentProviderNative; 20 import android.content.IContentProvider; 21 import android.content.pm.ProviderInfo; 22 import android.os.IBinder; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 26 /** 27 * Information you can retrieve about a particular application. 28 * 29 * @hide 30 */ 31 public class ContentProviderHolder implements Parcelable { 32 public final ProviderInfo info; 33 public IContentProvider provider; 34 public IBinder connection; 35 public boolean noReleaseNeeded; 36 ContentProviderHolder(ProviderInfo _info)37 public ContentProviderHolder(ProviderInfo _info) { 38 info = _info; 39 } 40 41 @Override describeContents()42 public int describeContents() { 43 return 0; 44 } 45 46 @Override writeToParcel(Parcel dest, int flags)47 public void writeToParcel(Parcel dest, int flags) { 48 info.writeToParcel(dest, 0); 49 if (provider != null) { 50 dest.writeStrongBinder(provider.asBinder()); 51 } else { 52 dest.writeStrongBinder(null); 53 } 54 dest.writeStrongBinder(connection); 55 dest.writeInt(noReleaseNeeded ? 1 : 0); 56 } 57 58 public static final Parcelable.Creator<ContentProviderHolder> CREATOR 59 = new Parcelable.Creator<ContentProviderHolder>() { 60 @Override 61 public ContentProviderHolder createFromParcel(Parcel source) { 62 return new ContentProviderHolder(source); 63 } 64 65 @Override 66 public ContentProviderHolder[] newArray(int size) { 67 return new ContentProviderHolder[size]; 68 } 69 }; 70 ContentProviderHolder(Parcel source)71 private ContentProviderHolder(Parcel source) { 72 info = ProviderInfo.CREATOR.createFromParcel(source); 73 provider = ContentProviderNative.asInterface( 74 source.readStrongBinder()); 75 connection = source.readStrongBinder(); 76 noReleaseNeeded = source.readInt() != 0; 77 } 78 }