当前位置: 首页 > 工具软件 > btScan > 使用案例 >

bluetooth scan

方奕
2023-12-01

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

 类似资料:

相关阅读

相关文章

相关问答