blob: ce67abf8d7c4ef3e1a18c0b0db20dc666853dc0f [file] [log] [blame]
Etan Cohenbd0ebf82019-02-08 08:21:28 -08001/*
2 * Copyright (C) 2019 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.net.wifi.aware;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
23 * A Parcelable {@link PeerHandle}. Can be constructed from a {@code PeerHandle} and then passed
24 * to any of the APIs which take a {@code PeerHandle} as inputs.
25 */
26public final class ParcelablePeerHandle extends PeerHandle implements Parcelable {
27 /**
28 * Construct a parcelable version of {@link PeerHandle}.
29 *
30 * @param peerHandle The {@link PeerHandle} to be made parcelable.
31 */
32 public ParcelablePeerHandle(PeerHandle peerHandle) {
33 super(peerHandle.peerId);
34 }
35
36 @Override
37 public int describeContents() {
38 return 0;
39 }
40
41 @Override
42 public void writeToParcel(Parcel dest, int flags) {
43 dest.writeInt(peerId);
44 }
45
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070046 public static final @android.annotation.NonNull Creator<ParcelablePeerHandle> CREATOR =
Etan Cohenbd0ebf82019-02-08 08:21:28 -080047 new Creator<ParcelablePeerHandle>() {
48 @Override
49 public ParcelablePeerHandle[] newArray(int size) {
50 return new ParcelablePeerHandle[size];
51 }
52
53 @Override
54 public ParcelablePeerHandle createFromParcel(Parcel in) {
55 int peerHandle = in.readInt();
56 return new ParcelablePeerHandle(new PeerHandle(peerHandle));
57 }
58 };
59}