Loading packages/SystemUI/aconfig/systemui.aconfig +9 −0 Original line number Original line Diff line number Diff line Loading @@ -420,3 +420,12 @@ flag { } } } } flag { name: "get_connected_device_name_unsynchronized" namespace: "systemui" description: "Decide whether to fetch the connected bluetooth device name outside a synchronized block." bug: "323995015" metadata { purpose: PURPOSE_BUGFIX } } packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +16 −3 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfile; import com.android.settingslib.bluetooth.LocalBluetoothProfile; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.systemui.Flags; import com.android.systemui.bluetooth.BluetoothLogger; import com.android.systemui.bluetooth.BluetoothLogger; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Background; Loading Loading @@ -240,11 +241,23 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa @WorkerThread @WorkerThread @Override @Override public String getConnectedDeviceName() { public String getConnectedDeviceName() { if (Flags.getConnectedDeviceNameUnsynchronized()) { CachedBluetoothDevice connectedDevice = null; // Calling the getName() API for CachedBluetoothDevice outside the synchronized block // so that the main thread is not blocked. synchronized (mConnectedDevices) { if (mConnectedDevices.size() == 1) { connectedDevice = mConnectedDevices.get(0); } } return connectedDevice != null ? connectedDevice.getName() : null; } else { synchronized (mConnectedDevices) { synchronized (mConnectedDevices) { if (mConnectedDevices.size() == 1) { if (mConnectedDevices.size() == 1) { return mConnectedDevices.get(0).getName(); return mConnectedDevices.get(0).getName(); } } } } } return null; return null; } } Loading Loading
packages/SystemUI/aconfig/systemui.aconfig +9 −0 Original line number Original line Diff line number Diff line Loading @@ -420,3 +420,12 @@ flag { } } } } flag { name: "get_connected_device_name_unsynchronized" namespace: "systemui" description: "Decide whether to fetch the connected bluetooth device name outside a synchronized block." bug: "323995015" metadata { purpose: PURPOSE_BUGFIX } }
packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +16 −3 Original line number Original line Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothManager; import com.android.settingslib.bluetooth.LocalBluetoothProfile; import com.android.settingslib.bluetooth.LocalBluetoothProfile; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.settingslib.bluetooth.LocalBluetoothProfileManager; import com.android.systemui.Flags; import com.android.systemui.bluetooth.BluetoothLogger; import com.android.systemui.bluetooth.BluetoothLogger; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.Background; Loading Loading @@ -240,11 +241,23 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa @WorkerThread @WorkerThread @Override @Override public String getConnectedDeviceName() { public String getConnectedDeviceName() { if (Flags.getConnectedDeviceNameUnsynchronized()) { CachedBluetoothDevice connectedDevice = null; // Calling the getName() API for CachedBluetoothDevice outside the synchronized block // so that the main thread is not blocked. synchronized (mConnectedDevices) { if (mConnectedDevices.size() == 1) { connectedDevice = mConnectedDevices.get(0); } } return connectedDevice != null ? connectedDevice.getName() : null; } else { synchronized (mConnectedDevices) { synchronized (mConnectedDevices) { if (mConnectedDevices.size() == 1) { if (mConnectedDevices.size() == 1) { return mConnectedDevices.get(0).getName(); return mConnectedDevices.get(0).getName(); } } } } } return null; return null; } } Loading