diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java b/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java
index 7ee61ee249..db5af0f02c 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePairingDetailBase.java
@@ -35,6 +35,9 @@ import com.android.settings.accessibility.AccessibilityStatsLogUtils;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
/**
* Abstract class for providing basic interaction for a list of Bluetooth devices in bluetooth
@@ -60,6 +63,22 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
mInitialScanStarted = false;
super.onViewCreated(view, savedInstanceState);
}
+
+ private static final int MSG_BLUETOOT_UPDATE =99;
+ private BluetoothHandler mHander =new BluetoothHandler(Looper.getMainLooper());
+ private class BluetoothHandler extends Handler{
+ BluetoothHandler(Looper looper){
+ super(looper);
+ }
+ @Override
+ public void handleMessage(@NonNull Message msg) {
+ switch (msg.what){
+ case MSG_BLUETOOT_UPDATE:
+ updateBluetooth();
+ break;
+ }
+ }
+ }
@Override
public void onStart() {
@@ -68,7 +87,8 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
Log.e(getLogTag(), "Bluetooth is not supported on this device");
return;
}
- updateBluetooth();
+ mHander.sendEmptyMessageDelayed(MSG_BLUETOOT_UPDATE,1500);
+ //updateBluetooth();
}
@Override
@@ -78,6 +98,7 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
Log.e(getLogTag(), "Bluetooth is not supported on this device");
return;
}
+ mHander.removeMessages(MSG_BLUETOOT_UPDATE);
disableScanning();
}
diff --git a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
index a4a9891797..67af43fe65 100644
--- a/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
+++ b/src/com/android/settings/bluetooth/DeviceListPreferenceFragment.java
@@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
+import android.text.TextUtils;
/**
* Parent class for settings fragments that contain a list of Bluetooth
@@ -147,6 +148,7 @@ public abstract class DeviceListPreferenceFragment extends
if (mLocalManager == null || isUiRestricted()) {
return;
}
+ stopClassicScanning();
removeAllDevices();
mLocalManager.setForegroundActivity(null);
@@ -199,6 +201,11 @@ public abstract class DeviceListPreferenceFragment extends
if (mBluetoothAdapter.getState() != BluetoothAdapter.STATE_ON) {
return;
}
+ String name = cachedDevice.getDevice().getName();
+ if (TextUtils.isEmpty(name)){
+ return;
+ }
+
if (mFilter != null && mFilter.matches(cachedDevice.getDevice())) {
createDevicePreference(cachedDevice);
@@ -223,13 +230,24 @@ public abstract class DeviceListPreferenceFragment extends
preference.hideSecondTarget(true);
mDeviceListGroup.addPreference(preference);
}
-
+ android.util.Log.d(TAG, "find bt devices: =========="+mDevicePreferenceMap.size());
initDevicePreference(preference);
mDevicePreferenceMap.put(cachedDevice, preference);
+
}
+ boolean is50 = false;
protected void initDevicePreference(BluetoothDevicePreference preference) {
// Does nothing by default
+ // liujunjie add size > 50 stop
+ if(mDevicePreferenceMap.size() >= 50 ){
+ android.util.Log.d(TAG, "size >= 50 stopClassicScanning : =========="+mDevicePreferenceMap);
+ is50 = true;
+ //stopScanning();
+ }else{
+ is50 = false;
+ }
+
}
@VisibleForTesting
@@ -284,10 +302,12 @@ public abstract class DeviceListPreferenceFragment extends
@VisibleForTesting
void startScanning() {
- if (mFilter != null) {
+ if (mFilter != null && !is50) {
startClassicScanning();
+ android.util.Log.d("liujunjie55","startScanning ====startClassicScanning ");
} else if (mLeScanFilters != null) {
startLeScanning();
+ android.util.Log.d("liujunjie55","startScanning ====startLeScanning ");
}
}
RK3562 安卓14 优化 Settings 蓝牙搜索报错的问题(只能搜索50个设备)
最新推荐文章于 2024-07-17 23:45:02 发布