Home | History | Annotate | Download | only in camera
      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.car.hardware.camera;
     18 
     19 import android.annotation.SystemApi;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 
     23 /**
     24  * CarCameraState object corresponds to a property of the car's Camera system
     25  * @hide
     26  */
     27 @SystemApi
     28 public class CarCameraState implements Parcelable {
     29     private boolean mCameraIsOn;
     30     private boolean mOverlayIsOn;
     31 
     32     public int describeContents() {
     33         return 0;
     34     }
     35 
     36     public void writeToParcel(Parcel out, int flags) {
     37         out.writeInt(mCameraIsOn ? 1 : 0);
     38         out.writeInt(mOverlayIsOn ? 1 : 0);
     39     }
     40 
     41     public static final Parcelable.Creator<CarCameraState> CREATOR
     42             = new Parcelable.Creator<CarCameraState>() {
     43         public CarCameraState createFromParcel(Parcel in) {
     44             return new CarCameraState(in);
     45         }
     46 
     47         public CarCameraState[] newArray(int size) {
     48             return new CarCameraState[size];
     49         }
     50     };
     51 
     52     private CarCameraState(Parcel in) {
     53         mCameraIsOn = in.readInt() == 1;
     54         mOverlayIsOn = in.readInt() == 1;
     55     }
     56 
     57     /**
     58      * Copy constructor
     59      * @param that
     60      */
     61     public CarCameraState(CarCameraState that) {
     62         mCameraIsOn = that.getCameraIsOn();
     63         mOverlayIsOn = that.getOverlayIsOn();
     64     }
     65 
     66     /**
     67      * Constructor
     68      */
     69     public CarCameraState(boolean overlayIsOn, boolean cameraIsOn) {
     70         mCameraIsOn = cameraIsOn;
     71         mOverlayIsOn = overlayIsOn;
     72     }
     73 
     74     // Getters.
     75     public boolean getCameraIsOn()  { return mCameraIsOn;  }
     76     public boolean getOverlayIsOn() { return mOverlayIsOn; }
     77 
     78     // Setters.
     79     public void setCameraIsOn(boolean v)  { mCameraIsOn = v; }
     80     public void setOverlayIsOn(boolean v) { mOverlayIsOn = v; }
     81 
     82     // Printer.
     83     public String toString() {
     84         String myString = "mCameraIsOn: "  + mCameraIsOn + " mOverlayIsOn: "  + mOverlayIsOn;
     85         return myString;
     86     }
     87 
     88     // Comparator.
     89     public boolean equals(Object o) {
     90         if (o instanceof CarCameraState) {
     91             CarCameraState that = (CarCameraState) o;
     92 
     93             return (that.getCameraIsOn()  == mCameraIsOn &&
     94                     that.getOverlayIsOn() == mOverlayIsOn);
     95         }
     96         return false;
     97     }
     98 }
     99