导航菜单

页面标题

页面副标题

xDrip+ v04633772025.07.16 - DisconnectReceiver.java 源代码

正在查看: xDrip+ v04633772025.07.16 应用的 DisconnectReceiver.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.eveningoutpost.dexdrip.utils;

import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.eveningoutpost.dexdrip.models.UserError;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class DisconnectReceiver extends BroadcastReceiver {
    private static final String TAG = "DisconnectReceiver";
    private static final ConcurrentHashMap<String, BtCallBack> callbacks = new ConcurrentHashMap<>();

    public static void addCallBack(BtCallBack btCallBack, String str) {
        callbacks.put(str, btCallBack);
    }

    public static void removeCallBack(String str) {
        callbacks.remove(str);
    }

    private synchronized void processCallBacks(String str, String str2) {
        for (Map.Entry<String, BtCallBack> entry : callbacks.entrySet()) {
            UserError.Log.d(TAG, "Callback: " + entry.getKey());
            entry.getValue().btCallback(str, str2);
        }
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String address;
        try {
            if (!intent.getAction().equals("android.bluetooth.device.action.ACL_DISCONNECTED") || (address = ((BluetoothDevice) intent.getParcelableExtra("android.bluetooth.device.extra.DEVICE")).getAddress()) == null) {
                return;
            }
            UserError.Log.d(TAG, "Disconnection notice: " + address);
            processCallBacks(address, "DISCONNECTED");
        } catch (NullPointerException e) {
            UserError.Log.e(TAG, "NPE in onReceive: " + e);
        }
    }
}