OSDN Git Service

camera_metadata: Add visibility support, and a HAL2 tag
[android-x86/system-media.git] / camera / docs / CameraMetadataKeys.mako
1 ## -*- coding: utf-8 -*-
2 /*
3  * Copyright (C) 2013 The Android Open Source Project
4  *
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 package android.hardware.photography;
19
20 import static android.hardware.photography.CameraMetadata.Key;
21
22 /**
23  * ! Do not edit this file directly !
24  *
25  * Generated automatically from ${java_class}Keys.mako
26  *
27  * TODO: Include a hash of the input files here that the build can check.
28  */
29
30 <%page args="java_class, xml_kind" />\
31 /**
32  * The base class for camera controls and information.
33  *
34  * This class defines the basic key/value map used for querying for camera
35  * characteristics or capture results, and for setting camera request
36  * parameters.
37  *
38  * @see ${java_class}
39  * @see CameraMetadata
40  * @hide
41  **/
42 ##
43 ## Function to generate an enum
44 <%def name="generate_enum(entry)">
45             % if entry.applied_visibility == 'hidden':
46             /**
47              * @hide
48              */
49             %endif
50             public static final class ${entry.get_name_minimal() | pascal_case}Key extends Key<${jtype(entry)}> {
51                 public enum Enum {
52                   % for value,last in enumerate_with_last(entry.enum.values):
53                     ${value.name | jidentifier}${"," if not last else ";"}
54                   % endfor
55                 }
56
57               % for value in entry.enum.values:
58                 public static final Enum ${value.name | jidentifier} = Enum.${value.name | jidentifier};
59               % endfor
60
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);
64                 }
65
66               % if entry.enum.has_values_with_id:
67                 static {
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}
71                       % endfor
72                     });
73                 }
74               % endif
75             }
76 </%def>\
77 ##
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')):
86     /**
87      * @hide
88      */
89     %endif
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')):
96             % if entry.enum:
97 ${generate_enum(entry)}
98             % if entry.applied_visibility == 'hidden':
99             /**
100              * @hide
101              */
102             %endif
103             public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
104                     new ${entry.get_name_minimal() | pascal_case}Key("${entry.name}");
105             % else:
106             % if entry.applied_visibility == 'hidden':
107             /**
108              * @hide
109              */
110             %endif
111             public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
112                     new Key<${jtype(entry)}>("${entry.name}", ${jclass(entry)});
113             % endif
114           % endfor
115         }
116       % endfor
117       % for entry in filter_visibility( \
118           get_children_by_filtering_kind(section, xml_name, 'merged_entries'), \
119                                          ('hidden', 'public')):
120         % if entry.enum:
121 ${generate_enum(entry)}
122           % if entry.applied_visibility == 'hidden':
123         /**
124          * @hide
125          */
126           %endif
127         public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
128                 new ${entry.get_name_minimal() | pascal_case}Key("${entry.name}");
129         % else:
130           % if entry.applied_visibility == 'hidden':
131         /**
132          * @hide
133          */
134           %endif
135         public static final Key<${jtype(entry)}> ${entry.get_name_minimal() | csym} =
136                 new Key<${jtype(entry)}>("${entry.name}", ${jclass(entry)});
137         % endif
138       % endfor
139
140     }
141
142     % endif
143   % endfor
144 % endfor
145 }
146 </%def>\
147 ##
148 ## Static properties only
149 ##${single_kind_keys('CameraPropertiesKeys', 'static')}
150 ##
151 ## Controls properties only
152 ##${single_kind_keys('CaptureRequestKeys', 'controls')}
153 ##
154 ## Dynamic properties only
155 ##${single_kind_keys('CaptureResultKeys', 'dynamic')}
156 ${single_kind_keys(java_class, xml_kind)}