1 ## -*- coding: utf-8 -*-
3 * Copyright (C) 2013 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package android.hardware.photography;
20 import static android.hardware.photography.CameraMetadata.Key;
23 * ! Do not edit this file directly !
25 * Generated automatically from ${java_class}Keys.mako
27 * TODO: Include a hash of the input files here that the build can check.
30 <%page args="java_class, xml_kind" />\
32 * The base class for camera controls and information.
34 * This class defines the basic key/value map used for querying for camera
35 * characteristics or capture results, and for setting camera request
43 ## Function to generate an enum
44 <%def name="generate_enum(entry)">
45 % if entry.applied_visibility == 'hidden':
50 public static final class ${entry.get_name_minimal() | pascal_case}Key extends Key<${jtype(entry)}> {
52 % for value,last in enumerate_with_last(entry.enum.values):
53 ${value.name | jidentifier}${"," if not last else ";"}
57 % for value in entry.enum.values:
58 public static final Enum ${value.name | jidentifier} = Enum.${value.name | jidentifier};
61 // TODO: remove requirement for constructor by making Key an interface
62 private ${entry.get_name_minimal() | pascal_case}Key(String name) {
63 super(name, ${jtype(entry)}.class);
66 % if entry.enum.has_values_with_id:
68 CameraMetadata.registerEnumValues(${jenum(entry.enum)}.class, new int[] {
69 % for (value, last) in enumerate_with_last(entry.enum.values):
70 ${enum_calculate_value_string(value)}${"," if not last else ""} // ${value.name | jidentifier}
78 ## Generate a list of only Static, Controls, or Dynamic properties.
79 <%def name="single_kind_keys(java_name, xml_name)">\
80 public final class ${java_name}Keys {
81 % for outer_namespace in metadata.outer_namespaces: ## assumes single 'android' namespace
82 % for section in outer_namespace.sections:
83 % if section.find_first(lambda x: isinstance(x, metadata_model.Entry) and x.kind == xml_name) and \
84 any_visible(section, xml_name, ('public','hidden') ):
85 % if not any_visible(section, xml_name, ('public')):
90 public static final class ${section.name | pascal_case} {
91 % for inner_namespace in get_children_by_filtering_kind(section, xml_name, 'namespaces'):
92 ## We only support 1 level of inner namespace, i.e. android.a.b and android.a.b.c works, but not android.a.b.c.d
93 ## If we need to support more, we should use a recursive function here instead.. but the indentation gets trickier.
94 public static final class ${inner_namespace.name| pascal_case} {
95 % for entry in filter_visibility(inner_namespace.merged_entries, ('hidden','public')):
97 ${generate_enum(entry)}
98 % if entry.applied_visibility == 'hidden':
103 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
104 new ${entry.get_name_minimal() | pascal_case}Key("${entry.name}");
106 % if entry.applied_visibility == 'hidden':
111 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
112 new Key<${jtype(entry)}>("${entry.name}", ${jclass(entry)});
117 % for entry in filter_visibility( \
118 get_children_by_filtering_kind(section, xml_name, 'merged_entries'), \
119 ('hidden', 'public')):
121 ${generate_enum(entry)}
122 % if entry.applied_visibility == 'hidden':
127 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
128 new ${entry.get_name_minimal() | pascal_case}Key("${entry.name}");
130 % if entry.applied_visibility == 'hidden':
135 public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
136 new Key<${jtype(entry)}>("${entry.name}", ${jclass(entry)});
148 ## Static properties only
149 ##${single_kind_keys('CameraPropertiesKeys', 'static')}
151 ## Controls properties only
152 ##${single_kind_keys('CaptureRequestKeys', 'controls')}
154 ## Dynamic properties only
155 ##${single_kind_keys('CaptureResultKeys', 'dynamic')}
156 ${single_kind_keys(java_class, xml_kind)}