version:1.5.1216
bugfixes: add:统一aidl,为中性mdm版本提供状态获取
This commit is contained in:
@@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -806,7 +808,7 @@ public class Utils {
|
||||
// if (NOSN.equalsIgnoreCase(getSn())) {
|
||||
// return getIMEI(context);
|
||||
// } else {
|
||||
return getSn();
|
||||
return getSn();
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1940,13 +1942,24 @@ public class Utils {
|
||||
}
|
||||
|
||||
|
||||
public static String getBluetoothList() {
|
||||
public static String getBluetoothList(Context context) {
|
||||
BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
// 获取所有通过 GATT 连接的设备(适用于低功耗蓝牙 BLE)
|
||||
List<BluetoothDevice> connectedDevices = bluetoothManager.getConnectedDevices(BluetoothProfile.GATT);
|
||||
|
||||
for (BluetoothDevice device : connectedDevices) {
|
||||
String deviceName = device.getName(); // 获取设备名称
|
||||
String deviceAddress = device.getAddress(); // 获取 MAC 地址
|
||||
Log.e("getBluetoothList", "已连接设备: " + deviceName + "(" + deviceAddress + ")");
|
||||
}
|
||||
|
||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (bluetoothAdapter == null) {
|
||||
return "没有蓝牙设备";
|
||||
} else {
|
||||
if (!bluetoothAdapter.isEnabled())//判断蓝牙设备是否已开起
|
||||
{
|
||||
Log.e(TAG, "getBluetoothList: getName = " + bluetoothAdapter.getName());
|
||||
//判断蓝牙设备是否已开起
|
||||
if (!bluetoothAdapter.isEnabled()) {
|
||||
return "蓝牙未开启";
|
||||
// //开起蓝牙设备
|
||||
// Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||
@@ -1956,9 +1969,12 @@ public class Utils {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Iterator<BluetoothDevice> iterator = devices.iterator(); iterator.hasNext(); ) {
|
||||
BluetoothDevice device = iterator.next();
|
||||
stringBuilder.append(device.getAlias()).append(";");
|
||||
if (device.isConnected()) {
|
||||
stringBuilder.append(device.getAlias()).append(";");
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "getBluetoothList: " + stringBuilder.toString());
|
||||
Log.e(TAG, "getConnectedBluetoothList: " + stringBuilder.toString());
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user