The com.prosyst.util.time.Time utility can be used instead of System.currentTimeMillis for measurement of time intervals through a native timer created in the OS.
The usage of the time utility can prevent possible problems from emerging when a device's time settings are changed - in such a case using System.currentTimeMillis, which returns absolute time, may result in later/earlier time notification, invalid time periods measurement, etc.
The OSGi Runtime offers implementations of the native timer for the following operating systems:
To make the Time class use the OS-appropriate native timer in its getTickCount method, prior to framework startup:
If mbs.native.time is false (default) or the corresponding shared library cannot be located, the standard approach with calling System.currentTimeMillis will be used. System.nanoTime() is used if supported by the jvm, otherwise System.currentTimeMillis() is used as a fallback.
By default, calls to Time.getTick() lead to invoking the clock_gettime(CLOCK_MONOTONIC, ...) native function. If the system does not support this function, you can configure the native timer to register itself as an alarm handler which increases its internal counter every 10ms when notified. To do this, set any value to an environment variable MBS_NTIME_SIGALRM prior to starting the OSGi runtime.
The default behavior, described above, is valid only when mbs.native.time property is set to true. mbs.native.time=true must be set in order to use the class specified by mbs.native.time.class property.
If needed you can implement a custom OS-specific com.prosyst.util.time.Time class. Then, to make the framework set your timer class in the generic Time class, in the default.prs or common.prs file before starting the framework set the mbs.native.time.class system property to the class name of your Time implementation.