Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6fb0195
Add Bluetooth support for WearOS devices
Dec 10, 2025
ef58386
Fix bugs reported by code review: thread safety, socket leaks, file l…
Dec 11, 2025
f663ea8
Fix bugs: race conditions, NPE, missing flush (Round 2)
Dec 11, 2025
febb05c
Refactor: Use standard MessageHandler for full protocol support (Roun…
Dec 11, 2025
5cf84de
Feat: Add basic Wearable UI for managing connections
Dec 11, 2025
7b4047c
Fix: Clear static impl reference on service destroy
Dec 11, 2025
ece85ec
Fix: TOCTOU race condition in WearableSettingsActivity
Dec 11, 2025
80ee65f
Fix: Socket leak on handshake failure and incomplete Connect message
Dec 11, 2025
ff4c1a9
Fix: Thread-safety for static impl and missing null check in Connecti…
Dec 11, 2025
fcba2eb
Fix: Define undefined adapter variable in ConnectionThread
Dec 11, 2025
1c4933f
Fix: Sync race condition in activeConnections access
Dec 11, 2025
725e7d4
Fix: Remove duplicate ACCESS_NETWORK_STATE permission
Dec 11, 2025
882fa2f
Docs: Add comments to handshake logic
Dec 11, 2025
0ffc9c2
Feat: UI/UX Improvements (Material Design, Scan, Disconnect)
Dec 11, 2025
6631713
Fix: Perms, Connection Race, and UI Status Logic
Dec 11, 2025
9149be9
Fix variable shadowing and connection race condition
Dec 12, 2025
b1d1aaa
Fix compilation error: remove duplicate closing brace
Dec 12, 2025
09f6146
Fix: Resolve all compilation errors for WearOS Bluetooth support
Dec 14, 2025
2b9c0be
Merge branch 'master' into wearos-bluetooth-support
SBALAVIGNESH123 Dec 14, 2025
c59523d
Fix: Add missing BLUETOOTH_CONNECT permission
Dec 15, 2025
eda5727
Merge branch 'wearos-bluetooth-support' of https://github.com/SBALAVI…
Dec 15, 2025
9440651
Merge branch 'master' into wearos-bluetooth-support
SBALAVIGNESH123 Dec 16, 2025
22b8895
Fix: Add runtime permission checks for BLUETOOTH_CONNECT
Dec 16, 2025
48c962e
Merge branch 'master' into wearos-bluetooth-support
SBALAVIGNESH123 Jan 6, 2026
7f8a5d0
Merge branch 'master' into wearos-bluetooth-support
SBALAVIGNESH123 Jan 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,16 @@
android:protectionLevel="signature"/>
<uses-permission android:name="com.google.android.gms.auth.permission.GOOGLE_ACCOUNT_CHANGE" />


<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- For Android 12+ -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Expand Down
10 changes: 10 additions & 0 deletions play-services-wearable/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<application>
<activity android:name="org.microg.gms.wearable.WearableSettingsActivity"
android:label="@string/wearable_settings_title"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2013-2019 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.microg.gms.wearable;

import android.bluetooth.BluetoothSocket;

import org.microg.wearable.WearableConnection;
import org.microg.wearable.proto.MessagePiece;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;

/**
* Bluetooth transport implementation for Wearable connections.
* Uses RFCOMM sockets to communicate with WearOS devices over Bluetooth Classic.
*/
public class BluetoothWearableConnection extends WearableConnection {
private final int MAX_PIECE_SIZE = 20 * 1024 * 1024; // 20MB limit
private final BluetoothSocket socket;
private final DataInputStream is;
private final DataOutputStream os;

public BluetoothWearableConnection(BluetoothSocket socket, Listener listener) throws IOException {
super(listener);
this.socket = socket;
this.is = new DataInputStream(socket.getInputStream());
this.os = new DataOutputStream(socket.getOutputStream());
}

@Override
protected void writeMessagePiece(MessagePiece piece) throws IOException {
byte[] bytes = piece.encode();
os.writeInt(bytes.length);
os.write(bytes);
os.flush();
}

@Override
protected MessagePiece readMessagePiece() throws IOException {
int len = is.readInt();
if (len > MAX_PIECE_SIZE || len < 0) {
throw new IOException("Piece size " + len + " exceeded limit of " + MAX_PIECE_SIZE + " bytes.");
}
byte[] bytes = new byte[len];
is.readFully(bytes);

// Use reflection to call wire.parseFrom() to work around Wire version incompatibility
// The inherited 'wire' instance from WearableConnection uses Wire 1.6.1 API
try {
Method parseFrom = wire.getClass().getMethod("parseFrom", byte[].class, Class.class);
return (MessagePiece) parseFrom.invoke(wire, bytes, MessagePiece.class);
} catch (Exception e) {
throw new IOException("Failed to deserialize MessagePiece: " + e.getMessage(), e);
}
}

public String getRemoteAddress() {
return socket.getRemoteDevice().getAddress();
}

@Override
public void close() throws IOException {
socket.close();
}
}
Loading