"""
A set of classes (models) each closely representing an XML node in the
-metadata_properties.xml file.
+metadata_definitions.xml file.
Node: Base class for most nodes.
Entry: A node corresponding to <entry> elements.
self._entry_map[p.kind].pop(p.name)
self._entries_ordered.remove(p)
+ def is_entry_this_kind(self, entry, kind):
+ """
+ Check if input entry if of input kind
+
+ Args:
+ entry: an Entry object
+ kind: a string. Possible values are "static", "dynamic", "controls"
+
+ Returns:
+ A boolean indicating whether input entry is of input kind.
+ """
+ if kind not in ("static", "dynamic", "controls"):
+ assert(False), "Unknown kind value " + kind
+
+ return entry.name in self._entry_map[kind]
# After all entries/clones are inserted,
# invoke this to generate the parent/child node graph all these objects
kinds: A sequence of Kind children.
merged_kinds: A sequence of virtual Kind children,
with each Kind's children merged by the kind.name
+ hal_versions: A set of tuples (major, minor) describing all the HAL versions entries in this section have
"""
def __init__(self, name, parent, description=None, kinds=[]):
self._name = name
self._leafs = []
-
@property
def description(self):
return self._description
def kinds(self):
return (i for i in self._kinds)
+ @property
+ def hal_versions(self):
+ hal_versions = set()
+ for i in self._kinds:
+ for entry in i.entries:
+ hal_versions.add( (entry.hal_major_version, entry.hal_minor_version) )
+ for namespace in i.namespaces:
+ hal_versions.update(namespace.hal_versions)
+ return hal_versions
+
def sort_children(self):
self.validate_tree()
# order is always controls,static,dynamic
namespaces: A sequence of InnerNamespace children.
entries: A sequence of Entry/Clone children.
merged_entries: A sequence of MergedEntry virtual nodes from entries
+ hal_versions: A set of tuples (major, minor) describing all the HAL versions entries in this section have
"""
def __init__(self, name, parent):
self._name = name
return self._entries
@property
+ def hal_versions(self):
+ hal_versions = set()
+ for entry in self.entries:
+ hal_versions.add( (entry.hal_major_version, entry.hal_minor_version) )
+ for namespace in self.namespaces:
+ hal_versions.update(namespace.hal_versions)
+ return hal_versions
+
+ @property
def merged_entries(self):
for i in self.entries:
yield i.merge()
Attributes (Read-Only):
name: A string, e.g. 'ON' or 'OFF'
id: An optional numeric string, e.g. '0' or '0xFF'
+ deprecated: A boolean, True if the enum should be deprecated.
optional: A boolean
+ hidden: A boolean, True if the enum should be hidden.
+ ndk_hidden: A boolean, True if the enum should be hidden in NDK
notes: A string describing the notes, or None.
+ sdk_notes: A string describing extra notes for public SDK only
+ ndk_notes: A string describing extra notes for public NDK only
parent: An edge to the parent, always an Enum instance.
+ hal_major_version: The major HIDL HAL version this value was first added in
+ hal_minor_version: The minor HIDL HAL version this value was first added in
"""
- def __init__(self, name, parent, id=None, optional=False, notes=None):
+ def __init__(self, name, parent,
+ id=None, deprecated=False, optional=False, hidden=False, notes=None, sdk_notes=None, ndk_notes=None, ndk_hidden=False, hal_version='3.2'):
self._name = name # str, e.g. 'ON' or 'OFF'
self._id = id # int, e.g. '0'
+ self._deprecated = deprecated # bool
self._optional = optional # bool
+ self._hidden = hidden # bool
+ self._ndk_hidden = ndk_hidden # bool
self._notes = notes # None or str
+ self._sdk_notes = sdk_notes # None or str
+ self._ndk_notes = ndk_notes # None or str
self._parent = parent
+ if hal_version is None:
+ if parent is not None and parent.parent is not None:
+ self._hal_major_version = parent.parent.hal_major_version
+ self._hal_minor_version = parent.parent.hal_minor_version
+ else:
+ self._hal_major_version = 3
+ self._hal_minor_version = 2
+ else:
+ self._hal_major_version = int(hal_version.partition('.')[0])
+ self._hal_minor_version = int(hal_version.partition('.')[2])
@property
def id(self):
return self._id
@property
+ def deprecated(self):
+ return self._deprecated
+
+ @property
def optional(self):
return self._optional
@property
+ def hidden(self):
+ return self._hidden
+
+ @property
+ def ndk_hidden(self):
+ return self._ndk_hidden
+
+ @property
def notes(self):
return self._notes
+ @property
+ def sdk_notes(self):
+ return self._sdk_notes
+
+ @property
+ def ndk_notes(self):
+ return self._ndk_notes
+
+ @property
+ def hal_major_version(self):
+ return self._hal_major_version
+
+ @property
+ def hal_minor_version(self):
+ return self._hal_minor_version
+
def _get_children(self):
return None
has_values_with_id: A boolean representing if any of the children have a
non-empty id property.
"""
- def __init__(self, parent, values, ids={}, optionals=[], notes={}):
- self._values = \
- [ EnumValue(val, self, ids.get(val), val in optionals, notes.get(val)) \
- for val in values ]
-
+ def __init__(self, parent, values, ids={}, deprecateds=[],
+ optionals=[], hiddens=[], notes={}, sdk_notes={}, ndk_notes={}, ndk_hiddens=[], hal_versions={}):
self._parent = parent
self._name = None
+ self._values = \
+ [ EnumValue(val, self, ids.get(val), val in deprecateds, val in optionals, val in hiddens, \
+ notes.get(val), sdk_notes.get(val), ndk_notes.get(val), val in ndk_hiddens, hal_versions.get(val)) \
+ for val in values ]
@property
def values(self):
def has_values_with_id(self):
return bool(any(i for i in self.values if i.id))
+ def has_new_values_added_in_hal_version(self, hal_major_version, hal_minor_version):
+ return bool(any(i for i in self.values if i.hal_major_version == hal_major_version and i.hal_minor_version == hal_minor_version))
+
def _get_children(self):
return (i for i in self._values)
public entries are visible in the Android SDK.
applied_visibility: As visibility, but always valid, defaulting to 'system'
if no visibility is given for an entry.
+ applied_ndk_visible: Always valid. Default is 'false'.
+ Set to 'true' when the visibility implied entry is visible
+ in NDK.
synthetic: The C-level visibility of this entry ('false', 'true').
Synthetic entries will not be generated into the native metadata
list of entries (in C code). In general a synthetic entry is
glued together at the Java layer from multiple visibiltity=hidden
entries.
+ hwlevel: The lowest hardware level at which the entry is guaranteed
+ to be supported by the camera device. All devices with higher
+ hwlevels will also include this entry. None means that the
+ entry is optional on any hardware level.
deprecated: Marks an entry as @Deprecated in the Java layer; if within an
unreleased version this needs to be removed altogether. If applied
to an entry from an older release, then this means the entry
tuple_values: A sequence of strings describing the tuple values,
None if container is not 'tuple'.
description: A string description, or None.
+ deprecation_description: A string describing the reason for deprecation. Must be present
+ if deprecated is true, otherwise may be None.
range: A string range, or None.
units: A string units, or None.
tags: A sequence of Tag nodes associated with this Entry.
name: A string with the fully qualified name, e.g. 'android.shading.mode'
type: A string describing the type, e.g. 'int32'
kind: A string describing the kind, e.g. 'static'
+ hal_version: A string for the initial HIDL HAL metadata version this entry
+ was added in
Args (if container):
container: A string describing the container, e.g. 'array' or 'tuple'
enum_optionals: A list of optional enum values, e.g. ['OFF']
enum_notes: A dictionary of value->notes strings.
enum_ids: A dictionary of value->id strings.
+ enum_hal_versions: A dictionary of value->hal version strings
+
+ Args (if the 'deprecated' attribute is true):
+ deprecation_description: A string explaining the deprecation, to be added
+ to the Java-layer @deprecated tag
Args (optional):
description: A string with a description of the entry.
units: A string with the units of the values, e.g. 'inches'
details: A string with the detailed documentation for the entry
hal_details: A string with the HAL implementation details for the entry
+ ndk_details: A string with the extra NDK API documentation for the entry=
tag_ids: A list of tag ID strings, e.g. ['BC', 'V1']
type_notes: A string with the notes for the type
visibility: A string describing the visibility, eg 'system', 'hidden',
'public'
synthetic: A bool to mark whether this entry is visible only at the Java
layer (True), or at both layers (False = default).
+ hwlevel: A string of the HW level (one of 'legacy', 'limited', 'full')
deprecated: A bool to mark whether this is @Deprecated at the Java layer
(default = False).
optional: A bool to mark whether optional for non-full hardware devices
return self._kind
@property
+ def hal_major_version(self):
+ return self._hal_major_version
+
+ @property
+ def hal_minor_version(self):
+ return self._hal_minor_version
+
+ @property
def visibility(self):
return self._visibility
return self._visibility or 'system'
@property
+ def applied_ndk_visible(self):
+ if self._visibility in ("public", "ndk_public"):
+ return "true"
+ return "false"
+
+ @property
def synthetic(self):
return self._synthetic
@property
+ def hwlevel(self):
+ return self._hwlevel
+
+ @property
def deprecated(self):
return self._deprecated
@property
+ def deprecation_description(self):
+ return self._deprecation_description
+
+ # TODO: optional should just return hwlevel is None
+ @property
def optional(self):
return self._optional
return self._hal_details
@property
+ def ndk_details(self):
+ return self._ndk_details
+
+ @property
+ def applied_ndk_details(self):
+ return (self._details or "") + (self._ndk_details or "")
+
+ @property
def tags(self):
if self._tags is None:
return None
def enum(self):
return self._enum
+ def has_new_values_added_in_hal_version(self, hal_major_version, hal_minor_version):
+ if self._enum is not None:
+ return self._enum.has_new_values_added_in_hal_version(hal_major_version,hal_minor_version)
+ else:
+ return False
+
def _get_children(self):
if self.enum:
yield self.enum
self._container = kwargs.get('container')
self._container_sizes = kwargs.get('container_sizes')
+ hal_version = kwargs.get('hal_version')
+ if hal_version is None:
+ self._hal_major_version = 3
+ self._hal_minor_version = 2
+ else:
+ self._hal_major_version = int(hal_version.partition('.')[0])
+ self._hal_minor_version = int(hal_version.partition('.')[2])
+
# access these via the 'enum' prop
enum_values = kwargs.get('enum_values')
+ enum_deprecateds = kwargs.get('enum_deprecateds')
enum_optionals = kwargs.get('enum_optionals')
+ enum_hiddens = kwargs.get('enum_hiddens')
+ enum_ndk_hiddens = kwargs.get('enum_ndk_hiddens')
enum_notes = kwargs.get('enum_notes') # { value => notes }
+ enum_sdk_notes = kwargs.get('enum_sdk_notes') # { value => sdk_notes }
+ enum_ndk_notes = kwargs.get('enum_ndk_notes') # { value => ndk_notes }
enum_ids = kwargs.get('enum_ids') # { value => notes }
+ enum_hal_versions = kwargs.get('enum_hal_versions') # { value => hal_versions }
+
self._tuple_values = kwargs.get('tuple_values')
self._description = kwargs.get('description')
self._units = kwargs.get('units')
self._details = kwargs.get('details')
self._hal_details = kwargs.get('hal_details')
+ self._ndk_details = kwargs.get('ndk_details')
self._tag_ids = kwargs.get('tag_ids', [])
self._tags = None # Filled in by Metadata::_construct_tags
self._typedef = None # Filled in by Metadata::_construct_types
if kwargs.get('enum', False):
- self._enum = Enum(self, enum_values, enum_ids, enum_optionals, enum_notes)
+ self._enum = Enum(self, enum_values, enum_ids, enum_deprecateds, enum_optionals,
+ enum_hiddens, enum_notes, enum_sdk_notes, enum_ndk_notes, enum_ndk_hiddens, enum_hal_versions)
else:
self._enum = None
self._visibility = kwargs.get('visibility')
self._synthetic = kwargs.get('synthetic', False)
+ self._hwlevel = kwargs.get('hwlevel')
self._deprecated = kwargs.get('deprecated', False)
+ self._deprecation_description = kwargs.get('deprecation_description')
+
self._optional = kwargs.get('optional')
+ self._ndk_visible = kwargs.get('ndk_visible')
self._property_keys = kwargs
type: A string describing the type, e.g. 'int32'
kind: A string describing the kind, e.g. 'static'
target_kind: A string for the kind of the target entry, e.g. 'dynamic'
+ hal_version: A string for the initial HIDL HAL metadata version this entry
+ was added in
Args (if container):
container: A string describing the container, e.g. 'array' or 'tuple'
units: A string with the units of the values, e.g. 'inches'
details: A string with the detailed documentation for the entry
hal_details: A string with the HAL implementation details for the entry
+ ndk_details: A string with the extra NDK documentation for the entry
tag_ids: A list of tag ID strings, e.g. ['BC', 'V1']
type_notes: A string with the notes for the type
entry: An Entry or Clone instance
"""
props_distinct = ['description', 'units', 'range', 'details',
- 'hal_details', 'tags', 'kind']
+ 'hal_details', 'ndk_details', 'tags', 'kind',
+ 'deprecation_description']
for p in props_distinct:
p = '_' + p
'type',
'type_notes',
'visibility',
+ 'ndk_visible',
'synthetic',
+ 'hwlevel',
'deprecated',
'optional',
- 'typedef'
+ 'typedef',
+ 'hal_major_version',
+ 'hal_minor_version'
]
for p in props_common: