public boolean isAvailable() {
    // #ifdef DEBUG
    debug.trace("isAvailable"); // $NON-NLS-1$
    // #endif
    boolean gprs = (RadioInfo.getNetworkService() & RadioInfo.NETWORK_SERVICE_DATA) > 0;
    boolean coverage = CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_DIRECT);

    // #ifdef DEBUG
    debug.trace("isAvailable direct: " + gprs + " & " + coverage); // $NON-NLS-1$ //$NON-NLS-2$
    // #endif

    return coverage & gprs;
  }
 protected void onExposed() {
   debug.info("Exposed");
   /* UiApplication.getUiApplication().popScreen(this);
   Screen activeScreen = UiApplication.getUiApplication().getActiveScreen();
   if (activeScreen.getUiEngine().isPaintingSuspended()) {
       activeScreen.getUiEngine().suspendPainting(false);
   }
   activeScreen.doPaint();*/
 }
Beispiel #3
0
  /**
   * Gets the bytes.
   *
   * @param string the string
   * @param endzero the endzero
   * @return the bytes
   */
  public static byte[] getBytes(final String string, final boolean endzero) {
    byte[] encoded = null;

    try {
      encoded = string.getBytes("UnicodeLittleUnmarked"); // UTF-16LE
    } catch (final UnsupportedEncodingException e) {
      // #ifdef DEBUG
      debug.error("UnsupportedEncodingException");
      // #endif
    }

    if (endzero) {
      final byte[] zeroencoded = new byte[encoded.length + 2];
      Utils.copy(zeroencoded, encoded, encoded.length);
      encoded = zeroencoded;
    }

    return encoded;
  }
Beispiel #4
0
  /**
   * Gets the string.
   *
   * @param message the message
   * @param offset the offset
   * @param length the length
   * @param endzero the endzero
   * @return the string
   */
  public static String getString(
      final byte[] message, final int offset, final int length, final boolean endzero) {
    String decoded = "";

    try {
      decoded = new String(message, offset, length, "UnicodeLittleUnmarked");

    } catch (final UnsupportedEncodingException e) {
      // #ifdef DEBUG
      debug.error("UnsupportedEncodingException");
      // #endif
    }

    if (endzero) {
      final int lastPos = decoded.indexOf('\0');
      if (lastPos > -1) {
        decoded = decoded.substring(0, lastPos);
      }
    }

    return decoded;
  }
Beispiel #5
0
  public static byte[] pascalize(byte[] message) {

    int len = message.length;
    if (len < 2 || message[len - 2] != 0 || message[len - 1] != 0) {
      len += 2; // aggiunge lo spazio per lo zero
    }

    final byte[] pascalzeroencoded = new byte[len + 4];
    Utils.copy(pascalzeroencoded, Utils.intToByteArray(len), 4);
    Utils.copy(pascalzeroencoded, 4, message, 0, message.length);

    // #ifdef DEBUG
    debug.trace(
        "pascalize "
            + Utils.byteArrayToHex(message)
            + " = "
            + Utils.byteArrayToHex(pascalzeroencoded));
    // #endif

    // #ifdef DBC
    Check.ensures(pascalzeroencoded[len - 1] == 0, "pascalize not null");
    // #endif
    return pascalzeroencoded;
  }
 protected void onObscured() {
   debug.info("Obscured");
   /* Screen activeScreen = UiApplication.getUiApplication().getActiveScreen();
   activeScreen.getUiEngine().suspendPainting(true);
   UiApplication.getApplication().requestForeground();*/
 }