11 Replies Latest reply on Jan 16, 2018 1:27 AM by Patrick Kirsch

    EMDK ProfileManager

    Patrick Kirsch

      Hello,

       

      I'm really new to programming with EMDK on Android and currently in the progress of programming an App for my company special for the TC56/51.

      Now i'm stuck with the ProfileManager, i'm trying to upgrade the app via the AppManager feature to accomplish this I'm setting the Profile in the extra Data:

      extraData[0] =                      "<?xml version=\"1.0\" encoding=\"UTF - 8\"?>" +                      "<characteristic type=\"Profile\">" +                      "<parm name=\"ProfileName\" value=\"UpdateMobileClient\"/>" +                      "<characteristic type=\"AppMgr\" version=\"5.1\">" +                      "<parm name=\"emdk_name\" value=\"UpdatePaxControlMobile\"/>" +                      "<parm name=\"Action\" value=\"Upgrade\"/>" +                      $"<parm name=\"APK\" value=\"{updateFilePath}\"/>" +                      "</characteristic>" +                      "</characteristic>";                      var emdkStatus = eMDKProvider.ProfileManager.ProcessProfile("UpdateMobileClient", Symbol.XamarinEMDK.ProfileManager.PROFILE_FLAG.Set, extraData);

       

      But the only Result i get is this:

        <?xml version="1.0" encoding="UTF-8"?>   <wap-provisioningdoc>     <characteristic type="status">       <parm name="code" value="1"/>       <parm name="description" value="Failure"/>       <characteristic type="extended_status">         <parm name="code" value="10"/>         <parm name="description" value="Failed to connect dependency services."/>       </characteristic>     </characteristic>   </wap-provisioningdoc>

       

      So far i was not able to find any solution, the the APK file is in the right spot.

       

      I really don't know how to get more information why the profile does not work or  were my problem is.

       

      I hope someone can help me out.

       

      Patrick

        • Re: EMDK ProfileManager
          Darryn Campbell

          Hi,

           

          That error would indicate that something has gone wrong opening the EMDK service, perhaps you invoked the API before it was ready?  I suggest taking a look at the sample app for application installation: App Manager - Zebra Technologies TechDocs , hopefully that will be a good starting point to figure out what is going wrong.

            • Re: EMDK ProfileManager
              Patrick Kirsch

              Hi Darryn,

               

              thanks for your fast reply I forgot to mention that i'm using the EMDK under xamarin Android. so far i had no problem with the EMDKManager and the BarcodeScanning features with the build in scanner on the TC56. So i think the API should be ready if the scanner works perfectly fine and i try then to execute the AppManager routine?

              I tried some Sample code from the Wifi Sample but it also shows up the same message, so i think you are right that some where else musst be the problem.

              This i my current code for the providing of the EMDK API for My app, it will be initialized as one of the first things because Scanner initialization will be also very early in the Init Prozess of the App:

              public class EMDKProvider : Java.Lang.Object, EMDKManager.IEMDKListener, IDisposable
                  {
                      /// <summary>
                      /// Reference to the Logger.
                      /// </summary>
                      private readonly ILogger log;
                      /// <summary>
                      /// Reference to the EMDKManager.
                      /// </summary>
                      public EMDKManager EMDKManager { get; private set; }
                      /// <summary>
                      /// 
                      /// </summary>
                      public ProfileManager ProfileManager { get; private set; }
                      /// <summary>
                      /// Gets called after the connection to the EMDKManager is unexpectedly closed.
                      /// </summary>
                      public event Action EMDKManagerClosed;
                      /// <summary>
                      /// Flag if inizialition is allready started.
                      /// </summary>
                      public bool initialized { get; private set; }
                      private TaskCompletionSource<bool> taskCompletionSource;
                      [DependencyConstructor]
                      public EMDKProvider(
                          [DependencyParameter(false)] ILogger log)
                      {
                          this.log = log == null ? NullLogger.Default : log.For(LogDomains.Common);
                          taskCompletionSource = new TaskCompletionSource<bool>();
                      }
                      /// <summary>
                      /// Init EMDKProvider async
                      /// </summary>
                      /// <returns></returns>
                      public Task<bool> InitAsync()
                      {
                          initialized = true;
                          EMDKResults results = EMDKManager.GetEMDKManager(Application.Context, this);
                          if (results.StatusCode == EMDKResults.STATUS_CODE.Success)
                              log.Info("EMDKManager object creation succeeded.");
                          else
                          {
                              log.Error($"EMDKManager object creation faild: {results.ExtendedStatusMessage}");
                              taskCompletionSource.TrySetResult(false);
                          }
                          return taskCompletionSource.Task;
                      }
                      public void OnClosed()
                      {
                          log.Critical("EMDKManager closed unexpectedly.");
                          EMDKManager.Release();
                          EMDKManager = null;
                          EMDKManagerClosed?.Invoke();
                      }
                      public void OnOpened(EMDKManager eMDKManager)
                      {
                          log.Info("New EMDKManager Reference");
                          //Save reference to the EMDKManager
                          this.EMDKManager = eMDKManager;
                          ProfileManager = EMDKManager.GetInstance(EMDKManager.FEATURE_TYPE.Profile) as ProfileManager;
                          taskCompletionSource.TrySetResult(true);
                      }
                      protected override void Dispose(bool disposing)
                      {
                          EMDKManager?.Release();
                          base.Dispose(disposing);
                      }
                  }
              

               

              Also i looked into the App Manager Sample, and as far as i can see i'm doing it right...

               

              Also one question more poped up in my head, all the profiles i set or i will set get saved internal by the API, right? Is there a way to see wich profiles allready loaded in?

              I found nowhere an answer to this?

               

              But thanks for your help so far.

                • Re: EMDK ProfileManager
                  Darryn Campbell

                  You say you tried the WiFi sample... do you mean this one? WiFi Configuration - Zebra Technologies TechDocs .  And that didn't work?  I don't see why that would not work on a TC56, you should be able to disable and enable the WiFi.  If you can get that WiFi sample working then if you modify the EMDKConfig.xml as follows:

                  <?xml version="1.0" encoding="UTF-8"?><!--This is an auto generated document. Changes to this document may cause incorrect behavior.--><wap-provisioningdoc>
                    <characteristic type="ProfileInfo">
                      <parm name="created_wizard_version" value="2.1.9"/>
                    </characteristic>
                    <characteristic type="Profile">
                      <parm name="ProfileName" value="AppMgrProfile-1"/>
                      <parm name="ModifiedDate" value="2014-06-20 16:34:43"/>
                      <characteristic type="AppMgr" version="0.5">
                        <parm name="emdk_name" value=""/>
                        <parm name="Action" value="Install"/>
                        <parm name="APK" value="/sdcard/LeadCapture.apk"/>
                      </characteristic>
                    </characteristic>
                  </wap-provisioningdoc>
                  

                   

                  And modify the MainActivity.cs as follows:

                              // Call processPrfoileAsync with profile name, 'Set' flag and modify data to update the profile
                              string[] modifyData1 = new string[1];
                              EMDKResults results = profileManager.ProcessProfileAsync("AppMgrProfile-1", ProfileManager.PROFILE_FLAG.Set, modifyData1);
                  

                  it should install the apk (obviously there is a step there about adding the apk to the device in the correct name / location)

                   

                  But I really don't understand why the WiFi sample I linked to above would not work on a TC56 I'm afraid.

                    • Re: EMDK ProfileManager
                      Darryn Campbell

                      > Also one question more popped up in my head, all the profiles i set or i will set get saved internal by the API, right? Is there a way to see wich profiles allready loaded in?

                      No, I don't believe so, they are just applied to the device.

                      • Re: EMDK ProfileManager
                        Patrick Kirsch

                        Oh i think i  miss described it, i copied the the xml from the Wifi Sample over to my code and tried to prozess this, but with the same result(see my first post)

                        i haven't tried the complet sample code yet, but i will later.

                         

                        thanks for your help so far

                        • Re: EMDK ProfileManager
                          Patrick Kirsch

                          Good morning from Germany,

                           

                          this morning i tried the Wifi Sample and it worked perfectly on the TC56, sorry for the bad description.

                          I now tried also to add the profile xml Data via extraData and EMDKConfig.xml, but every time i get the result that says:

                          Failed to connect dependency services.

                          But in the next moment, i try the scanner, wich also needs the EMDK API but the BarcodeScanner not the ProfileManager and it works perfectly fine...

                          I really have no idea what i'm doing wrong!?

                          Is it because i'm using Xamarin.Android? but the Sample works fine so far?

                          Or is Xamarin.Forms a problem?

                            • Re: EMDK ProfileManager
                              Pietro Francesco Maggi

                              Hi Patrick,

                              I've used in the past our EMDK with Xamarin.Android and Xamarin.Forms and it works, once you keep in mind the lifecycle of your application/activities.

                               

                              I don't think that the problem is in the XML you're using per se, but in the way you're using the EMDK in your codes.

                              If I understand correctly, you're able to request a ProfileManager instance using:

                              ProfileManager = EMDKManager.GetInstance(EMDKManager.FEATURE_TYPE.Profile) as ProfileManager;

                               

                              But you get the "Failed to connect dependency services." once you try to set an actual profile with:

                              var emdkStatus = eMDKProvider.ProfileManager.ProcessProfile("UpdateMobileClient", Symbol.XamarinEMDK.ProfileManager.PROFILE_FLAG.Set, extraData); 

                               

                              What I don't understand is why you're building a Task to execute the Synchronous ProfileProcess API when there's an Async version API in the EMDK:

                              ProfileManager - Zebra Technologies TechDocs

                               

                              ~Pietro

                               

                                • Re: EMDK ProfileManager
                                  Patrick Kirsch

                                  Hi Pietro,

                                   

                                  it's good to hear that it should work so there have to be a issue/solution

                                  If I understand correctly, you're able to request a ProfileManager instance using:

                                  ProfileManager = EMDKManager.GetInstance(EMDKManager.FEATURE_TYPE.Profile) as ProfileManager;

                                  yes, with this code, i get an instance of the profileManager and as far as i can see while debugging, this works.

                                   

                                  But you get the "Failed to connect dependency services." once you try to set an actual profile with:

                                  var emdkStatus = eMDKProvider.ProfileManager.ProcessProfile("UpdateMobileClient", Symbol.XamarinEMDK.ProfileManager.PROFILE_FLAG.Set, extraData); 

                                  yes that's exactly what's happen all the time.

                                  What I don't understand is why you're building a Task to execute the Synchronous ProfileProcess API when there's an Async version API in the EMDK:

                                  ProfileManager - Zebra Technologies TechDocs

                                  I have tried also the Async version, but with the same result, so as long as i'm try to get it to run, i switched back to the synchronous version but it really doesn't seem to matter when it came to the error (Failed to connect dependency services) both versions return the same Xml result.

                                    • Re: EMDK ProfileManager
                                      Pietro Francesco Maggi

                                      Ok, I cannot see anything from wrong what you posted.

                                      Let's do some basic error checking (sorry for the "is the light on?" kind of questions).

                                       

                                      Which version of EMDK are you using?

                                      Which version of Mono, Xamarin.Android and Xamarin.Forms are you using?

                                      Which build number and patch level is on your TC51/TC56 (from  the settings, about phone/device)?

                                       

                                      Would be possible to have a test project to test from our side?

                                       

                                      thanks

                                      ~Pietro

                          • Re: EMDK ProfileManager
                            Patrick Kirsch

                            Hello everyone,

                             

                            I now found my bug, i was using a second EMDKListener, that steels/reInit the EMDKManager and the profilemanager is so not longer working...

                            Sry for that :/

                            I now fixed it, and it works, but i can't upgrade the app, is it possible to upgrade the app itself, while it is running?

                            (should i make a new thread)

                             

                            Thanks for all your help

                             

                            Patrick