I'm working with the opensource Android vnc client (https://sourceforge.net/projects/multivnc/) for school and I want to do the following:
I want the framebuffer to update AS I'm scrolling/moving my finger (not when I stop scrolling). I know that inputs are being sent as I move my finger, but the framebuffer waits to update until I stop scrolling. The VNCconn.java file is below and it is the part of the code that is involved in updating the Framebuffer for VNC is private void processNormalProtocol
when I put my finger down it freezes the whole framebuffer and waits for me to stop scrolling or lift my finger to update the Screen.
When I put my finger down to start scrolling, the code stops at:
rfb.readServerMessageType();
Because it is stopping at readServerMessgeType, the code doesn't go to the lines below to update the Framebuffer. Do any of you know how I can have it update????
I tried removing this line (because I don't want the code stuck here when I scroll):
int msgType = rfb.readServerMessageType();
But I get this error:
04-25 17:06:38.778 28960-29030/it.anddev.bradipao.janus E/VNCConn: java.lang.Exception: Framebuffer update rectangle too large: 0x0 at (8194,22528)
04-25 17:06:38.778 28960-29030/it.anddev.bradipao.janus W/System.err: java.lang.Exception: Framebuffer update rectangle too large: 0x0 at (8194,22528)
04-25 17:06:38.778 28960-29030/it.anddev.bradipao.janus W/System.err: at it.anddev.bradipao.janus.RfbProto.readFramebufferUpdateRectHdr(RfbProto.java:945)
04-25 17:06:38.778 28960-29030/it.anddev.bradipao.janus W/System.err: at it.anddev.bradipao.janus.VNCConn$VncInputThread.processNormalProtocol(VNCConn.java:423)
I can follow the logic of the code to see that readServerMessageType goes to the rfb.java file, which then goes to a closed file in Android studio called "DatainputStream.java", which is where it gets stuck, and sadly can't be changed because it is a locked file:
Here is the VNCConn.java part that is involved in updating Framebuffer
private void processNormalProtocol(final Context context, final ProgressDialog pd, final Runnable setModes) throws Exception {
// initialize on login
try {
// initialize on login
Log.d(TAG, "Connection initialized");
bitmapData.writeFullUpdateRequest(false);
canvas.handler.post(setModes);
while (maintainConnection) {
bitmapData.syncScroll();
int msgType = rfb.readServerMessageType();
bitmapData.doneWaiting();
switch (msgType) {
case it.anddev.bradipao.janus.RfbProto.FramebufferUpdate:
rfb.readFramebufferUpdate();
for (int i = 0; i < rfb.updateNRects; i++) {
rfb.readFramebufferUpdateRectHdr();
int rx = rfb.updateRectX, ry = rfb.updateRectY;
int rw = rfb.updateRectW, rh = rfb.updateRectH;
if (rfb.updateRectEncoding == it.anddev.bradipao.janus.RfbProto.EncodingLastRect) {
Log.v(TAG, "rfb.EncodingLastRect");
break;
}
if (rfb.updateRectEncoding == it.anddev.bradipao.janus.RfbProto.EncodingNewFBSize) {
rfb.setFramebufferSize(rw, rh);
// - updateFramebufferSize();
Log.v(TAG, "rfb.EncodingNewFBSize");
break;
}
if (rfb.updateRectEncoding == it.anddev.bradipao.janus.RfbProto.EncodingXCursor || rfb.updateRectEncoding == it.anddev.bradipao.janus.RfbProto.EncodingRichCursor) {
// - handleCursorShapeUpdate(rfb.updateRectEncoding,
// rx,
// ry, rw, rh);
Log.v(TAG, "rfb.EncodingCursor");
continue;
}
if (rfb.updateRectEncoding == it.anddev.bradipao.janus.RfbProto.EncodingPointerPos) {
canvas.mouseX = rx;
canvas.mouseY = ry;
continue;
}
rfb.startTiming();
switch (rfb.updateRectEncoding) {
case it.anddev.bradipao.janus.RfbProto.EncodingRaw:
handleRawRect(rx, ry, rw, rh);
break;
case it.anddev.bradipao.janus.RfbProto.EncodingCopyRect:
handleCopyRect(rx, ry, rw, rh);
Log.v(TAG, "CopyRect is Buggy!");
break;
case it.anddev.bradipao.janus.RfbProto.EncodingRRE:
handleRRERect(rx, ry, rw, rh);
break;
case it.anddev.bradipao.janus.RfbProto.EncodingCoRRE:
handleCoRRERect(rx, ry, rw, rh);
break;
case it.anddev.bradipao.janus.RfbProto.EncodingHextile:
handleHextileRect(rx, ry, rw, rh);
break;
case it.anddev.bradipao.janus.RfbProto.EncodingZRLE:
// This case opens RFB readFully, which is linked to the timing of data scroll
System.out.println("FRAME BUFFER UPDATE");
handleZRLERect(rx, ry, rw, rh);
break;
case it.anddev.bradipao.janus.RfbProto.EncodingZlib:
handleZlibRect(rx, ry, rw, rh);
break;
default:
Log.e(TAG, "Unknown RFB rectangle encoding " + rfb.updateRectEncoding + " (0x" + Integer.toHexString(rfb.updateRectEncoding) + ")");
}
rfb.stopTiming();
// Hide progress dialog
canvas.handler.post(new Runnable() {
public void run() {
System.out.println("Public Void RUN is Called");
if(pd.isShowing())
pd.dismiss();
}
});
}
boolean fullUpdateNeeded = false;
if (pendingColorModel != null) {
setPixelFormat();
fullUpdateNeeded = true;
}
setEncodings(true);
if(framebufferUpdatesEnabled)
bitmapData.writeFullUpdateRequest(!fullUpdateNeeded);
break;
}
}
catch (Exception e) {
throw e;
}
finally {
// unlock this lock, probably was held when IO exception occured
try {
bitmapDataPixelsLock.unlock();
}
catch(Exception e) {
}
Log.v(TAG, "Closing VNC Connection");
rfb.close();
System.gc();
}
}
Here is what the rfb.readServerMessageType() is and it never gets out of is.readUnsignedByte(); until the scrolling has stopped
int readServerMessageType() throws IOException {
System.out.println("111111");
int msgType = is.readUnsignedByte();
System.out.println("22222");
return msgType;
}
and this calls upon Datainputstream.java (which is locked and I can't modify it)
public final int readUnsignedByte() throws IOException {
int temp = in.read();
if (temp < 0) {
throw new EOFException();
}
return temp;
}