Exemple #1
0
  public void showConnectionInfo() {
    if (rfbconn == null) return;

    String msg = null;
    int idx = rfbconn.desktopName().indexOf("(");
    if (idx > 0) {
      // Breakup actual desktop name from IP addresses for improved
      // readability
      String dn = rfbconn.desktopName().substring(0, idx).trim();
      String ip = rfbconn.desktopName().substring(idx).trim();
      msg = dn + "\n" + ip;
    } else msg = rfbconn.desktopName();
    msg += "\n" + rfbconn.framebufferWidth() + "x" + rfbconn.framebufferHeight();
    String enc = rfbconn.getEncoding();
    // Encoding might not be set when we display this message
    if (decoder.getColorModel() != null) {
      if (enc != null && !enc.equals(""))
        msg += ", " + rfbconn.getEncoding() + " encoding, " + decoder.getColorModel().toString();
      else msg += ", " + decoder.getColorModel().toString();
    }
    Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show();
  }
Exemple #2
0
  void initializeBitmap(int dx, int dy) throws IOException {
    Log.i(TAG, "Desktop name is " + rfbconn.desktopName());
    Log.i(
        TAG, "Desktop size is " + rfbconn.framebufferWidth() + " x " + rfbconn.framebufferHeight());
    int fbsize = rfbconn.framebufferWidth() * rfbconn.framebufferHeight();
    capacity =
        BCFactory.getInstance()
            .getBCActivityManager()
            .getMemoryClass(Utils.getActivityManager(getContext()));

    if (connection.getForceFull() == BitmapImplHint.AUTO) {
      if (fbsize * CompactBitmapData.CAPACITY_MULTIPLIER <= capacity * 1024 * 1024) {
        useFull = true;
        compact = true;
      } else if (fbsize * FullBufferBitmapData.CAPACITY_MULTIPLIER <= capacity * 1024 * 1024) {
        useFull = true;
      } else {
        useFull = false;
      }
    } else useFull = (connection.getForceFull() == BitmapImplHint.FULL);

    if (!useFull) {
      bitmapData = new LargeBitmapData(rfbconn, this, dx, dy, capacity);
      android.util.Log.i(TAG, "Using LargeBitmapData.");
    } else {
      try {
        // TODO: Remove this if Android 4.2 receives a fix which causes it to stop drawing
        // the bitmap in CompactBitmapData when under load (say playing a video over VNC).
        if (!compact || android.os.Build.VERSION.SDK_INT == 17) {
          bitmapData = new FullBufferBitmapData(rfbconn, this, capacity);
          android.util.Log.i(TAG, "Using FullBufferBitmapData.");
        } else {
          bitmapData = new CompactBitmapData(rfbconn, this);
          android.util.Log.i(TAG, "Using CompactBufferBitmapData.");
        }
      } catch (Throwable e) { // If despite our efforts we fail to allocate memory, use LBBM.
        if (bitmapData != null) bitmapData.dispose();
        bitmapData = null;
        System.gc();
        useFull = false;
        bitmapData = new LargeBitmapData(rfbconn, this, dx, dy, capacity);
        android.util.Log.i(TAG, "Using LargeBitmapData.");
      }
    }

    decoder.setBitmapData(bitmapData);
  }