Documentation for the Unreal C++ Plugin
Loading...
Searching...
No Matches
PixoUtilities.java
Go to the documentation of this file.
1package com.Pixo.PixoPlatform;
2
3import android.os.Build;
4import java.lang.reflect.Method;
5import android.util.Log;
6import android.Manifest.permission;
7import android.net.wifi.WifiManager;
8import android.net.wifi.WifiInfo;
9import java.net.NetworkInterface;
10import java.util.List;
11import java.util.Collections;
12
13public class PixoUtilities {
14 public static String getSerialNumber()
15 {
16 String serialNumber;
17
18 try {
19 Class<?> c = Class.forName("android.os.SystemProperties");
20 Method get = c.getMethod("get", String.class);
21
22 serialNumber = (String) get.invoke(c, "gsm.sn1");
23 if (serialNumber.equals(""))
24 serialNumber = (String) get.invoke(c, "ril.serialnumber");
25 if (serialNumber.equals(""))
26 serialNumber = (String) get.invoke(c, "ro.serialno");
27 if (serialNumber.equals(""))
28 serialNumber = (String) get.invoke(c, "sys.serialnumber");
29 if (serialNumber.equals(""))
30 serialNumber = Build.SERIAL;
31
32 // If none of the methods above worked
33 if (serialNumber.equals(""))
34 serialNumber = "";
35 } catch (Exception e) {
36 e.printStackTrace();
37 serialNumber = "";
38 }
39
40 return serialNumber;
41 }
42
43 public static String getMacAddress()
44 {
45 Log.d("PixoUtilities", "Getting mac address.");
46 try {
47 List<NetworkInterface> ifaceList = Collections.list(NetworkInterface.getNetworkInterfaces());
48 for (NetworkInterface iface : ifaceList) {
49 if (iface == null) {
50 continue;
51 }
52 if (!iface.getName().equalsIgnoreCase("wlan0")) {
53 continue;
54 }
55 byte[] macBytes = iface.getHardwareAddress();
56 if (macBytes == null) {
57 return "";
58 }
59 StringBuilder macSb = new StringBuilder();
60 for (byte bytes : macBytes) {
61 macSb.append(String.format("%02X", bytes));
62 }
63 if (macSb.length() == 0) {
64 return "";
65 }
66 return macSb.toString();
67 }
68 } catch (Exception ex) {
69 ex.printStackTrace();
70 }
71 return "";
72 }
73}