blob: c92ccae66ff8fd9698d6db373dc3be77495178f9 [file] [log] [blame]
Alan Viverette3da604b2020-06-10 18:34:39 +00001/*
2 * Copyright (C) 2020 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.window;
18
19import android.annotation.NonNull;
20import android.annotation.TestApi;
21import android.os.IBinder;
22import android.os.Parcel;
23import android.os.Parcelable;
24
25/**
26 * Interface for a window container to communicate with the window manager. This also acts as a
27 * token.
28 * @hide
29 */
30@TestApi
31public final class WindowContainerToken implements Parcelable {
32
33 private final IWindowContainerToken mRealToken;
34
35 /** @hide */
36 public WindowContainerToken(IWindowContainerToken realToken) {
37 mRealToken = realToken;
38 }
39
40 private WindowContainerToken(Parcel in) {
41 mRealToken = IWindowContainerToken.Stub.asInterface(in.readStrongBinder());
42 }
43
44 /** @hide */
45 public IBinder asBinder() {
46 return mRealToken.asBinder();
47 }
48
49 @Override
50 /** @hide */
51 public void writeToParcel(@NonNull Parcel dest, int flags) {
52 dest.writeStrongBinder(mRealToken.asBinder());
53 }
54
55 @NonNull
56 public static final Creator<WindowContainerToken> CREATOR =
57 new Creator<WindowContainerToken>() {
58 @Override
59 public WindowContainerToken createFromParcel(Parcel in) {
60 return new WindowContainerToken(in);
61 }
62
63 @Override
64 public WindowContainerToken[] newArray(int size) {
65 return new WindowContainerToken[size];
66 }
67 };
68
69 @Override
70 /** @hide */
71 public int describeContents() {
72 return 0;
73 }
74
75 @Override
76 public int hashCode() {
77 return mRealToken.asBinder().hashCode();
78 }
79
80 @Override
81 public boolean equals(Object obj) {
82 if (!(obj instanceof WindowContainerToken)) {
83 return false;
84 }
85 return mRealToken.asBinder() == ((WindowContainerToken) obj).asBinder();
86 }
87}