ZebraDevs / DataWedge-Ionic-Demo

Demo Ionic application using Datawedge on Zebra mobile devices
Other
43 stars 21 forks source link

SET_CONFIG seems to fail partially #7

Closed tafh closed 5 years ago

tafh commented 5 years ago

I am trying to set the config like this:

    //  Configure the created profile (associated app and keyboard plugin)

let profileConfig = { "PROFILE_NAME": My-App", "PROFILE_ENABLED": "true", "CONFIG_MODE": "UPDATE", "PLUGIN_CONFIG": { "PLUGIN_NAME": "BARCODE", "RESET_CONFIG": "true", "PARAM_LIST": { "remote_scanner_audio_feedback_mode": "0", "remote_scanner_led_feedback_mode": "0", } }, "APP_LIST": [{ "PACKAGE_NAME": "nl.my.app", "ACTIVITY_LIST": ["*"] }] }; this.barcodeProvider.sendCommand("com.symbol.datawedge.api.SET_CONFIG", profileConfig);

    //  Configure the created profile (intent plugin)
    let profileConfig2 = {
      "PROFILE_NAME": "My-App",
      "PROFILE_ENABLED": "true",
      "CONFIG_MODE": "UPDATE",
      "PLUGIN_CONFIG": {
        "PLUGIN_NAME": "INTENT",
        "RESET_CONFIG": "true",
        "PARAM_LIST": {
          "intent_output_enabled": "true",
          "intent_action": "nl.my.app.ACTION",
          "intent_delivery": "2"
        }
      }
    };
    this.barcodeProvider.sendCommand("com.symbol.datawedge.api.SET_CONFIG", profileConfig2);

But this fails partially, I found this via LogCat:

2019-02-07 12:23:29.586 1275-1275/? W/Bundle: Key PLUGIN_CONFIG expected ArrayList but value was a android.os.Bundle. The default value was returned. 2019-02-07 12:23:29.587 1275-1275/? W/Bundle: Attempt to cast generated internal exception: java.lang.ClassCastException: android.os.Bundle cannot be cast to java.util.ArrayList at android.os.Bundle.getParcelableArrayList(Bundle.java:916) at com.symbol.datawedge.api.ProfileSettings.setConfiguration(ProfileSettings.java:124) at com.symbol.datawedge.api.APISetConfigurationManager.setConfiguration(APISetConfigurationManager.java:35) at com.symbol.datawedge.api.APIConfigurationManager.processIntent(APIConfigurationManager.java:72) at com.symbol.datawedge.api.IntentProcessor.processIntent(IntentProcessor.java:132) at com.symbol.datawedge.api.IntentAPIManager.onReceive(IntentAPIManager.java:114) at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1122) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Here is my system info:

Received Intent: {"com.symbol.datawedge.api.RESULT_GET_VERSION_INFO":{"BARCODE_SCANNING":"19.21.37.0","DATAWEDGE":"6.9.49","DECODER_LIBRARY":"N/A","SCANNER_FIRMWARE":["\nRS6000 Bluetooth Scanner: PAACSS00-001-R03 "]}}

I tried formatting the PLUGIN_CONFIG in all sorts of ways (i.e. like an array), but no success. I can successfully configure on the device via the datawedge app and the profile is created (via the SET_CONFIG) but it is missing the first profile's PARAM_LIST entries. Am I missing something? I

darryncampbell commented 5 years ago

Hi, did you try specifying the parameters as integers rather than strings? According to http://techdocs.zebra.com/datawedge/7-1/guide/api/setconfig/ they should be ints. Regarding the logcat message, I have never seen that but probably because I have never specifically looked for it... if the profile is still partially working it may be a red herring.

tafh commented 5 years ago

I spent last Friday on solving this problem, I found this problem was sort of a problem of the config in conjunction with cordova-intent-plugin. Also your sample works fine with DataWedge <6.6, I am running 6.9 which requires a slightly changed config. I forked the intent-plugin and created a workaround but I figure you want to do a more proper solution. But at least you are now aware of this problem. I now can successfully set a config like this:

     let profileConfig = {
      "PROFILE_NAME": "My-App",
      "PROFILE_ENABLED": "true",
      "CONFIG_MODE": "UPDATE",
      "PLUGIN_CONFIG": [{
        "PLUGIN_NAME": "BARCODE",
        "RESET_CONFIG": "true",
        "PARAM_LIST": {
          "scanner_selection": "auto",
          "scanner_input_enabled": "true",
          "remote_scanner_audio_feedback_mode": 0,
          "remote_scanner_led_feedback_mode": 0,
        }
      }, {
        "PLUGIN_NAME": "INTENT",
        "RESET_CONFIG": "true",
        "PARAM_LIST": {
          "intent_output_enabled": "true",
          "intent_action": "nl.my.app.ACTION",
          "intent_delivery": 2
        }
      }],
      "APP_LIST": [{
        "PACKAGE_NAME": "nl.my.app",
        "ACTIVITY_LIST": ["*"]
      }]
    };
    this.barcodeProvider.sendCommand("com.symbol.datawedge.api.SET_CONFIG", profileConfig);

This is my commit that enables 6.6> style configs: https://github.com/tafh/darryncampbell-cordova-plugin-intent/commit/8b8788e78b2db523e3c8c3f9f8aaf6053e6e6418

darryncampbell commented 5 years ago

I agree there must be a much cleaner way to address this, the issue is how to map the JavaScript [{}] to either an array or arrayList. I have taken your suggested changes and incorporated into 1.1.4 as this is likely to affect others and when I get the opportunity to address this properly I will revisit this. https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/commit/cd67a2f098b13d589440fe1fd337b041a79db6e1

Thanks, can we close this issue?

tafh commented 5 years ago

Awesome! But be aware this will break the config for <6.6 DataWedge devices. I think that either a notice or even better an if statement will be the best way to go.

darryncampbell commented 5 years ago

Thanks, I'm not too worried about < DW 6.6 since I'm pretty sure you could not specify an array of plugins, you had to specify each plugin individually which is why this sample calls SET_CONFIG twice