Home | History | Annotate | Download | only in app
      1 /*
      2  * Copyright (C) 2017 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.ComponentName;
     20 import android.os.Parcel;
     21 import android.os.Parcelable;
     22 
     23 import java.io.PrintWriter;
     24 
     25 /**
     26  * Display properties to be used by VR mode when creating a virtual display.
     27  *
     28  * @hide
     29  */
     30 public class Vr2dDisplayProperties implements Parcelable {
     31 
     32    /**
     33     * The actual width, height and dpi.
     34     */
     35     private final int mWidth;
     36     private final int mHeight;
     37     private final int mDpi;
     38 
     39     public Vr2dDisplayProperties(int width, int height, int dpi) {
     40         mWidth = width;
     41         mHeight = height;
     42         mDpi = dpi;
     43     }
     44 
     45     @Override
     46     public int hashCode() {
     47         int result = getWidth();
     48         result = 31 * result + getHeight();
     49         result = 31 * result + getDpi();
     50         return result;
     51     }
     52 
     53     @Override
     54     public String toString() {
     55         return "Vr2dDisplayProperties{" +
     56                 "mWidth=" + mWidth +
     57                 ", mHeight=" + mHeight +
     58                 ", mDpi=" + mDpi +
     59                 "}";
     60     }
     61 
     62     @Override
     63     public boolean equals(Object o) {
     64         if (this == o) return true;
     65         if (o == null || getClass() != o.getClass()) return false;
     66 
     67         Vr2dDisplayProperties that = (Vr2dDisplayProperties) o;
     68 
     69         if (getWidth() != that.getWidth()) return false;
     70         if (getHeight() != that.getHeight()) return false;
     71         return getDpi() == that.getDpi();
     72     }
     73 
     74     @Override
     75     public int describeContents() {
     76         return 0;
     77     }
     78 
     79     @Override
     80     public void writeToParcel(Parcel dest, int flags) {
     81         dest.writeInt(mWidth);
     82         dest.writeInt(mHeight);
     83         dest.writeInt(mDpi);
     84     }
     85 
     86     public static final Parcelable.Creator<Vr2dDisplayProperties> CREATOR
     87             = new Parcelable.Creator<Vr2dDisplayProperties>() {
     88         @Override
     89         public Vr2dDisplayProperties createFromParcel(Parcel source) {
     90             return new Vr2dDisplayProperties(source);
     91         }
     92 
     93         @Override
     94         public Vr2dDisplayProperties[] newArray(int size) {
     95             return new Vr2dDisplayProperties[size];
     96         }
     97     };
     98 
     99     private Vr2dDisplayProperties(Parcel source) {
    100         mWidth = source.readInt();
    101         mHeight = source.readInt();
    102         mDpi = source.readInt();
    103     }
    104 
    105     public void dump(PrintWriter pw, String prefix) {
    106         pw.println(prefix + "Vr2dDisplayProperties:");
    107         pw.println(prefix + "  width=" + mWidth);
    108         pw.println(prefix + "  height=" + mHeight);
    109         pw.println(prefix + "  dpi=" + mDpi);
    110     }
    111 
    112     public int getWidth() {
    113         return mWidth;
    114     }
    115 
    116     public int getHeight() {
    117         return mHeight;
    118     }
    119 
    120     public int getDpi() {
    121         return mDpi;
    122     }
    123 }
    124