]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/platform-hardware-interfaces.git/commitdiff
Update Light extension example to match docs.
authorSteven Moreland <smoreland@google.com>
Tue, 17 Oct 2017 01:29:46 +0000 (18:29 -0700)
committerSteven Moreland <smoreland@google.com>
Wed, 18 Oct 2017 01:33:26 +0000 (18:33 -0700)
This light extension example was more of a POC. Now it
matches the suggestions for minor version requirements
and vendor extensions that are spelled out in publically
available documentation.

This includes things like:
- taking advantage of namespacing rather than renaming things
- adding documentation when extension differs from what a minor
  version extension should be
- importing things specifically rather than dumping namespaces
  into the types.hal file

Test: compilation only -- it doesn't do anything
Change-Id: Ia1bf9baaddcb630cc1b6cd4fe272def0c7c492e9
Fixes: 67787567
tests/extension/light/2.0/Android.bp
tests/extension/light/2.0/ILight.hal [moved from tests/extension/light/2.0/IExtLight.hal with 74% similarity]
tests/extension/light/2.0/default/Light.cpp
tests/extension/light/2.0/default/Light.h
tests/extension/light/2.0/types.hal

index 796e2565f651a31eafbd222b3942ffcccefedcbb..612c2d6db98d5eafbae6deb0460d4091b2aff15f 100644 (file)
@@ -4,7 +4,7 @@ filegroup {
     name: "android.hardware.tests.extension.light@2.0_hal",
     srcs: [
         "types.hal",
-        "IExtLight.hal",
+        "ILight.hal",
     ],
 }
 
@@ -17,7 +17,7 @@ genrule {
     ],
     out: [
         "android/hardware/tests/extension/light/2.0/types.cpp",
-        "android/hardware/tests/extension/light/2.0/ExtLightAll.cpp",
+        "android/hardware/tests/extension/light/2.0/LightAll.cpp",
     ],
 }
 
@@ -31,11 +31,11 @@ genrule {
     out: [
         "android/hardware/tests/extension/light/2.0/types.h",
         "android/hardware/tests/extension/light/2.0/hwtypes.h",
-        "android/hardware/tests/extension/light/2.0/IExtLight.h",
-        "android/hardware/tests/extension/light/2.0/IHwExtLight.h",
-        "android/hardware/tests/extension/light/2.0/BnHwExtLight.h",
-        "android/hardware/tests/extension/light/2.0/BpHwExtLight.h",
-        "android/hardware/tests/extension/light/2.0/BsExtLight.h",
+        "android/hardware/tests/extension/light/2.0/ILight.h",
+        "android/hardware/tests/extension/light/2.0/IHwLight.h",
+        "android/hardware/tests/extension/light/2.0/BnHwLight.h",
+        "android/hardware/tests/extension/light/2.0/BpHwLight.h",
+        "android/hardware/tests/extension/light/2.0/BsLight.h",
     ],
 }
 
@@ -72,10 +72,10 @@ genrule {
         ":android.hardware.tests.extension.light@2.0_hal",
     ],
     out: [
+        "android/hardware/tests/extension/light/V2_0/Brightness.java",
         "android/hardware/tests/extension/light/V2_0/Default.java",
-        "android/hardware/tests/extension/light/V2_0/ExtBrightness.java",
-        "android/hardware/tests/extension/light/V2_0/ExtLightState.java",
-        "android/hardware/tests/extension/light/V2_0/IExtLight.java",
+        "android/hardware/tests/extension/light/V2_0/LightState.java",
+        "android/hardware/tests/extension/light/V2_0/ILight.java",
     ],
 }
 
@@ -102,7 +102,7 @@ genrule {
         ":android.hardware.tests.extension.light@2.0_hal",
     ],
     out: [
-        "android/hardware/tests/extension/light/2.0/AExtLight.cpp",
+        "android/hardware/tests/extension/light/2.0/ALight.cpp",
     ],
 }
 
@@ -114,7 +114,7 @@ genrule {
         ":android.hardware.tests.extension.light@2.0_hal",
     ],
     out: [
-        "android/hardware/tests/extension/light/2.0/AExtLight.h",
+        "android/hardware/tests/extension/light/2.0/ALight.h",
     ],
 }
 
similarity index 74%
rename from tests/extension/light/2.0/IExtLight.hal
rename to tests/extension/light/2.0/ILight.hal
index 1515b869c040e05c095eb1c380a461575daad56c..94781c0838654a9df18e35d5aa9fc3e3fec1f3b6 100644 (file)
 // vendor partition.
 package android.hardware.tests.extension.light@2.0;
 
-import android.hardware.light@2.0;
+import android.hardware.light@2.0::ILight;
+import android.hardware.light@2.0::Status;
+import android.hardware.light@2.0::Type;
 
-interface IExtLight extends android.hardware.light@2.0::ILight {
+interface ILight extends android.hardware.light@2.0::ILight {
 
     /**
      * Set the provided lights to the provided values.
      *
+     * If this was a minor version extension, the recommended
+     * name would be setLight_2_1.
+     *
      * @param type logical light to set
      * @param state describes what the light should look like.
      * @return status result of applying state transformation.
      */
-    setExtLight(Type type, ExtLightState state) generates (Status status);
-
+    setLightExt(Type type, LightState state) generates (Status status);
 };
index d941e73e0068b4bcec4d25d84d8d32334833f354..9df79248a775dcb2740b99e306219185c008aeae 100644 (file)
@@ -24,18 +24,15 @@ namespace V2_0 {
 namespace implementation {
 
 // Methods from ::android::hardware::light::V2_0::ILight follow.
-Return<Status> Light::setLight(Type type, const LightState& state)  {
+Return<Status> Light::setLight(Type type, const OldLightState& state) {
     // Forward types for new methods.
 
-    ExtLightState extState {
-        .state = state,
-        .interpolationOmega =
-            static_cast<int32_t>(Default::INTERPOLATION_OMEGA),
-        .brightness = // ExtBrightness inherits from Brightness
-            static_cast<ExtBrightness>(state.brightnessMode)
-    };
+    LightState extState{.state = state,
+                        .interpolationOmega = static_cast<int32_t>(Default::INTERPOLATION_OMEGA),
+                        .brightness =  // Brightness inherits from Brightness
+                        static_cast<Brightness>(state.brightnessMode)};
 
-    return setExtLight(type, extState);
+    return setLightExt(type, extState);
 }
 
 Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb)  {
@@ -52,9 +49,7 @@ Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb)  {
 }
 
 // Methods from ::android::hardware::example::extension::light::V2_0::ILight follow.
-Return<Status> Light::setExtLight(Type /* type */,
-                                  const ExtLightState& /* state */)  {
-
+Return<Status> Light::setLightExt(Type /* type */, const LightState& /* state */) {
     // ******************************************************
     // Note: awesome proprietary hardware implementation here
     // ******************************************************
index dc2c5dd5379c09d06da8038a77352e845d74ed4c..d178e75cbcf11db514b24e757c9ef1ecd0313bcf 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef ANDROID_HARDWARE_TESTS_EXTENSION_LIGHT_V2_0_LIGHT_H
 #define ANDROID_HARDWARE_TESTS_EXTENSION_LIGHT_V2_0_LIGHT_H
 
-#include <android/hardware/tests/extension/light/2.0/IExtLight.h>
+#include <android/hardware/tests/extension/light/2.0/ILight.h>
 #include <hidl/Status.h>
 
 #include <hidl/MQDescriptor.h>
@@ -28,26 +28,25 @@ namespace light {
 namespace V2_0 {
 namespace implementation {
 
-using ::android::hardware::tests::extension::light::V2_0::ExtLightState;
-using ::android::hardware::tests::extension::light::V2_0::IExtLight;
-using ::android::hardware::light::V2_0::ILight;
-using ::android::hardware::light::V2_0::LightState;
+using ::android::hardware::tests::extension::light::V2_0::LightState;
+using ::android::hardware::tests::extension::light::V2_0::ILight;
+// If using a minor version upgrade, we could just reference these as
+// V2_0::LightState vs. V2_1::LightState, but this makes things easier.
+using OldLightState = ::android::hardware::light::V2_0::LightState;
 using ::android::hardware::light::V2_0::Status;
 using ::android::hardware::light::V2_0::Type;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
 using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
 using ::android::sp;
 
-struct Light : public IExtLight {
+struct Light : public ILight {
     // Methods from ::android::hardware::light::V2_0::ILight follow.
-    Return<Status> setLight(Type type, const LightState& state)  override;
+    Return<Status> setLight(Type type, const OldLightState& state) override;
     Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb)  override;
 
     // Methods from ::android::hardware::example::extension::light::V2_0::ILight follow.
-    Return<Status> setExtLight(Type type, const ExtLightState& state)  override;
-
+    Return<Status> setLightExt(Type type, const LightState& state) override;
 };
 
 }  // namespace implementation
index 1b094796db006a130bf769016a5278cb335ffb14..c05e099f2af7b8422baa9032ddaf2ab17594c082 100644 (file)
 
 package android.hardware.tests.extension.light@2.0;
 
-import android.hardware.light@2.0;
+// If importing something from the same package, the preference is:
+// import @2.0::Foo. However, since this isn't a minor version upgrade
+// we have to use the fully-qualified names here.
+import android.hardware.light@2.0::Brightness;
+import android.hardware.light@2.0::LightState;
 
 enum Default : int32_t {
     // for calls to setLight from the framework that don't know about this
@@ -28,7 +32,7 @@ enum Default : int32_t {
  * One possibility is renaming an old type. Another possibility is taking
  * advantages of the different namespaces.
  */
-enum ExtBrightness : Brightness {
+enum Brightness : android.hardware.light@2.0::Brightness {
     /**
      * Say we're really going to use the phone as a heater.
      */
@@ -43,10 +47,10 @@ enum ExtBrightness : Brightness {
 /**
  * Structs can't inherit eachother in hidl. Use composition instead. In this
  * case, I won't use inheritence because I want to replace Brightness with
- * ExtBrightness.
+ * the new enumeration.
  */
-struct ExtLightState {
-    LightState state;
+struct LightState {
+    android.hardware.light@2.0::LightState state;
 
     /**
      * This is the secret sauce that will really make this extension shine.
@@ -64,5 +68,5 @@ struct ExtLightState {
     /**
      * Include new values.
      */
-    ExtBrightness brightness;
+    Brightness brightness;
 };