1 /* 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 17 package android.bluetooth.le; 18 19 import android.annotation.SystemApi; 20 import android.os.Parcel; 21 import android.os.Parcelable; 22 23 /** 24 * Describes the way to store scan result. 25 * 26 * @hide 27 */ 28 @SystemApi 29 public 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 81 public static final Parcelable.Creator<ResultStorageDescriptor> 82 CREATOR = new Creator<ResultStorageDescriptor>() { 83 @Override 84 public ResultStorageDescriptor createFromParcel(Parcel source) { 85 return new ResultStorageDescriptor(source); 86 } 87 88 @Override 89 public ResultStorageDescriptor[] newArray(int size) { 90 return new ResultStorageDescriptor[size]; 91 } 92 }; 93 } 94