@Test public void getFatBeaconTitleTest() throws UnsupportedEncodingException { assertEquals("", EddystoneBeacon.getFatBeaconTitle(new byte[]{})); assertEquals("", EddystoneBeacon.getFatBeaconTitle(new byte[]{0x01})); assertEquals("", EddystoneBeacon.getFatBeaconTitle(new byte[]{0x01, 0x02})); assertEquals("", EddystoneBeacon.getFatBeaconTitle(new byte[]{0x01, 0x02, 0x00})); String title = "title"; byte[] titleBytes = title.getBytes("UTF-8"); int length = titleBytes.length; byte[] serviceData = new byte[length + 3]; System.arraycopy(titleBytes, 0, serviceData, 3, length); serviceData[0] = 0x10; serviceData[1] = 0x00; serviceData[2] = 0x0e; assertEquals(title, EddystoneBeacon.getFatBeaconTitle(serviceData)); }
public static String getFatBeaconTitle(byte[] serviceData) { if (serviceData.length > 2) { byte[] bytes = Arrays.copyOfRange(serviceData, 3, serviceData.length); String title = new String(bytes, Charset.forName("UTF-8")).trim(); return title.indexOf('\uFFFD') == -1 ? title : ""; } return ""; }
EddystoneBeacon { public static String getFatBeaconTitle(byte[] serviceData) { if (serviceData.length > 2) { byte[] bytes = Arrays.copyOfRange(serviceData, 3, serviceData.length); String title = new String(bytes, Charset.forName("UTF-8")).trim(); return title.indexOf('\uFFFD') == -1 ? title : ""; } return ""; } }
EddystoneBeacon { public static String getFatBeaconTitle(byte[] serviceData) { if (serviceData.length > 2) { byte[] bytes = Arrays.copyOfRange(serviceData, 3, serviceData.length); String title = new String(bytes, Charset.forName("UTF-8")).trim(); return title.indexOf('\uFFFD') == -1 ? title : ""; } return ""; } private  EddystoneBeacon(byte flags, byte txPower, String url); }
EddystoneBeacon { public static String getFatBeaconTitle(byte[] serviceData) { if (serviceData.length > 2) { byte[] bytes = Arrays.copyOfRange(serviceData, 3, serviceData.length); String title = new String(bytes, Charset.forName("UTF-8")).trim(); return title.indexOf('\uFFFD') == -1 ? title : ""; } return ""; } private  EddystoneBeacon(byte flags, byte txPower, String url); static String getFatBeaconTitle(byte[] serviceData); static boolean isFatBeacon(byte[] serviceData); static boolean isUrlFrame(byte[] serviceData); static EddystoneBeacon parseFromServiceData(byte[] urlServiceData, byte[] uriServiceData); String getUrl(); byte getTxPowerLevel(); byte getFlags(); }
EddystoneBeacon { public static String getFatBeaconTitle(byte[] serviceData) { if (serviceData.length > 2) { byte[] bytes = Arrays.copyOfRange(serviceData, 3, serviceData.length); String title = new String(bytes, Charset.forName("UTF-8")).trim(); return title.indexOf('\uFFFD') == -1 ? title : ""; } return ""; } private  EddystoneBeacon(byte flags, byte txPower, String url); static String getFatBeaconTitle(byte[] serviceData); static boolean isFatBeacon(byte[] serviceData); static boolean isUrlFrame(byte[] serviceData); static EddystoneBeacon parseFromServiceData(byte[] urlServiceData, byte[] uriServiceData); String getUrl(); byte getTxPowerLevel(); byte getFlags();  }