1 /* 2 * Copyright (C) 2014 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 android.bluetooth.le; 18 19 import java.util.List; 20 21 /** 22 * Bluetooth LE scan callbacks. Scan results are reported using these callbacks. 23 * 24 * @see BluetoothLeScanner#startScan 25 */ 26 public abstract class ScanCallback { 27 /** 28 * Fails to start scan as BLE scan with the same settings is already started by the app. 29 */ 30 public static final int SCAN_FAILED_ALREADY_STARTED = 1; 31 32 /** 33 * Fails to start scan as app cannot be registered. 34 */ 35 public static final int SCAN_FAILED_APPLICATION_REGISTRATION_FAILED = 2; 36 37 /** 38 * Fails to start scan due an internal error 39 */ 40 public static final int SCAN_FAILED_INTERNAL_ERROR = 3; 41 42 /** 43 * Fails to start power optimized scan as this feature is not supported. 44 */ 45 public static final int SCAN_FAILED_FEATURE_UNSUPPORTED = 4; 46 47 /** 48 * Fails to start scan as it is out of hardware resources. 49 * @hide 50 */ 51 public static final int SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES = 5; 52 53 static final int NO_ERROR = 0; 54 55 /** 56 * Callback when a BLE advertisement has been found. 57 * 58 * @param callbackType Determines how this callback was triggered. Could be one of 59 * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES}, 60 * {@link ScanSettings#CALLBACK_TYPE_FIRST_MATCH} or 61 * {@link ScanSettings#CALLBACK_TYPE_MATCH_LOST} 62 * @param result A Bluetooth LE scan result. 63 */ onScanResult(int callbackType, ScanResult result)64 public void onScanResult(int callbackType, ScanResult result) { 65 } 66 67 /** 68 * Callback when batch results are delivered. 69 * 70 * @param results List of scan results that are previously scanned. 71 */ onBatchScanResults(List<ScanResult> results)72 public void onBatchScanResults(List<ScanResult> results) { 73 } 74 75 /** 76 * Callback when scan could not be started. 77 * 78 * @param errorCode Error code (one of SCAN_FAILED_*) for scan failure. 79 */ onScanFailed(int errorCode)80 public void onScanFailed(int errorCode) { 81 } 82 } 83