Fix android build
Fixes changes to grpc services and downgrades appcompat due to a bug in dependency versions
This commit is contained in:
@@ -32,7 +32,7 @@ android {
|
||||
dependencies {
|
||||
implementation project(':protobuf')
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.5.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
@@ -42,9 +42,9 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
implementation 'io.grpc:grpc-okhttp:1.29.0' // CURRENT_GRPC_VERSION
|
||||
implementation 'io.grpc:grpc-protobuf-lite:1.39.0' // CURRENT_GRPC_VERSION
|
||||
implementation 'io.grpc:grpc-stub:1.39.0' // CURRENT_GRPC_VERSION
|
||||
implementation 'io.grpc:grpc-okhttp:1.29.0'
|
||||
implementation 'io.grpc:grpc-protobuf-lite:1.39.0'
|
||||
implementation 'io.grpc:grpc-stub:1.39.0'
|
||||
implementation 'javax.annotation:javax.annotation-api:1.3.2'
|
||||
implementation 'org.zeromq:jeromq:0.5.2'
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ public class PiLoader implements Runnable {
|
||||
|
||||
private Integer steeringValue = 50;
|
||||
private Integer throttleValue = 50;
|
||||
private ManagedChannel mChannel;
|
||||
private final ManagedChannel mChannel;
|
||||
|
||||
private CarControlGrpc.CarControlBlockingStub stub;
|
||||
private AtomicBoolean stop = new AtomicBoolean(false);
|
||||
private final CarControlGrpc.CarControlBlockingStub stub;
|
||||
private final AtomicBoolean stop = new AtomicBoolean(false);
|
||||
private Thread piUpdaterThread;
|
||||
private boolean useGrpcStream;
|
||||
private final boolean useGrpcStream;
|
||||
|
||||
public PiLoader(String host, Integer port, boolean useGrpcStream) {
|
||||
mChannel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build();
|
||||
@@ -72,10 +72,10 @@ public class PiLoader implements Runnable {
|
||||
try {
|
||||
SteeringResponse steeringResponse = stub.setSteering(
|
||||
SteeringRequest.newBuilder().setSteering((float) steeringValue / 50f - 1)
|
||||
.build());
|
||||
.build());
|
||||
ThrottleResponse throttleResponse = stub.setThrottle(
|
||||
ThrottleRequest.newBuilder().setThrottle((float) throttleValue / 50f - 1)
|
||||
.build());
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error");
|
||||
stop();
|
||||
@@ -93,9 +93,9 @@ public class PiLoader implements Runnable {
|
||||
private void doStreamUpdates() {
|
||||
// Stream if user sets use_grpc_streams to true. This method is more efficient but less compatible.
|
||||
final CountDownLatch finishLatch = new CountDownLatch(1);
|
||||
StreamObserver<Empty> responseObserver = new StreamObserver<Empty>() {
|
||||
StreamObserver<Vehicle2DResponse> responseObserver = new StreamObserver<Vehicle2DResponse>() {
|
||||
@Override
|
||||
public void onNext(Empty value) {
|
||||
public void onNext(Vehicle2DResponse value) {
|
||||
finishLatch.countDown();
|
||||
Log.d("PiLoader", "Finished streaming");
|
||||
}
|
||||
@@ -113,23 +113,23 @@ public class PiLoader implements Runnable {
|
||||
}
|
||||
};
|
||||
StreamObserver<Vehicle2DRequest> requestStreamObserver = CarControlGrpc.newStub(mChannel)
|
||||
.streamVehicle2d(
|
||||
responseObserver);
|
||||
.streamVehicle2d(
|
||||
responseObserver);
|
||||
while (!stop.get() && !Thread.interrupted() && finishLatch.getCount() > 0) {
|
||||
requestStreamObserver.onNext(Vehicle2DRequest.newBuilder()
|
||||
.setThrottle(ThrottleRequest.newBuilder()
|
||||
.setThrottle(
|
||||
(float) throttleValue /
|
||||
50f -
|
||||
1)
|
||||
.build())
|
||||
.setSteering(SteeringRequest.newBuilder()
|
||||
.setSteering(
|
||||
(float) steeringValue /
|
||||
50f -
|
||||
1)
|
||||
.build())
|
||||
.build());
|
||||
.setThrottle(ThrottleRequest.newBuilder()
|
||||
.setThrottle(
|
||||
(float) throttleValue /
|
||||
50f -
|
||||
1)
|
||||
.build())
|
||||
.setSteering(SteeringRequest.newBuilder()
|
||||
.setSteering(
|
||||
(float) steeringValue /
|
||||
50f -
|
||||
1)
|
||||
.build())
|
||||
.build());
|
||||
try {
|
||||
// Use the same update rate as a typical screen refresh rate.
|
||||
TimeUnit.MILLISECONDS.sleep(200);
|
||||
@@ -141,12 +141,12 @@ public class PiLoader implements Runnable {
|
||||
|
||||
public void saveRecording() {
|
||||
// Ideally don't want to use a blocking stub here, android may complain.
|
||||
Empty done = stub.saveRecordedData(SaveRequest.newBuilder().setFile("Test").build());
|
||||
SaveResponse done = stub.saveRecordedData(SaveRequest.newBuilder().setFile("Test").build());
|
||||
}
|
||||
|
||||
|
||||
public void record(boolean record) {
|
||||
// Ideally don't want to use a blocking stub here, android may complain.
|
||||
Empty done = stub.record(RecordingReqeust.newBuilder().setRecord(record).build());
|
||||
RecordingResponse done = stub.record(RecordingReqeust.newBuilder().setRecord(record).build());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user