1bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski/* 2bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Copyright (C) 2016 The Android Open Source Project 3bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * 4bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Licensed under the Apache License, Version 2.0 (the "License"); 5bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * you may not use this file except in compliance with the License. 6bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * You may obtain a copy of the License at 7bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * 8bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * http://www.apache.org/licenses/LICENSE-2.0 9bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * 10bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Unless required by applicable law or agreed to in writing, software 11bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * distributed under the License is distributed on an "AS IS" BASIS, 12bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * See the License for the specific language governing permissions and 14bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * limitations under the License. 15bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 16bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskipackage android.bluetooth; 17bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 18bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskiimport android.os.Parcel; 19bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskiimport android.os.Parcelable; 20bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskiimport android.os.ParcelUuid; 21bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskiimport java.util.ArrayList; 22bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskiimport java.util.List; 23bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskiimport java.util.UUID; 24bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 25bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski/** 26bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Represents a Bluetooth GATT Included Service 27bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * @hide 28bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 29bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowskipublic class BluetoothGattIncludedService implements Parcelable { 30bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 31bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 32bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * The UUID of this service. 33bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 34bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski protected UUID mUuid; 35bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 36bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 37bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Instance ID for this service. 38bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 39bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski protected int mInstanceId; 40bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 41bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 42bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Service type (Primary/Secondary). 43bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 44bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski protected int mServiceType; 45bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 46bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 47bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Create a new BluetoothGattIncludedService 48bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 49bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public BluetoothGattIncludedService(UUID uuid, int instanceId, int serviceType) { 50bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski mUuid = uuid; 51bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski mInstanceId = instanceId; 52bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski mServiceType = serviceType; 53bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 54bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 55bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public int describeContents() { 56bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski return 0; 57bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 58bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 59bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public void writeToParcel(Parcel out, int flags) { 60bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski out.writeParcelable(new ParcelUuid(mUuid), 0); 61bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski out.writeInt(mInstanceId); 62bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski out.writeInt(mServiceType); 63bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 64bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 65bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public static final Parcelable.Creator<BluetoothGattIncludedService> CREATOR 66bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski = new Parcelable.Creator<BluetoothGattIncludedService>() { 67bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public BluetoothGattIncludedService createFromParcel(Parcel in) { 68bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski return new BluetoothGattIncludedService(in); 69bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 70bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 71bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public BluetoothGattIncludedService[] newArray(int size) { 72bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski return new BluetoothGattIncludedService[size]; 73bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 74bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski }; 75bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 76bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski private BluetoothGattIncludedService(Parcel in) { 77bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid(); 78bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski mInstanceId = in.readInt(); 79bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski mServiceType = in.readInt(); 80bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 81bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 82bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 83bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Returns the UUID of this service 84bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * 85bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * @return UUID of this service 86bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 87bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public UUID getUuid() { 88bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski return mUuid; 89bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 90bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 91bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 92bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Returns the instance ID for this service 93bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * 94bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * <p>If a remote device offers multiple services with the same UUID 95bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * (ex. multiple battery services for different batteries), the instance 96bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * ID is used to distuinguish services. 97bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * 98bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * @return Instance ID of this service 99bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 100bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public int getInstanceId() { 101bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski return mInstanceId; 102bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 103bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski 104bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski /** 105bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski * Get the type of this service (primary/secondary) 106bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski */ 107bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski public int getType() { 108bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski return mServiceType; 109bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski } 110bf0faed3597b92d950febafcf555ad05529559d6Jakub Pawlowski} 111