Class KosCore

java.lang.Object
com.kosdev.kos.core.app.KosCore

public final class KosCore extends Object
Static accessor for a number of core KOS components that are so common it's inefficient to inject them everywhere they're needed.

Usage Example

  
      Mode mode = KosCore.getMode();
      BeanContext ctx = KosCore.getCtx();
  
 
Since:
1
Version:
9
  • Method Details

    • hasProfile

      public static boolean hasProfile(String profile)
      Returns true if the specified profile is active.
      Parameters:
      profile - the profile to check
      Since:
      1
    • getMode

      public static Mode getMode()
      Returns the current operational mode.
      Since:
      1
    • isTest

      public static boolean isTest()
      Returns true if the current operational mode is TEST.
      Since:
      1
    • isProd

      public static boolean isProd()
      Returns true if the current operational mode is PROD (production).
      Since:
      1
    • isSimulator

      public static boolean isSimulator()
      Returns true if we're running inside the Studio simulator.
      Since:
      1
    • isPrimary

      public static boolean isPrimary()
      Returns true if we're running on the system's primary node.
      Since:
      1
    • getPrimaryNodeId

      public static NodeId getPrimaryNodeId()
      Returns the nodeId of the primary node.
      Since:
      1
    • getDeviceType

      public static String getDeviceType()
      Returns the device type of the overall device the node is part of.
      Since:
      1
    • getVendorAuthority

      public static String getVendorAuthority()
      Returns the vendor authority of this node.
      Since:
      1
    • getMfgAuthority

      public static String getMfgAuthority()
      Returns the manufacturer authority of this node.
      Since:
      1
    • getBoardType

      public static String getBoardType()
      Returns the board type of this node.
      Since:
      1
    • getArch

      public static String getArch()
      Returns the arch of this node.
      Since:
      1
    • getCtx

      public static BeanContext getCtx()
      Returns the root BeanContext for KOS.
      Since:
      1
    • getSystemCtx

      public static BeanContext getSystemCtx()
      Returns the BeanContext for the system app.
      Since:
      1
    • getSystemApp

      public static SystemApplication<?> getSystemApp()
      Return the system application.
      Since:
      1
    • getAutostartsReady

      public static ReadyIndicator getAutostartsReady()
      Return a ReadyIndicator that becomes ready when all the autostart apps have been started.
      Since:
      8
    • getManifestService

      public static ManifestService getManifestService()
      Return a reference to ManifestService .
      Since:
      9
    • getHardwareService

      public static HardwareService getHardwareService()
      Return a reference to HardwareService .
      Since:
      9
    • getPort

      public static int getPort()
      Returns the port number that KOS is running on. It defaults to 8081.
      Since:
      1
    • getNodeId

      public static NodeId getNodeId()
      Returns the ID of the node we're running on.
      Since:
      1
    • getMfgDir

      public static File getMfgDir()
      Return the manufacturer data directory.
      Since:
      1
    • getMfgFile

      public static File getMfgFile(String path)
      Return a File for the specified path in the manufacturer data directory.
      Since:
      1
    • getAnalytics

      public static AnalyticsService getAnalytics()
      Return the AnalyticsService in order to log analytic data. This avoids the need to autowire the service everywhere.
      Since:
      6
    • hasGrant

      public static boolean hasGrant(String expr)
      Return true if the specified grant expression is true.
      Parameters:
      expr - the grant expression to check
      Since:
      9
    • verifyGrant

      public static void verifyGrant(String expr)
      Return if the specified grant expression is true, otherwise throws GrantException .
      Parameters:
      expr - the grant expression to verify
      Since:
      9
    • getVersion

      public static String getVersion()
      Return the currently running version of KOS
      Since:
      1
    • formatISO8601

      public static String formatISO8601(long ms)
      Format the epoch time in ms as an ISO-8601 string with fractional second resolution and timezone offset. This preserves the timezone information such that external systems have the benefit of localtime as well as the ability to normalize the time using the timezone offset.
      Parameters:
      ms - the time in ms
      Since:
      1
    • getApiVersion

      public static int getApiVersion(String appId)
      Return the api version for the specified app or extension. Returns the corresponding api version or -1 if the app or extension is not installed. Also returns -1 if appId is null.
      Parameters:
      appId - the id of the application or name of the extension
      Since:
      9
    • getCoreApiVersion

      public static int getCoreApiVersion()
      Return the api version of KOS core.
      Since:
      9