Resource: Device Database

Andrew Bestic edited this page May 28, 2015 · 3 revisions

Device Expansion

The device database is designed to reduce repetition within the User Agent files. When running a build, the device "expansion" takes place. Unlike the Platform Expansion there is no replacement of any placeholders.

For example, if you had the following devices database:

{
  "devices": {
    "unknown": {
      "properties": {
        "Device_Name": "unknown",
        "Device_Maker": "unknown",
        "Device_Type": "unknown",
        "Device_Pointing_Method": "unknown",
        "Device_Code_Name": "unknown",
        "Device_Brand_Name": "unknown",
        "isMobileDevice": "false",
        "isTablet": "false"
      }
    },
    "general Mobile Device": {
      "properties": {
        "Device_Name": "general Mobile Device",
        "Device_Maker": "unknown",
        "Device_Type": "Mobile Device",
        "Device_Pointing_Method": "unknown",
        "Device_Code_Name": "general Mobile Device",
        "Device_Brand_Name": "unknown",
        "isMobileDevice": "true",
        "isTablet": "false"
      }
    }
  }
}

You could then use the unknown and general Mobile Device identifiers in the device definition in the UA JSON file:

{
  "division": "Division",
  "sortIndex": 100,
  "userAgents": [
    {
      "userAgent": "UA",
      "properties": {
        "Parent": "DefaultProperties",
        "Comment": "UA",
        "Browser": "UA"
      },
      "children": {
        "match": "UA String (#PLATFORM#)",
        "device": "general Mobile Device"
      }
    }
  ]
}

In the generated INI file, this would generate 3 sections:

[UA]
Parent=DefaultProperties
Comment=UA
Browser=UA

[UA String (*Platform 1*)]
Parent=UA
Platform=Platform 1
Win32=true
Device_Name=general Mobile Device
Device_Maker=unknown
Device_Type=Mobile Device
Device_Pointing_Method=unknown
Device_Code_Name=general Mobile Device
Device_Brand_Name=unknown
isMobileDevice=true
isTablet=false

Note that any properties in the device definition are copied across into the child sections in the INI file.

Device Definition

The definition for a device should look like the following JSON object:

{
  /* Device Identifier */: {
    "properties": {
      /* Properties for expansion */
    }
  }
}

Device Property Definition

For device information we have the following properties.

Device_Code_Name

This is the device key from the UA expect we find something else with Google.

Device_Name

This is the marketing name for the device. Some device makers (e.g. Samsung) have more than one code name for one marketing name. This may be different for market regions, features or vendors.

Device_Maker

The company who builds the device.

Device_Brand_Name

The company which the device is branded with (e.g. Google for the Nexus series).

Device_Type

This property holds the information about the type of the device. These values are possible:

  • Console
  • TV Device
  • Tablet
  • Mobile Phone
  • Mobile Device
  • Desktop
  • Ebook Reader
  • Car Entertainment System
  • Digital Camera

Device_Pointing_Method

This property hold the information how to interact with the device. Desktops normally use a mouse and Smartphones a touchscreen.

isMobileDevice

This property is set to "true" if the device is a Mobile Device. This includes Mobile Phones, Tablets, Mobile Game Consoles and other Mobiles (e.g. iPod). This property should be seen as deprecated. The property Device_Type should be used instead.

isTablet

This property is set to "true" if the device is a Tablet. This property should be seen as deprecated. The property Device_Type should be used instead.