public CCZHeader(final byte[] pData) { this.mDataByteBuffer = ByteBuffer.wrap(pData); this.mDataByteBuffer.rewind(); this.mDataByteBuffer.order(ByteOrder.BIG_ENDIAN); /* Check magic bytes. */ if (!ArrayUtils.equals( pData, 0, CCZHeader.MAGIC_IDENTIFIER, 0, CCZHeader.MAGIC_IDENTIFIER.length)) { throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!"); } // TODO Check the version? this.mCCZCompressionFormat = CCZCompressionFormat.fromID(this.getCCZCompressionFormatID()); }
/** @param pData */ public PVRTextureHeader(final byte[] pData) { this.mDataByteBuffer = ByteBuffer.wrap(pData); this.mDataByteBuffer.rewind(); this.mDataByteBuffer.order(ByteOrder.LITTLE_ENDIAN); /* Check magic bytes. */ if (!ArrayUtils.equals( pData, 11 * DataConstants.BYTES_PER_INT, PVRTextureHeader.MAGIC_IDENTIFIER, 0, PVRTextureHeader.MAGIC_IDENTIFIER.length)) { throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!"); } this.mPVRTextureFormat = PVRTextureFormat.fromID(this.getFlags() & PVRTextureHeader.FORMAT_FLAG_MASK); }
/** * @return prefers to return an IPv4 address if found, otherwise an IPv6 address. * @throws org.andengine.util.WifiUtils.WifiUtilsException */ @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static byte[] getWifiHotspotIPAddressRaw() throws WifiUtilsException { try { byte[] ipv6Address = null; final Enumeration<NetworkInterface> networkInterfaceEnumeration = NetworkInterface.getNetworkInterfaces(); while (networkInterfaceEnumeration.hasMoreElements()) { final NetworkInterface networkInterface = networkInterfaceEnumeration.nextElement(); if (SystemUtils.isAndroidVersionOrLower(Build.VERSION_CODES.FROYO) || !networkInterface.isLoopback()) { final String networkInterfaceName = networkInterface.getName(); if (ArrayUtils.contains(WifiUtils.HOTSPOT_NETWORKINTERFACE_NAMES, networkInterfaceName)) { final Enumeration<InetAddress> inetAddressEnumeration = networkInterface.getInetAddresses(); while (inetAddressEnumeration.hasMoreElements()) { final InetAddress inetAddress = inetAddressEnumeration.nextElement(); if (!inetAddress.isLoopbackAddress()) { final byte[] ipAddress = inetAddress.getAddress(); if (ipAddress.length == IPUtils.IPV4_LENGTH) { return ipAddress; } else { ipv6Address = ipAddress; } } } } } } if (ipv6Address != null) { return ipv6Address; } else { throw new WifiUtilsException( "No IP bound to '" + Arrays.toString(WifiUtils.HOTSPOT_NETWORKINTERFACE_NAMES) + "'!"); } } catch (final SocketException e) { throw new WifiUtilsException("Unexpected error!", e); } }