1 /* 2 * Copyright (C) 2013 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 com.android.bluetooth.gatt; 18 19 import android.bluetooth.le.ResultStorageDescriptor; 20 import android.bluetooth.le.ScanFilter; 21 import android.bluetooth.le.ScanSettings; 22 23 import java.util.List; 24 import java.util.Objects; 25 import java.util.UUID; 26 27 /** 28 * Helper class identifying a client that has requested LE scan results. 29 * 30 * @hide 31 */ 32 /* package */class ScanClient { 33 int clientIf; 34 boolean isServer; 35 UUID[] uuids; 36 ScanSettings settings; 37 List<ScanFilter> filters; 38 List<List<ResultStorageDescriptor>> storages; 39 // App associated with the scan client died. 40 boolean appDied; 41 42 private static final ScanSettings DEFAULT_SCAN_SETTINGS = new ScanSettings.Builder() 43 .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); 44 ScanClient(int appIf, boolean isServer)45 ScanClient(int appIf, boolean isServer) { 46 this(appIf, isServer, new UUID[0], DEFAULT_SCAN_SETTINGS, null, null); 47 } 48 ScanClient(int appIf, boolean isServer, UUID[] uuids)49 ScanClient(int appIf, boolean isServer, UUID[] uuids) { 50 this(appIf, isServer, uuids, DEFAULT_SCAN_SETTINGS, null, null); 51 } 52 ScanClient(int appIf, boolean isServer, ScanSettings settings, List<ScanFilter> filters)53 ScanClient(int appIf, boolean isServer, ScanSettings settings, 54 List<ScanFilter> filters) { 55 this(appIf, isServer, new UUID[0], settings, filters, null); 56 } 57 ScanClient(int appIf, boolean isServer, ScanSettings settings, List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages)58 ScanClient(int appIf, boolean isServer, ScanSettings settings, 59 List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages) { 60 this(appIf, isServer, new UUID[0], settings, filters, storages); 61 } 62 ScanClient(int appIf, boolean isServer, UUID[] uuids, ScanSettings settings, List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages)63 private ScanClient(int appIf, boolean isServer, UUID[] uuids, ScanSettings settings, 64 List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages) { 65 this.clientIf = appIf; 66 this.isServer = isServer; 67 this.uuids = uuids; 68 this.settings = settings; 69 this.filters = filters; 70 this.storages = storages; 71 } 72 73 @Override equals(Object obj)74 public boolean equals(Object obj) { 75 if (this == obj) { 76 return true; 77 } 78 if (obj == null || getClass() != obj.getClass()) { 79 return false; 80 } 81 ScanClient other = (ScanClient) obj; 82 return clientIf == other.clientIf; 83 } 84 85 @Override hashCode()86 public int hashCode() { 87 return Objects.hash(clientIf); 88 } 89 } 90