Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
*/

buildscript {
ext.wireVersion = '1.6.1'
ext.wireVersion = '4.9.9'

dependencies {
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
}
repositories {
mavenCentral()
google()
}
}

String gitDescribeVersion() {
Expand All @@ -25,6 +33,7 @@ allprojects {

subprojects {
repositories {
jcenter()
mavenCentral()
google()
}
}
6 changes: 2 additions & 4 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# SPDX-FileCopyrightText: 2015, microG Project Team
# SPDX-License-Identifier: CC0-1.0

#Mon Dec 22 23:44:23 EET 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions wearable-tools/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apply plugin: 'java'

dependencies {
implementation project(':wearable')
implementation "com.squareup.wire:wire-runtime:$wireVersion"
}

if (file('user.gradle').exists()) {
Expand Down
26 changes: 24 additions & 2 deletions wearable/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,32 @@
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'com.squareup.wire'

dependencies {
compile "com.squareup.wire:wire-runtime:$wireVersion"
implementation "com.squareup.wire:wire-runtime:$wireVersion"
}

wire {
sourcePath {
srcDir 'src/main/protos-repo'
}

protoPath {
srcDir 'src/main/protos-repo'
}

java {
out = file("$buildDir/generated/source/wire")
}
}

sourceSets {
main {
java.srcDirs += 'src/main/protos-java'
java {
srcDirs += 'src/main/java'
srcDirs += "$buildDir/generated/source/wire"
}
}
}

Expand All @@ -22,6 +40,10 @@ java {
withSourcesJar()
}

sourcesJar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

afterEvaluate {
publishing {
publications {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public SocketWearableConnection(Socket socket, Listener listener) throws IOExcep
}

protected void writeMessagePiece(MessagePiece piece) throws IOException {
byte[] bytes = piece.toByteArray();
byte[] bytes = MessagePiece.ADAPTER.encode(piece);
os.writeInt(bytes.length);
os.write(bytes);
}
Expand All @@ -46,7 +46,7 @@ protected MessagePiece readMessagePiece() throws IOException {
System.out.println("Reading piece of length " + len);
byte[] bytes = new byte[len];
is.readFully(bytes);
return new Wire().parseFrom(bytes, MessagePiece.class);
return MessagePiece.ADAPTER.decode(bytes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

public abstract class WearableConnection implements Runnable {
private static String B64ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
protected static Wire wire = new Wire();

private HashMap<Integer, List<MessagePiece>> piecesQueues = new HashMap<Integer, List<MessagePiece>>();
private final Listener listener;
Expand Down Expand Up @@ -54,7 +53,7 @@ public static String calculateDigest(byte[] bytes) {
}

public void writeMessage(RootMessage message) throws IOException {
byte[] bytes = message.toByteArray();
byte[] bytes = RootMessage.ADAPTER.encode(message);
// TODO: cut in pieces
writeMessagePiece(new MessagePiece.Builder()
.data(ByteString.of(bytes))
Expand All @@ -70,7 +69,7 @@ protected RootMessage readMessage() throws IOException {
System.out.println("Waiting for new message...");
MessagePiece piece = readMessagePiece();
if (piece.totalPieces == 1) {
return wire.parseFrom(piece.data.toByteArray(), RootMessage.class);
return RootMessage.ADAPTER.decode(piece.data);
} else {
if (piece.thisPiece == 1) {
List<MessagePiece> queue = piecesQueues.get(piece.queueId);
Expand All @@ -93,7 +92,7 @@ protected RootMessage readMessage() throws IOException {
throw new IOException("Received " + piece.thisPiece + " but expected piece" + queue.size() + 1);
}
queue.add(piece);
if (piece.thisPiece.equals(piece.totalPieces)) {
if (piece.thisPiece == piece.totalPieces) {
piecesQueues.remove(piece.queueId);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
for (MessagePiece messagePiece : queue) {
Expand All @@ -103,7 +102,7 @@ protected RootMessage readMessage() throws IOException {
if (!calculateDigest(bytes).equals(piece.digest)) {
throw new IOException("Merged pieces have digest " + calculateDigest(bytes) + ", but should be " + piece.digest);
}
return wire.parseFrom(bytes, RootMessage.class);
return RootMessage.ADAPTER.decode(bytes);
}
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading