blob: a608bb08836f0ba8b8c6d5408f4bbdaebe13d523 [file] [log] [blame]
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -07001/*
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
17package android.app;
18
19import android.content.ComponentName;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23import java.io.PrintWriter;
24
25/**
26 * Display properties to be used by VR mode when creating a virtual display.
27 *
28 * @hide
29 */
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070030public class Vr2dDisplayProperties implements Parcelable {
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070031
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
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070039 public Vr2dDisplayProperties(int width, int height, int dpi) {
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070040 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() {
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070055 return "Vr2dDisplayProperties{" +
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070056 "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
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070067 Vr2dDisplayProperties that = (Vr2dDisplayProperties) o;
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070068
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
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070086 public static final Parcelable.Creator<Vr2dDisplayProperties> CREATOR
87 = new Parcelable.Creator<Vr2dDisplayProperties>() {
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070088 @Override
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070089 public Vr2dDisplayProperties createFromParcel(Parcel source) {
90 return new Vr2dDisplayProperties(source);
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070091 }
92
93 @Override
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070094 public Vr2dDisplayProperties[] newArray(int size) {
95 return new Vr2dDisplayProperties[size];
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -070096 }
97 };
98
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -070099 private Vr2dDisplayProperties(Parcel source) {
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -0700100 mWidth = source.readInt();
101 mHeight = source.readInt();
102 mDpi = source.readInt();
103 }
104
105 public void dump(PrintWriter pw, String prefix) {
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -0700106 pw.println(prefix + "Vr2dDisplayProperties:");
Karthik Ravi Shankarcdf9ce72017-04-12 15:31:20 -0700107 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}