• 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 import java.util.UUID;
28 
29 /**
30  * Helper class identifying a client that has requested LE scan results.
31  *
32  * @hide
33  */
34 /* package */class ScanClient {
35     public int scannerId;
36     public UUID[] uuids;
37     public ScanSettings settings;
38     public ScanSettings passiveSettings;
39     public int appUid;
40     public List<ScanFilter> filters;
41     public List<List<ResultStorageDescriptor>> storages;
42     // App associated with the scan client died.
43     public boolean appDied;
44     public boolean hasLocationPermission;
45     public UserHandle userHandle;
46     public boolean isQApp;
47     public boolean hasNetworkSettingsPermission;
48     public boolean hasNetworkSetupWizardPermission;
49 
50     public AppScanStats stats = null;
51 
52     private static final ScanSettings DEFAULT_SCAN_SETTINGS =
53             new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
54 
ScanClient(int scannerId)55     ScanClient(int scannerId) {
56         this(scannerId, new UUID[0], DEFAULT_SCAN_SETTINGS, null, null);
57     }
58 
ScanClient(int scannerId, UUID[] uuids)59     ScanClient(int scannerId, UUID[] uuids) {
60         this(scannerId, uuids, DEFAULT_SCAN_SETTINGS, null, null);
61     }
62 
ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters)63     ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters) {
64         this(scannerId, new UUID[0], settings, filters, null);
65     }
66 
ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages)67     ScanClient(int scannerId, ScanSettings settings, List<ScanFilter> filters,
68             List<List<ResultStorageDescriptor>> storages) {
69         this(scannerId, new UUID[0], settings, filters, storages);
70     }
71 
ScanClient(int scannerId, UUID[] uuids, ScanSettings settings, List<ScanFilter> filters, List<List<ResultStorageDescriptor>> storages)72     private ScanClient(int scannerId, UUID[] uuids, ScanSettings settings, List<ScanFilter> filters,
73             List<List<ResultStorageDescriptor>> storages) {
74         this.scannerId = scannerId;
75         this.uuids = uuids;
76         this.settings = settings;
77         this.passiveSettings = null;
78         this.filters = filters;
79         this.storages = storages;
80         this.appUid = Binder.getCallingUid();
81     }
82 
83     @Override
equals(Object obj)84     public boolean equals(Object obj) {
85         if (this == obj) {
86             return true;
87         }
88         if (obj == null || getClass() != obj.getClass()) {
89             return false;
90         }
91         ScanClient other = (ScanClient) obj;
92         return scannerId == other.scannerId;
93     }
94 
95     @Override
hashCode()96     public int hashCode() {
97         return Objects.hash(scannerId);
98     }
99 }
100