Debian Codegraph @

core/java/android/window/WindowContainerToken.java

raw symbols SCIP
1 /*
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
17 package android.window;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.TestApi;
22 import android.os.IBinder;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25
26 /**
27 * Interface for a window container to communicate with the window manager. This also acts as a
28 * token.
29 * @hide
30 */
31 @TestApi
32 public final class WindowContainerToken implements Parcelable {
33
34 private final IWindowContainerToken mRealToken;
35
36 /** @hide */
37 public WindowContainerToken(IWindowContainerToken realToken) {
38 mRealToken = realToken;
39 }
40
41 private WindowContainerToken(Parcel in) {
42 mRealToken = IWindowContainerToken.Stub.asInterface(in.readStrongBinder());
43 }
44
45 /** @hide */
46 public IBinder asBinder() {
47 return mRealToken.asBinder();
48 }
49
50 @Override
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 public int describeContents() {
71 return 0;
72 }
73
74 @Override
75 public int hashCode() {
76 return mRealToken.asBinder().hashCode();
77 }
78
79 @Override
80 public String toString() {
81 return "WCT{" + mRealToken + "}";
82 }
83
84 @Override
85 public boolean equals(@Nullable Object obj) {
86 if (!(obj instanceof WindowContainerToken)) {
87 return false;
88 }
89 return mRealToken.asBinder() == ((WindowContainerToken) obj).asBinder();
90 }
91 }