Permission Required

I wrote my first Datafield based on Peter's AWESOME note (his source code was a Watchface, I just changed it to be a DataField): "Pro Tip: Tackling Connect IQ Versions, Screen Shapes and Memory Limitations".

It adapts to screen size, CIQ versions, Memory Limitations, etc! Then I added a Barrel for Sunrise and Sunset.

The Barrel allows "Positioning" permissions. The Datafield code allows "Background", "Communications" and "Positioning" permissions.

It all works amazingly. Thank you!!

However, when I run it in the Eclipse Simulator (I have all the latest updates for the SDK and Eclipse), I get this in the console. Five "Permission required" and One "Permission Required" messages. With no indication that my datafield is broken, or tp what permissions it refers.

Any ideas? community.garmin.com/.../1402234.jpg
  • Look like it's two "required", then a "Required", and then that repeats. All at once, or are they spaced out in time? Are you using things like SensorHistory or User Profile that also need permissions? Things you can do in the background but not in the main app, (Sensor in the case of a DF, for exanple). Do you have a background process? What's it trying to do?
  • Look like it's two "required", then a "Required", and then that repeats. All at once, or are they spaced out in time? Are you using things like SensorHistory or User Profile that also need permissions? Things you can do in the background but not in the main app, (Sensor in the case of a DF, for exanple). Do you have a background process? What's it trying to do?


    This is just the source code from Peter's example in that "Pro Tip" blog, which for CIQ3 does do background processing. Yes, I get two "required" and one "Required", almost instantly when the simulator opens the datafield. Here are the interesting lines. I do have background and communications permissions set on my datafield code. But on on the barrel, because that just does sunrise and sunset, I only have positioning permission. I added positioning permissions to my datafield also even if not needed, since the barrel uses that permission and I think I read it needed to match?

    Background.registerForTemporalEvent(new Time.Duration(5 * 60));

    System.ServiceDelegate.initialize();

    Comm.makeWebRequest(
    "jsonplaceholder.typicode.com/.../" + (Math.rand() % 100 + 1), // get a random number between 1 and 100...
    {},
    { "Content-Type" => Comm.REQUEST_CONTENT_TYPE_URL_ENCODED },
    method(:onReceive)
  • Actually, you need the positioning on the DF, and it's "optional" on the barrel. For sunrise/set, I have it on my barrel so I get remined (an error) if I don't set it on an app that uses the barrel.

    You say you get the two "required" and one "Required" immediately, but when does the second set occur?
    Do you still get them if you don't register the background temporal event? What if you don't use the barrel (just comment out the code that uses it)
  • Actually, you need the positioning on the DF, and it's "optional" on the barrel. For sunrise/set, I have it on my barrel so I get remined (an error) if I don't set it on an app that uses the barrel.

    You say you get the two "required" and one "Required" immediately, but when does the second set occur?
    Do you still get them if you don't register the background temporal event? What if you don't use the barrel (just comment out the code that uses it)



    WOW... I don't get this. You probably will. I simply had to comment out my constant "aliases" for colors. And the permission warnings were eliminated. I just went back to using the Gfx.xxx color names in my code.


    =====================

    using Toybox.Graphics as Gfx;

    /*
    const d_BLUE = Gfx.COLOR_DK_BLUE, d_YELLOW = 0xFFFF44, d_WHITE = Gfx.COLOR_WHITE;
    const d_ORANGE = Gfx.COLOR_ORANGE, d_BLACK = Gfx.COLOR_BLACK, d_RED = Gfx.COLOR_RED;
    const d_TRANS = Gfx.COLOR_TRANSPARENT, d_GREEN = Gfx.COLOR_GREEN, d_GRAY = Gfx.COLOR_DK_GRAY, d_NONE = -1;
    */

    // inherit from the view that contains the commonlogic
    class DeviceView extends CIQView {

    // it's good practice to always have an initialize, make sure to call your parent class here!
    function initialize() {
    CIQView.initialize();
    }
  • I actually have no idea why you got permission problems with that! :o
  • Glad I could inspire you with my article :)

    The fact that you get a permission error on defining constants for the color definitions seems like a bug to me.
    Can you try doing your project without barrels (just use a seperate class for the sunrise calculation and move it into your project) and see if you get the same issue then?
  • Glad I could inspire you with my article :)

    The fact that you get a permission error on defining constants for the color definitions seems like a bug to me.
    Can you try doing your project without barrels (just use a seperate class for the sunrise calculation and move it into your project) and see if you get the same issue then?


    I did totally remove the barrels, and all the background comm stuff. This was minimized to essentially a VERY basic version of your example Peter. And I still got the permission errors (note that the app still ran in the simulator, but those "errors" were reported in the console at run time. Once I commented out those 3 lines, the 3 "errors" disappeared.
  • Hi, tried to add Background processing to a data field and have noticed what seems to be a similar or even the same issue.

    My questions:
    - Has the one mentioned above already be resolved? If not, are there any plans for this?
    - Is there a way to get the line number / source file for the "Permission Required" error when running on the Simulator?

    In my case, I see just "Permission required" when running on the simulator; if I sideload, I get at least the file name and a line number for the error: Error: Permission Required
    Details: Permission required
    Time: 2019-01-07T00:47:55Z
    Part-Number: [...]
    Firmware-Version: '10.00'
    Language-Code: eng
    ConnectIQ-Version: 3.0.7
    Filename: [...]
    Appname: [...]
    Stack:
    - pc: 0x10000246
    File: 'C:\Users\[...]\Display.mc'
    Line: 43
    Function: <init>

    but the line referred to is just a declaration of a global variable var statusFontSize = Gfx.FONT_LARGE;

    and the error seems to occur the first time this variable is used in the view's onLayout(). Other than that, the code for the Background process is taken from a working minimal example for a data field with Background process and I have even emptied the contents of the Background process to make sure there should be nothing else causing this. The data field I am working on has already about 120kB of source code so I want to avoid having to work around a bug in the system by repeated sideloading and trial-and-error.

    Thanks in advance to anyone who might be able to help.
  • Yep this is a weird error. No solution or explanation. I made a change and moved the global assignments of a set of colors into an array, into a function, and the issue went away. In my case.