1

我正在为学校使用开源 Android vnc 客户端 ( https://sourceforge.net/projects/multivnc/ ),我想做以下事情:

我希望帧缓冲区在我滚动/移动手指时更新(而不是在我停止滚动时)。我知道在我移动手指时正在发送输入,但帧缓冲区会等待更新,直到我停止滚动。VNCconn.java 文件在下面,它是更新 VNC 的帧缓冲区所涉及的代码部分是private void processNormalProtocol

当我放下手指时,它会冻结整个帧缓冲区并等待我停止滚动或抬起手指来更新屏幕。

当我放下手指开始滚动时,代码停在:

rfb.readServerMessageType();

因为它在 readServerMessgeType 处停止,所以代码不会转到下面的行来更新 Framebuffer。有大佬知道怎么更新吗???

我尝试删除此行(因为我不希望滚动时代码卡在此处):

int msgType = rfb.readServerMessageType();

但我得到这个错误:

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)

我可以按照代码的逻辑看到 readServerMessageType 转到 rfb.java 文件,然后转到 Android Studio 中一个名为“DatainputStream.java”的已关闭文件,这是卡住的地方,遗憾的是不能更改,因为它是一个锁定的文件:

这是涉及更新 Framebuffer 的 VNCConn.java 部分

     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();
     }
  }

这是 rfb.readServerMessageType() 是什么,它永远不会脱离 is.readUnsignedByte(); 直到滚动停止

int readServerMessageType() throws IOException {
  System.out.println("111111");
  int msgType = is.readUnsignedByte();
  System.out.println("22222");
  return msgType;
}

这会调用 Datainputstream.java (已锁定,我无法修改)

    public final int readUnsignedByte() throws IOException {
        int temp = in.read();
        if (temp < 0) {
            throw new EOFException();
        }
        return temp;
    }
4

0 回答 0