Split up headers.

This splits headers into three locations:
include - for backwards compatibility, the global include
include_all - for things system/vendor both use
include_vendor - for things that only vendors use

The goal is to gradually have system things stop referencing
(at least most) of these headers.

Bug: 37280010
Test: build (CL on top adds back in symlinks)

Change-Id: Ibf194276b7faa857e1e7605d7719f4e7d873ecba
diff --git a/Android.bp b/Android.bp
index 6baab68..70d76fa 100644
--- a/Android.bp
+++ b/Android.bp
@@ -32,6 +32,7 @@
 
 cc_library_headers {
     name: "libhardware_headers",
+
     header_libs: [
         "libaudio_system_headers",
         "libsystem_headers",
@@ -45,11 +46,22 @@
         "libbluetooth-types-header",
     ],
 
-    export_include_dirs: ["include"],
     recovery_available: true,
     vendor_available: true,
     // TODO(b/153609531): remove when no longer needed.
     native_bridge_supported: true,
+
+    // There are three include directories currently:
+    // - include: this directory is the original location of libhardware headers. It is globally
+    //       available (even if you do not depend on libhardware). Many locations also use
+    //       LOCAL_C_INCLUDES or include_dirs to access these from a global namespace. These processes
+    //       should replace this dependency with a direct dependency on libhardware(_headers)?.
+    // - include_all: this directory is for system and vendor include files. Gradually, the number of
+    //       files here should be reduced to 0 by moving them to vendor as old code is phased out.
+    // - include_vendor: this directory is the current designated resting place for these headers.
+    //       They are kept around to try to help insure existing codebases can function.
+    export_include_dirs: ["include_all"],
+
     target: {
         recovery: {
             exclude_header_libs: [
@@ -60,6 +72,12 @@
         windows: {
             enabled: true,
         },
+        vendor: {
+            override_export_include_dirs: [
+                "include_all",
+                "include_vendor",
+            ],
+        },
     },
     apex_available: [
         "//apex_available:platform",
diff --git a/include/hardware/activity_recognition.h b/include_all/hardware/activity_recognition.h
similarity index 100%
rename from include/hardware/activity_recognition.h
rename to include_all/hardware/activity_recognition.h
diff --git a/include/hardware/audio.h b/include_all/hardware/audio.h
similarity index 100%
rename from include/hardware/audio.h
rename to include_all/hardware/audio.h
diff --git a/include/hardware/audio_alsaops.h b/include_all/hardware/audio_alsaops.h
similarity index 100%
rename from include/hardware/audio_alsaops.h
rename to include_all/hardware/audio_alsaops.h
diff --git a/include/hardware/audio_effect.h b/include_all/hardware/audio_effect.h
similarity index 100%
rename from include/hardware/audio_effect.h
rename to include_all/hardware/audio_effect.h
diff --git a/include/hardware/audio_policy.h b/include_all/hardware/audio_policy.h
similarity index 100%
rename from include/hardware/audio_policy.h
rename to include_all/hardware/audio_policy.h
diff --git a/include/hardware/bluetooth.h b/include_all/hardware/bluetooth.h
similarity index 100%
rename from include/hardware/bluetooth.h
rename to include_all/hardware/bluetooth.h
diff --git a/include/hardware/boot_control.h b/include_all/hardware/boot_control.h
similarity index 100%
rename from include/hardware/boot_control.h
rename to include_all/hardware/boot_control.h
diff --git a/include/hardware/camera.h b/include_all/hardware/camera.h
similarity index 100%
rename from include/hardware/camera.h
rename to include_all/hardware/camera.h
diff --git a/include/hardware/camera2.h b/include_all/hardware/camera2.h
similarity index 100%
rename from include/hardware/camera2.h
rename to include_all/hardware/camera2.h
diff --git a/include/hardware/camera3.h b/include_all/hardware/camera3.h
similarity index 100%
rename from include/hardware/camera3.h
rename to include_all/hardware/camera3.h
diff --git a/include/hardware/camera_common.h b/include_all/hardware/camera_common.h
similarity index 100%
rename from include/hardware/camera_common.h
rename to include_all/hardware/camera_common.h
diff --git a/include/hardware/consumerir.h b/include_all/hardware/consumerir.h
similarity index 100%
rename from include/hardware/consumerir.h
rename to include_all/hardware/consumerir.h
diff --git a/include/hardware/context_hub.h b/include_all/hardware/context_hub.h
similarity index 100%
rename from include/hardware/context_hub.h
rename to include_all/hardware/context_hub.h
diff --git a/include/hardware/fb.h b/include_all/hardware/fb.h
similarity index 100%
rename from include/hardware/fb.h
rename to include_all/hardware/fb.h
diff --git a/include/hardware/fingerprint.h b/include_all/hardware/fingerprint.h
similarity index 100%
rename from include/hardware/fingerprint.h
rename to include_all/hardware/fingerprint.h
diff --git a/include/hardware/fused_location.h b/include_all/hardware/fused_location.h
similarity index 100%
rename from include/hardware/fused_location.h
rename to include_all/hardware/fused_location.h
diff --git a/include/hardware/gatekeeper.h b/include_all/hardware/gatekeeper.h
similarity index 100%
rename from include/hardware/gatekeeper.h
rename to include_all/hardware/gatekeeper.h
diff --git a/include/hardware/gnss-base.h b/include_all/hardware/gnss-base.h
similarity index 100%
rename from include/hardware/gnss-base.h
rename to include_all/hardware/gnss-base.h
diff --git a/include/hardware/gps.h b/include_all/hardware/gps.h
similarity index 100%
rename from include/hardware/gps.h
rename to include_all/hardware/gps.h
diff --git a/include/hardware/gps_internal.h b/include_all/hardware/gps_internal.h
similarity index 100%
rename from include/hardware/gps_internal.h
rename to include_all/hardware/gps_internal.h
diff --git a/include/hardware/gralloc.h b/include_all/hardware/gralloc.h
similarity index 100%
rename from include/hardware/gralloc.h
rename to include_all/hardware/gralloc.h
diff --git a/include/hardware/gralloc1.h b/include_all/hardware/gralloc1.h
similarity index 100%
rename from include/hardware/gralloc1.h
rename to include_all/hardware/gralloc1.h
diff --git a/include/hardware/hardware.h b/include_all/hardware/hardware.h
similarity index 100%
rename from include/hardware/hardware.h
rename to include_all/hardware/hardware.h
diff --git a/include/hardware/hdmi_cec.h b/include_all/hardware/hdmi_cec.h
similarity index 100%
rename from include/hardware/hdmi_cec.h
rename to include_all/hardware/hdmi_cec.h
diff --git a/include/hardware/hw_auth_token.h b/include_all/hardware/hw_auth_token.h
similarity index 100%
rename from include/hardware/hw_auth_token.h
rename to include_all/hardware/hw_auth_token.h
diff --git a/include/hardware/hwcomposer.h b/include_all/hardware/hwcomposer.h
similarity index 100%
rename from include/hardware/hwcomposer.h
rename to include_all/hardware/hwcomposer.h
diff --git a/include/hardware/hwcomposer2.h b/include_all/hardware/hwcomposer2.h
similarity index 100%
rename from include/hardware/hwcomposer2.h
rename to include_all/hardware/hwcomposer2.h
diff --git a/include/hardware/hwcomposer_defs.h b/include_all/hardware/hwcomposer_defs.h
similarity index 100%
rename from include/hardware/hwcomposer_defs.h
rename to include_all/hardware/hwcomposer_defs.h
diff --git a/include/hardware/input.h b/include_all/hardware/input.h
similarity index 100%
rename from include/hardware/input.h
rename to include_all/hardware/input.h
diff --git a/include/hardware/keymaster1.h b/include_all/hardware/keymaster1.h
similarity index 100%
rename from include/hardware/keymaster1.h
rename to include_all/hardware/keymaster1.h
diff --git a/include/hardware/keymaster2.h b/include_all/hardware/keymaster2.h
similarity index 100%
rename from include/hardware/keymaster2.h
rename to include_all/hardware/keymaster2.h
diff --git a/include/hardware/keymaster_common.h b/include_all/hardware/keymaster_common.h
similarity index 100%
rename from include/hardware/keymaster_common.h
rename to include_all/hardware/keymaster_common.h
diff --git a/include/hardware/keymaster_defs.h b/include_all/hardware/keymaster_defs.h
similarity index 100%
rename from include/hardware/keymaster_defs.h
rename to include_all/hardware/keymaster_defs.h
diff --git a/include/hardware/lights.h b/include_all/hardware/lights.h
similarity index 100%
rename from include/hardware/lights.h
rename to include_all/hardware/lights.h
diff --git a/include/hardware/local_time_hal.h b/include_all/hardware/local_time_hal.h
similarity index 100%
rename from include/hardware/local_time_hal.h
rename to include_all/hardware/local_time_hal.h
diff --git a/include/hardware/memtrack.h b/include_all/hardware/memtrack.h
similarity index 100%
rename from include/hardware/memtrack.h
rename to include_all/hardware/memtrack.h
diff --git a/include/hardware/nfc-base.h b/include_all/hardware/nfc-base.h
similarity index 100%
rename from include/hardware/nfc-base.h
rename to include_all/hardware/nfc-base.h
diff --git a/include/hardware/nfc.h b/include_all/hardware/nfc.h
similarity index 100%
rename from include/hardware/nfc.h
rename to include_all/hardware/nfc.h
diff --git a/include/hardware/nfc_tag.h b/include_all/hardware/nfc_tag.h
similarity index 100%
rename from include/hardware/nfc_tag.h
rename to include_all/hardware/nfc_tag.h
diff --git a/include/hardware/nvram.h b/include_all/hardware/nvram.h
similarity index 100%
rename from include/hardware/nvram.h
rename to include_all/hardware/nvram.h
diff --git a/include/hardware/nvram_defs.h b/include_all/hardware/nvram_defs.h
similarity index 100%
rename from include/hardware/nvram_defs.h
rename to include_all/hardware/nvram_defs.h
diff --git a/include/hardware/power.h b/include_all/hardware/power.h
similarity index 100%
rename from include/hardware/power.h
rename to include_all/hardware/power.h
diff --git a/include/hardware/radio.h b/include_all/hardware/radio.h
similarity index 100%
rename from include/hardware/radio.h
rename to include_all/hardware/radio.h
diff --git a/include/hardware/sensors-base.h b/include_all/hardware/sensors-base.h
similarity index 100%
rename from include/hardware/sensors-base.h
rename to include_all/hardware/sensors-base.h
diff --git a/include/hardware/sensors.h b/include_all/hardware/sensors.h
similarity index 100%
rename from include/hardware/sensors.h
rename to include_all/hardware/sensors.h
diff --git a/include/hardware/sound_trigger.h b/include_all/hardware/sound_trigger.h
similarity index 100%
rename from include/hardware/sound_trigger.h
rename to include_all/hardware/sound_trigger.h
diff --git a/include/hardware/thermal.h b/include_all/hardware/thermal.h
similarity index 100%
rename from include/hardware/thermal.h
rename to include_all/hardware/thermal.h
diff --git a/include/hardware/tv_input.h b/include_all/hardware/tv_input.h
similarity index 100%
rename from include/hardware/tv_input.h
rename to include_all/hardware/tv_input.h
diff --git a/include/hardware/vibrator.h b/include_all/hardware/vibrator.h
similarity index 100%
rename from include/hardware/vibrator.h
rename to include_all/hardware/vibrator.h
diff --git a/include/hardware/vr.h b/include_all/hardware/vr.h
similarity index 100%
rename from include/hardware/vr.h
rename to include_all/hardware/vr.h
diff --git a/update-includes.sh b/update-includes.sh
new file mode 100755
index 0000000..92aafc9
--- /dev/null
+++ b/update-includes.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set +ex
+
+if [ ! "$ANDROID_BUILD_TOP" ]; then
+    echo "lunch?"
+    exit 1
+fi
+
+function update-includes() {
+    find -L "$ANDROID_BUILD_TOP/hardware/libhardware/include/hardware" -maxdepth 1 -xtype l -exec rm {} \;
+
+    for f in $ANDROID_BUILD_TOP/hardware/libhardware/include_all/hardware/*; do
+        local bn="$(basename $f)"
+        ln -s "../../include_all/hardware/$bn" "$ANDROID_BUILD_TOP/hardware/libhardware/include/hardware/$bn"
+    done
+}
+
+update-includes