1 /* 2 * Copyright (C) 2022 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.service.games; 18 19 import android.annotation.Hide; 20 import android.annotation.NonNull; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import java.util.Objects; 25 26 /** 27 * Represents the configuration of the {@link android.view.SurfaceControlViewHost} used to render 28 * the overlay for a game session. 29 * 30 * @hide 31 */ 32 @Hide 33 public final class GameSessionViewHostConfiguration implements Parcelable { 34 35 @NonNull 36 public static final Creator<GameSessionViewHostConfiguration> CREATOR = 37 new Creator<GameSessionViewHostConfiguration>() { 38 @Override 39 public GameSessionViewHostConfiguration createFromParcel(Parcel source) { 40 return new GameSessionViewHostConfiguration( 41 source.readInt(), 42 source.readInt(), 43 source.readInt()); 44 } 45 46 @Override 47 public GameSessionViewHostConfiguration[] newArray(int size) { 48 return new GameSessionViewHostConfiguration[0]; 49 } 50 }; 51 52 final int mDisplayId; 53 final int mWidthPx; 54 final int mHeightPx; 55 GameSessionViewHostConfiguration(int displayId, int widthPx, int heightPx)56 public GameSessionViewHostConfiguration(int displayId, int widthPx, int heightPx) { 57 this.mDisplayId = displayId; 58 this.mWidthPx = widthPx; 59 this.mHeightPx = heightPx; 60 } 61 62 @Override describeContents()63 public int describeContents() { 64 return 0; 65 } 66 67 @Override writeToParcel(@onNull Parcel dest, int flags)68 public void writeToParcel(@NonNull Parcel dest, int flags) { 69 dest.writeInt(mDisplayId); 70 dest.writeInt(mWidthPx); 71 dest.writeInt(mHeightPx); 72 } 73 74 @Override equals(Object o)75 public boolean equals(Object o) { 76 if (this == o) return true; 77 if (!(o instanceof GameSessionViewHostConfiguration)) return false; 78 GameSessionViewHostConfiguration that = (GameSessionViewHostConfiguration) o; 79 return mDisplayId == that.mDisplayId && mWidthPx == that.mWidthPx 80 && mHeightPx == that.mHeightPx; 81 } 82 83 @Override hashCode()84 public int hashCode() { 85 return Objects.hash(mDisplayId, mWidthPx, mHeightPx); 86 } 87 88 @Override toString()89 public String toString() { 90 return "GameSessionViewHostConfiguration{" 91 + "mDisplayId=" + mDisplayId 92 + ", mWidthPx=" + mWidthPx 93 + ", mHeightPx=" + mHeightPx 94 + '}'; 95 } 96 } 97