From b11dc42911952b1585ab9ebc42c125f9a848f4de Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 09:58:09 +0100 Subject: [PATCH 01/18] Added basic cache mechanism. --- DeviceIdentifiersWrapper/build.gradle | 4 +- .../deviceidentifierswrapper/DIHelper.java | 67 +++++++++++++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index 1b0b60a..0a4ac26 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -12,8 +12,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 32 - versionCode 2 - versionName "0.2" + versionCode 4 + versionName "0.4" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java index 78a9905..d36a624 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java @@ -24,9 +24,23 @@ public class DIHelper { // TODO: Put your custom certificate in the apkCertificate member for MX AccessMgr registering (only if necessary and if you know what you are doing) public static Signature apkCertificate = null; + protected static String sIMEI = null; + protected static String sSerialNumber = null; + + public static void resetCachedValues() + { + sIMEI = null; + sSerialNumber = null; + } + // This method will return the serial number in the string passed through the onSuccess method public static void getSerialNumber(Context context, IDIResultCallbacks callbackInterface) { + if(sSerialNumber != null) + { + callbackInterface.onSuccess(sSerialNumber); + return; + } if (android.os.Build.VERSION.SDK_INT < 29) { returnSerialUsingAndroidAPIs(context, callbackInterface); } else { @@ -37,9 +51,11 @@ public static void getSerialNumber(Context context, IDIResultCallbacks callbackI @SuppressLint({"MissingPermission", "ObsoleteSdkInt", "HardwareIds"}) private static void returnSerialUsingAndroidAPIs(Context context, IDIResultCallbacks callbackInterface) { if (android.os.Build.VERSION.SDK_INT < 26) { + sSerialNumber = Build.SERIAL; callbackInterface.onSuccess(Build.SERIAL); } else { if (ContextCompat.checkSelfPermission(context, permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { + sSerialNumber = Build.getSerial(); callbackInterface.onSuccess(Build.getSerial()); } else { callbackInterface.onError("Please grant READ_PHONE_STATE permission"); @@ -47,15 +63,38 @@ private static void returnSerialUsingAndroidAPIs(Context context, IDIResultCallb } } - private static void returnSerialUsingZebraAPIs(Context context, IDIResultCallbacks callbackInterface) { + private static void returnSerialUsingZebraAPIs(Context context, final IDIResultCallbacks callbackInterface) { + IDIResultCallbacks tempCallbackInterface = new IDIResultCallbacks() { + @Override + public void onSuccess(String message) { + sSerialNumber = message; + callbackInterface.onSuccess(message); + } + + @Override + public void onError(String message) { + callbackInterface.onError(message); + } + + @Override + public void onDebugStatus(String message) { + callbackInterface.onDebugStatus(message); + } + }; + new RetrieveOEMInfoTask() .execute(context, Uri.parse("content://oem_info/oem.zebra.secure/build_serial"), - callbackInterface); + tempCallbackInterface); } // This method will return the imei number in the string passed through the onSuccess method public static void getIMEINumber(Context context, IDIResultCallbacks callbackInterface) { + if(sIMEI != null) + { + callbackInterface.onSuccess(sIMEI); + return; + } if (android.os.Build.VERSION.SDK_INT < 29) { returnImeiUsingAndroidAPIs(context, callbackInterface); } else { @@ -68,6 +107,7 @@ private static void returnImeiUsingAndroidAPIs(Context context, IDIResultCallbac TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (android.os.Build.VERSION.SDK_INT < 26) {String imei = telephonyManager.getDeviceId(); if (imei != null && !imei.isEmpty()) { + sIMEI = imei; callbackInterface.onSuccess(imei); } else { callbackInterface.onError("Could not get IMEI number"); @@ -76,6 +116,7 @@ private static void returnImeiUsingAndroidAPIs(Context context, IDIResultCallbac if (ContextCompat.checkSelfPermission(context, permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) { String imei = telephonyManager.getImei(); if (imei != null && !imei.isEmpty()) { + sIMEI = imei; callbackInterface.onSuccess(imei); } else { callbackInterface.onError("Could not get IMEI number"); @@ -86,8 +127,26 @@ private static void returnImeiUsingAndroidAPIs(Context context, IDIResultCallbac } } - private static void returnImeiUsingZebraAPIs(Context context, IDIResultCallbacks callbackInterface) { + private static void returnImeiUsingZebraAPIs(Context context, final IDIResultCallbacks callbackInterface) { + IDIResultCallbacks tempCallbackInterface = new IDIResultCallbacks() { + @Override + public void onSuccess(String message) { + sIMEI = message; + callbackInterface.onSuccess(message); + } + + @Override + public void onError(String message) { + callbackInterface.onError(message); + } + + @Override + public void onDebugStatus(String message) { + callbackInterface.onDebugStatus(message); + } + }; + new RetrieveOEMInfoTask().execute(context, Uri.parse("content://oem_info/wan/imei"), - callbackInterface); + tempCallbackInterface); } } From 4acda07f527bfc94bfac191272ac1f47c95c7541 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:36:15 +0100 Subject: [PATCH 02/18] Added a wait for EMDK mechanism. This can become handy when your app respond to the BOOT_COMPLETED event. Changed the architecture of the sample. --- DeviceIdentifiersWrapper/build.gradle | 6 +++- .../deviceidentifierswrapper/DIHelper.java | 3 ++ .../DIProfileManagerCommand.java | 32 +++++++++++++++++++ .../RetrieveOEMInfoTask.java | 3 +- README.md | 12 +++++-- 5 files changed, 52 insertions(+), 4 deletions(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index 0a4ac26..98b3a42 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -10,7 +10,7 @@ android { compileSdkVersion 32 defaultConfig { - minSdkVersion 19 + minSdkVersion 28 targetSdkVersion 32 versionCode 4 versionName "0.4" @@ -25,6 +25,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java index d36a624..054b6b7 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java @@ -27,6 +27,9 @@ public class DIHelper { protected static String sIMEI = null; protected static String sSerialNumber = null; + private static final long MIN_IN_MS = 1000 * 60; + public static long MAX_EMDK_TIMEOUT_IN_MS = 10 * MIN_IN_MS; // 10 minutes + public static void resetCachedValues() { sIMEI = null; diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java index f7b4435..5b636db 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java @@ -17,6 +17,7 @@ import java.io.StringReader; import java.util.ArrayList; +import java.util.Date; class DIProfileManagerCommand extends DICommandBase { public class ErrorHolder @@ -55,6 +56,8 @@ public class ErrorHolder // Provides full error description string public String msErrorString = ""; + private boolean bInitializing = false; + // Status Listener implementation (ensure that we retrieve the profile manager asynchronously EMDKManager.StatusListener mStatusListener = new EMDKManager.StatusListener() { @Override @@ -114,6 +117,9 @@ public void execute(String mxProfile, String mxProfileName, IDIResultCallbacks r private void initializeEMDK() { + if(bInitializing) + return; + bInitializing = true; if(mEMDKManager == null) { EMDKResults results = null; @@ -126,6 +132,7 @@ private void initializeEMDK() { logMessage("Error while requesting EMDKManager.\n" + e.getLocalizedMessage(), EMessageType.ERROR); e.printStackTrace(); + waitForEMDK(); return; } @@ -134,6 +141,7 @@ private void initializeEMDK() logMessage("EMDKManager request command issued with success", EMessageType.DEBUG); }else { logMessage("EMDKManager request command error", EMessageType.ERROR); + waitForEMDK(); } } else @@ -142,6 +150,29 @@ private void initializeEMDK() } } + private void waitForEMDK() + { + Thread t = new Thread(new Runnable() { + @Override + public void run() { + long startDate = new Date().getTime(); + long delta = 0; + long maxWait = 1000 * 60 * 10; // We will try for 10 mns... before stopping + while(mEMDKManager == null || delta < DIHelper.MAX_EMDK_TIMEOUT_IN_MS ) { + initializeEMDK(); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + delta = new Date().getTime() - startDate; + } + } + }); + t.setPriority(Thread.MIN_PRIORITY); + t.start(); + } + private void onEMDKManagerRetrieved(EMDKManager emdkManager) { mEMDKManager = emdkManager; @@ -186,6 +217,7 @@ private void releaseManagers() private void onProfileManagerInitialized(ProfileManager profileManager) { mProfileManager = profileManager; + bInitializing = false; logMessage("Profile Manager retrieved.", EMessageType.DEBUG); processMXContent(); } diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java index a13a4ff..8681321 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java @@ -1,5 +1,6 @@ package com.zebra.deviceidentifierswrapper; +import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -163,7 +164,7 @@ private static void getURIValue(Cursor cursor, Uri uri, IDIResultCallbacks resul else{ for (int i = 0; i < cursor.getColumnCount(); i++) { try { - String data = cursor.getString(cursor.getColumnIndex(cursor.getColumnName(i))); + @SuppressLint("Range") String data = cursor.getString(cursor.getColumnIndex(cursor.getColumnName(i))); resultCallbacks.onSuccess(data); cursor.close(); return; diff --git a/README.md b/README.md index d4fd336..3b59a93 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,16 @@ ## Sample Repository https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample - -## Update for A11 +## V0.4 : Basic cache mechanism +```text + Added basic cache mechanism. + The IMei and the Serial number will be cached once they get retrieved. + The cache can be reset with the method: + DIHelper.resetCachedValues() + Added a mechanism to wait for the EMDK if it is not available (when responding to the BOOT_COMPLETED event for ex. + To be tested... feel free to report any issue regarding this feature. +``` +## V0.3 : Update for A11 ```text Update your graddle distribution to >= 7.3.3 update your compileSdkVersion to 30 From 346e0c5db0f1e109ae0560c1a7c12aab0bfeb5fe Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:39:52 +0100 Subject: [PATCH 03/18] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3b59a93..518c984 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ ## Sample Repository https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample -## V0.4 : Basic cache mechanism +## V0.4 : Basic cache mechanism & Wait for EMDK availability ```text Added basic cache mechanism. - The IMei and the Serial number will be cached once they get retrieved. - The cache can be reset with the method: - DIHelper.resetCachedValues() - Added a mechanism to wait for the EMDK if it is not available (when responding to the BOOT_COMPLETED event for ex. - To be tested... feel free to report any issue regarding this feature. + The IMei and the Serial number will be cached once they get retrieved. + The cache can be reset with the method: + DIHelper.resetCachedValues() + Added a mechanism to wait for the EMDK if it is not available (when responding to the BOOT_COMPLETED event for ex. + To be tested... feel free to report any issue regarding this feature. ``` ## V0.3 : Update for A11 ```text From 307f226961b6e75eebaaf5ebc5509caefd0e0383 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:40:27 +0100 Subject: [PATCH 04/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 518c984..9bf4940 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample The IMei and the Serial number will be cached once they get retrieved. The cache can be reset with the method: DIHelper.resetCachedValues() - Added a mechanism to wait for the EMDK if it is not available (when responding to the BOOT_COMPLETED event for ex. + Added a mechanism to wait for the EMDK if it is not available (when responding to the BOOT_COMPLETED event for ex.) To be tested... feel free to report any issue regarding this feature. ``` ## V0.3 : Update for A11 From 7d5775fb44a842eb0bc743483f7ccdb5a29c8947 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:41:00 +0100 Subject: [PATCH 05/18] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9bf4940..21fd5fb 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,11 @@ https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample ## Important !! ```text Due to usage of the EMDK and the need to register the application, it is strongly advised to call the methods in your application class - Check https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample implementation. - It's a basic implementation using static members. - Feel free to remove statics and replace them with a better code in terms of architecture. - The goal was to pass the idea that theses number should be retrieved only once, and the best place for it is the Application class. - Note that a mechanism has been added in V0.4 to wait for the EMDK in case it would not be available (the classic use case is when your app respond to the BOOT_COMPLETED event that occurs way before the EMDK finishes its initialization) + Check https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample implementation. + It's a basic implementation using static members. + Feel free to remove statics and replace them with a better code in terms of architecture. + The goal was to pass the idea that theses number should be retrieved only once, and the best place for it is the Application class. + Note that a mechanism has been added in V0.4 to wait for the EMDK in case it would not be available (the classic use case is when your app respond to the BOOT_COMPLETED event that occurs way before the EMDK finishes its initialization) ``` ## Description From f916c786cb44ff60b1b543cc57c527a8536967e3 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:43:19 +0100 Subject: [PATCH 06/18] Reverted to Min SDK 19 --- DeviceIdentifiersWrapper/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index 98b3a42..724a8da 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -10,7 +10,7 @@ android { compileSdkVersion 32 defaultConfig { - minSdkVersion 28 + minSdkVersion 19 targetSdkVersion 32 versionCode 4 versionName "0.4" From c34c72760710e2cba4cf0b555f4e465f6e5252ef Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:45:02 +0100 Subject: [PATCH 07/18] Revert to min SDK 19 --- .../deviceidentifierswrapper/RetrieveOEMInfoTask.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java index 8681321..1d885b7 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/RetrieveOEMInfoTask.java @@ -107,7 +107,10 @@ private static void registerCurrentApplication(Context context, Uri serviceIdent // You can copy/paste this snippet if you want to provide your own // certificate // TODO: use the following code snippet to extract your custom certificate if necessary - final Signature[] arrSignatures = packageInfo.signingInfo.getApkContentsSigners(); + Signature[] arrSignatures = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) { + arrSignatures = packageInfo.signingInfo.getApkContentsSigners(); + } if(arrSignatures == null || arrSignatures.length == 0) { if(callbackInterface != null) @@ -125,7 +128,10 @@ private static void registerCurrentApplication(Context context, Uri serviceIdent final byte[] rawCert = sig.toByteArray(); // Get the certificate as a base64 string - String encoded = Base64.getEncoder().encodeToString(rawCert); + String encoded = null; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + encoded = Base64.getEncoder().encodeToString(rawCert); + } profileData = "" + From 1a583fcd9fe75e25239f705ffc96d1591e27bf1f Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 10:49:34 +0100 Subject: [PATCH 08/18] Update version to push on jitpack --- DeviceIdentifiersWrapper/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index 724a8da..b5d97d3 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -12,8 +12,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 32 - versionCode 4 - versionName "0.4" + versionCode 5 + versionName "0.5" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" From bcb9a68c110f5315bd6a88423041efa0abc4485b Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 12:16:53 +0100 Subject: [PATCH 09/18] added more log information --- .idea/.name | 1 - .idea/gradle.xml | 1 - .../com/zebra/deviceidentifierswrapper/DIHelper.java | 4 +++- .../DIProfileManagerCommand.java | 9 +++++++-- settings.gradle | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 .idea/.name diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 8f326a5..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -EMDK-DeviceIdentifiers-Sample \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 6593b67..0108d6b 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -13,7 +13,6 @@ diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java index 054b6b7..d7f6c8a 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java @@ -27,8 +27,10 @@ public class DIHelper { protected static String sIMEI = null; protected static String sSerialNumber = null; - private static final long MIN_IN_MS = 1000 * 60; + public static final long SEC_IN_MS = 1000; + public static final long MIN_IN_MS = SEC_IN_MS * 60; public static long MAX_EMDK_TIMEOUT_IN_MS = 10 * MIN_IN_MS; // 10 minutes + public static long WAIT_PERIOD_BEFORE_RETRY_EMDK_RETRIEVAL_IN_MS = 2 * SEC_IN_MS; // 2 seconds public static void resetCachedValues() { diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java index 5b636db..91ee444 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java @@ -152,20 +152,25 @@ private void initializeEMDK() private void waitForEMDK() { + logMessage("EMDKManager error, this could be a BOOT_COMPLETED issue.", EMessageType.DEBUG); + logMessage("Starting watcher thread to wait for EMDK initialization.", EMessageType.DEBUG); Thread t = new Thread(new Runnable() { @Override public void run() { long startDate = new Date().getTime(); long delta = 0; - long maxWait = 1000 * 60 * 10; // We will try for 10 mns... before stopping while(mEMDKManager == null || delta < DIHelper.MAX_EMDK_TIMEOUT_IN_MS ) { + // Try to initialize EMDK + logMessage("Calling EMDK Initialization method", EMessageType.DEBUG); initializeEMDK(); try { - Thread.sleep(5000); + logMessage("Waiting " + DIHelper.WAIT_PERIOD_BEFORE_RETRY_EMDK_RETRIEVAL_IN_MS + " milliseconds before retrying.", EMessageType.DEBUG); + Thread.sleep(DIHelper.WAIT_PERIOD_BEFORE_RETRY_EMDK_RETRIEVAL_IN_MS); } catch (InterruptedException e) { e.printStackTrace(); } delta = new Date().getTime() - startDate; + logMessage("Delta in ms since first EMDK retrieval try: " + delta + "ms stops at " + DIHelper.MAX_EMDK_TIMEOUT_IN_MS + "ms", EMessageType.DEBUG); } } }); diff --git a/settings.gradle b/settings.gradle index 09209e7..54716ae 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -include ':SampleApplication',':DeviceIdentifiersWrapper' -rootProject.name = "EMDK-DeviceIdentifiers-Sample" \ No newline at end of file +include ':DeviceIdentifiersWrapper' +rootProject.name = "DeviceIdentifiersWrapper" \ No newline at end of file From 8f21a54867514c968934f977546f87fb56185bfb Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 12:19:26 +0100 Subject: [PATCH 10/18] More log info (when waiting for EMDK initialization) --- DeviceIdentifiersWrapper/build.gradle | 4 ++-- .../deviceidentifierswrapper/DIProfileManagerCommand.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index f20a084..b8cbaa1 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -12,8 +12,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 32 - versionCode 6 - versionName "0.6" + versionCode 7 + versionName "0.7" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java index 91ee444..bab5fa3 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java @@ -172,6 +172,7 @@ public void run() { delta = new Date().getTime() - startDate; logMessage("Delta in ms since first EMDK retrieval try: " + delta + "ms stops at " + DIHelper.MAX_EMDK_TIMEOUT_IN_MS + "ms", EMessageType.DEBUG); } + logMessage("Could not retrieve EMDK Manager after waiting " + DIHelper.WAIT_PERIOD_BEFORE_RETRY_EMDK_RETRIEVAL_IN_MS/DIHelper.SEC_IN_MS + " seconds. Please contact your administrator or check logcat for any EMDK related error.", EMessageType.ERROR); } }); t.setPriority(Thread.MIN_PRIORITY); From fdcf240d4d99ed8fbaf64e8b555f4357cd2a00e1 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 12:33:45 +0100 Subject: [PATCH 11/18] update gradle version --- DeviceIdentifiersWrapper/build.gradle | 8 ++------ build.gradle | 21 +++------------------ gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index b8cbaa1..b17ff18 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -1,9 +1,5 @@ -apply plugin: 'com.android.library' - -ext { - PUBLISH_GROUP_ID = 'com.zebra.deviceidentifierswrapper' - PUBLISH_ARTIFACT_ID = 'deviceidentifierswrapper' - PUBLISH_VERSION = '0.2' +plugins { + id 'com.android.library' } android { diff --git a/build.gradle b/build.gradle index da807a2..5ae9a7b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - google() - jcenter() - } - dependencies { - classpath "com.android.tools.build:gradle:4.0.0" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - } +plugins { + id 'com.android.application' version '7.2.2' apply false + id 'com.android.library' version '7.2.2' apply false } task clean(type: Delete) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fe0dbff..5fe5e46 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip diff --git a/settings.gradle b/settings.gradle index 54716ae..88cd915 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,22 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + jcenter() + maven { url 'https://jitpack.io' } + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + jcenter() + maven { url 'https://jitpack.io' } + } +} + + include ':DeviceIdentifiersWrapper' rootProject.name = "DeviceIdentifiersWrapper" \ No newline at end of file From a790aa802d75b165318587fb039e5e1e89672ac2 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 12:50:06 +0100 Subject: [PATCH 12/18] Log when identifiers are already cached --- DeviceIdentifiersWrapper/build.gradle | 4 ++-- .../java/com/zebra/deviceidentifierswrapper/DIHelper.java | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/DeviceIdentifiersWrapper/build.gradle b/DeviceIdentifiersWrapper/build.gradle index b17ff18..f6c0991 100644 --- a/DeviceIdentifiersWrapper/build.gradle +++ b/DeviceIdentifiersWrapper/build.gradle @@ -8,8 +8,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 32 - versionCode 7 - versionName "0.7" + versionCode 8 + versionName "0.8" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java index d7f6c8a..fcca803 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIHelper.java @@ -43,6 +43,10 @@ public static void getSerialNumber(Context context, IDIResultCallbacks callbackI { if(sSerialNumber != null) { + if(callbackInterface != null) + { + callbackInterface.onDebugStatus("Serial number already in cache."); + } callbackInterface.onSuccess(sSerialNumber); return; } @@ -97,6 +101,10 @@ public static void getIMEINumber(Context context, IDIResultCallbacks callbackInt { if(sIMEI != null) { + if(callbackInterface != null) + { + callbackInterface.onDebugStatus("IMEI number already in cache."); + } callbackInterface.onSuccess(sIMEI); return; } From 39aed87b051d038382d589d556fbba13f55c1b67 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 13:00:46 +0100 Subject: [PATCH 13/18] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21fd5fb..4284f31 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ## Sample Repository https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample -## V0.4 : Basic cache mechanism & Wait for EMDK availability +## V0.4 to v0.8 : Basic cache mechanism & Wait for EMDK availability ```text Added basic cache mechanism. The IMei and the Serial number will be cached once they get retrieved. @@ -19,6 +19,9 @@ https://github.com/ltrudu/DeviceIdentifiersWrapper-Sample DIHelper.resetCachedValues() Added a mechanism to wait for the EMDK if it is not available (when responding to the BOOT_COMPLETED event for ex.) To be tested... feel free to report any issue regarding this feature. + Check the sample for a basic implementation. + Added lots of logs that will be sent to logCat or to the onDebugStatus callback method. + Updated gradle version to release 7.3.3 ``` ## V0.3 : Update for A11 ```text From c5f7a52e7259186227970605f40fe14b32ab260c Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Mon, 7 Nov 2022 13:53:19 +0100 Subject: [PATCH 14/18] Fix a bug that could prevent later EMDK initialization --- .../zebra/deviceidentifierswrapper/DIProfileManagerCommand.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java index bab5fa3..661d88e 100644 --- a/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java +++ b/DeviceIdentifiersWrapper/src/main/java/com/zebra/deviceidentifierswrapper/DIProfileManagerCommand.java @@ -56,6 +56,7 @@ public class ErrorHolder // Provides full error description string public String msErrorString = ""; + // To prevent multiple initializations at the same time private boolean bInitializing = false; // Status Listener implementation (ensure that we retrieve the profile manager asynchronously @@ -172,6 +173,7 @@ public void run() { delta = new Date().getTime() - startDate; logMessage("Delta in ms since first EMDK retrieval try: " + delta + "ms stops at " + DIHelper.MAX_EMDK_TIMEOUT_IN_MS + "ms", EMessageType.DEBUG); } + bInitializing = false; logMessage("Could not retrieve EMDK Manager after waiting " + DIHelper.WAIT_PERIOD_BEFORE_RETRY_EMDK_RETRIEVAL_IN_MS/DIHelper.SEC_IN_MS + " seconds. Please contact your administrator or check logcat for any EMDK related error.", EMessageType.ERROR); } }); From e044919b052faa7b3937046ca19f671239207953 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Tue, 8 Nov 2022 10:19:22 +0100 Subject: [PATCH 15/18] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4284f31..4d32fab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # DeviceIdentifiersWrapper - - +## Easy access to serial number and IMEI +Forget about StageNow, EMDK, complexity.... +Just get the serial number and the IMEI number of your Zebra device in one line of code (see at the end of this document). +Have fun with Zebra's devices :) ## Change Log !!! ### 1. Change of REPOSITORY From f060b6e894517e2776d49c46f908a4137a690a04 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Tue, 8 Nov 2022 10:19:48 +0100 Subject: [PATCH 16/18] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 4d32fab..9cd16a1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ # DeviceIdentifiersWrapper ## Easy access to serial number and IMEI + Forget about StageNow, EMDK, complexity.... + Just get the serial number and the IMEI number of your Zebra device in one line of code (see at the end of this document). + Have fun with Zebra's devices :) + + + + ## Change Log !!! ### 1. Change of REPOSITORY ### 2. UPDATED FOR A11... From cacfdeb0f8dc51ca8874d3b4f05368ef9db08b07 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Tue, 8 Nov 2022 10:20:18 +0100 Subject: [PATCH 17/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9cd16a1..f64ead7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Forget about StageNow, EMDK, complexity.... -Just get the serial number and the IMEI number of your Zebra device in one line of code (see at the end of this document). +Just get the serial number and the IMEI number of your Zebra device in one method call (see at the end of this document). Have fun with Zebra's devices :) From bf15b0fb6517eaaaf77c6778846c59a16a60c017 Mon Sep 17 00:00:00 2001 From: Trudu Laurent Date: Tue, 8 Nov 2022 10:20:59 +0100 Subject: [PATCH 18/18] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f64ead7..9477554 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Easy access to serial number and IMEI -Forget about StageNow, EMDK, complexity.... +Forget about StageNow, EMDK, certificates, application signature... complexity.... Just get the serial number and the IMEI number of your Zebra device in one method call (see at the end of this document).