×

Discussion Board

Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Timer independent of system time even in background and offline mode

    Hi,

    I created a wiki article explaining to achieve the task. Follow http://www.developer.nokia.com/Commu..._Windows_Phone for details.

    Feel free to improve it.
    Regards,
    Vinay

  2. #17
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Timer independent of system time even in background and offline mode

    Quote Originally Posted by hamishwillee View Post
    Would setting a block flag and then using a 30 minute periodic task to reset it work (if they try again then clear that task and recreate another double length one).

    Yes, are you happy to write a wiki article on this, it is an interesting question?
    I don't thing that using periodic agent is a good idea, the "30min interval" rule isn't fix : "Periodic agents typically run every 30 minutes. To optimize battery life, periodic agents may be run in alignment with other background processes and therefore the execution time may drift by up to 10 minutes."
    and it's possible that the device cant run the background agent (low memory, or exceeded the background agents number limit).

  3. #18
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Timer independent of system time even in background and offline mode

    Hi Yassine,
    Quote Originally Posted by Loukt View Post
    I don't thing that using periodic agent is a good idea, the "30min interval" rule isn't fix : "Periodic agents typically run every 30 minutes. To optimize battery life, periodic agents may be run in alignment with other background processes and therefore the execution time may drift by up to 10 minutes."
    and it's possible that the device cant run the background agent (low memory, or exceeded the background agents number limit).
    Yes the things you mentioned are right according to documentation. But i personally tested Periodic agents on my lumia for a week and almost every time the interval is very close to 30 min. In very rare cases it differs by more than 5 mins. Periodic agents ran even when my battery was close to 10%. So i guess in case we do not have a network, we can use it for approximating elapsed time or to check if user has tampered with system time as a fallback part.

    Regards,
    Vinay

  4. #19
    Registered User
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: Timer independent of system time even in background and offline mode

    Quote Originally Posted by joaocardoso View Post
    Just save 2 date/time fields and a control field or number of changes on date/time
    .....

    Eventually the user will give up trying to do the same again or it will just be such a pain that will eventually will not do it again.
    Hi Joao

    I think I'm being dim, but I think what you're suggesting is a solution that will work if they push the clock forward, but will then stop working when they move back to proper time and penalise them in "proper time" for having tried this approach. It relies on the fact that they can move forward but once they have done so when they next move back they will be blocked and for more than double the time. Is that correct? If so, you're a devious man.

    The problem I see with this is if it is essential that the app never work if spoofed - for example if moving the time to the future then grants access to credit card details.

    Regards
    Hamish
    Last edited by hamishwillee; 2013-04-10 at 07:04.

  5. #20
    Registered User
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: Timer independent of system time even in background and offline mode

    Hi Vinay

    Sorry for the late response and thank you for creating the document - pretty good but some suggestions below

    Firstly, the solution I suggested does have the limitations that Yassine suggested. Secondly it might have others - for example you can't do things like display the "time to unlock". I also wonder if the notification will occur even after the app is turned off then on again, and whether it is impacted by the system time too. I should read up on that. Assuming all things are equal I think for some applications this degree of tolerance might be fine and the ease of implementation would make it an acceptable trade off. However for others it might not be. Point is that if you're documenting a solution these trade-offs should be visible to the user.

    Secondly, given that we have no single great implementation that we can package for reuse by others, it makes sense to outline all the solutions, not just one (as an aside, if we do cover just one solution of many in an article then it is best to use a specific title that matches the particular solution covered so users know what specific option we're presenting - hope that makes sense).

    Lastly, we need to decide if the article is about system independent timers, or it is about making time "unattractive to spoof" which is what Joaos solution is about ... and set the title appropriately. As an aside, is there a tickcount on WP? This would be easiest mechanism as long as we don't care about "device off" time.

    So I will do some edits to this but I am wondering if:
    * you can create real code for the solution you have implemented in a downloadable zip.
    * You can also update to include some of the other solutions, and if not, can the "authors" of these solutions add to them?

    Regards
    H
    Last edited by hamishwillee; 2013-04-10 at 07:23.

  6. #21
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Timer independent of system time even in background and offline mode

    Quote Originally Posted by hamishwillee View Post
    Secondly, given that we have no single great implementation that we can package for reuse by others, it makes sense to outline all the solutions, not just one (as an aside, if we do cover just one solution of many in an article then it is best to use a specific title that matches the particular solution covered so users know what specific option we're presenting - hope that makes sense).

    Lastly, we need to decide if the article is about system independent timers, or it is about making time "unattractive to spoof" which is what Joaos solution is about ... and set the title appropriately. As an aside, is there a tickcount on WP? This would be easiest mechanism as long as we don't care about "device off" time.
    I suggest that we put there all the solutions, system dependent, network dependent timers ... I really got confused reading the article (sorry vinayppatil)
    regarding Joaocardoso solution, it could be added in the end of the article as a bonus/extension.
    and Yes there is a tickcount => System.Environment.TickCount

  7. #22
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Timer independent of system time even in background and offline mode

    Hi Yassine,
    Quote Originally Posted by Loukt View Post
    I suggest that we put there all the solutions, system dependent, network dependent timers ... I really got confused reading the article (sorry vinayppatil)
    regarding Joaocardoso solution, it could be added in the end of the article as a bonus/extension.
    and Yes there is a tickcount => System.Environment.TickCount
    Sorry if that confused you bud. Let us make it more clear and understandable. Feel free to make required changes.

    Regards,
    Vinay

  8. #23
    Registered User
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: Timer independent of system time even in background and offline mode

    Thanks guys. Yassine, if you read the article after I made this post then probably I confused you - since I pulled it into pieces but didn't yet put it back together.

    Vinay, the reason the pseudo code is confusing is that you cover a bunch of methods here - network checks, timers etc. What I would do is have section on Network check where you just show (real) code that might be used to check the network time. In this section you cover the fact that network time is something you can't rely on due to the user being able to turn it off, or possibly being out of range. Then cover the "pros" - ie completely reliable if you can get it.

    You'd have the another section for each possible solution e.g. System.Environment.TickCount - again covering pros like the fact that changing the system time won't affect it and the limitations that tick count is reset when the OS restarts. Presumably this means that when your app is closed you'd save the elapsed tick count and the current tc. When the app restarts you'd check if stored tc>current tc indicating restart and then calculate time elapsed from zero ticks. If current TC>stored tc you assume that the device hasn't been restarted - sure you might be wrong but in most cases they would still only have to wait half an hour. I like this mechanism probably best of all because you can provide a count down timer.

    The pseudo code still has a use - you'd have this at the end in its own section explaining this particular solution uses networking etc etc and why you like it. We might similarly have "Joao"s implementation at the end.

    Anyway I will try find time to have another look at this today or Tomorrow and create a "standard structure" for the sections. Then we can share the load.

  9. #24
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: Timer independent of system time even in background and offline mode

    Hi Hamish,
    Quote Originally Posted by hamishwillee View Post
    Thanks guys. Yassine, if you read the article after I made this post then probably I confused you - since I pulled it into pieces but didn't yet put it back together.

    Vinay, the reason the pseudo code is confusing is that you cover a bunch of methods here - network checks, timers etc. What I would do is have section on Network check where you just show (real) code that might be used to check the network time. In this section you cover the fact that network time is something you can't rely on due to the user being able to turn it off, or possibly being out of range. Then cover the "pros" - ie completely reliable if you can get it.

    You'd have the another section for each possible solution e.g. System.Environment.TickCount - again covering pros like the fact that changing the system time won't affect it and the limitations that tick count is reset when the OS restarts. Presumably this means that when your app is closed you'd save the elapsed tick count and the current tc. When the app restarts you'd check if stored tc>current tc indicating restart and then calculate time elapsed from zero ticks. If current TC>stored tc you assume that the device hasn't been restarted - sure you might be wrong but in most cases they would still only have to wait half an hour. I like this mechanism probably best of all because you can provide a count down timer.

    The pseudo code still has a use - you'd have this at the end in its own section explaining this particular solution uses networking etc etc and why you like it. We might similarly have "Joao"s implementation at the end.

    Anyway I will try find time to have another look at this today or Tomorrow and create a "standard structure" for the sections. Then we can share the load.
    Sounds good to me. By the time you create the structure will see if i can come up with some real code.

    Regards,
    Vinay

  10. #25
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Timer independent of system time even in background and offline mode

    Sorry guys didn't have much time to edit, I did some code on the wikipage now if you could review it (it's TBC).
    need to add a feature in the snippet :
    - if there is no connection block complety the UI and ask the user to get a internet connection to continue

    also there was a crazy bug, it erased all my edits after validation, Fortunately I saved them in a file.

  11. #26
    Registered User
    Join Date
    Jan 2009
    Location
    Melbourne, Australia
    Posts
    2,578

    Re: Timer independent of system time even in background and offline mode

    Hi Guys

    I didn't get back to it yet but the structure is there. IMO the way to handle this is to have separate sections for each option for getting time "e.g. Network Time" and in those sections explain how to do it (in code) and advantages and disadvantages and workarounds/options (like blocking UI until network restored and it can be tested).

    Then we can still have a pseudo code section which shows how we pull the whole thing together and explain why we think this is a good balance of the tradeoffs.

    Quote Originally Posted by Loukt View Post
    Sorry guys didn't have much time to edit, I did some code on the wikipage now if you could review it (it's TBC).
    need to add a feature in the snippet :
    - if there is no connection block completely the UI and ask the user to get a Internet connection to continue
    I like the idea, but as above this also has trade offs - ie if you're out of Internet then you can't use the app, and that might or might not be fine for however long it takes to get connection again.


    Quote Originally Posted by Loukt View Post
    also there was a crazy bug, it erased all my edits after validation, Fortunately I saved them in a file.
    That sux. It can help to preview regularly using the button at the bottom of the page - then you can usually browse back to find content even if there is an issue saving the page. I rarely get issues with saving content, but saving talk pages does occasionally fail for me.


    Regards
    Hamsih

Similar Threads

  1. QGraphicsGeoMap offline mode
    By smitis in forum Qt
    Replies: 3
    Last Post: 2012-03-29, 06:57
  2. Replies: 8
    Last Post: 2009-10-21, 08:55
  3. How to set a device in offline mode?
    By bijen.singh@dbydx.com in forum Symbian
    Replies: 2
    Last Post: 2008-09-10, 20:24
  4. Offline mode.
    By naimidrees in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-07-23, 08:58
  5. Offline mode and demo mode
    By teura666 in forum General Development Questions
    Replies: 1
    Last Post: 2006-01-12, 19:59

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •