Debian Codegraph @

core/java/android/service/games/CreateGameSessionRequest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 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.NonNull;
20 import android.annotation.SystemApi;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 import java.util.Objects;
25
26 /**
27 * Request object providing the context in order to create a new {@link GameSession}.
28 *
29 * This is provided to the Game Service provider via
30 * {@link GameSessionService#onNewSession(CreateGameSessionRequest)}. It includes game
31 * (see {@link #getGamePackageName()}) that the session is associated with and a task
32 * (see {@link #getTaskId()}.
33 *
34 * @hide
35 */
36 @SystemApi
37 public final class CreateGameSessionRequest implements Parcelable {
38
39 @NonNull
40 public static final Parcelable.Creator<CreateGameSessionRequest> CREATOR =
41 new Parcelable.Creator<CreateGameSessionRequest>() {
42 @Override
43 public CreateGameSessionRequest createFromParcel(Parcel source) {
44 return new CreateGameSessionRequest(
45 source.readInt(),
46 source.readString8());
47 }
48
49 @Override
50 public CreateGameSessionRequest[] newArray(int size) {
51 return new CreateGameSessionRequest[0];
52 }
53 };
54
55 private final int mTaskId;
56 private final String mGamePackageName;
57
58 public CreateGameSessionRequest(int taskId, @NonNull String gamePackageName) {
59 this.mTaskId = taskId;
60 this.mGamePackageName = gamePackageName;
61 }
62
63 @Override
64 public int describeContents() {
65 return 0;
66 }
67
68 @Override
69 public void writeToParcel(@NonNull Parcel dest, int flags) {
70 dest.writeInt(mTaskId);
71 dest.writeString8(mGamePackageName);
72 }
73
74 /**
75 * Unique identifier for the task.
76 */
77 public int getTaskId() {
78 return mTaskId;
79 }
80
81 /**
82 * The package name of the game associated with the session.
83 */
84 @NonNull
85 public String getGamePackageName() {
86 return mGamePackageName;
87 }
88
89 @Override
90 public String toString() {
91 return "GameSessionRequest{"
92 + "mTaskId="
93 + mTaskId
94 + ", mGamePackageName='"
95 + mGamePackageName
96 + "\'}";
97 }
98
99 @Override
100 public boolean equals(Object o) {
101 if (this == o) {
102 return true;
103 }
104
105 if (!(o instanceof CreateGameSessionRequest)) {
106 return false;
107 }
108
109 CreateGameSessionRequest that = (CreateGameSessionRequest) o;
110 return mTaskId == that.mTaskId
111 && Objects.equals(mGamePackageName, that.mGamePackageName);
112 }
113
114 @Override
115 public int hashCode() {
116 return Objects.hash(mTaskId, mGamePackageName);
117 }
118 }