Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.4k
Add Bluetooth support for WearOS devices#3178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
SBALAVIGNESH123 wants to merge23 commits intomicrog:masterChoose a base branch fromSBALAVIGNESH123:wearos-bluetooth-support
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes from1 commit
Commits
Show all changes
23 commits Select commitHold shift + click to select a range
6fb0195 Add Bluetooth support for WearOS devices
ef58386 Fix bugs reported by code review: thread safety, socket leaks, file l…
f663ea8 Fix bugs: race conditions, NPE, missing flush (Round 2)
febb05c Refactor: Use standard MessageHandler for full protocol support (Roun…
5cf84de Feat: Add basic Wearable UI for managing connections
7b4047c Fix: Clear static impl reference on service destroy
ece85ec Fix: TOCTOU race condition in WearableSettingsActivity
80ee65f Fix: Socket leak on handshake failure and incomplete Connect message
ff4c1a9 Fix: Thread-safety for static impl and missing null check in Connecti…
fcba2eb Fix: Define undefined adapter variable in ConnectionThread
1c4933f Fix: Sync race condition in activeConnections access
725e7d4 Fix: Remove duplicate ACCESS_NETWORK_STATE permission
882fa2f Docs: Add comments to handshake logic
0ffc9c2 Feat: UI/UX Improvements (Material Design, Scan, Disconnect)
6631713 Fix: Perms, Connection Race, and UI Status Logic
9149be9 Fix variable shadowing and connection race condition
b1d1aaa Fix compilation error: remove duplicate closing brace
09f6146 Fix: Resolve all compilation errors for WearOS Bluetooth support
2b9c0be Merge branch 'master' into wearos-bluetooth-support
SBALAVIGNESH123c59523d Fix: Add missing BLUETOOTH_CONNECT permission
eda5727 Merge branch 'wearos-bluetooth-support' of https://github.com/SBALAVI…
9440651 Merge branch 'master' into wearos-bluetooth-support
SBALAVIGNESH12322b8895 Fix: Add runtime permission checks for BLUETOOTH_CONNECT
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
Add Bluetooth support for WearOS devices
Implements RFCOMM transport layer for WearOS connectivity without Google Play Services.- Created BluetoothWearableConnection for Bluetooth Classic transport- Added automatic device discovery and connection in WearableImpl- Added necessary Bluetooth permissions to manifestAddresses#2843 - + bounty for WearOS support
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
7 changes: 7 additions & 0 deletionsplay-services-core/src/main/AndroidManifest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions...ices-wearable/core/src/main/java/org/microg/gms/wearable/BluetoothWearableConnection.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * 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 com.squareup.wire.Wire; | ||
| import org.microg.wearable.WearableConnection; | ||
| import org.microg.wearable.proto.MessagePiece; | ||
| import java.io.DataInputStream; | ||
| import java.io.DataOutputStream; | ||
| import java.io.IOException; | ||
| /** | ||
| * 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.toByteArray(); | ||
| os.writeInt(bytes.length); | ||
| os.write(bytes); | ||
| } | ||
| @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); | ||
| return new Wire().parseFrom(bytes, MessagePiece.class); | ||
| } | ||
| @Override | ||
| public void close() throws IOException { | ||
| socket.close(); | ||
| } | ||
| } |
104 changes: 104 additions & 0 deletionsplay-services-wearable/core/src/main/java/org/microg/gms/wearable/WearableImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.