Skip to content

Commit ff4c1a9

Browse files
author
SBALAVIGNESH123
committed
Fix: Thread-safety for static impl and missing null check in ConnectionThread
1 parent 80ee65f commit ff4c1a9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

play-services-wearable/core/src/main/java/org/microg/gms/wearable/WearableImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,10 @@ private class ConnectionThread extends Thread {
686686
public void run() {
687687
while (!isInterrupted()) {
688688
try {
689-
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
690689
if (adapter != null && adapter.isEnabled()) {
691690
Set<BluetoothDevice> bondedDevices = adapter.getBondedDevices();
692-
for (BluetoothDevice device : bondedDevices) {
691+
if (bondedDevices != null) {
692+
for (BluetoothDevice device : bondedDevices) {
693693
// Synchronized check for existing connections to this device
694694
boolean isConnected = false;
695695
synchronized (activeConnections) {
@@ -760,6 +760,7 @@ public void run() {
760760
}
761761

762762
}
763+
}
763764
}
764765
} catch (Exception e) {
765766
Log.w(TAG, "Error in Bluetooth ConnectionThread", e);

play-services-wearable/core/src/main/java/org/microg/gms/wearable/WearableService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public WearableService() {
3333
super("GmsWearSvc", GmsService.WEAR);
3434
}
3535

36-
public static WearableImpl impl;
36+
public static volatile WearableImpl impl;
3737

3838
@Override
3939
public void onCreate() {

0 commit comments

Comments
 (0)