am ec585647: (-s ours) am f9df59a7: Merge "Add KM_TAG_MIN_MAC_LENGTH." into mnc-dev

* commit 'ec58564768e4aebb71910ed6066ce523bc14991c':
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index da7f4b8..3427213 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -542,6 +542,12 @@
      * Function is synchronous and |fd| is owned by caller.
      */
     void (*dump)(int fd);
+
+    /**
+     * Clear /data/misc/bt_config.conf and erase all stored connections
+     */
+    int (*config_clear)(void);
+
 } bt_interface_t;
 
 /** TODO: Need to add APIs for Service Discovery, Service authorization and
diff --git a/include/hardware/fingerprint.h b/include/hardware/fingerprint.h
index 075e18b..ac88c10 100644
--- a/include/hardware/fingerprint.h
+++ b/include/hardware/fingerprint.h
@@ -31,23 +31,41 @@
     FINGERPRINT_AUTHENTICATED = 5
 } fingerprint_msg_type_t;
 
+/*
+ * Fingerprint errors are meant to tell the framework to terminate the current operation and ask
+ * for the user to correct the situation. These will almost always result in messaging and user
+ * interaction to correct the problem.
+ *
+ * For example, FINGERPRINT_ERROR_CANCELED should follow any acquisition message that results in
+ * a situation where the current operation can't continue without user interaction. For example,
+ * if the sensor is dirty during enrollment and no further enrollment progress can be made,
+ * send FINGERPRINT_ACQUIRED_IMAGER_DIRTY followed by FINGERPRINT_ERROR_CANCELED.
+ */
 typedef enum fingerprint_error {
-    FINGERPRINT_ERROR_HW_UNAVAILABLE = 1,
-    FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2,
-    FINGERPRINT_ERROR_TIMEOUT = 3,
+    FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, /* The hardware has an error that can't be resolved. */
+    FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2, /* Bad data; operation can't continue */
+    FINGERPRINT_ERROR_TIMEOUT = 3, /* The operation has timed out waiting for user input. */
     FINGERPRINT_ERROR_NO_SPACE = 4, /* No space available to store a template */
-    FINGERPRINT_ERROR_CANCELED = 5,
-    FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint id can't be removed */
+    FINGERPRINT_ERROR_CANCELED = 5, /* The current operation can't proceed. See above. */
+    FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint with given id can't be removed */
     FINGERPRINT_ERROR_VENDOR_BASE = 1000 /* vendor-specific error messages start here */
 } fingerprint_error_t;
 
+/*
+ * Fingerprint acquisition info is meant as feedback for the current operation.  Anything but
+ * FINGERPRINT_ACQUIRED_GOOD will be shown to the user as feedback on how to take action on the
+ * current operation. For example, FINGERPRINT_ACQUIRED_IMAGER_DIRTY can be used to tell the user
+ * to clean the sensor.  If this will cause the current operation to fail, an additional
+ * FINGERPRINT_ERROR_CANCELED can be sent to stop the operation in progress (e.g. enrollment).
+ * In general, these messages will result in a "Try again" message.
+ */
 typedef enum fingerprint_acquired_info {
     FINGERPRINT_ACQUIRED_GOOD = 0,
-    FINGERPRINT_ACQUIRED_PARTIAL = 1,
-    FINGERPRINT_ACQUIRED_INSUFFICIENT = 2,
-    FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3,
-    FINGERPRINT_ACQUIRED_TOO_SLOW = 4,
-    FINGERPRINT_ACQUIRED_TOO_FAST = 5,
+    FINGERPRINT_ACQUIRED_PARTIAL = 1, /* sensor needs more data, i.e. longer swipe. */
+    FINGERPRINT_ACQUIRED_INSUFFICIENT = 2, /* image doesn't contain enough detail for recognition*/
+    FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3, /* sensor needs to be cleaned */
+    FINGERPRINT_ACQUIRED_TOO_SLOW = 4, /* mostly swipe-type sensors; not enough data collected */
+    FINGERPRINT_ACQUIRED_TOO_FAST = 5, /* for swipe and area sensors; tell user to slow down*/
     FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000 /* vendor-specific acquisition messages start here */
 } fingerprint_acquired_info_t;
 
diff --git a/include/hardware/keymaster1.h b/include/hardware/keymaster1.h
index 77243af..afd202c 100644
--- a/include/hardware/keymaster1.h
+++ b/include/hardware/keymaster1.h
@@ -250,11 +250,8 @@
      * of useful keys are:
      *
      * - KM_TAG_ALGORITHM;
-     * - KM_TAG_PURPOSE;
-     * - KM_TAG_USER_ID or KM_TAG_ALL_USERS;
-     * - KM_TAG_USER_AUTH_ID or KM_TAG_NO_AUTH_REQUIRED;
-     * - KM_TAG_APPLICATION_ID or KM_TAG_ALL_APPLICATIONS; and
-     * - KM_TAG_ORIGINATION_EXPIRE_DATETIME
+     * - KM_TAG_PURPOSE; and
+     * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED.
      *
      * KM_TAG_AUTH_TIMEOUT should generally be specified unless KM_TAG_NO_AUTH_REQUIRED is present,
      * or the user will have to authenticate for every use.
@@ -262,25 +259,11 @@
      * KM_TAG_BLOCK_MODE, KM_TAG_PADDING, KM_TAG_MAC_LENGTH and KM_TAG_DIGEST must be specified for
      * algorithms that require them.
      *
-     * The following tags will take default values if unspecified:
-     *
-     * - KM_TAG_KEY_SIZE defaults to a recommended key size for the  specified algorithm.
-     *
-     * - KM_TAG_USAGE_EXPIRE_DATETIME defaults to the value of KM_TAG_ORIGINATION_EXPIRE_DATETIME.
-     *
-     * - KM_TAG_ACTIVE_DATETIME will default to the value of KM_TAG_CREATION_DATETIME
-     *
-     * - KM_TAG_ROOT_OF_TRUST will default to the current root of trust.
-     *
-     * - KM_TAG_{RSA|DSA|DH}_* will default to values appropriate for the specified key size.
-     *
      * The following tags may not be specified; their values will be provided by the implementation.
      *
      * - KM_TAG_ORIGIN,
-     *
      * - KM_TAG_ROLLBACK_RESISTANT,
-     *
-     * - KM_TAG_CREATION_DATETIME,
+     * - KM_TAG_CREATION_DATETIME
      *
      * \param[in] dev The keymaster device structure.
      *
@@ -288,12 +271,11 @@
      *
      * \param[in] params_count Length of \p params.
      *
-     * \param[out] key_blob returns the generated key. If \p key_blob is NULL, no key is generated,
-     * but the characteristics of the key that would be generated are returned.  The caller assumes
-     * ownership key_blob->key_material and must free() it.
+     * \param[out] key_blob returns the generated key. \p key_blob must not be NULL.  The caller
+     * assumes ownership key_blob->key_material and must free() it.
      *
-     * \param[out] characteristics returns the characteristics of the key that was, or would be,
-     * generated, if non-NULL.  The caller assumes ownership, and the object must be freed with
+     * \param[out] characteristics returns the characteristics of the key that was, generated, if
+     * non-NULL.  If non-NULL, the caller assumes ownership and must deallocate with
      * keymaster_free_characteristics().  Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and
      * KM_TAG_APPLICATION_DATA are never returned.
      */
@@ -303,11 +285,13 @@
                                       keymaster_key_characteristics_t** characteristics);
 
     /**
-     * Returns the characteristics of the specified key, or NULL if the key_blob is invalid
-     * (implementations must fully validate the integrity of the key).  client_id and app_data must
-     * be the ID and data provided when the key was generated or imported.  Those values are not
-     * included in the returned characteristics.  Caller assumes ownership of the allocated
-     * characteristics object, which must be deallocated with keymaster_free_characteristics().
+     * Returns the characteristics of the specified key, or KM_ERROR_INVALID_KEY_BLOB if the
+     * key_blob is invalid (implementations must fully validate the integrity of the key).
+     * client_id and app_data must be the ID and data provided when the key was generated or
+     * imported, or empty if KM_TAG_APPLICATION_ID and/or KM_TAG_APPLICATION_DATA were not provided
+     * during generation.  Those values are not included in the returned characteristics.  The
+     * caller assumes ownership of the allocated characteristics object, which must be deallocated
+     * with keymaster_free_characteristics().
      *
      * Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never
      * returned.
@@ -332,38 +316,26 @@
      * Imports a key, or key pair, returning a key blob and/or a description of the key.
      *
      * Most key import parameters are defined as keymaster tag/value pairs, provided in "params".
-     * See keymaster_tag_t for the full list.  Some values that are always required for import of
-     * useful keys are:
+     * See keymaster_tag_t for the full list.  Values that are always required for import of useful
+     * keys are:
      *
-     * - KM_TAG_PURPOSE;
-     *
-     * - KM_TAG_USER_ID
-     *
-     * - KM_TAG_USER_AUTH_ID;
-     *
-     * - KM_TAG_APPLICATION_ID or KM_TAG_ALL_APPLICATIONS;
-     *
-     * - KM_TAG_PRIVKEY_EXPIRE_DATETIME.
+     * - KM_TAG_ALGORITHM;
+     * - KM_TAG_PURPOSE; and
+     * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED.
      *
      * KM_TAG_AUTH_TIMEOUT should generally be specified. If unspecified, the user will have to
-     * authenticate for every use, unless KM_TAG_USER_AUTH_ID is set to
-     * KM_NO_AUTHENTICATION_REQUIRED.
+     * authenticate for every use.
      *
      * The following tags will take default values if unspecified:
      *
-     * - KM_TAG_PUBKEY_EXPIRE_DATETIME will default to the value for KM_TAG_PRIVKEY_EXPIRE_DATETIME.
-     *
-     * - KM_TAG_ACTIVE_DATETIME will default to the value of KM_TAG_CREATION_DATETIME
-     *
-     * - KM_TAG_ROOT_OF_TRUST will default to the current root of trust.
+     * - KM_TAG_KEY_SIZE will default to the size of the key provided.
+     * - KM_TAG_RSA_PUBLIC_EXPONENT will default to the value in the key provided (for RSA keys)
      *
      * The following tags may not be specified; their values will be provided by the implementation.
      *
      * - KM_TAG_ORIGIN,
-     *
      * - KM_TAG_ROLLBACK_RESISTANT,
-     *
-     * - KM_TAG_CREATION_DATETIME,
+     * - KM_TAG_CREATION_DATETIME
      *
      * \param[in] dev The keymaster device structure.
      *
@@ -378,7 +350,9 @@
      *
      * \param[out] characteristics Used to return the characteristics of the imported key.  May be
      * NULL, in which case no characteristics will be returned.  If non-NULL, the caller assumes
-     * ownership and must deallocate with keymaster_free_characteristics().
+     * ownership and must deallocate with keymaster_free_characteristics().  Note that
+     * KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and
+     * KM_TAG_APPLICATION_DATA are never returned.
      */
     keymaster_error_t (*import_key)(const struct keymaster1_device* dev,
                                     const keymaster_key_param_set_t* params,
@@ -439,37 +413,40 @@
      *
      * It is critical that each call to begin() be paired with a subsequent call to finish() or
      * abort(), to allow the keymaster implementation to clean up any internal operation state.
-     * Failure to do this will leak internal state space or other internal resources and will
+     * Failure to do this may leak internal state space or other internal resources and may
      * eventually cause begin() to return KM_ERROR_TOO_MANY_OPERATIONS when it runs out of space for
-     * operations.
+     * operations.  Any result other than KM_ERROR_OK from begin(), update() or finish() implicitly
+     * aborts the operation, in which case abort() need not be called (and will return
+     * KM_ERROR_INVALID_OPERATION_HANDLE if called).
      *
      * \param[in] dev The keymaster device structure.
      *
      * \param[in] purpose The purpose of the operation, one of KM_PURPOSE_ENCRYPT,
      * KM_PURPOSE_DECRYPT, KM_PURPOSE_SIGN or KM_PURPOSE_VERIFY. Note that for AEAD modes,
-     * encryption and decryption imply signing and verification, respectively.
+     * encryption and decryption imply signing and verification, respectively, but should be
+     * specified as KM_PURPOSE_ENCRYPT and KM_PURPOSE_DECRYPT.
      *
      * \param[in] key The key to be used for the operation. \p key must have a purpose compatible
      * with \p purpose and all of its usage requirements must be satisfied, or begin() will return
      * an appropriate error code.
      *
-     * \param[in] params Additional parameters for the operation.  This is typically used to provide
-     * client ID information, with tags KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA.  If the
-     * client information associated with the key is not provided, begin() will fail and return
-     * KM_ERROR_INVALID_KEY_BLOB.  For operations that require a nonce or IV, this must contain a
-     * tag KM_TAG_NONCE.  For AEAD operations KM_TAG_CHUNK_SIZE is specified here.
+     * \param[in] in_params Additional parameters for the operation.  This is typically used to
+     * provide authentication data, with KM_TAG_AUTH_TOKEN.  If KM_TAG_APPLICATION_ID or
+     * KM_TAG_APPLICATION_DATA were provided during generation, they must be provided here, or the
+     * operation will fail with KM_ERROR_INVALID_KEY_BLOB.  For operations that require a nonce or
+     * IV, on keys that were generated with KM_TAG_CALLER_NONCE, in_params may contain a tag
+     * KM_TAG_NONCE.  For AEAD operations KM_TAG_CHUNK_SIZE is specified here.
      *
-     * \param[in] params_count The number of entries in \p params.
-     *
-     * \param[out] out_params Array of output parameters.  The caller takes ownership of the output
-     * parametes array and must free it.  out_params may be set to NULL if no output parameters are
-     * expected.  If NULL, and output paramaters are generated, begin() will return
+     * \param[out] out_params Output parameters.  Used to return additional data from the operation
+     * initialization, notably to return the IV or nonce from operations that generate an IV or
+     * nonce.  The caller takes ownership of the output parameters array and must free it with
+     * keymaster_free_param_set().  out_params may be set to NULL if no output parameters are
+     * expected.  If out_params is NULL, and output paramaters are generated, begin() will return
      * KM_ERROR_OUTPUT_PARAMETER_NULL.
      *
-     * \param[out] out_params_count The length of out_params.
-     *
      * \param[out] operation_handle The newly-created operation handle which must be passed to
-     * update(), finish() or abort().
+     * update(), finish() or abort().  If operation_handle is NULL, begin() will return
+     * KM_ERROR_OUTPUT_PARAMETER_NULL.
      */
     keymaster_error_t (*begin)(const struct keymaster1_device* dev, keymaster_purpose_t purpose,
                                const keymaster_key_blob_t* key,
@@ -483,37 +460,37 @@
      *
      * If operation_handle is invalid, update() will return KM_ERROR_INVALID_OPERATION_HANDLE.
      *
-     * Not all of the data provided in the data buffer may be consumed.  update() will return the
-     * amount consumed in *data_consumed.  The caller should provide the unconsumed data in a
+     * update() may not consume all of the data provided in the data buffer.  update() will return
+     * the amount consumed in *data_consumed.  The caller should provide the unconsumed data in a
      * subsequent call.
      *
      * \param[in] dev The keymaster device structure.
      *
      * \param[in] operation_handle The operation handle returned by begin().
      *
-     * \param[in] params Additional parameters for the operation.  For AEAD modes, this is used to
-     * specify KM_TAG_ADDITIONAL_DATA.
-     *
-     * \param[in] params_count Length of \p params.
+     * \param[in] in_params Additional parameters for the operation.  For AEAD modes, this is used
+     * to specify KM_TAG_ADDITIONAL_DATA.  Note that additional data may be provided in multiple
+     * calls to update(), but only until input data has been provided.
      *
      * \param[in] input Data to be processed, per the parameters established in the call to begin().
-     * Note that update() may or may not consume all of the data provided.  See \p data_consumed.
-     *
-     * \param[in] input_length Length of \p input.
+     * Note that update() may or may not consume all of the data provided.  See \p input_consumed.
      *
      * \param[out] input_consumed Amount of data that was consumed by update().  If this is less
      * than the amount provided, the caller should provide the remainder in a subsequent call to
      * update().
      *
+     * \param[out] out_params Output parameters.  Used to return additional data from the operation
+     * The caller takes ownership of the output parameters array and must free it with
+     * keymaster_free_param_set().  out_params may be set to NULL if no output parameters are
+     * expected.  If out_params is NULL, and output paramaters are generated, begin() will return
+     * KM_ERROR_OUTPUT_PARAMETER_NULL.
+     *
      * \param[out] output The output data, if any.  The caller assumes ownership of the allocated
-     * buffer.  If output is NULL then NO input data is consumed and no output is produced, but
-     * *output_length is set to an estimate of the size that would have been produced by this
-     * update() and a subsequent finish().
+     * buffer.  output must not be NULL.
      *
-     * \param[out] output_length The length of the output buffer.
-     *
-     * Note that update() may not provide any output, in which case *output_length will be zero, and
-     * *output may be either NULL or zero-length (so the caller should always free() it).
+     * Note that update() may not provide any output, in which case output->data_length will be
+     * zero, and output->data may be either NULL or zero-length (so the caller should always free()
+     * it).
      */
     keymaster_error_t (*update)(const struct keymaster1_device* dev,
                                 keymaster_operation_handle_t operation_handle,
@@ -522,8 +499,7 @@
                                 keymaster_key_param_set_t* out_params, keymaster_blob_t* output);
 
     /**
-     * Finalizes a cryptographic operation begun with begin() and invalidates operation_handle
-     * (except in the insufficient buffer case, detailed below).
+     * Finalizes a cryptographic operation begun with begin() and invalidates \p operation_handle.
      *
      * \param[in] dev The keymaster device structure.
      *
@@ -531,20 +507,14 @@
      * invalidated.
      *
      * \param[in] params Additional parameters for the operation.  For AEAD modes, this is used to
-     * specify KM_TAG_ADDITIONAL_DATA.
-     *
-     * \param[in] params_count Length of \p params.
+     * specify KM_TAG_ADDITIONAL_DATA, but only if no input data was provided to update().
      *
      * \param[in] signature The signature to be verified if the purpose specified in the begin()
      * call was KM_PURPOSE_VERIFY.
      *
-     * \param[in] signature_length The length of \p signature.
-     *
      * \param[out] output The output data, if any.  The caller assumes ownership of the allocated
      * buffer.
      *
-     * \param[out] output_length The length of the output buffer.
-     *
      * If the operation being finished is a signature verification or an AEAD-mode decryption and
      * verification fails then finish() will return KM_ERROR_VERIFICATION_FAILED.
      */
@@ -556,7 +526,7 @@
 
     /**
      * Aborts a cryptographic operation begun with begin(), freeing all internal resources and
-     * invalidating operation_handle.
+     * invalidating \p operation_handle.
      */
     keymaster_error_t (*abort)(const struct keymaster1_device* dev,
                                keymaster_operation_handle_t operation_handle);
diff --git a/include/hardware/keymaster_defs.h b/include/hardware/keymaster_defs.h
index b19086e..5be956d 100644
--- a/include/hardware/keymaster_defs.h
+++ b/include/hardware/keymaster_defs.h
@@ -115,8 +115,7 @@
     KM_TAG_CREATION_DATETIME = KM_DATE | 701,  /* Key creation time */
     KM_TAG_ORIGIN = KM_ENUM | 702,             /* keymaster_key_origin_t. */
     KM_TAG_ROLLBACK_RESISTANT = KM_BOOL | 703, /* Whether key is rollback-resistant. */
-    KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704,     /* Root of trust ID.  Empty array means usable by all
-                                                  roots. */
+    KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704,     /* Root of trust ID. */
 
     /* Tags used only to provide data to or receive data from operations */
     KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000, /* Used to provide associated data for AEAD modes. */
diff --git a/modules/gralloc/framebuffer.cpp b/modules/gralloc/framebuffer.cpp
index 486e27a..eadcdaa 100644
--- a/modules/gralloc/framebuffer.cpp
+++ b/modules/gralloc/framebuffer.cpp
@@ -33,7 +33,7 @@
 #include <cutils/log.h>
 #include <cutils/atomic.h>
 
-#if HAVE_ANDROID_OS
+#ifdef __ANDROID__
 #include <linux/fb.h>
 #endif
 
diff --git a/modules/sensors/Android.mk b/modules/sensors/Android.mk
index 445f69e..94d100b 100644
--- a/modules/sensors/Android.mk
+++ b/modules/sensors/Android.mk
@@ -20,9 +20,9 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := sensors.$(TARGET_DEVICE)
+LOCAL_MODULE := sensors.$(TARGET_BOARD_PLATFORM)
 
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_RELATIVE_PATH := hw
 
 LOCAL_CFLAGS := -DLOG_TAG=\"MultiHal\"
 
diff --git a/modules/sensors/multihal.cpp b/modules/sensors/multihal.cpp
index cd67f6d..8330ff3 100644
--- a/modules/sensors/multihal.cpp
+++ b/modules/sensors/multihal.cpp
@@ -27,6 +27,8 @@
 #include <cutils/log.h>
 
 #include <vector>
+#include <string>
+#include <fstream>
 #include <map>
 #include <string>
 
@@ -34,10 +36,10 @@
 #include <dlfcn.h>
 #include <SensorEventQueue.h>
 
+#include <limits.h>
+#include <stdlib.h>
 
 static const char* CONFIG_FILENAME = "/system/etc/sensors/hals.conf";
-static const char* LEGAL_SUBHAL_PATH_PREFIX = "/system/lib/hw/";
-static const char* LEGAL_SUBHAL_ALTERNATE_PATH_PREFIX = "/system/vendor/lib/";
 static const int MAX_CONF_LINE_LENGTH = 1024;
 
 static pthread_mutex_t init_modules_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -463,39 +465,19 @@
  * Adds valid paths from the config file to the vector passed in.
  * The vector must not be null.
  */
-static void get_so_paths(std::vector<char*> *so_paths) {
-    FILE *conf_file = fopen(CONFIG_FILENAME, "r");
-    if (conf_file == NULL) {
+static void get_so_paths(std::vector<std::string> *so_paths) {
+    std::string line;
+    std::ifstream conf_file(CONFIG_FILENAME);
+
+    if(!conf_file) {
         ALOGW("No multihal config file found at %s", CONFIG_FILENAME);
         return;
     }
     ALOGV("Multihal config file found at %s", CONFIG_FILENAME);
-    char *line = NULL;
-    size_t len = 0;
-    int line_count = 0;
-    while (getline(&line, &len, conf_file) != -1) {
-        // overwrite trailing eoln with null char
-        char* pch = strchr(line, '\n');
-        if (pch != NULL) {
-            *pch = '\0';
-        }
-        ALOGV("config file line #%d: '%s'", ++line_count, line);
-        char *real_path = realpath(line, NULL);
-        if (starts_with(real_path, LEGAL_SUBHAL_PATH_PREFIX) ||
-		starts_with(real_path, LEGAL_SUBHAL_ALTERNATE_PATH_PREFIX)) {
-            ALOGV("accepting valid path '%s'", real_path);
-            char* compact_line = new char[strlen(real_path) + 1];
-            strcpy(compact_line, real_path);
-            so_paths->push_back(compact_line);
-        } else {
-            ALOGW("rejecting path '%s' because it does not start with '%s' or '%s'",
-                    real_path, LEGAL_SUBHAL_PATH_PREFIX, LEGAL_SUBHAL_ALTERNATE_PATH_PREFIX);
-        }
-        free(real_path);
+    while (std::getline(conf_file, line)) {
+        ALOGV("config file line: '%s'", line.c_str());
+        so_paths->push_back(line);
     }
-    free(line);
-    fclose(conf_file);
-    ALOGV("hals.conf contained %d lines", line_count);
 }
 
 /*
@@ -508,15 +490,15 @@
         pthread_mutex_unlock(&init_modules_mutex);
         return;
     }
-    std::vector<char*> *so_paths = new std::vector<char*>();
+    std::vector<std::string> *so_paths = new std::vector<std::string>();
     get_so_paths(so_paths);
 
     // dlopen the module files and cache their module symbols in sub_hw_modules
     sub_hw_modules = new std::vector<hw_module_t *>();
     dlerror(); // clear any old errors
     const char* sym = HAL_MODULE_INFO_SYM_AS_STR;
-    for (std::vector<char*>::iterator it = so_paths->begin(); it != so_paths->end(); it++) {
-        char* path = *it;
+    for (std::vector<std::string>::iterator it = so_paths->begin(); it != so_paths->end(); it++) {
+        const char* path = it->c_str();
         void* lib_handle = dlopen(path, RTLD_LAZY);
         if (lib_handle == NULL) {
             ALOGW("dlerror(): %s", dlerror());
diff --git a/modules/usbaudio/audio_hal.c b/modules/usbaudio/audio_hal.c
index bbea5f5..38fea86 100644
--- a/modules/usbaudio/audio_hal.c
+++ b/modules/usbaudio/audio_hal.c
@@ -442,8 +442,16 @@
 static int out_get_presentation_position(const struct audio_stream_out *stream,
                                          uint64_t *frames, struct timespec *timestamp)
 {
-    /* FIXME - This needs to be implemented */
-    return -EINVAL;
+    struct stream_out *out = (struct stream_out *)stream; // discard const qualifier
+    lock_output_stream(out);
+
+    const alsa_device_proxy *proxy = &out->proxy;
+    const int ret = proxy_get_presentation_position(proxy, frames, timestamp);
+
+    pthread_mutex_unlock(&out->lock);
+    ALOGV("out_get_presentation_position() status:%d  frames:%llu",
+            ret, (unsigned long long)*frames);
+    return ret;
 }
 
 static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)