PendingHandoverTransfer.java revision be1939b4b6003ac7a65fcb95a3912f5e1ce8e75f
1package com.android.nfc.handover;
2
3import android.bluetooth.BluetoothDevice;
4import android.net.Uri;
5import android.os.Parcel;
6import android.os.Parcelable;
7
8public class PendingHandoverTransfer implements Parcelable {
9    public int id;
10    public boolean incoming;
11    public BluetoothDevice remoteDevice;
12    public boolean remoteActivating;
13    public Uri[] uris;
14
15    PendingHandoverTransfer(int id, boolean incoming, BluetoothDevice remoteDevice,
16            boolean remoteActivating, Uri[] uris) {
17        this.id = id;
18        this.incoming = incoming;
19        this.remoteDevice = remoteDevice;
20        this.remoteActivating = remoteActivating;
21        this.uris = uris;
22    }
23
24    public static final Parcelable.Creator<PendingHandoverTransfer> CREATOR
25            = new Parcelable.Creator<PendingHandoverTransfer>() {
26        public PendingHandoverTransfer createFromParcel(Parcel in) {
27            int id = in.readInt();
28            boolean incoming = (in.readInt() == 1) ? true : false;
29            BluetoothDevice remoteDevice = in.readParcelable(getClass().getClassLoader());
30            boolean remoteActivating = (in.readInt() == 1) ? true : false;
31            int numUris = in.readInt();
32            Uri[] uris = null;
33            if (numUris > 0) {
34                uris = new Uri[numUris];
35                in.readTypedArray(uris, Uri.CREATOR);
36            }
37            return new PendingHandoverTransfer(id, incoming, remoteDevice,
38                    remoteActivating, uris);
39        }
40
41        @Override
42        public PendingHandoverTransfer[] newArray(int size) {
43            return new PendingHandoverTransfer[size];
44        }
45    };
46
47    @Override
48    public int describeContents() {
49        return 0;
50    }
51
52    @Override
53    public void writeToParcel(Parcel dest, int flags) {
54        dest.writeInt(id);
55        dest.writeInt(incoming ? 1 : 0);
56        dest.writeParcelable(remoteDevice, 0);
57        dest.writeInt(remoteActivating ? 1 : 0);
58        dest.writeInt(uris != null ? uris.length : 0);
59        if (uris != null && uris.length > 0) {
60            dest.writeTypedArray(uris, 0);
61        }
62    }
63}
64