package com.ycgis.macall.personalcenter.m.provider;

import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.ycgis.macall.personalcenter.m.adapterbean.BluetoothOV;
import com.ycgis.macall.personalcenter.util.BluetoothManage;

import org.greenrobot.eventbus.EventBus;

/**
 * created by:   Macall
 * create time:  2025/5/29 17:37
 * copyright:    @ruansee.com
 * Describe:
 */
public class BluetoothBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.ERROR);
            int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, BluetoothDevice.ERROR);
            if (bondState == BluetoothDevice.BOND_BONDING) {

                // 正在配对
            } else if (bondState == BluetoothDevice.BOND_BONDED) {
                // 配对成功

            } else if (bondState == BluetoothDevice.BOND_NONE) {

                // 取消配对/配对失败
            }
        }
        if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
            // 设备已连接
        } else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
            // 设备已断开
        }
    }

}
