Skip to content

Commit 8c2a87a

Browse files
committed
Check for invalid request type
1 parent 0720c51 commit 8c2a87a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

app/src/main/java/net/sourceforge/opencamera/sensorremote/RemoteRpcRequestHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ private String getSensorData(File imuFile) throws IOException {
6161
return res;
6262
}
6363

64+
RemoteRpcResponse handleInvalidRequest() {
65+
return mResponseBuilder.error("Invalid request", mContext);
66+
}
67+
6468
RemoteRpcResponse handleImuRequest(long durationMillis, boolean wantAccel, boolean wantGyro) {
6569
if (mRawSensorInfo != null && !mRawSensorInfo.isRecording()) {
6670
// TODO: custom rates?

app/src/main/java/net/sourceforge/opencamera/sensorremote/RemoteRpcServer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ private void handleRequest(String msg, PrintStream outputStream, BufferedOutputS
8686
if (MyDebug.LOG) {
8787
Log.d(TAG, "IMU request file sent");
8888
}
89-
return;
90-
}
91-
92-
// Video remote control API
93-
if (msg.equals(mConfig.getProperty("VIDEO_START_REQUEST"))) {
89+
} else if (msg.equals(mConfig.getProperty("VIDEO_START_REQUEST"))) {
9490
outputStream.println(
9591
mRequestHandler.handleVideoStartRequest()
9692
);
@@ -100,6 +96,10 @@ private void handleRequest(String msg, PrintStream outputStream, BufferedOutputS
10096
);
10197
} else if (msg.equals(mConfig.getProperty("GET_VIDEO_REQUEST"))) {
10298
mRequestHandler.handleVideoGetRequest(outputStream);
99+
} else {
100+
outputStream.println(
101+
mRequestHandler.handleInvalidRequest()
102+
);
103103
}
104104
}
105105

0 commit comments

Comments
 (0)