1 /* 2 * Copyright (C) 2013 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.hardware.camera2.utils; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 import android.os.IBinder; 22 23 /** 24 * @hide 25 */ 26 public class BinderHolder implements Parcelable { 27 private IBinder mBinder = null; 28 29 @Override 30 public int describeContents() { 31 return 0; 32 } 33 34 @Override 35 public void writeToParcel(Parcel dest, int flags) { 36 dest.writeStrongBinder(mBinder); 37 } 38 39 public void readFromParcel(Parcel src) { 40 mBinder = src.readStrongBinder(); 41 } 42 43 public static final Parcelable.Creator<BinderHolder> CREATOR = 44 new Parcelable.Creator<BinderHolder>() { 45 @Override 46 public BinderHolder createFromParcel(Parcel in) { 47 return new BinderHolder(in); 48 } 49 50 @Override 51 public BinderHolder[] newArray(int size) { 52 return new BinderHolder[size]; 53 } 54 }; 55 56 public IBinder getBinder() { 57 return mBinder; 58 } 59 60 public void setBinder(IBinder binder) { 61 mBinder = binder; 62 } 63 64 public BinderHolder() {} 65 66 public BinderHolder(IBinder binder) { 67 mBinder = binder; 68 } 69 70 private BinderHolder(Parcel in) { 71 mBinder = in.readStrongBinder(); 72 } 73 } 74 75