Easy detection of "System level"

Hi, I implement some features in my apps that require specific System levels so need to understand what System level the target runs. For system level 7 is pretty straight forward, I just check the monkeyversion, like so:

var version = System.getDeviceSettings().monkeyVersion;
system7 = (version[0] >= 5) ? true : false;

 

But for System 6,5,4 it becomes a bit more complicated 

system6 = ((version[0] = 3 && version[1] >= 4) || (version[0] = 4 && version[1] >= 2)) ? true : false

- System 4 is CIQ version 3.2 for CIQ 3 devices and CIQ 4.0 for CIQ 4 devices

- System 5 is CIQ version 3.3 for CIQ 3 devices and CIQ 4.1 for CIQ 4 devices

- System 6 is CIQ version 3.4 for CIQ 3 devices and CIQ 4.2 for CIQ 4 devices

Isn't there an easier way to do this? Like e.g. getDeviceSettings().systemVersion 

  • It's probably better to just use has for this kind of thing.

  • Hi. Can you provide an example how to use has for system level please? 

  • It doesn't give you system level, but allows you to code to what is available on the device.

    Using "floors" as an example, system level doesn't tell you they are available, as they aren't available on a va5, as there is no baro altimeter, even though it's System 7

    And only the va5 and venu3 have wheelchair mode but other System 7 devices don't

    Another example is vector/scalable fonts - not all System 7 devices have them.

  • Can you provide an example how to use has for system level please? 

    Sorry, I should've elaborated.

    I implement some features in my apps that require specific System levels

    The idea is to use has to check for any CIQ API feature you require which may not be available on all devices that your app targets, as opposed to trying to determine the system level of the device your app is running on..

    Can you give a specific example of how your features depend on system levels?

    I mean, if you *really* need to check for a specific system level, the code isn't hard to write, and it shouldn't take too much memory (in code), either. You've already written half of it in the OP.

    But it's not clear to me whether that's the best approach. Garmin doesn't seem to think so, as CIQ doesn't have a built-in way of determining the system level. They don't even document the system levels (as in your OP).

  • Got it, I do that for some features butto check support for e.g. personality, it cannot be detected this way AFAIK.  

  • yes. Just to give a bit more context to my problem: I develop a super app/widget and want it to support as many devices as possible with the same code base. It has features like a glance view (that consumes quite a lot of memory), complications, and personality. I use annotations to exclude glance view for low-memory devices. I use has :Complications to enable complications, and for personality I have to detect if the device is System 6 or higher as per above. 

    I can get all of that working, but I also have to figure out a way to include or exclude the peronsality drawables and complication resources or else I get compiler errors.

    My jungle file:

     

    # monkey.jungle file for Widget
    project.manifest = manifest.xml
    
    resourceBase = resources
    base.resourcePath = $(resourceBase);personality-resources;complications-resources
    
    # These devices have no support for personality or complications
    venu.resourcePath = $(resourceBase)
    ... more devices here ... 
    
    
    # These devices have no support for high-mem Glance views
    # Exclude the 'high_mem' annotation
    enduro.excludeAnnotations = $(enduro.excludeAnnotations);high_mem
    fenix6.excludeAnnotations = $(fenix6.excludeAnnotations);high_mem
    ... more devices here ...

       

    Ideally, I don't want to edit the jungle file for any new device (which likely will support all of the feature set), and use the jungle file to opt-out rather than opt-in. 

    Is there anither way?  

  • I also have to figure out a way to include or exclude the peronsality drawables and complication resources or else I get compiler errors.

    I see. Based on your post, I thought you were looking for a way to do this at runtime (which obviously wouldn't help with the resource stuff).

    Ideally, I don't want to edit the jungle file for any new device (which likely will support all of the feature set), and use the jungle file to opt-out rather than opt-in. 

    You should be able to accomplish this by using defaults that assume all the "features" (e.g. complications, personality, high memory), as you already appear to be doing.

    Only time this will get tricky is if and when your defaults change in the future. If some new feature gets added in CIQ 6 like "super complications" or something, and you want all your new devices to implicitly support it, then you'll have to go back and change config for devices already mentioned in the jungle, and add config for devices that aren't mentioned. At the point, it would probably be easier to just edit the jungle file for new devices or perhaps look into auto-generating your jungle. flocsy has a script for generating jungle files which you could use as a starting point.