Merge "Use libgtest_prod_headers."
diff --git a/Android.bp b/Android.bp
index 3ac123e..ebdd254 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,35 @@
 // Copyright 2006 The Android Open Source Project
 
+package {
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
+// Added automatically by a large-scale-change that took the approach of
+// 'apply every license found to every target'. While this makes sure we respect
+// every license restriction, it may not be entirely correct.
+//
+// e.g. GPL in an MIT project might only apply to the contrib/ directory.
+//
+// Please consider splitting the single license below into multiple licenses,
+// taking care not to lose any license_kind information, and overriding the
+// default license using the 'licenses: [...]' property on targets as needed.
+//
+// For unused files, consider creating a 'fileGroup' with "//visibility:private"
+// to attach the license to, and including a comment whether the files may be
+// used in the current project.
+// See: http://go/android-license-faq
+license {
+    name: "hardware_libhardware_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-Apache-2.0",
+        "SPDX-license-identifier-BSD",
+    ],
+    license_text: [
+        "NOTICE",
+    ],
+}
+
 cc_library_headers {
     name: "libhardware_headers",
     header_libs: [
diff --git a/OWNERS b/OWNERS
index da2454a..b6b18da 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,4 @@
-eisenbach@google.com
+zachoverflow@google.com
 elaurent@google.com
 jpawlowski@google.com
 malchev@google.com
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 3fe6aa8..afa0eef 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -258,19 +258,25 @@
     void *val;
 } bt_property_t;
 
-/** Bluetooth Out Of Band data for bonding */
-typedef struct
-{
-   uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
-   uint8_t c192[16]; /* Simple Pairing Hash C-192 */
-   uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
-   uint8_t c256[16]; /* Simple Pairing Hash C-256 */
-   uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
-   uint8_t sm_tk[16]; /* Security Manager TK Value */
-   uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */
-   uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
-} bt_out_of_band_data_t;
+/** Represents the actual Out of Band data itself */
+typedef struct {
+    // Both
+    uint8_t address[7]; /* Bluetooth Device Address (6) plus Address Type (1) */
+    uint8_t c[16];      /* Simple Pairing Hash C-192/256 (Classic or LE) */
+    uint8_t r[16];      /* Simple Pairing Randomizer R-192/256 (Classic or LE) */
+    uint8_t device_name[256]; /* Name of the device */
 
+    // Classic
+    uint8_t oob_data_length[2]; /* Classic only data Length. Value includes this
+                                   in length */
+    uint8_t class_of_device[2]; /* Class of Device (Classic or LE) */
+
+    // LE
+    uint8_t le_device_role;   /* Supported and preferred role of device */
+    uint8_t sm_tk[16];        /* Security Manager TK Value (LE Only) */
+    uint8_t le_flags;         /* LE Flags for discoverability and features */
+    uint8_t le_appearance[2]; /* For the appearance of the device */
+} bt_oob_data_t;
 
 
 /** Bluetooth Device Type */
@@ -508,7 +514,8 @@
 
     /** Create Bluetooth Bond using out of band data */
     int (*create_bond_out_of_band)(const RawAddress *bd_addr, int transport,
-                                   const bt_out_of_band_data_t *oob_data);
+                                   const bt_oob_data_t *p192_data,
+                                   const bt_oob_data_t *p256_data);
 
     /** Remove Bond */
     int (*remove_bond)(const RawAddress *bd_addr);
diff --git a/include/hardware/keymaster_defs.h b/include/hardware/keymaster_defs.h
index a0a1c8e..c0b3800 100644
--- a/include/hardware/keymaster_defs.h
+++ b/include/hardware/keymaster_defs.h
@@ -193,7 +193,7 @@
                                                         proving that the user confirmed a signing
                                                         request. */
 
-    KM_TAG_CERTIFICATE_SERIAL = KM_UINT | 1006,      /* The serial number that should be
+    KM_TAG_CERTIFICATE_SERIAL = KM_BIGNUM | 1006,      /* The serial number that should be
                                                         set in the attestation certificate
                                                         to be generated. */
 
@@ -201,7 +201,19 @@
                                                         set in the attestation certificate
                                                         to be generated. */
 
+    KM_TAG_CERTIFICATE_NOT_BEFORE = KM_DATE | 1008,  /* Epoch time in milliseconds of the start of
+                                                        the to be generated certificate's validity.
+                                                        The value should interpreted as too's
+                                                        complement signed integer. Negative values
+                                                        indicate dates before Jan 1970 */
 
+    KM_TAG_CERTIFICATE_NOT_AFTER = KM_DATE | 1009,  /*  Epoch time in milliseconds of the end of
+                                                        the to be generated certificate's validity.
+                                                        The value should interpreted as too's
+                                                        complement signed integer. Negative values
+                                                        indicate dates before Jan 1970 */
+    KM_TAG_MAX_BOOT_LEVEL = KM_UINT | 1010, /* Specifies a maximum boot level at which a key
+                                               should function. */
 } keymaster_tag_t;
 
 /**
@@ -333,7 +345,7 @@
     KM_PURPOSE_DERIVE_KEY = 4, /* Usable with EC keys. */
     KM_PURPOSE_WRAP = 5,       /* Usable with wrapped keys. */
     KM_PURPOSE_AGREE_KEY = 6,  /* Usable with EC keys. */
-
+    KM_PURPOSE_ATTEST_KEY = 7  /* Usabe with RSA and EC keys */
 } keymaster_purpose_t;
 
 typedef struct {
@@ -496,6 +508,11 @@
     KM_ERROR_ATTESTATION_IDS_NOT_PROVISIONED = -75,
     KM_ERROR_INCOMPATIBLE_MGF_DIGEST = -78,
     KM_ERROR_UNSUPPORTED_MGF_DIGEST = -79,
+    KM_ERROR_MISSING_NOT_BEFORE = -80,
+    KM_ERROR_MISSING_NOT_AFTER = -81,
+    KM_ERROR_MISSING_ISSUER_SUBJECT = -82,
+    KM_ERROR_INVALID_ISSUER_SUBJECT = -83,
+    KM_ERROR_BOOT_LEVEL_EXCEEDED = -84,
 
     KM_ERROR_UNIMPLEMENTED = -100,
     KM_ERROR_VERSION_MISMATCH = -101,
diff --git a/modules/audio/Android.bp b/modules/audio/Android.bp
index a7467c2..1b34336 100644
--- a/modules/audio/Android.bp
+++ b/modules/audio/Android.bp
@@ -18,6 +18,15 @@
 //
 // The format of the name is audio.<type>.<hardware/etc>.so where the only
 // required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc.
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "audio.primary.default",
     relative_install_path: "hw",
diff --git a/modules/audio_remote_submix/Android.bp b/modules/audio_remote_submix/Android.bp
index 9523438..53555f5 100644
--- a/modules/audio_remote_submix/Android.bp
+++ b/modules/audio_remote_submix/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "audio.r_submix.default",
     relative_install_path: "hw",
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index 72e1fa5..b43a44d 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -196,6 +196,7 @@
     struct timespec record_start_time;
     // how many frames have been requested to be read
     uint64_t read_counter_frames;
+    uint64_t read_counter_frames_since_standby;
 
 #if ENABLE_LEGACY_INPUT_OPEN
     // Number of references to this input stream.
@@ -836,7 +837,7 @@
         sp<MonoPipeReader> source = rsxadev->routes[out->route_handle].rsxSource;
         const struct submix_stream_in *in = rsxadev->routes[out->route_handle].input;
         const bool dont_block = (in == NULL)
-                || (in->input_standby && (in->read_counter_frames != 0));
+                || (in->input_standby && (in->read_counter_frames_since_standby != 0));
         if (dont_block && availableToWrite < frames) {
             static uint8_t flush_buffer[64];
             const size_t flushBufferSizeFrames = sizeof(flush_buffer) / frame_size;
@@ -1141,11 +1142,12 @@
         // or when we start recording silence, and reset projected time
         int rc = clock_gettime(CLOCK_MONOTONIC, &in->record_start_time);
         if (rc == 0) {
-            in->read_counter_frames = 0;
+            in->read_counter_frames_since_standby = 0;
         }
     }
 
     in->read_counter_frames += frames_to_read;
+    in->read_counter_frames_since_standby += frames_to_read;
     size_t remaining_frames = frames_to_read;
 
     {
@@ -1324,12 +1326,12 @@
             record_duration.tv_nsec += 1000000000;
         }
 
-        // read_counter_frames contains the number of frames that have been read since the
-        // beginning of recording (including this call): it's converted to usec and compared to
+        // read_counter_frames_since_standby contains the number of frames that have been read since
+        // the beginning of recording (including this call): it's converted to usec and compared to
         // how long we've been recording for, which gives us how long we must wait to sync the
         // projected recording time, and the observed recording time.
         long projected_vs_observed_offset_us =
-                ((int64_t)(in->read_counter_frames
+                ((int64_t)(in->read_counter_frames_since_standby
                             - (record_duration.tv_sec*sample_rate)))
                         * 1000000 / sample_rate
                 - (record_duration.tv_nsec / 1000);
@@ -1353,6 +1355,37 @@
     return 0;
 }
 
+static int in_get_capture_position(const struct audio_stream_in *stream,
+                                   int64_t *frames, int64_t *time)
+{
+    if (stream == NULL || frames == NULL || time == NULL) {
+        return -EINVAL;
+    }
+
+    struct submix_stream_in * const in = audio_stream_in_get_submix_stream_in(
+            (struct audio_stream_in*)stream);
+    struct submix_audio_device * const rsxadev = in->dev;
+
+    pthread_mutex_lock(&rsxadev->lock);
+    sp<MonoPipeReader> source = rsxadev->routes[in->route_handle].rsxSource;
+    if (source == NULL) {
+        ALOGW("%s called on released input", __FUNCTION__);
+        pthread_mutex_unlock(&rsxadev->lock);
+        return -ENODEV;
+    }
+    *frames = in->read_counter_frames;
+    const ssize_t frames_in_pipe = source->availableToRead();
+    pthread_mutex_unlock(&rsxadev->lock);
+    if (frames_in_pipe > 0) {
+        *frames += frames_in_pipe;
+    }
+
+    struct timespec timestamp;
+    clock_gettime(CLOCK_MONOTONIC, &timestamp);
+    *time = timestamp.tv_sec * 1000000000LL + timestamp.tv_nsec;
+    return 0;
+}
+
 static int in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
 {
     (void)stream;
@@ -1671,6 +1704,7 @@
         in->stream.set_gain = in_set_gain;
         in->stream.read = in_read;
         in->stream.get_input_frames_lost = in_get_input_frames_lost;
+        in->stream.get_capture_position = in_get_capture_position;
 
         in->dev = rsxadev;
 #if LOG_STREAMS_TO_FILES
@@ -1680,6 +1714,7 @@
 
     // Initialize the input stream.
     in->read_counter_frames = 0;
+    in->read_counter_frames_since_standby = 0;
     in->input_standby = true;
     if (rsxadev->routes[route_idx].output != NULL) {
         in->output_standby_rec_thr = rsxadev->routes[route_idx].output->output_standby;
diff --git a/modules/audio_remote_submix/tests/Android.bp b/modules/audio_remote_submix/tests/Android.bp
index 8e4d42d..490a402 100644
--- a/modules/audio_remote_submix/tests/Android.bp
+++ b/modules/audio_remote_submix/tests/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_test {
     name: "r_submix_tests",
 
diff --git a/modules/camera/3_0/Android.bp b/modules/camera/3_0/Android.bp
index 6d6d1d7..d8aac4f 100644
--- a/modules/camera/3_0/Android.bp
+++ b/modules/camera/3_0/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "camera.default",
     relative_install_path: "hw",
diff --git a/modules/camera/3_4/Android.mk b/modules/camera/3_4/Android.mk
index de584e3..aa23097 100644
--- a/modules/camera/3_4/Android.mk
+++ b/modules/camera/3_4/Android.mk
@@ -88,6 +88,9 @@
 # ==============================================================================
 include $(CLEAR_VARS)
 LOCAL_MODULE := camera.v4l2
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../../NOTICE
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_CFLAGS += $(v4l2_cflags)
 LOCAL_SHARED_LIBRARIES := $(v4l2_shared_libs)
@@ -102,6 +105,9 @@
 # ==============================================================================
 include $(CLEAR_VARS)
 LOCAL_MODULE := camera.v4l2_test
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../../NOTICE
 LOCAL_CFLAGS += $(v4l2_cflags)
 LOCAL_SHARED_LIBRARIES := $(v4l2_shared_libs)
 LOCAL_STATIC_LIBRARIES := \
diff --git a/modules/consumerir/Android.bp b/modules/consumerir/Android.bp
index 4f700c2..f33e4e5 100644
--- a/modules/consumerir/Android.bp
+++ b/modules/consumerir/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "consumerir.default",
     relative_install_path: "hw",
diff --git a/modules/fingerprint/Android.bp b/modules/fingerprint/Android.bp
index 22648b1..5c95374 100644
--- a/modules/fingerprint/Android.bp
+++ b/modules/fingerprint/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "fingerprint.default",
     relative_install_path: "hw",
diff --git a/modules/gralloc/Android.mk b/modules/gralloc/Android.mk
index ff5808d..439c95d 100644
--- a/modules/gralloc/Android.mk
+++ b/modules/gralloc/Android.mk
@@ -31,6 +31,9 @@
 LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 LOCAL_MODULE := gralloc.default
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../NOTICE
 LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc\" -Wno-missing-field-initializers
 ifeq ($(TARGET_USE_PAN_DISPLAY),true)
 LOCAL_CFLAGS += -DUSE_PAN_DISPLAY=1
diff --git a/modules/hwcomposer/Android.bp b/modules/hwcomposer/Android.bp
index 4f429be..6a864c8 100644
--- a/modules/hwcomposer/Android.bp
+++ b/modules/hwcomposer/Android.bp
@@ -14,6 +14,15 @@
 
 // HAL module implemenation stored in
 // hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "hwcomposer.default",
     relative_install_path: "hw",
diff --git a/modules/input/evdev/Android.bp b/modules/input/evdev/Android.bp
index bcd563f..9817c73 100644
--- a/modules/input/evdev/Android.bp
+++ b/modules/input/evdev/Android.bp
@@ -13,6 +13,15 @@
 // limitations under the License.
 
 // Evdev module implementation
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "libinput_evdev",
 
diff --git a/modules/local_time/Android.bp b/modules/local_time/Android.bp
index 9f140b3..a4101c0 100644
--- a/modules/local_time/Android.bp
+++ b/modules/local_time/Android.bp
@@ -21,6 +21,15 @@
 // seen in libhardware/hardware.c
 //
 // The format of the name is local_time.<hardware>.so
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "local_time.default",
     relative_install_path: "hw",
diff --git a/modules/nfc-nci/Android.bp b/modules/nfc-nci/Android.bp
index 282e925..31d89aa 100644
--- a/modules/nfc-nci/Android.bp
+++ b/modules/nfc-nci/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "nfc_nci.default",
     relative_install_path: "hw",
diff --git a/modules/nfc/Android.bp b/modules/nfc/Android.bp
index 7c69f11..61fe1b8 100644
--- a/modules/nfc/Android.bp
+++ b/modules/nfc/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "nfc.default",
     relative_install_path: "hw",
diff --git a/modules/power/Android.bp b/modules/power/Android.bp
index 6b0b31f..4abcf37 100644
--- a/modules/power/Android.bp
+++ b/modules/power/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "power.default",
     relative_install_path: "hw",
diff --git a/modules/radio/Android.bp b/modules/radio/Android.bp
index 7f98f0d..7240869 100644
--- a/modules/radio/Android.bp
+++ b/modules/radio/Android.bp
@@ -13,6 +13,15 @@
 // limitations under the License.
 
 // Stub radio HAL module, used for tests
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "radio.fm.default",
     relative_install_path: "hw",
diff --git a/modules/sensors/Android.bp b/modules/sensors/Android.bp
index 3d14bdf..61590a5 100644
--- a/modules/sensors/Android.bp
+++ b/modules/sensors/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_static {
     name: "multihal",
     vendor: true,
diff --git a/modules/sensors/Android.mk b/modules/sensors/Android.mk
index 2becc97..69889de 100644
--- a/modules/sensors/Android.mk
+++ b/modules/sensors/Android.mk
@@ -21,6 +21,9 @@
 include $(CLEAR_VARS)
 
 LOCAL_MODULE := sensors.$(TARGET_DEVICE)
+LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
+LOCAL_LICENSE_CONDITIONS := notice
+LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../../NOTICE
 
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_PROPRIETARY_MODULE := true
diff --git a/modules/sensors/dynamic_sensor/Android.bp b/modules/sensors/dynamic_sensor/Android.bp
index 214d97c..1ebc04d 100644
--- a/modules/sensors/dynamic_sensor/Android.bp
+++ b/modules/sensors/dynamic_sensor/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_defaults {
     name: "dynamic_sensor_defaults",
 
diff --git a/modules/sensors/dynamic_sensor/HidUtils/Android.bp b/modules/sensors/dynamic_sensor/HidUtils/Android.bp
index 0eb43f8..bbed032 100644
--- a/modules/sensors/dynamic_sensor/HidUtils/Android.bp
+++ b/modules/sensors/dynamic_sensor/HidUtils/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_defaults {
     name: "hid_defaults",
     cflags: [
diff --git a/modules/soundtrigger/Android.bp b/modules/soundtrigger/Android.bp
index aa5e804..86cc593 100644
--- a/modules/soundtrigger/Android.bp
+++ b/modules/soundtrigger/Android.bp
@@ -13,6 +13,15 @@
 // limitations under the License.
 
 // Stub sound_trigger HAL module, used for tests
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "sound_trigger.stub.default",
     relative_install_path: "hw",
diff --git a/modules/thermal/Android.bp b/modules/thermal/Android.bp
index ab5c408..9ac84d7 100644
--- a/modules/thermal/Android.bp
+++ b/modules/thermal/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "thermal.default",
     relative_install_path: "hw",
diff --git a/modules/tv_input/Android.bp b/modules/tv_input/Android.bp
index b9d8afa..13dd301 100644
--- a/modules/tv_input/Android.bp
+++ b/modules/tv_input/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "tv_input.default",
     relative_install_path: "hw",
diff --git a/modules/usbaudio/Android.bp b/modules/usbaudio/Android.bp
index c7d403f..0be27c3 100644
--- a/modules/usbaudio/Android.bp
+++ b/modules/usbaudio/Android.bp
@@ -12,18 +12,43 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-cc_library_shared {
-    name: "audio.usb.default",
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
+cc_defaults {
+    name: "audio.usb_defaults",
     relative_install_path: "hw",
     vendor: true,
     srcs: ["audio_hal.c"],
     shared_libs: [
         "liblog",
         "libcutils",
-        "libtinyalsa",
         "libaudioutils",
-        "libalsautils",
     ],
     cflags: ["-Wno-unused-parameter"],
     header_libs: ["libhardware_headers"],
 }
+
+cc_library_shared {
+    name: "audio.usb.default",
+    defaults: ["audio.usb_defaults"],
+    shared_libs: [
+        "libtinyalsa",
+        "libalsautils",
+    ],
+}
+
+cc_library_shared {
+    name: "audio.usbv2.default",
+    defaults: ["audio.usb_defaults"],
+    shared_libs: [
+        "libtinyalsav2",
+        "libalsautilsv2",
+    ],
+}
diff --git a/modules/usbcamera/Android.bp b/modules/usbcamera/Android.bp
index 5e44d3c..07eb85b 100644
--- a/modules/usbcamera/Android.bp
+++ b/modules/usbcamera/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "camera.usb.default",
     relative_install_path: "hw",
diff --git a/modules/vibrator/Android.bp b/modules/vibrator/Android.bp
index 13ffc83..2412d4d 100644
--- a/modules/vibrator/Android.bp
+++ b/modules/vibrator/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "vibrator.default",
 
diff --git a/modules/vr/Android.bp b/modules/vr/Android.bp
index 40f4510..121939b 100644
--- a/modules/vr/Android.bp
+++ b/modules/vr/Android.bp
@@ -12,6 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_shared {
     name: "vr.default",
     relative_install_path: "hw",
diff --git a/tests/camera3/Android.bp b/tests/camera3/Android.bp
index 55486ba..6d43066 100644
--- a/tests/camera3/Android.bp
+++ b/tests/camera3/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_test {
     name: "camera3_tests",
     srcs: ["camera3tests.cpp"],
diff --git a/tests/fingerprint/Android.bp b/tests/fingerprint/Android.bp
index 9524b7b..9827e89 100644
--- a/tests/fingerprint/Android.bp
+++ b/tests/fingerprint/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_test {
     name: "fingerprint_tests",
     srcs: ["fingerprint_tests.cpp"],
diff --git a/tests/hardware/Android.bp b/tests/hardware/Android.bp
index 2f5db12..b137684 100644
--- a/tests/hardware/Android.bp
+++ b/tests/hardware/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_static {
     name: "static-hal-check",
     srcs: [
diff --git a/tests/hwc/Android.bp b/tests/hwc/Android.bp
index 782a314..82a00e4 100644
--- a/tests/hwc/Android.bp
+++ b/tests/hwc/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_library_static {
     name: "libcnativewindow",
     srcs: [
diff --git a/tests/input/evdev/Android.bp b/tests/input/evdev/Android.bp
index fa03a00..10fa146 100644
--- a/tests/input/evdev/Android.bp
+++ b/tests/input/evdev/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_test {
     name: "libinput_evdevtests",
 
diff --git a/tests/nusensors/Android.bp b/tests/nusensors/Android.bp
index 8b267db..f06cf7a 100644
--- a/tests/nusensors/Android.bp
+++ b/tests/nusensors/Android.bp
@@ -1,3 +1,12 @@
+package {
+    // See: http://go/android-license-faq
+    // A large-scale-change added 'default_applicable_licenses' to import
+    // all of the 'license_kinds' from "hardware_libhardware_license"
+    // to get the below license kinds:
+    //   SPDX-license-identifier-Apache-2.0
+    default_applicable_licenses: ["hardware_libhardware_license"],
+}
+
 cc_binary {
     name: "test-nusensors",