blob: 796c815d69bbd4309832c731e99ba4a225148a21 [file] [log] [blame]
Wei Wang0d0df3c2014-07-30 15:19:08 -07001/*
2 * Copyright (C) 2014 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.bluetooth.le;
18
19import android.annotation.SystemApi;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
24 * Describes the way to store scan result.
25 *
26 * @hide
27 */
28@SystemApi
29public final class ResultStorageDescriptor implements Parcelable {
30 private int mType;
31 private int mOffset;
32 private int mLength;
33
34 public int getType() {
35 return mType;
36 }
37
38 public int getOffset() {
39 return mOffset;
40 }
41
42 public int getLength() {
43 return mLength;
44 }
45
46 /**
47 * Constructor of {@link ResultStorageDescriptor}
48 *
49 * @param type Type of the data.
50 * @param offset Offset from start of the advertise packet payload.
51 * @param length Byte length of the data
52 */
53 public ResultStorageDescriptor(int type, int offset, int length) {
54 mType = type;
55 mOffset = offset;
56 mLength = length;
57 }
58
59 @Override
60 public int describeContents() {
61 return 0;
62 }
63
64 @Override
65 public void writeToParcel(Parcel dest, int flags) {
66 dest.writeInt(mType);
67 dest.writeInt(mOffset);
68 dest.writeInt(mLength);
69 }
70
71 private ResultStorageDescriptor(Parcel in) {
72 ReadFromParcel(in);
73 }
74
75 private void ReadFromParcel(Parcel in) {
76 mType = in.readInt();
77 mOffset = in.readInt();
78 mLength = in.readInt();
79 }
80
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070081 public static final @android.annotation.NonNull Parcelable.Creator<ResultStorageDescriptor> CREATOR =
Jack He2992cd02017-08-22 21:21:23 -070082 new Creator<ResultStorageDescriptor>() {
Jack Hea355e5e2017-08-22 16:06:54 -070083 @Override
84 public ResultStorageDescriptor createFromParcel(Parcel source) {
85 return new ResultStorageDescriptor(source);
86 }
Wei Wang0d0df3c2014-07-30 15:19:08 -070087
Jack Hea355e5e2017-08-22 16:06:54 -070088 @Override
89 public ResultStorageDescriptor[] newArray(int size) {
90 return new ResultStorageDescriptor[size];
91 }
92 };
Wei Wang0d0df3c2014-07-30 15:19:08 -070093}