22
33import android .Manifest .permission ;
44import android .annotation .SuppressLint ;
5+ import android .bluetooth .BluetoothAdapter ;
56import android .content .Context ;
67import android .content .pm .PackageInfo ;
78import android .content .pm .PackageManager ;
@@ -27,6 +28,8 @@ public class DIHelper {
2728 protected static String sIMEI = null ;
2829 protected static String sSerialNumber = null ;
2930
31+ protected static String sBtMacAddress = null ;
32+
3033 public static final long SEC_IN_MS = 1000 ;
3134 public static final long MIN_IN_MS = SEC_IN_MS * 60 ;
3235 public static long MAX_EMDK_TIMEOUT_IN_MS = 10 * MIN_IN_MS ; // 10 minutes
@@ -92,7 +95,7 @@ public void onDebugStatus(String message) {
9295 };
9396
9497 new RetrieveOEMInfoTask ()
95- .execute (context , Uri .parse ("content://oem_info/oem.zebra.secure/build_serial" ),
98+ .executeAsync (context , Uri .parse ("content://oem_info/oem.zebra.secure/build_serial" ),
9699 tempCallbackInterface );
97100 }
98101
@@ -159,7 +162,57 @@ public void onDebugStatus(String message) {
159162 }
160163 };
161164
162- new RetrieveOEMInfoTask ().execute (context , Uri .parse ("content://oem_info/wan/imei" ),
165+ new RetrieveOEMInfoTask ().executeAsync (context , Uri .parse ("content://oem_info/wan/imei" ),
163166 tempCallbackInterface );
164167 }
168+
169+ public static void getBtMacAddress (Context context , IDIResultCallbacks callbackInterface )
170+ {
171+ if (sBtMacAddress != null )
172+ {
173+ if (callbackInterface != null )
174+ {
175+ callbackInterface .onDebugStatus ("BT Mac address already in cache." );
176+ }
177+ callbackInterface .onSuccess (sBtMacAddress );
178+ return ;
179+ }
180+ if (android .os .Build .VERSION .SDK_INT < 23 ) {
181+ returnBtMacAddressUsingAndroidAPIs (context , callbackInterface );
182+ } else {
183+ returnBtMacAddressUsingZebraAPIs (context , callbackInterface );
184+ }
185+ }
186+
187+ private static void returnBtMacAddressUsingZebraAPIs (Context context , IDIResultCallbacks callbackInterface ) {
188+ IDIResultCallbacks tempCallbackInterface = new IDIResultCallbacks () {
189+ @ Override
190+ public void onSuccess (String message ) {
191+ sBtMacAddress = message ;
192+ callbackInterface .onSuccess (message );
193+ }
194+
195+ @ Override
196+ public void onError (String message ) {
197+ callbackInterface .onError (message );
198+ }
199+
200+ @ Override
201+ public void onDebugStatus (String message ) {
202+ callbackInterface .onDebugStatus (message );
203+ }
204+ };
205+
206+ new RetrieveOEMInfoTask ().executeAsync (context , Uri .parse ("content://oem_info/oem.zebra.secure/bt_mac" ),
207+ tempCallbackInterface );
208+ }
209+
210+ private static void returnBtMacAddressUsingAndroidAPIs (Context context , IDIResultCallbacks callbackInterface ) {
211+ BluetoothAdapter mBluetoothAdapter = BluetoothAdapter .getDefaultAdapter ();
212+ String macAddress = mBluetoothAdapter .getAddress ();
213+ if (callbackInterface != null )
214+ {
215+ callbackInterface .onSuccess (macAddress );
216+ }
217+ }
165218}
0 commit comments