Detect when running in simulator (Forerunner 735xt)

I'm looking for a way to detect when running in the simulator.

I know this question comes up every so often, but use case might be a little more interesting (or someone may be able to say "No you don't, do X instead" :)

So, I have an app that downloads FIT Workout files, as PersistedContent on supported devices.

After downloading a workout FIT file, the Forerunner 735xt will not automatically WatchUi.popView() the current view, unlike (I believe) every other model which supports PersistedContent.

As a consequence of this, I have a check in the code for "deviceSettings.monkeyVersion[0] < 3" to conditionally pop the view.

This works fine on a physical device - but the Simulator _does_ popView() when simulating a 735xt (not matching the physical device), so I have to add an additional check to avoid the 735xt workaround to avoid the app just exiting after download :)

Currently I have a config mc file in which I record the simulator deviceSettings.uniqueIdentifier and conditionally disable the popView if it matches, but it would be much cleaner to just be able to test "if running in simulator"

I therefore throw myself on the collective experience of the forum!

Thanks

  • What app type?  If it's a widget and not started from a glance, you can't pop the main view. 

  • Its a Widget - https://github.com/TrainAsONE/trainasone-connectiq - the logic is to avoid popping the main view :)

  • Widgets also time out.  Based on the device it will close 40sec to 2 minutes after they are opened.

    They never time out in the sim

  • Thats... a little hard to code against as a runtime test :-P

  • for now (and when debug) you can use

    isOnSIM = Toybox has Test;

    but when they will add Test to release you will have to find other solution.

  • If you don't want it to time out, change it from a widget to a device app.  You access those differently on a real device.  The only way to prevent a widget from timing out is to interact with it before the timeout occurs.

  • If the other tips don't work then it sounds like you can try this: in monkey.jungle set an annotation only on the 735xt (and other devices with similar problem) and use that annotation to use the matching version of the callback function that either pops or doesn't pop the current view.

  • conditionally pop the view

    Sorry if this is a dumb question, but have you tried tracking the current view using onShow()/onHide() in each view class? If you know what the current view is, you can avoid popping the main view for your edge case.

    Maybe not the most elegant solution (could argue it breaks encapsulation) but seems like the most bullet-proof (unless there's a reason I haven't considered that this won't work.)

  • popping the main view in a widget doesn't work, Just like System.exit() doesn't work. Possibly if the widget was started from a glance, but I don't remember trying that, as what I do in regular widget (like for a number of devices like the 735) also works if they were started from a glance

  • popping the main view in a widget doesn't work, Just like System.exit() doesn't work

    Thanks, I realize that, that's why I wrote "you can avoid popping the main view".

    The point is that OP does NOT want to pop the main view. Their specific problem is that for a real 735XT, they need to do an extra pop due to its behavior which differs from other watches, but the simulated 735XT does not behave the same way.

    After downloading a workout FIT file, the Forerunner 735xt will not automatically WatchUi.popView() the current view, unlike (I believe) every other model which supports PersistedContent.

    Currently they have a way to detect 735XT (as outlined in their post), but they don't have a satisfactory way to detect whether they're running in the sim, so they can distinguish the real 735XT from a simulated 735XT and change the behavior of their app appropriately.

    My suggestion is to avoid trying to detect real vs. simulated 735XT in the first place, and address the problem in a different way.

    Based on your comments I'm not sure if you actually read the OP though.

    Possibly if the widget was started from a glance

    No, you still can't pop the main view of a widget that was started from a glance. I actually made a feature request post about that years ago which you commented on, explaining why it doesn't work.