• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import android.os.Binder;
23 import android.os.UserHandle;
24 
25 import java.util.List;
26 import java.util.Objects;
27 
28 /**
29  * Helper class identifying a client that has requested LE scan results.
30  *
31  * @hide
32  */
33 /* package */class ScanClient {
34     public int scannerId;
35     public ScanSettings settings;
36     public ScanSettings passiveSettings;
37     public int appUid;
38     public List<ScanFilter> filters;
39     public List<List<ResultStorageDescriptor>> storages;
40     // App associated with the scan client died.
41     public boolean appDied;
42     public boolean hasLocationPermission;
43     public UserHandle userHandle;
44     public boolean isQApp;
45     public boolean eligibleForSanitizedExposureNotification;
46     public boolean hasNetworkSettingsPermission;
47     public boolean hasNetworkSetupWizardPermission;
48     public boolean hasScanWithoutLocationPermission;
49     public boolean hasDisavowedLocation;
50     public List<String> associatedDevices;
51 
52     public AppScanStats stats = null;
53 
54     private static final ScanSettings DEFAULT_SCAN_SETTINGS =
55             new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
56 
ScanClient(int scannerId)57     ScanClient(int scannerId) {
58         this(scannerId, DEFAULT_SCAN_SETTINGS, null, null);
59     }
60 
ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters)61     ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters) {
62         this(scannerId, settings, filters, null);
63     }
64 
ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages)65     ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters,
66             List<List<ResultStorageDescriptor>> storages) {
67         this.scannerId = scannerId;
68         this.settings = settings;
69         this.passiveSettings = null;
70         this.filters = filters;
71         this.storages = storages;
72         this.appUid = Binder.getCallingUid();
73     }
74 
75     @Override
equals(Object obj)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 scannerId == other.scannerId;
85     }
86 
87     @Override
hashCode()88     public int hashCode() {
89         return Objects.hash(scannerId);
90     }
91 }
92