IT. Expert System.

Android Reference



Class ObexHelper

  • public final class ObexHelper
    extends Object
    This class defines a set of helper methods for the implementation of Obex.
    • Field Detail


        public static final int BASE_PACKET_LENGTH
        Defines the basic packet length used by OBEX. Every OBEX packet has the same basic format:
        Byte 0: Request or Response Code Byte 1&2: Length of the packet.
        See Also:
        Constant Field Values

        public static final int MAX_PACKET_SIZE_INT
        The maximum packet size for OBEX packets that this client can handle. At present, this must be changed for each port. TODO: The max packet size should be the Max incoming MTU minus TODO: L2CAP package headers and RFCOMM package headers. TODO: Retrieve the max incoming MTU from TODO: LocalDevice.getProperty().
        See Also:
        Constant Field Values

        public static final int MAX_CLIENT_PACKET_SIZE
        Temporary workaround to be able to push files to Windows 7. TODO: Should be removed as soon as Microsoft updates their driver.
        See Also:
        Constant Field Values

        public static final int OBEX_OPCODE_RESERVED_FINAL
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ASCII
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_1
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_2
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_3
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_4
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_5
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_6
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_7
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_8
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_ISO_8859_9
        See Also:
        Constant Field Values

        public static final int OBEX_AUTH_REALM_CHARSET_UNICODE
        See Also:
        Constant Field Values
    • Method Detail

      • updateHeaderSet

        public static byte[] updateHeaderSet(HeaderSet header,
                             byte[] headerArray)
                                      throws IOException
        Updates the HeaderSet with the headers received in the byte array provided. Invalid headers are ignored.

        The first two bits of an OBEX Header specifies the type of object that is being sent. The table below specifies the meaning of the high bits.

        Bits 8 and 7 Value Description
        00 0x00 Null Terminated Unicode text, prefixed with 2 byte unsigned integer
        01 0x40 Byte Sequence, length prefixed with 2 byte unsigned integer
        10 0x80 1 byte quantity
        11 0xC0 4 byte quantity - transmitted in network byte order (high byte first
        This method uses the information in this table to determine the type of Java object to create and passes that object with the full header to setHeader() to update the HeaderSet object. Invalid headers will cause an exception to be thrown. When it is thrown, it is ignored.
        header - the HeaderSet to update
        headerArray - the byte array containing headers
        the result of the last start body or end body header provided; the first byte in the result will specify if a body or end of body is received
        IOException - if an invalid header was found
      • createHeader

        public static byte[] createHeader(HeaderSet head,
                          boolean nullOut)
        Creates the header part of OBEX packet based on the header provided. TODO: Could use getHeaderList() to get the array of headers to include and then use the high two bits to determine the the type of the object and construct the byte array from that. This will make the size smaller.
        head - the header used to construct the byte array
        nullOut - true if the header should be set to null once it is added to the array or false if it should not be nulled out
        the header of an OBEX packet
      • findHeaderEnd

        public static int findHeaderEnd(byte[] headerArray,
                        int start,
                        int maxSize)
        Determines where the maximum divide is between headers. This method is used by put and get operations to separate headers to a size that meets the max packet size allowed.
        headerArray - the headers to separate
        start - the starting index to search
        maxSize - the maximum size of a packet
        the index of the end of the header block to send or -1 if the header could not be divided because the header is too large
      • convertToLong

        public static long convertToLong(byte[] b)
        Converts the byte array to a long.
        b - the byte array to convert to a long
        the byte array as a long
      • convertToByteArray

        public static byte[] convertToByteArray(long l)
        Converts the long to a 4 byte array. The long must be non negative.
        l - the long to convert
        a byte array that is the same as the long
      • convertToUnicodeByteArray

        public static byte[] convertToUnicodeByteArray(String s)
        Converts the String to a UNICODE byte array. It will also add the ending null characters to the end of the string.
        s - the string to convert
        the unicode byte array of the string
      • getTagValue

        public static byte[] getTagValue(byte tag,
                         byte[] triplet)
        Retrieves the value from the byte array for the tag value specified. The array should be of the form Tag - Length - Value triplet.
        tag - the tag to retrieve from the byte array
        triplet - the byte sequence containing the tag length value form
        the value of the specified tag
      • findTag

        public static int findTag(byte tag,
                  byte[] value)
        Finds the index that starts the tag value pair in the byte array provide.
        tag - the tag to look for
        value - the byte array to search
        the starting index of the tag or -1 if the tag could not be found
      • convertToUnicode

        public static String convertToUnicode(byte[] b,
                              boolean includesNull)
        Converts the byte array provided to a unicode string.
        b - the byte array to convert to a string
        includesNull - determine if the byte string provided contains the UNICODE null character at the end or not; if it does, it will be removed
        a Unicode string
        IllegalArgumentException - if the byte array has an odd length
      • computeMd5Hash

        public static byte[] computeMd5Hash(byte[] in)
        Compute the MD5 hash of the byte array provided. Does not accumulate input.
        in - the byte array to hash
        the MD5 hash of the byte array
      • computeAuthenticationChallenge

        public static byte[] computeAuthenticationChallenge(byte[] nonce,
                                            String realm,
                                            boolean access,
                                            boolean userID)
                                                     throws IOException
        Computes an authentication challenge header.
        nonce - the challenge that will be provided to the peer; the challenge must be 16 bytes long
        realm - a short description that describes what password to use
        access - if true then full access will be granted if successful; if false then read only access will be granted if successful
        userID - if true, a user ID is required in the reply; if false, no user ID is required
        IllegalArgumentException - if the challenge is not 16 bytes long; if the realm can not be encoded in less then 255 bytes
        IOException - if the encoding scheme ISO 8859-1 is not supported


Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)





Java Script








Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 31 / 158662708. Delta: 0.04411 с