aboutsummaryrefslogtreecommitdiff
path: root/en/devices/architecture/hidl-java/types.html
diff options
context:
space:
mode:
authorAndroid Partner Docs <noreply@android.com>2017-08-22 10:41:24 -0700
committerClay Murphy <claym@google.com>2017-08-22 15:01:44 -0700
commitf16c42333aa6b2de30a344dd68246d4a33d93e7d (patch)
tree311af599312cacb21c888aeae828cae59b0d64a1 /en/devices/architecture/hidl-java/types.html
parent04426e67ca3ee557a0083f9b3c6ba789021bd7a0 (diff)
downloadsource.android.com-f16c42333aa6b2de30a344dd68246d4a33d93e7d.tar.gz
Docs: Changes to source.android.com
- 166080694 Devsite localized content from translation request a3d5a7... by Android Partner Docs <noreply@android.com> - 166079245 Remove duplicate TOC entry to oob-users.html. by mheco <mheco@google.com> - 166002955 Update builds for Oreo by Android Partner Docs <noreply@android.com> - 165977566 Fixing bad conversion by hvm <hvm@google.com> - 165977199 Edit links to point to public source files in AOSP. by cqn <cqn@google.com> - 165962883 Add codename to CTS downloads page. by gdimino <gdimino@google.com> - 165955117 Integration of O branch into mainline. by gdimino <gdimino@google.com> - 165638251 Update July public Android security bulletin to remove QC... by Android Partner Docs <noreply@android.com> - 165638198 Update June public Android security bulletin to remove QC... by Android Partner Docs <noreply@android.com> - 165638174 Update May public Android security bulletin to remove QC ... by Android Partner Docs <noreply@android.com> - 165638096 Update April public Android security bulletin to remove Q... by Android Partner Docs <noreply@android.com> - 165528993 Update to Keymaster 2 and remove requirements language by daroberts <daroberts@google.com> - 165511119 Add Bluetooth verification / debug information by cqn <cqn@google.com> - 165491345 Fixed link broken by file rename. by cqn <cqn@google.com> - 165381648 Fixed broken image paths and renamed HCI Requirements file. by cqn <cqn@google.com> - 165365185 Created high-level Bluetooth directory and added HTML ver... by cqn <cqn@google.com> - 165335694 Devsite localized content from translation request 66a39c... by Android Partner Docs <noreply@android.com> - 165246927 Update August 2017 bulletin with CVE-2017-0687 by daroberts <daroberts@google.com> PiperOrigin-RevId: 166080694 Change-Id: I2d3a8d77fa6a66c2099f13ba2e864545328fd17a
Diffstat (limited to 'en/devices/architecture/hidl-java/types.html')
-rw-r--r--en/devices/architecture/hidl-java/types.html161
1 files changed, 161 insertions, 0 deletions
diff --git a/en/devices/architecture/hidl-java/types.html b/en/devices/architecture/hidl-java/types.html
new file mode 100644
index 00000000..8cc2d258
--- /dev/null
+++ b/en/devices/architecture/hidl-java/types.html
@@ -0,0 +1,161 @@
+<html devsite>
+ <head>
+ <title>Data Types</title>
+ <meta name="project_path" value="/_project.yaml" />
+ <meta name="book_path" value="/_book.yaml" />
+ </head>
+ <body>
+ <!--
+ Copyright 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+
+<p>Given a HIDL interface file, the Java HIDL backend generates Java interfaces,
+Stub, and Proxy code. It supports all scalar HIDL types
+([<code>u</code>]<code>int</code>{<code>8,16,32,64}_t, float, double,</code> and
+<code>enum</code>s), as well as strings, interfaces, struct types, and arrays
+and vectors of supported HIDL types. The Java HIDL backend <strong>does NOT
+support union types, native handles, shared memory, and fmq types</strong>.</p>
+
+<p>As Java runtime does not support the concept of unsigned integers natively,
+all unsigned types (and enums based on them) are silently treated as their
+signed equivalents, i.e. <code>uint32_t</code> becomes an <code>int</code> in
+the Java interface. No value conversion is performed; the implementor on the
+Java side must use the signed values as if they were unsigned.</p>
+
+<h2 id=enum>Enums</h2>
+<p>Enums do not generate Java enum classes but are instead translated into inner
+classes containing a static constant definition for each enum case. If the enum
+class derives from some other enum class, it inherits that class's storage type.
+Enumerations based on an unsigned integer type are rewritten into their signed
+equivalent.</p>
+
+<p>For example, a <code>SomeBaseEnum</code> with a type of
+<code>uint8_t</code>:</p>
+
+<pre class="prettyprint">
+enum SomeBaseEnum : uint8_t { foo = 3 };
+enum SomeEnum : SomeBaseEnum {
+ quux = 33,
+ goober = 127
+};
+</pre>
+
+<p>… becomes:</p>
+
+<pre class="prettyprint">
+public final class SomeBaseEnum { public static final byte foo = 3; }
+public final class SomeEnum {
+ public static final byte foo = 3;
+ public static final byte quux = 33;
+ public static final byte goober = 127;
+}
+</pre>
+
+<p>And:</p>
+
+<pre class="prettyprint">
+enum SomeEnum : uint8_t {
+ FIRST_CASE = 10,
+ SECOND_CASE = 192
+};
+</pre>
+
+<p>… is rewritten as:</p>
+
+<pre class="prettyprint">
+public final class SomeEnum {
+ static public final byte FIRST_CASE = 10; // no change
+ static public final byte SECOND_CASE = -64;
+}
+</pre>
+
+<h2 id=string>Strings</h2>
+<p><code>String</code>s in Java are utf-8 or utf-16 but are converted to utf-8
+as the common HIDL type when transported. Additionally, a <code>String</code>
+must not be null when passed into HIDL.</p>
+
+<h2 id=array-vect>Arrays and vectors</h2>
+<p>Arrays are translated into Java arrays and vectors are translated into
+<code>ArrayList&lt;T&gt;</code> where T is the appropriate object type, possibly
+wrapping scalar types such as <code>vec&lt;int32_t&gt; =&gt;
+ArrayList&lt;Integer&gt;</code>). For example:</p>
+
+<pre class="prettyprint">
+takeAnArray(int32_t[3] array);
+returnAVector() generates (vec&lt;int32_t&gt; result);
+</pre>
+
+<p>… becomes:</p>
+
+<pre class="prettyprint">
+void takeAnArray(int[] array);
+ArrayList&lt;Integer&gt; returnAVector();
+</pre>
+
+<h2 id=struct>Structures</h2>
+<p>Structures are translated into Java classes with a similar layout. For
+example:</p>
+
+<pre class="prettyprint">
+struct Bar {vec&lt;bool&gt; someBools;
+ };
+ struct Foo {
+ int32_t a;
+ int8_t b;
+ float[10] c;
+ Bar d;
+ };
+</pre>
+
+<p>… becomes:</p>
+
+<pre class="prettyprint">
+class Bar {
+ public final ArrayList&lt;Boolean&gt; someBools = new ArrayList();
+};
+class Foo {
+ public int a;
+ public byte b;
+ public final float[] c = new float[10];
+ public final Bar d = new Bar();
+}
+</pre>
+
+<h2 id=declared>Declared types</h2>
+<p>Each top-level type declared in <code>types.hal</code> gets its own .java
+output file (as required by Java). For example, the following
+<code>types.hal</code> file results in two extra files being created (Foo.java
+and Bar.java):</p>
+
+<pre class="prettyprint">
+struct Foo {
+ ...
+};
+
+struct Bar {
+ ...
+
+ struct Baz {
+ };
+
+ ...
+};
+</pre>
+
+<p>The definition of Baz lives in a static inner class of Bar (in Bar.java).</p>
+
+ </body>
+</html>