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 * Callback when a BLE advertisement has been found. 49 * 50 * @param callbackType Determines how this callback was triggered. Currently could only be 51 * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES}. 52 * @param result A Bluetooth LE scan result. 53 */ 54 public void onScanResult(int callbackType, ScanResult result) { 55 } 56 57 /** 58 * Callback when batch results are delivered. 59 * 60 * @param results List of scan results that are previously scanned. 61 */ 62 public void onBatchScanResults(List<ScanResult> results) { 63 } 64 65 /** 66 * Callback when scan could not be started. 67 * 68 * @param errorCode Error code (one of SCAN_FAILED_*) for scan failure. 69 */ 70 public void onScanFailed(int errorCode) { 71 } 72 } 73