Debian Codegraph @

core/java/android/app/smartspace/SmartspaceSessionId.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.app.smartspace;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.os.UserHandle;
25
26 import java.util.Objects;
27
28 /**
29 * The id for an Smartspace session. See {@link SmartspaceSession}.
30 *
31 * @hide
32 */
33 @SystemApi
34 public final class SmartspaceSessionId implements Parcelable {
35
36 @NonNull
37 private final String mId;
38
39 @NonNull
40 private final UserHandle mUserHandle;
41
42 /**
43 * Creates a new id for a Smartspace session.
44 *
45 * @hide
46 */
47 public SmartspaceSessionId(@NonNull final String id, @NonNull final UserHandle userHandle) {
48 mId = id;
49 mUserHandle = userHandle;
50 }
51
52 private SmartspaceSessionId(Parcel p) {
53 mId = p.readString();
54 mUserHandle = p.readTypedObject(UserHandle.CREATOR);
55 }
56
57 /**
58 * Returns a {@link String} Id of this sessionId.
59 */
60 @Nullable
61 public String getId() {
62 return mId;
63 }
64
65 /**
66 * Returns the userId associated with this sessionId.
67 */
68 @NonNull
69 public UserHandle getUserHandle() {
70 return mUserHandle;
71 }
72
73 @Override
74 public boolean equals(@Nullable Object o) {
75 if (!getClass().equals(o != null ? o.getClass() : null)) return false;
76
77 SmartspaceSessionId other = (SmartspaceSessionId) o;
78 return mId.equals(other.mId) && mUserHandle == other.mUserHandle;
79 }
80
81 @Override
82 public String toString() {
83 return "SmartspaceSessionId{"
84 + "mId='" + mId + '\''
85 + ", mUserId=" + mUserHandle.getIdentifier()
86 + '}';
87 }
88
89 @Override
90 public int hashCode() {
91 return Objects.hash(mId, mUserHandle);
92 }
93
94 @Override
95 public int describeContents() {
96 return 0;
97 }
98
99 @Override
100 public void writeToParcel(@NonNull Parcel dest, int flags) {
101 dest.writeString(mId);
102 dest.writeTypedObject(this.mUserHandle, flags);
103 }
104
105 public static final @NonNull Creator<SmartspaceSessionId> CREATOR =
106 new Creator<SmartspaceSessionId>() {
107 public SmartspaceSessionId createFromParcel(Parcel parcel) {
108 return new SmartspaceSessionId(parcel);
109 }
110
111 public SmartspaceSessionId[] newArray(int size) {
112 return new SmartspaceSessionId[size];
113 }
114 };
115 }