Class LockingProcess

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void destroyLockingProcess​(SDKOptions sdkOptions, long maxTimeoutInMilliseconds)
      Checks if cache folder is locked.
      static java.lang.Integer getLockingProcessId​(SDKOptions options)
      Gets the process ID (PID) that currently locks the map cache or the persistent map storage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getLockingProcessId

        @Nullable
        public static java.lang.Integer getLockingProcessId​(@NonNull
                                                            SDKOptions options)

        Gets the process ID (PID) that currently locks the map cache or the persistent map storage. Returns null, when no lock is active. Usually, a lock is not happening on the current process. The PID of the current process can be checked with android.os.Process#myPid(). The PID can be used to kill or to send a signal to the process with the related functions: android.os.Process#killProcess(int) and android.os.Process#sendSignal(int,int). Note that the PID might belong to the current app process, so it is recommended to check this before a process is killed as otherwise you will kill your own app process. Alternatively, call the convenient function destroyLockingProcess(com.here.sdk.core.engine.SDKOptions, long).

        If a PID is available it means that there is a lock on either the cache or the persistant map storage and that the HERE SDK will be non-functional until the locking process is killed. In such a case, consider to kill the locking process.

        Note: The Operation is not atomic and may return a PID for a process which is already destroyed or the file might be locked by another thread or process after this function returned null.

        Parameters:
        options -

        The options which are supposed to be used for new instance of the engine.

        Returns:

        Process ID if the cache or the persistent map directory is locked and a process ID was successfully read.

      • destroyLockingProcess

        public static void destroyLockingProcess​(@NonNull
                                                 SDKOptions sdkOptions,
                                                 long maxTimeoutInMilliseconds)

        Checks if cache folder is locked. Does nothing if cache is not locked or locked by current process. If cache is locked by a different process then the HERE SDK makes a few attempts to kill the locking application during the specified timeout. If it fails to kill the application, it attempts to remove the cache at SDKOptions.cachePath. This function can be used before creating a SDKNativeEngine, i.e.

         
              SDKOptions options = new SDKOptions(...);
              LockingProcess.destroyLockingProcess(options, 300);
              SDKNativeEngine engine = new SDKNativeEngine(options);
         
         
        Parameters:
        sdkOptions -

        The options which are supposed to be used for a new instance of the engine.

        maxTimeoutInMilliseconds -

        The maximum timeout in milliseconds. Recommended value is 300 - 500 milliseconds. If 0 or a negative value is passed then it makes only one attempt to kill the locking process (if any) and waits 30 milliseconds before exit because the system may spend a small amount of time to perform the operation.