Merge "Annotated android.hardware.audio.common@2.0 package to prepare for automated"
diff --git a/nfc/1.0/Android.mk b/nfc/1.0/Android.mk
index 07775e9..b6840bc 100644
--- a/nfc/1.0/Android.mk
+++ b/nfc/1.0/Android.mk
@@ -13,9 +13,9 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (NfcEvent)
+# Build types.hal (nfc_data_t)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/NfcEvent.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_data_t.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -23,16 +23,16 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.NfcEvent
+        android.hardware.nfc@1.0::types.nfc_data_t
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
-# Build types.hal (NfcStatus)
+# Build types.hal (nfc_event_t)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/NfcStatus.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_event_t.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -40,7 +40,24 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.NfcStatus
+        android.hardware.nfc@1.0::types.nfc_event_t
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (nfc_status_t)
+#
+GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_status_t.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.nfc@1.0::types.nfc_status_t
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -99,9 +116,9 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (NfcEvent)
+# Build types.hal (nfc_data_t)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/NfcEvent.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_data_t.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -109,16 +126,16 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.NfcEvent
+        android.hardware.nfc@1.0::types.nfc_data_t
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
-# Build types.hal (NfcStatus)
+# Build types.hal (nfc_event_t)
 #
-GEN := $(intermediates)/android/hardware/nfc/1.0/NfcStatus.java
+GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_event_t.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -126,7 +143,24 @@
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.nfc@1.0::types.NfcStatus
+        android.hardware.nfc@1.0::types.nfc_event_t
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (nfc_status_t)
+#
+GEN := $(intermediates)/android/hardware/nfc/1.0/nfc_status_t.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.nfc@1.0::types.nfc_status_t
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
diff --git a/nfc/1.0/INfc.hal b/nfc/1.0/INfc.hal
index f003b2c..88fd39a 100644
--- a/nfc/1.0/INfc.hal
+++ b/nfc/1.0/INfc.hal
@@ -27,7 +27,7 @@
      * NCI initialization - ie accept CORE_RESET and subsequent commands through
      * the write() call.
      *
-     * If open() returns 0, the NCI stack will wait for a NfcEvent.OPEN_CPLT
+     * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT
      * before continuing.
      *
      * If open() returns any other value, the NCI stack will stop.
@@ -41,32 +41,32 @@
      * This method may queue writes and return immediately. The only
      * requirement is that the writes are executed in order.
      */
-    write(NfcData data) generates (int32_t retval);
+    write(nfc_data_t data) generates (int32_t retval);
 
     /*
-     * coreInitialized() is called after the CORE_INIT_RSP is received from the NFCC.
+     * core_initialized() is called after the CORE_INIT_RSP is received from the NFCC.
      * At this time, the HAL can do any chip-specific configuration.
      *
-     * If coreInitialized() returns 0, the NCI stack will wait for a NfcEvent.POST_INIT_CPLT
+     * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT
      * before continuing.
      *
-     * If coreInitialized() returns any other value, the NCI stack will continue
+     * If core_initialized() returns any other value, the NCI stack will continue
      * immediately.
      */
-    coreInitialized(NfcData data) generates (int32_t retval);
+    core_initialized(vec<uint8_t> data) generates (int32_t retval);
 
     /*
-     * prediscover is called every time before starting RF discovery.
+     * pre_discover is called every time before starting RF discovery.
      * It is a good place to do vendor-specific configuration that must be
      * performed every time RF discovery is about to be started.
      *
-     * If prediscover() returns 0, the NCI stack will wait for a NfcEvent.PREDISCOVER_CPLT
+     * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT
      * before continuing.
      *
-     * If prediscover() returns any other value, the NCI stack will start
+     * If pre_discover() returns any other value, the NCI stack will start
      * RF discovery immediately.
      */
-    prediscover() generates (int32_t retval);
+    pre_discover() generates (int32_t retval);
 
     /*
      * Close the NFC controller. Should free all resources.
@@ -75,15 +75,15 @@
 
     /*
      * Grant HAL the exclusive control to send NCI commands.
-     * Called in response to NfcEvent.REQUEST_CONTROL.
+     * Called in response to HAL_REQUEST_CONTROL_EVT.
      * Must only be called when there are no NCI commands pending.
-     * NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
+     * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control.
      */
-    controlGranted() generates (int32_t retval);
+    control_granted() generates (int32_t retval);
 
      /*
      * Restart controller by power cyle;
-     * NfcEvent.OPEN_CPLT will notify when operation is complete.
+     * HAL_OPEN_CPLT_EVT will notify when operation is complete.
      */
-    powerCycle() generates (int32_t retval);
+    power_cycle() generates (int32_t retval);
 };
diff --git a/nfc/1.0/INfcClientCallback.hal b/nfc/1.0/INfcClientCallback.hal
index a56cc09..f10062e 100644
--- a/nfc/1.0/INfcClientCallback.hal
+++ b/nfc/1.0/INfcClientCallback.hal
@@ -21,11 +21,11 @@
      * The callback passed in from the NFC stack that the HAL
      * can use to pass events back to the stack.
      */
-    sendEvent(NfcEvent event, NfcStatus status);
+    sendEvent(nfc_event_t event, nfc_status_t event_status);
 
     /*
      * The callback passed in from the NFC stack that the HAL
      * can use to pass incomming data to the stack.
      */
-    sendData(NfcData data);
+    sendData(nfc_data_t data);
 };
diff --git a/nfc/1.0/default/Nfc.cpp b/nfc/1.0/default/Nfc.cpp
index d3868c1..b836ada 100644
--- a/nfc/1.0/default/Nfc.cpp
+++ b/nfc/1.0/default/Nfc.cpp
@@ -19,19 +19,19 @@
 // Methods from ::android::hardware::nfc::V1_0::INfc follow.
 ::android::hardware::Return<int32_t> Nfc::open(const sp<INfcClientCallback>& clientCallback)  {
     mCallback = clientCallback;
-    return mDevice->open(mDevice, eventCallback, dataCallback);
+    return mDevice->open(mDevice, event_callback, data_callback);
 }
 
-::android::hardware::Return<int32_t> Nfc::write(const hidl_vec<uint8_t>& data)  {
-    return mDevice->write(mDevice, data.size(), &data[0]);
+::android::hardware::Return<int32_t> Nfc::write(const nfc_data_t& data)  {
+    return mDevice->write(mDevice, data.data.size(), &data.data[0]);
 }
 
-::android::hardware::Return<int32_t> Nfc::coreInitialized(const hidl_vec<uint8_t>& data)  {
+::android::hardware::Return<int32_t> Nfc::core_initialized(const hidl_vec<uint8_t>& data)  {
     hidl_vec<uint8_t> copy = data;
     return mDevice->core_initialized(mDevice, &copy[0]);
 }
 
-::android::hardware::Return<int32_t> Nfc::prediscover()  {
+::android::hardware::Return<int32_t> Nfc::pre_discover()  {
     return mDevice->pre_discover(mDevice);
 }
 
@@ -39,11 +39,11 @@
     return mDevice->close(mDevice);
 }
 
-::android::hardware::Return<int32_t> Nfc::controlGranted()  {
+::android::hardware::Return<int32_t> Nfc::control_granted()  {
     return mDevice->control_granted(mDevice);
 }
 
-::android::hardware::Return<int32_t> Nfc::powerCycle()  {
+::android::hardware::Return<int32_t> Nfc::power_cycle()  {
     return mDevice->power_cycle(mDevice);
 }
 
diff --git a/nfc/1.0/default/Nfc.h b/nfc/1.0/default/Nfc.h
index e596495..98cd57e 100644
--- a/nfc/1.0/default/Nfc.h
+++ b/nfc/1.0/default/Nfc.h
@@ -13,6 +13,7 @@
 
 using ::android::hardware::nfc::V1_0::INfc;
 using ::android::hardware::nfc::V1_0::INfcClientCallback;
+using ::android::hardware::nfc::V1_0::nfc_data_t;
 using ::android::hardware::Return;
 using ::android::hardware::Void;
 using ::android::hardware::hidl_vec;
@@ -22,23 +23,23 @@
 struct Nfc : public INfc {
   Nfc(nfc_nci_device_t* device);
   ::android::hardware::Return<int32_t> open(const sp<INfcClientCallback>& clientCallback)  override;
-  ::android::hardware::Return<int32_t> write(const hidl_vec<uint8_t>& data)  override;
-  ::android::hardware::Return<int32_t> coreInitialized(const hidl_vec<uint8_t>& data)  override;
-  ::android::hardware::Return<int32_t> prediscover()  override;
+  ::android::hardware::Return<int32_t> write(const nfc_data_t& data)  override;
+  ::android::hardware::Return<int32_t> core_initialized(const hidl_vec<uint8_t>& data)  override;
+  ::android::hardware::Return<int32_t> pre_discover()  override;
   ::android::hardware::Return<int32_t> close()  override;
-  ::android::hardware::Return<int32_t> controlGranted()  override;
-  ::android::hardware::Return<int32_t> powerCycle()  override;
+  ::android::hardware::Return<int32_t> control_granted()  override;
+  ::android::hardware::Return<int32_t> power_cycle()  override;
 
-  static void eventCallback(uint8_t event, uint8_t status) {
+  static void event_callback(uint8_t event, uint8_t status) {
       if (mCallback != nullptr) {
           mCallback->sendEvent(
-                  (::android::hardware::nfc::V1_0::NfcEvent) event,
-                  (::android::hardware::nfc::V1_0::NfcStatus) status);
+                  (::android::hardware::nfc::V1_0::nfc_event_t) event,
+                  (::android::hardware::nfc::V1_0::nfc_status_t) status);
       }
   }
-  static void dataCallback(uint16_t data_len, uint8_t* p_data) {
-      hidl_vec<uint8_t> data;
-      data.setToExternal(p_data, data_len);
+  static void data_callback(uint16_t data_len, uint8_t* p_data) {
+      nfc_data_t data;
+      data.data.setToExternal(p_data, data_len);
       if (mCallback != nullptr) {
           mCallback->sendData(data);
       }
diff --git a/nfc/1.0/types.hal b/nfc/1.0/types.hal
index a266178..738dfd9 100644
--- a/nfc/1.0/types.hal
+++ b/nfc/1.0/types.hal
@@ -16,22 +16,24 @@
 
 package android.hardware.nfc@1.0;
 
-enum NfcEvent : uint32_t {
-    OPEN_CPLT           = 0,
-    CLOSE_CPLT          = 1,
-    POST_INIT_CPLT      = 2,
-    PRE_DISCOVER_CPLT   = 3,
-    REQUEST_CONTROL     = 4,
-    RELEASE_CONTROL     = 5,
-    ERROR               = 6
+enum nfc_event_t : uint32_t {
+    HAL_NFC_OPEN_CPLT_EVT           = 0,
+    HAL_NFC_CLOSE_CPLT_EVT          = 1,
+    HAL_NFC_POST_INIT_CPLT_EVT      = 2,
+    HAL_NFC_PRE_DISCOVER_CPLT_EVT   = 3,
+    HAL_NFC_REQUEST_CONTROL_EVT     = 4,
+    HAL_NFC_RELEASE_CONTROL_EVT     = 5,
+    HAL_NFC_ERROR_EVT               = 6
 };
 
-enum NfcStatus : uint32_t {
-    OK               = 0,
-    FAILED           = 1,
-    ERR_TRANSPORT    = 2,
-    ERR_CMD_TIMEOUT  = 3,
-    REFUSED          = 4
+enum nfc_status_t : uint32_t {
+    HAL_NFC_STATUS_OK               = 0,
+    HAL_NFC_STATUS_FAILED           = 1,
+    HAL_NFC_STATUS_ERR_TRANSPORT    = 2,
+    HAL_NFC_STATUS_ERR_CMD_TIMEOUT  = 3,
+    HAL_NFC_STATUS_REFUSED          = 4
 };
 
-typedef vec<uint8_t> NfcData;
+struct nfc_data_t {
+    vec<uint8_t> data;
+};
diff --git a/tests/expression/1.0/IExpressionExt.hal b/tests/expression/1.0/IExpressionExt.hal
index e3edf29..e96bf0d 100644
--- a/tests/expression/1.0/IExpressionExt.hal
+++ b/tests/expression/1.0/IExpressionExt.hal
@@ -34,6 +34,7 @@
         SixteenColors my16Colors;
     };
 
+    @callflow(key=@1.0::IExpression.Constants:MAX_ARRAY_SIZE)
     foo3(int32_t[IExpression.Constants:MAX_ARRAY_SIZE] array);
     foo2(SixteenColors array);
     foo1(int32_t[Constants:CONST_FOO + 5] array);
diff --git a/wifi/1.0/IWifi.hal b/wifi/1.0/IWifi.hal
index 1feeb2a..d1311f5 100644
--- a/wifi/1.0/IWifi.hal
+++ b/wifi/1.0/IWifi.hal
@@ -28,8 +28,12 @@
   /**
    * Requests notifications of significant events for the HAL. Multiple calls to
    * this must register multiple callbacks each of which must receive all
-   * events. IWifiEventCallback registration must be independent of the state
-   * of the rest of the HAL and must persist though stops/starts.
+   * events. |IWifiEventCallback| object registration must be independent of the
+   * state of the rest of the HAL and must persist though stops/starts. These
+   * objects must be deleted when the corresponding client process is dead.
+   *
+   * @param callback An instance of the |IWifiEventCallback| HIDL interface
+   *        object.
    */
   @entry
   @callflow(next={"*"})
@@ -37,6 +41,8 @@
 
   /**
    * Get the current state of the HAL.
+   *
+   * @return started true if started, false otherwise.
    */
   isStarted() generates (bool started);
 
diff --git a/wifi/1.0/IWifiChip.hal b/wifi/1.0/IWifiChip.hal
index f5fe7a9..7a41ddf 100644
--- a/wifi/1.0/IWifiChip.hal
+++ b/wifi/1.0/IWifiChip.hal
@@ -24,7 +24,7 @@
  * to perform operations like NAN, RTT, etc.
  */
 interface IWifiChip {
-  enum InterfaceType : uint32_t {
+  enum IfaceType : uint32_t {
     STA, AP, P2P,
     /**
      * NAN control interface. Datapath support may be queried and created
@@ -35,11 +35,11 @@
 
   /**
    * Set of interface types with the maximum number of interfaces that can have
-   * one of the specified type for a given ChipInterfaceCombination. See
-   * ChipInterfaceCombination for examples.
+   * one of the specified type for a given ChipIfaceCombination. See
+   * ChipIfaceCombination for examples.
    */
-  struct ChipInterfaceCombinationLimit {
-    vec<InterfaceType> types; // Each InterfaceType may occur at most once
+  struct ChipIfaceCombinationLimit {
+    vec<IfaceType> types; // Each IfaceType may occur at most once
     uint32_t maxIfaces;
   };
 
@@ -66,8 +66,8 @@
    *       [], [STA], [STA+NAN], [STA+STA], [NAN]
    *       Not included [STA+STA+NAN]
    */
-  struct ChipInterfaceCombination {
-    vec<ChipInterfaceCombinationLimit> limits;
+  struct ChipIfaceCombination {
+    vec<ChipIfaceCombinationLimit> limits;
   };
 
   /**
@@ -80,7 +80,7 @@
    *
    * When in a mode, it must be possible to perform any combination of creating
    * and removing interfaces as long as at least one of the
-   * ChipInterfaceCombinations is satisfied. This means that if a chip has two
+   * ChipIfaceCombinations is satisfied. This means that if a chip has two
    * available combinations, [{STA} <= 1] and [{AP} <= 1] then it is expected
    * that exactly one STA interface or one AP interface can be created, but it
    * is not expected that both a STA and AP interface could be created. If it
@@ -118,48 +118,62 @@
      * A list of the possible interface combinations that the chip can have
      * while in this mode.
      */
-    vec<ChipInterfaceCombination> availableCombinations;
+    vec<ChipIfaceCombination> availableCombinations;
   };
 
   /**
    * Requests notifications of significant events on this chip. Multiple calls
    * to this will register multiple callbacks each of which will receive all
    * events.
+   *
+   * @param callback An instance of the |IWifiChipEventCallback| HIDL interface
+   *        object.
    */
   oneway registerEventCallback(IWifiChipEventCallback callback);
 
   /**
    * Get the set of operation modes that the chip supports.
+   *
+   * @return modes List of modes supported by the device.
    */
   getAvailableModes() generates (vec<ChipMode> modes);
 
   /**
-   * Reconfigure the Chip. Will trigger onChipReconfigured.
+   * Reconfigure the Chip.
+   * Must trigger |IWifiChipEventCallback.onChipReconfigured| on sucess,
+   * or |IWifiChipEventCallback.onChipReconfigureFailure| on failure.
    *
    * @param modeId The mode that the chip should switch to, corresponding to the
-   *               id property of the target ChipMode.
+   *        id property of the target ChipMode.
    */
   oneway configureChip(ChipModeId modeId);
 
   /**
    * Get the current mode that the chip is in.
+   *
+   * @return modeId The mode that the chip is currently configured to,
+   *         corresponding to the id property of the target ChipMode.
    */
   getMode() generates (ChipModeId modeId);
 
   /**
-   * Request information about the chip. Will trigger onChipDebugInfoAvailable.
+   * Request information about the chip.
+   * Must trigger |IWifiChipEventCallback.onChipDebugInfoAvailable| on sucess,
+   * or |IWifiChipEventCallback.onChipDebugInfoFailure| on failure.
    */
   oneway requestChipDebugInfo();
 
   /**
-   * Request vendor debug info from the driver. Will trigger
-   * onDriverDebugDumpAvailable.
+   * Request vendor debug info from the driver.
+   * Must trigger |IWifiChipEventCallback.onDriverDebugDumpAvailable| on success,
+   * or |IWifiChipEventCallback.onDriverDebugDumpFailure| on failure.
    */
   oneway requestDriverDebugDump();
 
   /**
-   * Request vendor debug info from the firmware. Will trigger
-   * onFirmwareDebugDumpAvailable.
+   * Request vendor debug info from the firmware.
+   * Must trigger |IWifiChipEventCallback.onFirmwareDebugDumpAvailable| on
+   * success, or |IWifiChipEventCallback.onFirmwareDebugDumpFailure| on failure.
    */
   oneway requestFirmwareDebugDump();
 };
diff --git a/wifi/1.0/IWifiChipEventCallback.hal b/wifi/1.0/IWifiChipEventCallback.hal
index 79f6d2a..2161c5d 100644
--- a/wifi/1.0/IWifiChipEventCallback.hal
+++ b/wifi/1.0/IWifiChipEventCallback.hal
@@ -24,7 +24,7 @@
    * considered invalid.
    *
    * @param modeId The mode that the chip switched to, corresponding to the id
-   *                property of the target ChipMode.
+   *        property of the target ChipMode.
    */
   oneway onChipReconfigured(ChipModeId modeId);
 
@@ -34,7 +34,8 @@
    * assumed to be invalid.
    *
    * @param modeId The mode that the chip failed switched to, corresponding to
-   *                the id property of the target ChipMode.
+   *        the id property of the target ChipMode.
+   * @param reason Failure reason code.
    */
   oneway onChipReconfigureFailure(ChipModeId modeId, FailureReason reason);
 
@@ -51,18 +52,45 @@
 
   /**
    * Callback with debug information about this chip
+   *
+   * @param info Instance of |ChipDebugInfo|.
    */
   oneway onChipDebugInfoAvailable(ChipDebugInfo info);
 
   /**
-   * Callback with a vendor specific debug blob from the driver.
-   * This blob will be dumped as part of the bug report.
+   * Callback to be invoked on failure to fetch debug info about this chip.
+   *
+   * @param reason Failure reason code.
    */
-  oneway onDriverDebugDumpAvailable(vec<uint8_t> blob);
+  oneway onChipDebugInfoFailure(FailureReason reason);
 
   /**
    * Callback with a vendor specific debug blob from the driver.
    * This blob will be dumped as part of the bug report.
+   *
+   * @param blob Vector of bytes retrieved from the driver.
+   */
+  oneway onDriverDebugDumpAvailable(vec<uint8_t> blob);
+
+  /**
+   * Callback to be invoked on failure to fetch debug blob from driver.
+   *
+   * @param reason Failure reason code.
+   */
+  oneway onDriverDebugDumpFailure(FailureReason reason);
+
+  /**
+   * Callback with a vendor specific debug blob from the driver.
+   * This blob will be dumped as part of the bug report.
+   *
+   * @param blob Vector of bytes retrieved from the driver.
    */
   oneway onFirmwareDebugDumpAvailable(vec<uint8_t> blob);
+
+  /**
+   * Callback to be invoked on failure to fetch debug blob from driver.
+   *
+   * @param reason Failure reason code.
+   */
+  oneway onFirmwareDebugDumpFailure(FailureReason reason);
 };
diff --git a/wifi/1.0/IWifiEventCallback.hal b/wifi/1.0/IWifiEventCallback.hal
index 84025ce..33accff 100644
--- a/wifi/1.0/IWifiEventCallback.hal
+++ b/wifi/1.0/IWifiEventCallback.hal
@@ -28,6 +28,8 @@
    * failed. After this callback the HAL will be considered stopped. Another
    * call to start will attempt to reinitialize the HAL; however, there is a
    * chance it may fail again.
+   *
+   * @param reason Failure reason code.
    */
   oneway onStartFailure(FailureReason reason);
 
@@ -43,6 +45,8 @@
    * Calling start again must restart Wi-Fi as if stop then start was called
    * (full state reset). When this event is received all IWifiChip objects
    * retrieved after the last call to start will be considered invalid.
+   *
+   * @param reason Failure reason code.
    */
   oneway onFailure(FailureReason reason);
 };
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
new file mode 100644
index 0000000..07865a5
--- /dev/null
+++ b/wifi/1.0/default/Android.mk
@@ -0,0 +1,57 @@
+# Copyright (C) 2016 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.
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.wifi@1.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_CPPFLAGS := -std=c++11 -Wall -Wno-unused-parameter -Werror -Wextra
+LOCAL_SRC_FILES := \
+    failure_reason_util.cpp \
+    wifi_chip.cpp \
+    wifi.cpp \
+    wifi_legacy_hal.cpp
+LOCAL_SHARED_LIBRARIES := \
+    android.hardware.wifi@1.0 \
+    libbase \
+    libcutils \
+    libhidl \
+    libhwbinder \
+    liblog \
+    libnl \
+    libutils \
+    libwifi-system
+LOCAL_WHOLE_STATIC_LIBRARIES := $(LIB_WIFI_HAL)
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.wifi@1.0-service
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_CPPFLAGS := -std=c++11 -Wall -Wno-unused-parameter -Werror -Wextra
+LOCAL_SRC_FILES := \
+    service.cpp
+LOCAL_SHARED_LIBRARIES := \
+    android.hardware.wifi@1.0 \
+    android.hardware.wifi@1.0-impl \
+    libbase \
+    libcutils \
+    libhidl \
+    libhwbinder \
+    liblog \
+    libnl \
+    libutils \
+    libwifi-system
+LOCAL_WHOLE_STATIC_LIBRARIES := $(LIB_WIFI_HAL)
+LOCAL_INIT_RC := android.hardware.wifi@1.0-service.rc
+include $(BUILD_EXECUTABLE)
diff --git a/wifi/1.0/default/android.hardware.wifi@1.0-service.rc b/wifi/1.0/default/android.hardware.wifi@1.0-service.rc
new file mode 100644
index 0000000..9d09347
--- /dev/null
+++ b/wifi/1.0/default/android.hardware.wifi@1.0-service.rc
@@ -0,0 +1,4 @@
+service wifi_hal_legacy /system/bin/hw/android.hardware.wifi@1.0-service
+    class hal
+    user wifi
+    group wifi
diff --git a/wifi/1.0/default/failure_reason_util.cpp b/wifi/1.0/default/failure_reason_util.cpp
new file mode 100644
index 0000000..f703ebe
--- /dev/null
+++ b/wifi/1.0/default/failure_reason_util.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+std::string LegacyErrorToString(wifi_error error) {
+  switch (error) {
+    case WIFI_SUCCESS:
+      return "SUCCESS";
+    case WIFI_ERROR_UNINITIALIZED:
+      return "UNINITIALIZED";
+    case WIFI_ERROR_NOT_AVAILABLE:
+      return "NOT_AVAILABLE";
+    case WIFI_ERROR_NOT_SUPPORTED:
+      return "NOT_SUPPORTED";
+    case WIFI_ERROR_INVALID_ARGS:
+      return "INVALID_ARGS";
+    case WIFI_ERROR_INVALID_REQUEST_ID:
+      return "INVALID_REQUEST_ID";
+    case WIFI_ERROR_TIMED_OUT:
+      return "TIMED_OUT";
+    case WIFI_ERROR_TOO_MANY_REQUESTS:
+      return "TOO_MANY_REQUESTS";
+    case WIFI_ERROR_OUT_OF_MEMORY:
+      return "OUT_OF_MEMORY";
+    case WIFI_ERROR_UNKNOWN:
+    default:
+      return "UNKNOWN";
+  }
+}
+
+FailureReason CreateFailureReason(CommandFailureReason reason,
+                                  const std::string& description) {
+  FailureReason result;
+  result.reason = reason;
+  result.description = description.data();
+  return result;
+}
+
+FailureReason CreateFailureReasonLegacyError(wifi_error error,
+                                             const std::string& desc) {
+  switch (error) {
+    case WIFI_ERROR_UNINITIALIZED:
+    case WIFI_ERROR_NOT_AVAILABLE:
+      return CreateFailureReason(CommandFailureReason::NOT_AVAILABLE, desc);
+
+    case WIFI_ERROR_NOT_SUPPORTED:
+      return CreateFailureReason(CommandFailureReason::NOT_SUPPORTED, desc);
+
+    case WIFI_ERROR_INVALID_ARGS:
+    case WIFI_ERROR_INVALID_REQUEST_ID:
+      return CreateFailureReason(CommandFailureReason::INVALID_ARGS, desc);
+
+    case WIFI_ERROR_TIMED_OUT:
+      return CreateFailureReason(CommandFailureReason::UNKNOWN,
+                                 desc + ", timed out");
+
+    case WIFI_ERROR_TOO_MANY_REQUESTS:
+      return CreateFailureReason(CommandFailureReason::UNKNOWN,
+                                 desc + ", too many requests");
+
+    case WIFI_ERROR_OUT_OF_MEMORY:
+      return CreateFailureReason(CommandFailureReason::UNKNOWN,
+                                 desc + ", out of memory");
+
+    case WIFI_ERROR_NONE:
+    case WIFI_ERROR_UNKNOWN:
+    default:
+      return CreateFailureReason(CommandFailureReason::UNKNOWN, "unknown");
+  }
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
diff --git a/wifi/1.0/default/failure_reason_util.h b/wifi/1.0/default/failure_reason_util.h
new file mode 100644
index 0000000..7d51bbf
--- /dev/null
+++ b/wifi/1.0/default/failure_reason_util.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef FAILURE_REASON_UTIL_H_
+#define FAILURE_REASON_UTIL_H_
+
+#include <android/hardware/wifi/1.0/IWifi.h>
+#include <hardware_legacy/wifi_hal.h>
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+std::string LegacyErrorToString(wifi_error error);
+
+FailureReason CreateFailureReason(CommandFailureReason reason,
+                                  const std::string& description);
+FailureReason CreateFailureReasonLegacyError(wifi_error error,
+                                             const std::string& description);
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
+
+#endif  // FAILURE_REASON_UTIL_H_
diff --git a/wifi/1.0/default/service.cpp b/wifi/1.0/default/service.cpp
new file mode 100644
index 0000000..10ce1db
--- /dev/null
+++ b/wifi/1.0/default/service.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <android-base/logging.h>
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Looper.h>
+#include <utils/StrongPointer.h>
+
+#include "wifi.h"
+
+using android::hardware::hidl_version;
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+using android::Looper;
+
+namespace {
+int OnBinderReadReady(int /*fd*/, int /*events*/, void* /*data*/) {
+  IPCThreadState::self()->handlePolledCommands();
+  return 1;  // continue receiving events
+}
+}
+
+int main(int /*argc*/, char** argv) {
+  android::base::InitLogging(argv,
+                             android::base::LogdLogger(android::base::SYSTEM));
+  LOG(INFO) << "wifi_hal_legacy is starting up...";
+
+  // Setup binder
+  int binder_fd = -1;
+  ProcessState::self()->setThreadPoolMaxThreadCount(0);
+  CHECK_EQ(IPCThreadState::self()->setupPolling(&binder_fd), android::NO_ERROR)
+      << "Failed to initialize binder polling";
+  CHECK_GE(binder_fd, 0) << "Invalid binder FD: " << binder_fd;
+
+  // Setup looper
+  android::sp<Looper> looper = Looper::prepare(0 /* no options */);
+  CHECK(looper->addFd(
+      binder_fd, 0, Looper::EVENT_INPUT, OnBinderReadReady, nullptr))
+      << "Failed to watch binder FD";
+
+  // Setup hwbinder service
+  android::sp<android::hardware::wifi::V1_0::IWifi> service =
+      new android::hardware::wifi::V1_0::implementation::Wifi();
+  CHECK_EQ(service->registerAsService("wifi"), android::NO_ERROR)
+      << "Failed to register wifi HAL";
+
+  // Loop
+  while (looper->pollAll(-1) != Looper::POLL_ERROR) {
+    // Keep polling until failure.
+  }
+
+  LOG(INFO) << "wifi_hal_legacy is terminating...";
+  return 0;
+}
diff --git a/wifi/1.0/default/wifi.cpp b/wifi/1.0/default/wifi.cpp
new file mode 100644
index 0000000..d5b69b8
--- /dev/null
+++ b/wifi/1.0/default/wifi.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "wifi.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+#include "wifi_chip.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+Wifi::Wifi()
+    : legacy_hal_(new WifiLegacyHal()), run_state_(RunState::STOPPED) {}
+
+Return<void> Wifi::registerEventCallback(
+    const sp<IWifiEventCallback>& callback) {
+  // TODO(b/31632518): remove the callback when the client is destroyed
+  callbacks_.insert(callback);
+  return Void();
+}
+
+Return<bool> Wifi::isStarted() {
+  return run_state_ != RunState::STOPPED;
+}
+
+Return<void> Wifi::start() {
+  if (run_state_ == RunState::STARTED) {
+    for (const auto& callback : callbacks_) {
+      callback->onStart();
+    }
+    return Void();
+  } else if (run_state_ == RunState::STOPPING) {
+    for (const auto& callback : callbacks_) {
+      callback->onStartFailure(CreateFailureReason(
+          CommandFailureReason::NOT_AVAILABLE, "HAL is stopping"));
+    }
+    return Void();
+  }
+
+  LOG(INFO) << "Starting HAL";
+  wifi_error status = legacy_hal_->start();
+  if (status != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to start Wifi HAL";
+    for (auto& callback : callbacks_) {
+      callback->onStartFailure(
+          CreateFailureReasonLegacyError(status, "Failed to start HAL"));
+    }
+    return Void();
+  }
+
+  // Create the chip instance once the HAL is started.
+  chip_ = new WifiChip(legacy_hal_);
+  run_state_ = RunState::STARTED;
+  for (const auto& callback : callbacks_) {
+    callback->onStart();
+  }
+  return Void();
+}
+
+Return<void> Wifi::stop() {
+  if (run_state_ == RunState::STOPPED) {
+    for (const auto& callback : callbacks_) {
+      callback->onStop();
+    }
+    return Void();
+  } else if (run_state_ == RunState::STOPPING) {
+    return Void();
+  }
+
+  LOG(INFO) << "Stopping HAL";
+  run_state_ = RunState::STOPPING;
+  const auto on_complete_callback_ = [&]() {
+    if (chip_.get()) {
+      chip_->invalidate();
+    }
+    chip_.clear();
+    run_state_ = RunState::STOPPED;
+    for (const auto& callback : callbacks_) {
+      callback->onStop();
+    }
+  };
+  wifi_error status = legacy_hal_->stop(on_complete_callback_);
+  if (status != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to stop Wifi HAL";
+    for (const auto& callback : callbacks_) {
+      callback->onFailure(
+          CreateFailureReasonLegacyError(status, "Failed to stop HAL"));
+    }
+  }
+  return Void();
+}
+
+Return<void> Wifi::getChip(getChip_cb cb) {
+  cb(chip_);
+  return Void();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
diff --git a/wifi/1.0/default/wifi.h b/wifi/1.0/default/wifi.h
new file mode 100644
index 0000000..e6cf1ac
--- /dev/null
+++ b/wifi/1.0/default/wifi.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef WIFI_H_
+#define WIFI_H_
+
+#include <functional>
+#include <set>
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifi.h>
+#include <utils/Looper.h>
+
+#include "wifi_chip.h"
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * Root HIDL interface object used to control the Wifi HAL.
+ */
+class Wifi : public IWifi {
+ public:
+  Wifi();
+
+  // HIDL methods exposed.
+  Return<void> registerEventCallback(
+      const sp<IWifiEventCallback>& callback) override;
+  Return<bool> isStarted() override;
+  Return<void> start() override;
+  Return<void> stop() override;
+  Return<void> getChip(getChip_cb cb) override;
+
+ private:
+  enum class RunState { STOPPED, STARTED, STOPPING };
+
+  // Instance is created in this root level |IWifi| HIDL interface object
+  // and shared with all the child HIDL interface objects.
+  std::shared_ptr<WifiLegacyHal> legacy_hal_;
+  RunState run_state_;
+  std::set<sp<IWifiEventCallback>> callbacks_;
+  sp<WifiChip> chip_;
+
+  DISALLOW_COPY_AND_ASSIGN(Wifi);
+};
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
+
+#endif  // WIFI_H_
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
new file mode 100644
index 0000000..df321e2
--- /dev/null
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "wifi_chip.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiChip::WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal)
+    : legacy_hal_(legacy_hal) {}
+
+void WifiChip::invalidate() {
+  legacy_hal_.reset();
+  callbacks_.clear();
+}
+
+Return<void> WifiChip::registerEventCallback(
+    const sp<IWifiChipEventCallback>& callback) {
+  if (!legacy_hal_.lock())
+    return Void();
+  // TODO(b/31632518): remove the callback when the client is destroyed
+  callbacks_.insert(callback);
+  return Void();
+}
+
+Return<void> WifiChip::getAvailableModes(getAvailableModes_cb cb) {
+  if (!legacy_hal_.lock()) {
+    cb(hidl_vec<ChipMode>());
+    return Void();
+  } else {
+    // TODO add implementation
+    return Void();
+  }
+}
+
+Return<void> WifiChip::configureChip(uint32_t /*mode_id*/) {
+  if (!legacy_hal_.lock())
+    return Void();
+  // TODO add implementation
+  return Void();
+}
+
+Return<uint32_t> WifiChip::getMode() {
+  if (!legacy_hal_.lock())
+    return 0;
+  // TODO add implementation
+  return 0;
+}
+
+Return<void> WifiChip::requestChipDebugInfo() {
+  if (!legacy_hal_.lock())
+    return Void();
+
+  IWifiChipEventCallback::ChipDebugInfo result;
+
+  std::pair<wifi_error, std::string> ret =
+      legacy_hal_.lock()->getWlanDriverVersion();
+  if (ret.first != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to get driver version: "
+               << LegacyErrorToString(ret.first);
+    return Void();
+  }
+  result.driverDescription = ret.second.c_str();
+
+  ret = legacy_hal_.lock()->getWlanFirmwareVersion();
+  if (ret.first != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to get firmware version: "
+               << LegacyErrorToString(ret.first);
+    return Void();
+  }
+  result.firmwareDescription = ret.second.c_str();
+
+  for (const auto& callback : callbacks_) {
+    callback->onChipDebugInfoAvailable(result);
+  }
+  return Void();
+}
+
+Return<void> WifiChip::requestDriverDebugDump() {
+  if (!legacy_hal_.lock())
+    return Void();
+
+  std::pair<wifi_error, std::vector<char>> ret =
+      legacy_hal_.lock()->requestWlanDriverMemoryDump();
+  if (ret.first != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to get driver debug dump: "
+               << LegacyErrorToString(ret.first);
+    return Void();
+  }
+
+  auto& driver_dump = ret.second;
+  hidl_vec<uint8_t> hidl_data;
+  hidl_data.setToExternal(reinterpret_cast<uint8_t*>(driver_dump.data()),
+                          driver_dump.size());
+  for (const auto& callback : callbacks_) {
+    callback->onDriverDebugDumpAvailable(hidl_data);
+  }
+  return Void();
+}
+
+Return<void> WifiChip::requestFirmwareDebugDump() {
+  if (!legacy_hal_.lock())
+    return Void();
+
+  std::pair<wifi_error, std::vector<char>> ret =
+      legacy_hal_.lock()->requestWlanFirmwareMemoryDump();
+  if (ret.first != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to get firmware debug dump: "
+               << LegacyErrorToString(ret.first);
+    return Void();
+  }
+
+  auto& firmware_dump = ret.second;
+  hidl_vec<uint8_t> hidl_data;
+  hidl_data.setToExternal(reinterpret_cast<uint8_t*>(firmware_dump.data()),
+                          firmware_dump.size());
+  for (const auto& callback : callbacks_) {
+    callback->onFirmwareDebugDumpAvailable(hidl_data);
+  }
+  return Void();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
diff --git a/wifi/1.0/default/wifi_chip.h b/wifi/1.0/default/wifi_chip.h
new file mode 100644
index 0000000..95fabe4
--- /dev/null
+++ b/wifi/1.0/default/wifi_chip.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef WIFI_CHIP_H_
+#define WIFI_CHIP_H_
+
+#include <set>
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiChip.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control a Wifi HAL chip instance.
+ * Since there is only a single chip instance used today, there is no
+ * identifying handle information stored here.
+ */
+class WifiChip : public IWifiChip {
+ public:
+  WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal);
+  // Invalidate this instance once the HAL is stopped.
+  void invalidate();
+
+  // HIDL methods exposed.
+  Return<void> registerEventCallback(
+      const sp<IWifiChipEventCallback>& callback) override;
+  Return<void> getAvailableModes(getAvailableModes_cb cb) override;
+  Return<void> configureChip(uint32_t mode_id) override;
+  Return<uint32_t> getMode() override;
+  Return<void> requestChipDebugInfo() override;
+  Return<void> requestDriverDebugDump() override;
+  Return<void> requestFirmwareDebugDump() override;
+
+ private:
+  std::weak_ptr<WifiLegacyHal> legacy_hal_;
+  std::set<sp<IWifiChipEventCallback>> callbacks_;
+
+  DISALLOW_COPY_AND_ASSIGN(WifiChip);
+};
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
+
+#endif  // WIFI_CHIP_H_
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
new file mode 100644
index 0000000..a6df996
--- /dev/null
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <array>
+
+#include "failure_reason_util.h"
+#include "wifi_legacy_hal.h"
+
+#include <android-base/logging.h>
+#include <cutils/properties.h>
+#include <wifi_system/hal_tool.h>
+#include <wifi_system/interface_tool.h>
+
+namespace {
+std::string getWlanInterfaceName() {
+  char buffer[PROPERTY_VALUE_MAX];
+  property_get("wifi.interface", buffer, "wlan0");
+  return buffer;
+}
+
+// Legacy HAL functions accept "C" style function pointers, so use global
+// functions to pass to the legacy HAL function and store the corresponding
+// std::function methods to be invoked.
+// Callback to be invoked once |stop| is complete.
+std::function<void(wifi_handle handle)> on_stop_complete_internal_callback;
+void onStopComplete(wifi_handle handle) {
+  if (on_stop_complete_internal_callback) {
+    on_stop_complete_internal_callback(handle);
+  }
+}
+
+// Callback to be invoked for driver dump.
+std::function<void(char*, int)> on_driver_memory_dump_internal_callback;
+void onDriverMemoryDump(char* buffer, int buffer_size) {
+  if (on_driver_memory_dump_internal_callback) {
+    on_driver_memory_dump_internal_callback(buffer, buffer_size);
+  }
+}
+
+// Callback to be invoked for firmware dump.
+std::function<void(char*, int)> on_firmware_memory_dump_internal_callback;
+void onFirmwareMemoryDump(char* buffer, int buffer_size) {
+  if (on_firmware_memory_dump_internal_callback) {
+    on_firmware_memory_dump_internal_callback(buffer, buffer_size);
+  }
+}
+}
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+const uint32_t WifiLegacyHal::kMaxVersionStringLength = 256;
+
+WifiLegacyHal::WifiLegacyHal()
+    : global_handle_(nullptr),
+      wlan_interface_handle_(nullptr),
+      awaiting_event_loop_termination_(false) {}
+
+wifi_error WifiLegacyHal::start() {
+  // Ensure that we're starting in a good state.
+  CHECK(!global_handle_ && !wlan_interface_handle_ &&
+        !awaiting_event_loop_termination_);
+
+  android::wifi_system::HalTool hal_tool;
+  android::wifi_system::InterfaceTool if_tool;
+  if (!hal_tool.InitFunctionTable(&global_func_table_)) {
+    LOG(ERROR) << "Failed to initialize legacy hal function table";
+    return WIFI_ERROR_UNKNOWN;
+  }
+  if (!if_tool.SetWifiUpState(true)) {
+    LOG(ERROR) << "Failed to set WiFi interface up";
+    return WIFI_ERROR_UNKNOWN;
+  }
+
+  LOG(INFO) << "Starting legacy HAL";
+  wifi_error status = global_func_table_.wifi_initialize(&global_handle_);
+  if (status != WIFI_SUCCESS || !global_handle_) {
+    LOG(ERROR) << "Failed to retrieve global handle";
+    return status;
+  }
+  event_loop_thread_ = std::thread(&WifiLegacyHal::runEventLoop, this);
+  status = retrieveWlanInterfaceHandle();
+  if (status != WIFI_SUCCESS || !wlan_interface_handle_) {
+    LOG(ERROR) << "Failed to retrieve wlan interface handle";
+    return status;
+  }
+  LOG(VERBOSE) << "Legacy HAL start complete";
+  return WIFI_SUCCESS;
+}
+
+wifi_error WifiLegacyHal::stop(
+    const std::function<void()>& on_stop_complete_user_callback) {
+  LOG(INFO) << "Stopping legacy HAL";
+  on_stop_complete_internal_callback = [&](wifi_handle handle) {
+    CHECK_EQ(global_handle_, handle) << "Handle mismatch";
+    on_stop_complete_user_callback();
+    global_handle_ = nullptr;
+    wlan_interface_handle_ = nullptr;
+    on_stop_complete_internal_callback = nullptr;
+  };
+  awaiting_event_loop_termination_ = true;
+  global_func_table_.wifi_cleanup(global_handle_, onStopComplete);
+  LOG(VERBOSE) << "Legacy HAL stop initiated";
+  return WIFI_SUCCESS;
+}
+
+std::pair<wifi_error, std::string> WifiLegacyHal::getWlanDriverVersion() {
+  std::array<char, kMaxVersionStringLength> buffer;
+  buffer.fill(0);
+  wifi_error status = global_func_table_.wifi_get_driver_version(
+      wlan_interface_handle_, buffer.data(), buffer.size());
+  return std::make_pair(status, buffer.data());
+}
+
+std::pair<wifi_error, std::string> WifiLegacyHal::getWlanFirmwareVersion() {
+  std::array<char, kMaxVersionStringLength> buffer;
+  buffer.fill(0);
+  wifi_error status = global_func_table_.wifi_get_firmware_version(
+      wlan_interface_handle_, buffer.data(), buffer.size());
+  return std::make_pair(status, buffer.data());
+}
+
+std::pair<wifi_error, std::vector<char>>
+WifiLegacyHal::requestWlanDriverMemoryDump() {
+  std::vector<char> driver_dump;
+  on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer,
+                                                           int buffer_size) {
+    driver_dump.insert(driver_dump.end(), buffer, buffer + buffer_size);
+  };
+  wifi_error status = global_func_table_.wifi_get_driver_memory_dump(
+      wlan_interface_handle_, {onDriverMemoryDump});
+  on_driver_memory_dump_internal_callback = nullptr;
+  return std::make_pair(status, std::move(driver_dump));
+}
+
+std::pair<wifi_error, std::vector<char>>
+WifiLegacyHal::requestWlanFirmwareMemoryDump() {
+  std::vector<char> firmware_dump;
+  on_firmware_memory_dump_internal_callback = [&firmware_dump](
+      char* buffer, int buffer_size) {
+    firmware_dump.insert(firmware_dump.end(), buffer, buffer + buffer_size);
+  };
+  wifi_error status = global_func_table_.wifi_get_firmware_memory_dump(
+      wlan_interface_handle_, {onFirmwareMemoryDump});
+  on_firmware_memory_dump_internal_callback = nullptr;
+  return std::make_pair(status, std::move(firmware_dump));
+}
+
+wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
+  const std::string& ifname_to_find = getWlanInterfaceName();
+
+  wifi_interface_handle* iface_handles = nullptr;
+  int num_iface_handles = 0;
+  wifi_error status = global_func_table_.wifi_get_ifaces(
+      global_handle_, &num_iface_handles, &iface_handles);
+  if (status != WIFI_SUCCESS) {
+    LOG(ERROR) << "Failed to enumerate interface handles: "
+               << LegacyErrorToString(status);
+    return status;
+  }
+  for (int i = 0; i < num_iface_handles; ++i) {
+    std::array<char, IFNAMSIZ> current_ifname;
+    current_ifname.fill(0);
+    status = global_func_table_.wifi_get_iface_name(
+        iface_handles[i], current_ifname.data(), current_ifname.size());
+    if (status != WIFI_SUCCESS) {
+      LOG(WARNING) << "Failed to get interface handle name: "
+                   << LegacyErrorToString(status);
+      continue;
+    }
+    if (ifname_to_find == current_ifname.data()) {
+      wlan_interface_handle_ = iface_handles[i];
+      return WIFI_SUCCESS;
+    }
+  }
+  return WIFI_ERROR_UNKNOWN;
+}
+
+void WifiLegacyHal::runEventLoop() {
+  LOG(VERBOSE) << "Starting legacy HAL event loop";
+  global_func_table_.wifi_event_loop(global_handle_);
+  if (!awaiting_event_loop_termination_) {
+    LOG(FATAL) << "Legacy HAL event loop terminated, but HAL was not stopping";
+  }
+  LOG(VERBOSE) << "Legacy HAL event loop terminated";
+  awaiting_event_loop_termination_ = false;
+  android::wifi_system::InterfaceTool if_tool;
+  if_tool.SetWifiUpState(false);
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
new file mode 100644
index 0000000..f691b9b
--- /dev/null
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef WIFI_LEGACY_WIFI_HAL_H_
+#define WIFI_LEGACY_WIFI_HAL_H_
+
+#include <functional>
+#include <thread>
+
+#include <hardware_legacy/wifi_hal.h>
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * Class that encapsulates all legacy HAL interactions.
+ * This class manages the lifetime of the event loop thread used by legacy HAL.
+ */
+class WifiLegacyHal {
+ public:
+  WifiLegacyHal();
+  // Initialize the legacy HAL and start the event looper thread.
+  wifi_error start();
+  // Deinitialize the legacy HAL and stop the event looper thread.
+  wifi_error stop(const std::function<void()>& on_complete_callback);
+  // Wrappers for all the functions in the legacy HAL function table.
+  std::pair<wifi_error, std::string> getWlanDriverVersion();
+  std::pair<wifi_error, std::string> getWlanFirmwareVersion();
+  std::pair<wifi_error, std::vector<char>> requestWlanDriverMemoryDump();
+  std::pair<wifi_error, std::vector<char>> requestWlanFirmwareMemoryDump();
+
+ private:
+  static const uint32_t kMaxVersionStringLength;
+
+  // Retrieve the interface handle to be used for the "wlan" interface.
+  wifi_error retrieveWlanInterfaceHandle();
+  // Run the legacy HAL event loop thread.
+  void runEventLoop();
+
+  // Event loop thread used by legacy HAL.
+  std::thread event_loop_thread_;
+  // Global function table of legacy HAL.
+  wifi_hal_fn global_func_table_;
+  // Opaque handle to be used for all global operations.
+  wifi_handle global_handle_;
+  // Opaque handle to be used for all wlan0 interface specific operations.
+  wifi_interface_handle wlan_interface_handle_;
+  // Flag to indicate if we have initiated the cleanup of legacy HAL.
+  bool awaiting_event_loop_termination_;
+};
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace wifi
+}  // namespace hardware
+}  // namespace android
+
+#endif  // WIFI_LEGACY_WIFI_HAL_H_