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 17package com.android.bluetooth.gatt; 18 19import android.bluetooth.le.ResultStorageDescriptor; 20import android.bluetooth.le.ScanFilter; 21import android.bluetooth.le.ScanSettings; 22 23import java.util.List; 24import java.util.Objects; 25import 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 boolean hasLocationPermission; 42 boolean hasPeersMacAddressPermission; 43 44 private static final ScanSettings DEFAULT_SCAN_SETTINGS = new ScanSettings.Builder() 45 .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build(); 46 47 ScanClient(int appIf, boolean isServer) { 48 this(appIf, isServer, new UUID[0], DEFAULT_SCAN_SETTINGS, null, null); 49 } 50 51 ScanClient(int appIf, boolean isServer, UUID[] uuids) { 52 this(appIf, isServer, uuids, DEFAULT_SCAN_SETTINGS, null, null); 53 } 54 55 ScanClient(int appIf, boolean isServer, ScanSettings settings, 56 List<ScanFilter> filters) { 57 this(appIf, isServer, new UUID[0], settings, filters, null); 58 } 59 60 ScanClient(int appIf, boolean isServer, ScanSettings settings, 61 List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages) { 62 this(appIf, isServer, new UUID[0], settings, filters, storages); 63 } 64 65 private ScanClient(int appIf, boolean isServer, UUID[] uuids, ScanSettings settings, 66 List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages) { 67 this.clientIf = appIf; 68 this.isServer = isServer; 69 this.uuids = uuids; 70 this.settings = settings; 71 this.filters = filters; 72 this.storages = storages; 73 } 74 75 @Override 76 public boolean equals(Object obj) { 77 if (this == obj) { 78 return true; 79 } 80 if (obj == null || getClass() != obj.getClass()) { 81 return false; 82 } 83 ScanClient other = (ScanClient) obj; 84 return clientIf == other.clientIf; 85 } 86 87 @Override 88 public int hashCode() { 89 return Objects.hash(clientIf); 90 } 91} 92