bluetooth scan

xiaoxiao2021-02-28  97

Settings app  ----(LocalBluetoothAdapter)----BluetoothAdapter

 

packages\apps\Settings\src\com\android\settings\bluetooth\DevicePickerFragment.java

mLocalAdapter.startScanning(true);

 

/**

 * LocalBluetoothAdapter provides an interface between the Settings app  * and the functionality of the local {@link BluetoothAdapter}, specifically  * those related to state transitions of the adapter itself.  *  * <p>Connection and bonding state changes affecting specific devices  * are handled by {@link CachedBluetoothDeviceManager},  * {@link BluetoothEventManager}, and {@link LocalBluetoothProfileManager}.  */

frameworks\base\packages\SettingsLib\src\com\android\settingslib\bluetooth\LocalBluetoothAdapter.java

 

/**  * Represents the local device Bluetooth adapter. The {@link BluetoothAdapter}  * lets you perform fundamental Bluetooth tasks, such as initiate  * device discovery, query a list of bonded (paired) devices,  * instantiate a {@link BluetoothDevice} using a known MAC address, and create  * a {@link BluetoothServerSocket} to listen for connection requests from other  * devices, and start a scan for Bluetooth LE devices.  *  * <p>To get a {@link BluetoothAdapter} representing the local Bluetooth  * adapter, when running on JELLY_BEAN_MR1 and below, call the  * static {@link #getDefaultAdapter} method; when running on JELLY_BEAN_MR2 and  * higher, call {@link BluetoothManager#getAdapter}.  * Fundamentally, this is your starting point for all  * Bluetooth actions. Once you have the local adapter, you can get a set of  * {@link BluetoothDevice} objects representing all paired devices with  * {@link #getBondedDevices()}; start device discovery with  * {@link #startDiscovery()}; or create a {@link BluetoothServerSocket} to  * listen for incoming connection requests with  * {@link #listenUsingRfcommWithServiceRecord(String,UUID)}; or start a scan for  * Bluetooth LE devices with {@link #startLeScan(LeScanCallback callback)}.  *  * <p>This class is thread safe.  *  * <p class="note"><strong>Note:</strong>  * Most methods require the {@link android.Manifest.permission#BLUETOOTH}  * permission and some also require the  * {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.  *  * <div class="special reference">  * <h3>Developer Guides</h3>  * <p>  *  For more information about using Bluetooth, read the <a href=  * "{@docRoot}guide/topics/connectivity/bluetooth.html">Bluetooth</a> developer  * guide.  * </p>  * </div>  *  * {@see BluetoothDevice}  * {@see BluetoothServerSocket}  */

frameworks\base\core\java\android\bluetooth\BluetoothAdapter.java

 

 

frameworks\base\services\core\java\com\android\server\BluetoothManagerService.java   extends IBluetoothManager.Stub 

 

packages\apps\Bluetooth\src\com\android\bluetooth\btservice\AdapterService.java

 

/**      * The Binder implementation must be declared to be a static class, with      * the AdapterService instance passed in the constructor. Furthermore,      * when the AdapterService shuts down, the reference to the AdapterService      * must be explicitly removed.      *      * Otherwise, a memory leak can occur from repeated starting/stopping the      * service...Please refer to android.os.Binder for further details on      * why an inner instance class should be avoided.      *      */     private static class AdapterServiceBinder extends IBluetooth.Stub

    

     private native boolean startDiscoveryNative();

 

packages\apps\Bluetooth\jni\com_android_bluetooth_btservice_AdapterService.cpp

 

 

android/system/bt/btif/src/bluetooth.c

 .get_bluetooth_interface = bluetooth__get_bluetooth_interface

转载请注明原文地址: https://www.6miu.com/read-26219.html

最新回复(0)