code:
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#ifndef LOC_TARGET_H
#define LOC_TARGET_H
#define TARGET_SET(gnss,ssc) ( (gnss<<1)|ssc )
#define TARGET_DEFAULT       TARGET_SET(GNSS_MSM, HAS_SSC)
#define TARGET_MDM           TARGET_SET(GNSS_MDM, HAS_SSC)
#define TARGET_APQ_SA        TARGET_SET(GNSS_GSS, NO_SSC)
#define TARGET_NO_GNSS       TARGET_SET(GNSS_NONE, NO_SSC)
#define TARGET_MSM_NO_SSC    TARGET_SET(GNSS_MSM, NO_SSC)
#define TARGET_AUTO          TARGET_SET(GNSS_AUTO, NO_SSC)
#define TARGET_UNKNOWN       TARGET_SET(GNSS_UNKNOWN, NO_SSC)
#define getTargetGnssType(target)  (target>>1)

#ifdef __cplusplus
extern "C"
{
#endif

unsigned int loc_get_target(void);

/*The character array passed to this function should have length
  of atleast PROPERTY_VALUE_MAX*/
void loc_get_target_baseband(char *baseband, int array_length);
/*The character array passed to this function should have length
  of atleast PROPERTY_VALUE_MAX*/
void loc_get_platform_name(char *platform_name, int array_length);
/*The character array passed to this function should have length
  of atleast PROPERTY_VALUE_MAX*/
void loc_get_auto_platform_name(char *platform_name, int array_length);
int loc_identify_low_ram_target();
/*The character array passed to this function should have length
  of atleast PROPERTY_VALUE_MAX*/
void loc_get_device_soc_id(char *soc_id_value, int array_length);

/* Please remember to update 'target_name' in loc_log.cpp,
   if do any changes to this enum. */
typedef enum {
    GNSS_NONE = 0,
    GNSS_MSM,
    GNSS_GSS,
    GNSS_MDM,
    GNSS_AUTO,
    GNSS_UNKNOWN
}GNSS_TARGET;

typedef enum {
    NO_SSC = 0,
    HAS_SSC
}SSC_TYPE;

#ifdef __cplusplus
}
#endif

#endif /*LOC_TARGET_H*/


code:
/* Copyright (c) 2013,2015 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation, nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef __LOC_DELAY_H__
#define __LOC_DELAY_H__

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stddef.h>
#include <stdint.h>
#include <loc_pla.h>
/*
    user_data: client context pointer, passthrough. Originally received
               from calling client when loc_timer_start() is called.
    result:    0 if timer successfully timed out; else timer failed.
*/
typedef void (*loc_timer_callback)(void *user_data, int32_t result);

/*
    delay_msec:         timeout value for the timer.
    cb_func:            callback function pointer, implemented by client.
                        Can not be NULL.
    user_data:          client context pointer, passthrough.  Will be
                        returned when loc_timer_callback() is called.
    wakeOnExpire:       true if to wake up CPU (if sleeping) upon timer
                                expiration and notify the client.
                        false if to wait until next time CPU wakes up (if
                                 sleeping) and then notify the client.
    Returns the handle, which can be used to stop the timer
                        NULL, if timer start fails (e.g. if cb_func is NULL).
*/
void* loc_timer_start(uint64_t delay_msec,
                      loc_timer_callback cb_func,
                      void *user_data,
                      bool wake_on_expire=false);

/*
    handle becomes invalid upon the return of the callback
*/
void loc_timer_stop(void*& handle);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif //__LOC_DELAY_H__

license: unknown


code:
/* Copyright (c) 2011-2014, 2020 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#ifndef __LOG_UTIL_H__
#define __LOG_UTIL_H__

#include <stdbool.h>
#include <loc_pla.h>
#if defined (USE_ANDROID_LOGGING) || defined (ANDROID)
// Android and LE targets with logcat support
#include <utils/Log.h>
#include <unistd.h>
#include <sys/syscall.h>

#elif defined (USE_GLIB)
// LE targets with no logcat support
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/syscall.h>

#ifndef LOG_TAG
#define LOG_TAG "GPS_UTILS"
#endif /* LOG_TAG */

// LE targets with no logcat support
#if defined(FEATURE_EXTERNAL_AP) || defined(USE_SYSLOG_LOGGING)
#include <syslog.h>
#define ALOGE(...) syslog(LOG_ERR,     "LOC_LOGE: " __VA_ARGS__);
#define ALOGW(...) syslog(LOG_WARNING, "LOC_LOGW: " __VA_ARGS__);
#define ALOGI(...) syslog(LOG_NOTICE,  "LOC_LOGI: " __VA_ARGS__);
#define ALOGD(...) syslog(LOG_DEBUG,   "LOC_LOGD: " __VA_ARGS__);
#define ALOGV(...) syslog(LOG_NOTICE,  "LOC_LOGV: " __VA_ARGS__);
#else /* FEATURE_EXTERNAL_AP */
#define TS_PRINTF(format, x...)                                  \
{                                                                \
    struct timeval tv;                                           \
    struct timezone tz;                                          \
    int hh, mm, ss;                                              \
    gettimeofday(&tv, &tz);                                      \
    hh = tv.tv_sec/3600%24;                                      \
    mm = (tv.tv_sec%3600)/60;                                    \
    ss = tv.tv_sec%60;                                           \
    fprintf(stdout,"%02d:%02d:%02d.%06ld]" format "\n", hh, mm, ss, tv.tv_usec, ##x);    \
}

#define ALOGE(format, x...) TS_PRINTF("E/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGW(format, x...) TS_PRINTF("W/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGI(format, x...) TS_PRINTF("I/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGD(format, x...) TS_PRINTF("D/%s (%d): " format , LOG_TAG, getpid(), ##x)
#define ALOGV(format, x...) TS_PRINTF("V/%s (%d): " format , LOG_TAG, getpid(), ##x)
#endif /* FEATURE_EXTERNAL_AP */

#endif /* #if defined (USE_ANDROID_LOGGING) || defined (ANDROID) */

#ifdef __cplusplus
extern "C"
{
#endif
/*=============================================================================
 *
 *                         LOC LOGGER TYPE DECLARATION
 *
 *============================================================================*/
/* LOC LOGGER */
typedef struct loc_logger_s
{
  unsigned long  DEBUG_LEVEL;
  unsigned long  TIMESTAMP;
  bool           LOG_BUFFER_ENABLE;
} loc_logger_s_type;

/*=============================================================================
 *
 *                               EXTERNAL DATA
 *
 *============================================================================*/

// Logging Improvements
extern const char *loc_logger_boolStr[];

extern loc_logger_s_type loc_logger;
extern const char *boolStr[];
extern const char VOID_RET[];
extern const char FROM_AFW[];
extern const char TO_MODEM[];
extern const char FROM_MODEM[];
extern const char TO_AFW[];
extern const char EXIT_TAG[];
extern const char ENTRY_TAG[];
extern const char EXIT_ERROR_TAG[];

#define BUILD_TYPE_PROP_NA 0
#define BUILD_TYPE_PROP_USER 1
#define BUILD_TYPE_PROP_USERDEBUG 2
#define BUILD_TYPE_PROP_INVALID 3
extern int build_type_prop;

/*=============================================================================
 *
 *                        MODULE EXPORTED FUNCTIONS
 *
 *============================================================================*/
inline void loc_logger_init(unsigned long debug, unsigned long timestamp)
{
    loc_logger.DEBUG_LEVEL = debug;

    if (BUILD_TYPE_PROP_NA == build_type_prop) {
        char value[PROPERTY_VALUE_MAX] = "NA";
        property_get("ro.build.type", value, "userdebug");
        if (0 == strcmp(value, "user")) {
            build_type_prop = BUILD_TYPE_PROP_USER;
        } else if (0 == strcmp(value, "userdebug")) {
            build_type_prop = BUILD_TYPE_PROP_USERDEBUG;
        } else {
            build_type_prop = BUILD_TYPE_PROP_INVALID;
        }
    }

    if (BUILD_TYPE_PROP_USER == build_type_prop) {
        // force user builds to 2 or less
        if (loc_logger.DEBUG_LEVEL > 2) {
            loc_logger.DEBUG_LEVEL = 2;
        }
     }

    loc_logger.TIMESTAMP = timestamp;
}

inline void log_buffer_init(bool enabled) {
    loc_logger.LOG_BUFFER_ENABLE = enabled;
}
extern void log_tag_level_map_init();
extern int get_tag_log_level(const char* tag);
extern char* get_timestamp(char* str, unsigned long buf_size);
extern void log_buffer_insert(char *str, unsigned long buf_size, int level);
/*=============================================================================
 *
 *                          LOGGING BUFFER MACROS
 *
 *============================================================================*/
#ifndef LOG_NDEBUG
#define LOG_NDEBUG 0
#endif
#define TOTAL_LOG_LEVELS 5
#define LOGGING_BUFFER_MAX_LEN 1024
#define IF_LOG_BUFFER_ENABLE if (loc_logger.LOG_BUFFER_ENABLE)
#define INSERT_BUFFER(flag, level, format, x...)                                              \
{                                                                                \
    IF_LOG_BUFFER_ENABLE {                                                                    \
        if (flag == 0) {                                                                      \
            char timestr[32];                                                                 \
            get_timestamp(timestr, sizeof(timestr));                                          \
            char log_str[LOGGING_BUFFER_MAX_LEN];                                             \
            snprintf(log_str, LOGGING_BUFFER_MAX_LEN, "%s %d %ld %s :" format "\n",           \
                    timestr, getpid(), syscall(SYS_gettid), LOG_TAG==NULL ? "": LOG_TAG, ##x);\
            log_buffer_insert(log_str, sizeof(log_str), level);                               \
        }                                                                                \
    }                                                                                \
}

#ifndef DEBUG_DMN_LOC_API

/* LOGGING MACROS */
/*loc_logger.DEBUG_LEVEL is initialized to 0xff in loc_cfg.cpp
  if that value remains unchanged, it means gps.conf did not
  provide a value and we default to the initial value to use
  Android's logging levels*/

/* Tag based logging control MACROS */
/* The logic is like this:
 * 1, LOCAL_LOG_LEVEL is defined as a static variable in log_util.h,
 *    then all source files which includes log_util.h will have its own LOCAL_LOG_LEVEL variable;
 * 2, For each source file,
 *    2.1, First time when LOC_LOG* is invoked(its LOCAL_LOG_LEVEL == -1),
 *         Set the tag based log level according to the <tag, level> map;
 *         If this tag isn't found in map, set local debug level as global loc_logger.DEBUG_LEVEL;
 *    2.2, If not the first time, use its LOCAL_LOG_LEVEL as the debug level of this tag.
*/
static int LOCAL_LOG_LEVEL = -1;
#define IF_LOC_LOG(x) \
    if (((LOCAL_LOG_LEVEL == -1 && (LOCAL_LOG_LEVEL = get_tag_log_level(LOG_TAG)) >= x) ||\
            LOCAL_LOG_LEVEL >= x) && LOCAL_LOG_LEVEL <= 5)

#define IF_LOC_LOGE IF_LOC_LOG(1)
#define IF_LOC_LOGW IF_LOC_LOG(2)
#define IF_LOC_LOGI IF_LOC_LOG(3)
#define IF_LOC_LOGD IF_LOC_LOG(4)
#define IF_LOC_LOGV IF_LOC_LOG(5)

#define LOC_LOGE(...) IF_LOC_LOGE { ALOGE(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 0, __VA_ARGS__);}
#define LOC_LOGW(...) IF_LOC_LOGW { ALOGW(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 1, __VA_ARGS__);}
#define LOC_LOGI(...) IF_LOC_LOGI { ALOGI(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 2, __VA_ARGS__);}
#define LOC_LOGD(...) IF_LOC_LOGD { ALOGD(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 3, __VA_ARGS__);}
#define LOC_LOGV(...) IF_LOC_LOGV { ALOGV(__VA_ARGS__); INSERT_BUFFER(LOG_NDEBUG, 4, __VA_ARGS__);}

#else /* DEBUG_DMN_LOC_API */

#define LOC_LOGE(...) ALOGE(__VA_ARGS__)
#define LOC_LOGW(...) ALOGW(__VA_ARGS__)
#define LOC_LOGI(...) ALOGI(__VA_ARGS__)
#define LOC_LOGD(...) ALOGD(__VA_ARGS__)
#define LOC_LOGV(...) ALOGV(__VA_ARGS__)

#endif /* DEBUG_DMN_LOC_API */

/*=============================================================================
 *
 *                          LOGGING IMPROVEMENT MACROS
 *
 *============================================================================*/
#define LOG_(LOC_LOG, ID, WHAT, SPEC, VAL)                                    \
    do {                                                                      \
        if (loc_logger.TIMESTAMP) {                                           \
            char ts[32];                                                      \
            LOC_LOG("[%s] %s %s line %d " #SPEC,                              \
                     get_timestamp(ts, sizeof(ts)), ID, WHAT, __LINE__, VAL); \
        } else {                                                              \
            LOC_LOG("%s %s line %d " #SPEC,                                   \
                     ID, WHAT, __LINE__, VAL);                                \
        }                                                                     \
    } while(0)

#define LOC_LOG_HEAD(fmt) "%s:%d] " fmt
#define LOC_LOGv(fmt,...) LOC_LOGV(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOC_LOGw(fmt,...) LOC_LOGW(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOC_LOGi(fmt,...) LOC_LOGI(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOC_LOGd(fmt,...) LOC_LOGD(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define LOC_LOGe(fmt,...) LOC_LOGE(LOC_LOG_HEAD(fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__)

#define LOG_I(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGI, ID, WHAT, SPEC, VAL)
#define LOG_V(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGV, ID, WHAT, SPEC, VAL)
#define LOG_E(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGE, ID, WHAT, SPEC, VAL)
#define LOG_D(ID, WHAT, SPEC, VAL) LOG_(LOC_LOGD, ID, WHAT, SPEC, VAL)

#define ENTRY_LOG() LOG_V(ENTRY_TAG, __FUNCTION__, %s, "")
#define EXIT_LOG(SPEC, VAL) LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL)
#define EXIT_LOG_WITH_ERROR(SPEC, VAL)                       \
    if (VAL != 0) {                                          \
        LOG_E(EXIT_ERROR_TAG, __FUNCTION__, SPEC, VAL);          \
    } else {                                                 \
        LOG_V(EXIT_TAG, __FUNCTION__, SPEC, VAL);                \
    }

// Used for logging callflow from Android Framework
#define ENTRY_LOG_CALLFLOW() LOG_I(FROM_AFW, __FUNCTION__, %s, "")
// Used for logging callflow to Modem
#define EXIT_LOG_CALLFLOW(SPEC, VAL) LOG_I(TO_MODEM, __FUNCTION__, SPEC, VAL)
// Used for logging callflow from Modem(TO_MODEM, __FUNCTION__, %s, "")
#define MODEM_LOG_CALLFLOW(SPEC, VAL) LOG_I(FROM_MODEM, __FUNCTION__, SPEC, VAL)
// Used for logging high frequency callflow from Modem(TO_MODEM, __FUNCTION__, %s, "")
#define MODEM_LOG_CALLFLOW_DEBUG(SPEC, VAL) LOG_D(FROM_MODEM, __FUNCTION__, SPEC, VAL)
// Used for logging callflow to Android Framework
#define CALLBACK_LOG_CALLFLOW(CB, SPEC, VAL) LOG_I(TO_AFW, CB, SPEC, VAL)

#ifdef __cplusplus
}
#endif

#endif // __LOG_UTIL_H__


code:
/* Copyright (c) 2011-2012, 2014, 2017 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation, nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

// Uncomment to log verbose logs
#define LOG_NDEBUG 1
#define LOG_TAG "LocSvc_utils_q"
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <loc_pla.h>
#include <log_util.h>
#include "linked_list.h"
#include "msg_q.h"

typedef struct msg_q {
   void* msg_list;                  /* Linked list to store information */
   pthread_cond_t  list_cond;       /* Condition variable for waiting on msg queue */
   pthread_mutex_t list_mutex;      /* Mutex for exclusive access to message queue */
   int unblocked;                   /* Has this message queue been unblocked? */
} msg_q;

/*===========================================================================
FUNCTION    convert_linked_list_err_type

DESCRIPTION
   Converts from one set of enum values to another.

   linked_list_val: Value to convert to msg_q_enum_type

DEPENDENCIES
   N/A

RETURN VALUE
   Corresponding linked_list_enum_type in msg_q_enum_type

SIDE EFFECTS
   N/A

===========================================================================*/
static msq_q_err_type convert_linked_list_err_type(linked_list_err_type linked_list_val)
{
   switch( linked_list_val )
   {
   case eLINKED_LIST_SUCCESS:
      return eMSG_Q_SUCCESS;
   case eLINKED_LIST_INVALID_PARAMETER:
      return eMSG_Q_INVALID_PARAMETER;
   case eLINKED_LIST_INVALID_HANDLE:
      return eMSG_Q_INVALID_HANDLE;
   case eLINKED_LIST_UNAVAILABLE_RESOURCE:
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   case eLINKED_LIST_INSUFFICIENT_BUFFER:
      return eMSG_Q_INSUFFICIENT_BUFFER;

   case eLINKED_LIST_FAILURE_GENERAL:
   default:
      return eMSG_Q_FAILURE_GENERAL;
   }
}

/* ----------------------- END INTERNAL FUNCTIONS ---------------------------------------- */

/*===========================================================================

  FUNCTION:   msg_q_init

  ===========================================================================*/
msq_q_err_type msg_q_init(void** msg_q_data)
{
   if( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_PARAMETER;
   }

   msg_q* tmp_msg_q;
   tmp_msg_q = (msg_q*)calloc(1, sizeof(msg_q));
   if( tmp_msg_q == NULL )
   {
      LOC_LOGE("%s: Unable to allocate space for message queue!\n", __FUNCTION__);
      return eMSG_Q_FAILURE_GENERAL;
   }

   if( linked_list_init(&tmp_msg_q->msg_list) != 0 )
   {
      LOC_LOGE("%s: Unable to initialize storage list!\n", __FUNCTION__);
      free(tmp_msg_q);
      return eMSG_Q_FAILURE_GENERAL;
   }

   if( pthread_mutex_init(&tmp_msg_q->list_mutex, NULL) != 0 )
   {
      LOC_LOGE("%s: Unable to initialize list mutex!\n", __FUNCTION__);
      linked_list_destroy(&tmp_msg_q->msg_list);
      free(tmp_msg_q);
      return eMSG_Q_FAILURE_GENERAL;
   }

   if( pthread_cond_init(&tmp_msg_q->list_cond, NULL) != 0 )
   {
      LOC_LOGE("%s: Unable to initialize msg q cond var!\n", __FUNCTION__);
      linked_list_destroy(&tmp_msg_q->msg_list);
      pthread_mutex_destroy(&tmp_msg_q->list_mutex);
      free(tmp_msg_q);
      return eMSG_Q_FAILURE_GENERAL;
   }

   tmp_msg_q->unblocked = 0;

   *msg_q_data = tmp_msg_q;

   return eMSG_Q_SUCCESS;
}

/*===========================================================================

  FUNCTION:   msg_q_init2

  ===========================================================================*/
const void* msg_q_init2()
{
  void* q = NULL;
  if (eMSG_Q_SUCCESS != msg_q_init(&q)) {
    q = NULL;
  }
  return q;
}

/*===========================================================================

  FUNCTION:   msg_q_destroy

  ===========================================================================*/
msq_q_err_type msg_q_destroy(void** msg_q_data)
{
   if( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   msg_q* p_msg_q = (msg_q*)*msg_q_data;

   linked_list_destroy(&p_msg_q->msg_list);
   pthread_mutex_destroy(&p_msg_q->list_mutex);
   pthread_cond_destroy(&p_msg_q->list_cond);

   p_msg_q->unblocked = 0;

   free(*msg_q_data);
   *msg_q_data = NULL;

   return eMSG_Q_SUCCESS;
}

/*===========================================================================

  FUNCTION:   msg_q_snd

  ===========================================================================*/
msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*))
{
   msq_q_err_type rv;
   if( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }
   if( msg_obj == NULL )
   {
      LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_PARAMETER;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;

   pthread_mutex_lock(&p_msg_q->list_mutex);
   LOC_LOGV("%s: Sending message with handle = %p\n", __FUNCTION__, msg_obj);

   if( p_msg_q->unblocked )
   {
      LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   }

   rv = convert_linked_list_err_type(linked_list_add(p_msg_q->msg_list, msg_obj, dealloc));

   /* Show data is in the message queue. */
   pthread_cond_signal(&p_msg_q->list_cond);

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGV("%s: Finished Sending message with handle = %p\n", __FUNCTION__, msg_obj);

   return rv;
}

/*===========================================================================

  FUNCTION:   msg_q_rcv

  ===========================================================================*/
msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj)
{
   msq_q_err_type rv;
   if( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   if( msg_obj == NULL )
   {
      LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_PARAMETER;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;

   pthread_mutex_lock(&p_msg_q->list_mutex);

   if( p_msg_q->unblocked )
   {
      LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   }

   /* Wait for data in the message queue */
   while( linked_list_empty(p_msg_q->msg_list) && !p_msg_q->unblocked )
   {
      pthread_cond_wait(&p_msg_q->list_cond, &p_msg_q->list_mutex);
   }

   rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj));

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGV("%s: Received message %p rv = %d\n", __FUNCTION__, *msg_obj, rv);

   return rv;
}

/*===========================================================================

  FUNCTION:   msg_q_rmv

  ===========================================================================*/
msq_q_err_type msg_q_rmv(void* msg_q_data, void** msg_obj)
{
   msq_q_err_type rv;
   if (msg_q_data == NULL) {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   if (msg_obj == NULL) {
      LOC_LOGE("%s: Invalid msg_obj parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_PARAMETER;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;

   pthread_mutex_lock(&p_msg_q->list_mutex);

   if (p_msg_q->unblocked) {
      LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   }

   if (linked_list_empty(p_msg_q->msg_list)) {
      LOC_LOGW("%s: list is empty !!\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eLINKED_LIST_EMPTY;
   }

   rv = convert_linked_list_err_type(linked_list_remove(p_msg_q->msg_list, msg_obj));

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGV("%s: Removed message %p rv = %d\n", __FUNCTION__, *msg_obj, rv);

   return rv;
}

/*===========================================================================

  FUNCTION:   msg_q_flush

  ===========================================================================*/
msq_q_err_type msg_q_flush(void* msg_q_data)
{
   msq_q_err_type rv;
   if ( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;

   LOC_LOGD("%s: Flushing Message Queue\n", __FUNCTION__);

   pthread_mutex_lock(&p_msg_q->list_mutex);

   /* Remove all elements from the list */
   rv = convert_linked_list_err_type(linked_list_flush(p_msg_q->msg_list));

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGD("%s: Message Queue flushed\n", __FUNCTION__);

   return rv;
}

/*===========================================================================

  FUNCTION:   msg_q_unblock

  ===========================================================================*/
msq_q_err_type msg_q_unblock(void* msg_q_data)
{
   if ( msg_q_data == NULL )
   {
      LOC_LOGE("%s: Invalid msg_q_data parameter!\n", __FUNCTION__);
      return eMSG_Q_INVALID_HANDLE;
   }

   msg_q* p_msg_q = (msg_q*)msg_q_data;
   pthread_mutex_lock(&p_msg_q->list_mutex);

   if( p_msg_q->unblocked )
   {
      LOC_LOGE("%s: Message queue has been unblocked.\n", __FUNCTION__);
      pthread_mutex_unlock(&p_msg_q->list_mutex);
      return eMSG_Q_UNAVAILABLE_RESOURCE;
   }

   LOC_LOGD("%s: Unblocking Message Queue\n", __FUNCTION__);
   /* Unblocking message queue */
   p_msg_q->unblocked = 1;

   /* Allow all the waiters to wake up */
   pthread_cond_broadcast(&p_msg_q->list_cond);

   pthread_mutex_unlock(&p_msg_q->list_mutex);

   LOC_LOGD("%s: Message Queue unblocked\n", __FUNCTION__);

   return eMSG_Q_SUCCESS;
}


code:
/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __MSG_Q_H__
#define __MSG_Q_H__

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <stdlib.h>

/** Linked List Return Codes */
typedef enum
{
  eMSG_Q_SUCCESS                             = 0,
     /**< Request was successful. */
  eMSG_Q_FAILURE_GENERAL                     = -1,
     /**< Failed because of a general failure. */
  eMSG_Q_INVALID_PARAMETER                   = -2,
     /**< Failed because the request contained invalid parameters. */
  eMSG_Q_INVALID_HANDLE                      = -3,
     /**< Failed because an invalid handle was specified. */
  eMSG_Q_UNAVAILABLE_RESOURCE                = -4,
     /**< Failed because an there were not enough resources. */
  eMSG_Q_INSUFFICIENT_BUFFER                 = -5,
     /**< Failed because an the supplied buffer was too small. */
}msq_q_err_type;

/*===========================================================================
FUNCTION    msg_q_init

DESCRIPTION
   Initializes internal structures for message queue.

   msg_q_data: pointer to an opaque Q handle to be returned; NULL if fails

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_init(void** msg_q_data);

/*===========================================================================
FUNCTION    msg_q_init2

DESCRIPTION
   Initializes internal structures for message queue.

DEPENDENCIES
   N/A

RETURN VALUE
   opaque handle to the Q created; NULL if create fails

SIDE EFFECTS
   N/A

===========================================================================*/
const void* msg_q_init2();

/*===========================================================================
FUNCTION    msg_q_destroy

DESCRIPTION
   Releases internal structures for message queue.

   msg_q_data: State of message queue to be released.

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_destroy(void** msg_q_data);

/*===========================================================================
FUNCTION    msg_q_snd

DESCRIPTION
   Sends data to the message queue. The passed in data pointer
   is not modified or freed. Passed in msg_obj is expected to live throughout
   the use of the msg_q (i.e. data is not allocated internally)

   msg_q_data: Message Queue to add the element to.
   msgp:       Pointer to data to add into message queue.
   dealloc:    Function used to deallocate memory for this element. Pass NULL
               if you do not want data deallocated during a flush operation

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_snd(void* msg_q_data, void* msg_obj, void (*dealloc)(void*));

/*===========================================================================
FUNCTION    msg_q_rcv

DESCRIPTION
   Retrieves data from the message queue. msg_obj is the oldest message received
   and pointer is simply removed from message queue.

   msg_q_data: Message Queue to copy data from into msgp.
   msg_obj:    Pointer to space to copy msg_q contents to.

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_rcv(void* msg_q_data, void** msg_obj);

/*===========================================================================
FUNCTION    msg_q_rmv

DESCRIPTION
   Remove data from the message queue. msg_obj is the oldest message received
   and pointer is simply removed from message queue.

   msg_q_data: Message Queue to copy data from into msgp.
   msg_obj:    Pointer to space to copy msg_q contents to.

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_rmv(void* msg_q_data, void** msg_obj);

/*===========================================================================
FUNCTION    msg_q_flush

DESCRIPTION
   Function removes all elements from the message queue.

   msg_q_data: Message Queue to remove elements from.

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_flush(void* msg_q_data);

/*===========================================================================
FUNCTION    msg_q_unblock

DESCRIPTION
   This function will stop use of the message queue. All waiters will wake up
   and likely receive nothing from the queue resulting in a negative return
   value. The message queue can no longer be used until it is destroyed
   and initialized again after calling this function.

   msg_q_data: Message queue to unblock.

DEPENDENCIES
   N/A

RETURN VALUE
   Look at error codes above.

SIDE EFFECTS
   N/A

===========================================================================*/
msq_q_err_type msg_q_unblock(void* msg_q_data);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __MSG_Q_H__ */


code:
//
// Copyright (C) 2019 The LineageOS 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.
//

cc_library_static {
    name: "libinit_sdm660",
    recovery_available: true,
    srcs: ["init_sdm660.cpp"],
    whole_static_libs: ["libbase"],
    include_dirs: [
        "system/core/init",
        "system/libbase/include"
    ]
}


code:
/*
   Copyright (c) 2016, The CyanogenMod Project
   Copyright (c) 2019, The LineageOS Project

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are
   met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
   ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
   BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
   OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <cstdlib>
#include <fstream>
#include <string.h>
#include <sys/sysinfo.h>
#include <unistd.h>

#include <android-base/properties.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>

#include "vendor_init.h"
#include "property_service.h"

using android::base::GetProperty;
using std::string;

void property_override(string prop, string value)
{
    auto pi = (prop_info*) __system_property_find(prop.c_str());

    if (pi != nullptr)
        __system_property_update(pi, value.c_str(), value.size());
    else
        __system_property_add(prop.c_str(), prop.size(), value.c_str(), value.size());
}

void set_avoid_gfxaccel_config() {
    struct sysinfo sys;
    sysinfo(&sys);

    if (sys.totalram <= 3072ull * 1024 * 1024) {
        // Reduce memory footprint
        property_override("ro.config.avoid_gfx_accel", "true");
    }
}

void NFC_check()
{
    // Check NFC
    std::ifstream infile("/proc/NFC_CHECK");
    std::string check;

    getline(infile, check);
    if (!check.compare("SUPPORTED")) {
        property_override("ro.hq.support.nfc", "1");
        property_override("ro.boot.product.hardware.sku", "NFC");
    } else
        property_override("ro.hq.support.nfc", "0");
}

void vendor_load_properties()
{
    set_avoid_gfxaccel_config();
    NFC_check();
}


code:
BasedOnStyle: Google
AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: Inline
ColumnLimit: 100
CommentPragmas: NOLINT:.*
DerivePointerAlignment: false
IndentWidth: 4
PointerAlignment: Left
TabWidth: 4
UseTab: Never
PenaltyExcessCharacter: 32


code:
//
// Copyright (C) 2018 The LineageOS 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.

cc_binary {
    defaults: ["hidl_defaults"],
    name: "android.hardware.light@2.0-service.asus_sdm660",
    init_rc: ["android.hardware.light@2.0-service.asus_sdm660.rc"],
    vintf_fragments: ["android.hardware.light@2.0-service.asus_sdm660.xml"],
    srcs: ["service.cpp", "Light.cpp"],
    shared_libs: [
        "libbase",
        "libcutils",
        "libhardware",
        "libhidlbase",
        "libutils",
        "android.hardware.light@2.0",
    ],
    relative_install_path : "hw",
    vendor: true,
}


code:
/*
 * Copyright (C) 2019 Vyacheslav Vidanov (aka Anomalchik)
 * Copyright (C) 2018 The LineageOS 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.
 */

/*
 * Lights HAL for Asus X00T & X01BD (RG led and LCD BACKLIGHT)
 *    RG led scenarios:
 *       Battery:
 *           -red blink
 *           -red light
 *           -orange light
 *           -green light
 *       Notifications:
 *           -green blink
 *           -green light
 */

//#define HAL_DEBUG
#define LOG_TAG "LightService"

#include "Light.h"

#ifdef HAL_DEBUG
#include <android-base/logging.h>
#endif

namespace {
using android::hardware::light::V2_0::LightState;

static constexpr int DEFAULT_MAX_BRIGHTNESS = 255;

static uint32_t rgbToBrightness(const LightState& state) {
    uint32_t color = state.color & 0x00ffffff;
    return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) + (29 * (color & 0xff))) >>
           8;
}

static bool isLit(const LightState& state) {
    return (state.color & 0x00ffffff);
}

}  // anonymous namespace

namespace android {
namespace hardware {
namespace light {
namespace V2_0 {
namespace implementation {

Light::Light(std::pair<std::ofstream, uint32_t>&& lcd_backlight, std::ofstream&& red_blink,
             std::ofstream&& red_led, std::ofstream&& green_blink, std::ofstream&& green_led)
    : mLcdBacklight(std::move(lcd_backlight)),
      mRedBlink(std::move(red_blink)),
      mRedLed(std::move(red_led)),
      mGreenBlink(std::move(green_blink)),
      mGreenLed(std::move(green_led)) {
    auto attnFn(std::bind(&Light::setAttentionLight, this, std::placeholders::_1));
    auto backlightFn(std::bind(&Light::setLcdBacklight, this, std::placeholders::_1));
    auto batteryFn(std::bind(&Light::setBatteryLight, this, std::placeholders::_1));
    auto buttonsFn(
        std::bind(&Light::setButtonsBacklight, this, std::placeholders::_1));  // fake button dummy
    auto notifFn(std::bind(&Light::setNotificationLight, this, std::placeholders::_1));
    mLights.emplace(std::make_pair(Type::ATTENTION, attnFn));
    mLights.emplace(std::make_pair(Type::BACKLIGHT, backlightFn));
    mLights.emplace(std::make_pair(Type::BATTERY, batteryFn));
    mLights.emplace(std::make_pair(Type::BUTTONS, buttonsFn));  // fake button dummy
    mLights.emplace(std::make_pair(Type::NOTIFICATIONS, notifFn));
}

// Methods from ::android::hardware::light::V2_0::ILight follow.
Return<Status> Light::setLight(Type type, const LightState& state) {
    auto it = mLights.find(type);

    if (it == mLights.end()) {
        return Status::LIGHT_NOT_SUPPORTED;
    }

    it->second(state);

    return Status::SUCCESS;
}

Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
    std::vector<Type> types;

    for (auto const& light : mLights) {
        types.push_back(light.first);
    }

    _hidl_cb(types);

    return Void();
}

void Light::setAttentionLight(const LightState& state) {
    std::lock_guard<std::mutex> lock(mLock);
    mAttentionState = state;
    setSpeakerBatteryLightLocked();
}

void Light::setLcdBacklight(const LightState& state) {
    std::lock_guard<std::mutex> lock(mLock);

    uint32_t brightness = rgbToBrightness(state);

    // If max panel brightness is not the default (255),
    // apply linear scaling across the accepted range.
    if (mLcdBacklight.second != DEFAULT_MAX_BRIGHTNESS) {
#ifdef HAL_DEBUG
        int old_brightness = brightness;
#endif
        brightness = brightness * mLcdBacklight.second / DEFAULT_MAX_BRIGHTNESS;
#ifdef HAL_DEBUG
        LOG(VERBOSE) << "scaling brightness " << old_brightness << " => " << brightness;
#endif
    }

    mLcdBacklight.first << brightness << std::endl;
}

void Light::setButtonsBacklight(const LightState& state) {
    // We have no buttons light management, so do nothing.
    // This function required to shut up warnings about missing functionality.
    (void)state;
}

void Light::setBatteryLight(const LightState& state) {
    std::lock_guard<std::mutex> lock(mLock);
    mBatteryState = state;
    setSpeakerBatteryLightLocked();
}

void Light::setNotificationLight(const LightState& state) {
    std::lock_guard<std::mutex> lock(mLock);
    mNotificationState = state;
    setSpeakerBatteryLightLocked();
}

void Light::setSpeakerBatteryLightLocked() {
    if (isLit(mNotificationState)) {
        setSpeakerLightLocked(mNotificationState);
    } else if (isLit(mAttentionState)) {
        setSpeakerLightLocked(mAttentionState);
    } else if (isLit(mBatteryState)) {
        setSpeakerLightLocked(mBatteryState);
    } else {
        // Lights off
#ifdef HAL_DEBUG
        LOG(VERBOSE) << "Light::setSpeakerBatteryLightLocked: Lights off";
#endif
        mRedLed << 0 << std::endl;
        mGreenLed << 0 << std::endl;
        mRedBlink << 0 << std::endl;
        mGreenBlink << 0 << std::endl;
    }
}

void Light::setSpeakerLightLocked(const LightState& state) {
    int red, green;
    int blink;
    int onMs, offMs;
    uint32_t colorARGB = state.color;

#ifdef HAL_DEBUG
    int stateMode;
#endif

    // Disable previous active light
    mRedBlink << 0 << std::endl;
    mGreenBlink << 0 << std::endl;

    switch (state.flashMode) {
        case Flash::TIMED:
            onMs = state.flashOnMs;
            offMs = state.flashOffMs;
#ifdef HAL_DEBUG
            stateMode = 1;
#endif
            break;
        case Flash::NONE:
        default:
            onMs = 0;
            offMs = 0;
#ifdef HAL_DEBUG
            stateMode = 0;
#endif
            break;
    }

    red = (colorARGB >> 16) & 0xff;
    green = (colorARGB >> 8) & 0xff;

    if (onMs > 0 && offMs > 0)
        blink = 1;
    else
        blink = 0;

    // Use only 255(0xFF) for base colors
    if (colorARGB > 0xFF000000 && state == mBatteryState) {
        if (red >= green) {
            green = 0;
            red = 0xFF;
        } else if (!blink && red >= 0x50 && green > red) {  // try make orange
            green = 0xFF;
            red = 0x08;
        } else {
            green = 0xFF;
            red = 0;
        }
    } else if (colorARGB > 0xFF000000 && state == mNotificationState) {
        green = 0xFF;
        red = 0;
    } else {
        green = 0;
        red = 0;
    }

#ifdef HAL_DEBUG
    int ledState;
    if (state == mBatteryState)
        ledState = 1;
    else if (state == mNotificationState)
        ledState = 2;
    else
        ledState = 0;

    LOG(VERBOSE) << "Light::setSpeakerLightLocked: mode=" << stateMode << " ledState=" << ledState
                 << " colorARGB=" << colorARGB << " onMS=" << onMs << " offMS=" << offMs
                 << " blink=" << blink << " red=" << red << " green" << green;
#endif

    if (blink) {
        if (green) {
            mGreenBlink << blink << std::endl;  // green blink for notifications only
        }
        if (red) {
            mRedBlink << blink << std::endl;  // red blink for battery only
        }
    } else {
        mRedLed << red << std::endl;
        mGreenLed << green << std::endl;
    }
}

}  // namespace implementation
}  // namespace V2_0
}  // namespace light
}  // namespace hardware
}  // namespace android


code:
/*
 * Copyright (C) 2019 Vyacheslav Vidanov (aka Anomalchik)
 * Copyright (C) 2018 The LineageOS 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 ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H

#include <android/hardware/light/2.0/ILight.h>
#include <hidl/Status.h>

#include <fstream>
#include <mutex>
#include <unordered_map>

namespace android {
namespace hardware {
namespace light {
namespace V2_0 {
namespace implementation {

struct Light : public ILight {
    Light(std::pair<std::ofstream, uint32_t>&& lcd_backlight, std::ofstream&& red_blink,
          std::ofstream&& red_led, std::ofstream&& green_blink, std::ofstream&& green_led);

    // Methods from ::android::hardware::light::V2_0::ILight follow.
    Return<Status> setLight(Type type, const LightState& state) override;
    Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;

  private:
    void setAttentionLight(const LightState& state);
    void setBatteryLight(const LightState& state);
    void setButtonsBacklight(const LightState& state);
    void setLcdBacklight(const LightState& state);
    void setNotificationLight(const LightState& state);
    void setSpeakerBatteryLightLocked();
    void setSpeakerLightLocked(const LightState& state);

    std::pair<std::ofstream, uint32_t> mLcdBacklight;

    // Red led
    std::ofstream mRedBlink;
    std::ofstream mRedLed;

    // Green led
    std::ofstream mGreenBlink;
    std::ofstream mGreenLed;

    LightState mAttentionState;
    LightState mBatteryState;
    LightState mNotificationState;

    std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
    std::mutex mLock;
};

}  // namespace implementation
}  // namespace V2_0
}  // namespace light
}  // namespace hardware
}  // namespace android

#endif  // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H


code:
on init
    # Notification LED
    chown system system /sys/class/leds/red/blink
    chown system system /sys/class/leds/red/brightness
    chown system system /sys/class/leds/green/blink
    chown system system /sys/class/leds/green/brightness

    chmod 0664 /sys/class/leds/red/blink
    chmod 0644 /sys/class/leds/red/brightness
    chmod 0664 /sys/class/leds/green/blink
    chmod 0644 /sys/class/leds/green/brightness

    # LCD backlight
    chown system system /sys/class/leds/lcd-backlight/brightness

service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.asus_sdm660
    interface android.hardware.light@2.0::ILight default
    class hal
    user system
    group system
    # shutting off lights while powering-off
    shutdown critical
    task_profiles ServiceCapacityLow


code:
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>android.hardware.light</name>
        <transport>hwbinder</transport>
        <version>2.0</version>
        <interface>
            <name>ILight</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>


code:
/*
 * Copyright (C) 2019 Vyacheslav Vidanov (aka Anomalchik)
 * Copyright (C) 2018 The LineageOS 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.
 */

#define LOG_TAG "android.hardware.light@2.0-service.asus_sdm660"

#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <utils/Errors.h>

#include "Light.h"

// libhwbinder:
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;

// Generated HIDL files
using android::hardware::light::V2_0::ILight;
using android::hardware::light::V2_0::implementation::Light;

// LCD
const static std::string kLcdBacklightPath = "/sys/class/leds/lcd-backlight/brightness";
const static std::string kLcdMaxBacklightPath = "/sys/class/leds/lcd-backlight/max_brightness";

// Red led
const static std::string kRedBlinkPath = "/sys/class/leds/red/blink";
const static std::string kRedLedPath = "/sys/class/leds/red/brightness";

// Green led
const static std::string kGreenBlinkPath = "/sys/class/leds/green/blink";
const static std::string kGreenLedPath = "/sys/class/leds/green/brightness";

int main() {
    uint32_t lcdMaxBrightness = 255;

    std::ofstream lcdBacklight(kLcdBacklightPath);
    if (!lcdBacklight) {
        LOG(ERROR) << "Failed to open " << kLcdBacklightPath << ", error=" << errno << " ("
                   << strerror(errno) << ")";
        return -errno;
    }

    std::ifstream lcdMaxBacklight(kLcdMaxBacklightPath);
    if (!lcdMaxBacklight) {
        LOG(ERROR) << "Failed to open " << kLcdMaxBacklightPath << ", error=" << errno << " ("
                   << strerror(errno) << ")";
        return -errno;
    } else {
        lcdMaxBacklight >> lcdMaxBrightness;
    }

    std::ofstream redBlink(kRedBlinkPath);
    if (!redBlink) {
        LOG(ERROR) << "Failed to open " << kRedBlinkPath << ", error=" << errno << " ("
                   << strerror(errno) << ")";
        return -errno;
    }

    std::ofstream redLed(kRedLedPath);
    if (!redLed) {
        LOG(ERROR) << "Failed to open " << kRedLedPath << ", error=" << errno << " ("
                   << strerror(errno) << ")";
        return -errno;
    }

    std::ofstream greenBlink(kGreenBlinkPath);
    if (!greenBlink) {
        LOG(ERROR) << "Failed to open " << kGreenBlinkPath << ", error=" << errno << " ("
                   << strerror(errno) << ")";
        return -errno;
    }

    std::ofstream greenLed(kGreenLedPath);
    if (!greenLed) {
        LOG(ERROR) << "Failed to open " << kGreenLedPath << ", error=" << errno << " ("
                   << strerror(errno) << ")";
        return -errno;
    }

    android::sp<ILight> service =
        new Light({std::move(lcdBacklight), lcdMaxBrightness}, std::move(redBlink),
                  std::move(redLed), std::move(greenBlink), std::move(greenLed));

    configureRpcThreadpool(1, true);

    android::status_t status = service->registerAsService();

    if (status != android::OK) {
        LOG(ERROR) << "Cannot register Light HAL service";
        return 1;
    }

    LOG(INFO) << "Light HAL Ready.";
    joinRpcThreadpool();
    // Under normal cases, execution will not reach this line.
    LOG(ERROR) << "Light HAL failed to join thread pool.";
    return 1;
}


code:
<!--
    This is a skeleton device manifest. Notes:
    1. If a HAL is supported in both hwbinder and passthrough transport,
       only hwbinder is shown.
    2. It is likely that HALs in passthrough transport does not have
       <interface> declared; users will have to write them by hand.
    3. A HAL with lower minor version can be overridden by a HAL with
       higher minor version if they have the same name and major version.
-->
<manifest version="1.0" type="device" target-level="3">
    <hal format="hidl">
        <name>android.hardware.audio</name>
        <transport>hwbinder</transport>
        <version>6.0</version>
        <interface>
            <name>IDevicesFactory</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.audio.effect</name>
        <transport>hwbinder</transport>
        <version>6.0</version>
        <interface>
            <name>IEffectsFactory</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.biometrics.fingerprint</name>
        <transport>hwbinder</transport>
        <version>2.2</version>
        <interface>
            <name>IBiometricsFingerprint</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.bluetooth</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IBluetoothHci</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.bluetooth.audio</name>
        <transport>hwbinder</transport>
        <version>2.1</version>
        <interface>
            <name>IBluetoothAudioProvidersFactory</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.broadcastradio</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IBroadcastRadioFactory</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.camera.provider</name>
        <transport>hwbinder</transport>
        <version>2.4</version>
        <interface>
            <name>ICameraProvider</name>
            <instance>legacy/0</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.configstore</name>
        <transport>hwbinder</transport>
        <version>1.1</version>
        <interface>
            <name>ISurfaceFlingerConfigs</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.gatekeeper</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IGatekeeper</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.graphics.allocator</name>
        <transport>hwbinder</transport>
        <version>2.0</version>
        <interface>
            <name>IAllocator</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.graphics.composer</name>
        <transport>hwbinder</transport>
        <version>2.1</version>
        <interface>
            <name>IComposer</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.graphics.mapper</name>
        <transport arch="32+64">passthrough</transport>
        <version>2.1</version>
        <interface>
            <name>IMapper</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.keymaster</name>
        <transport>hwbinder</transport>
        <version>3.0</version>
        <interface>
            <name>IKeymasterDevice</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.media.omx</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IOmx</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IOmxStore</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.memtrack</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IMemtrack</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.radio</name>
        <transport>hwbinder</transport>
        <fqname>@1.2::ISap/slot1</fqname>
        <fqname>@1.2::ISap/slot2</fqname>
        <fqname>@1.4::IRadio/slot1</fqname>
        <fqname>@1.4::IRadio/slot2</fqname>
    </hal>
    <hal format="hidl">
        <name>android.hardware.radio.config</name>
        <transport>hwbinder</transport>
        <version>1.2</version>
        <interface>
            <name>IRadioConfig</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.sensors</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ISensors</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.tetheroffload.config</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IOffloadConfig</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.tetheroffload.control</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IOffloadControl</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>android.hardware.vr</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IVr</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>com.dsi.ant</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IAnt</name>
            <instance>default</instance>
        </interface>
        <fqname>@1.0::IAnt/default</fqname>
    </hal>
    <hal format="hidl">
        <name>com.qualcomm.qti.dpm.api</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IdpmQmi</name>
            <instance>dpmQmiService</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>com.qualcomm.qti.imscmservice</name>
        <transport>hwbinder</transport>
        <version>2.2</version>
        <interface>
            <name>IImsCmService</name>
            <instance>qti.ims.connectionmanagerservice</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>com.qualcomm.qti.uceservice</name>
        <transport>hwbinder</transport>
        <version>2.3</version>
        <interface>
            <name>IUceService</name>
            <instance>com.qualcomm.qti.uceservice</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.display.color</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IDisplayColor</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.display.config</name>
        <transport>hwbinder</transport>
        <version>1.9</version>
        <interface>
            <name>IDisplayConfig</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.display.postproc</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IDisplayPostproc</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.lineage.livedisplay</name>
        <transport>hwbinder</transport>
        <version>2.0</version>
        <interface>
            <name>IPictureAdjustment</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.data.factory</name>
        <transport>hwbinder</transport>
        <version>2.2</version>
        <interface>
            <name>IFactory</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.esepowermanager</name>
        <transport>hwbinder</transport>
        <version>1.1</version>
        <interface>
            <name>IEsePowerManager</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.alarm</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IAlarm</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.bluetooth_sar</name>
        <transport>hwbinder</transport>
        <version>1.1</version>
        <interface>
            <name>IBluetoothSar</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.btconfigstore</name>
        <transport>hwbinder</transport>
        <version>2.0</version>
        <interface>
            <name>IBTConfigStore</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.data.connection</name>
        <transport>hwbinder</transport>
        <version>1.1</version>
        <interface>
            <name>IDataConnection</name>
            <instance>slot1</instance>
            <instance>slot2</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.data.iwlan</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IIWlan</name>
            <instance>slot1</instance>
            <instance>slot2</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.data.latency</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ILinkLatency</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.fm</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IFmHci</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl" optional="true">
        <name>vendor.qti.hardware.qccvndhal</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IQccvndhal</name>
            <instance>qccvndhal</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.perf</name>
        <transport>hwbinder</transport>
        <version>2.2</version>
        <interface>
            <name>IPerf</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.qteeconnector</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IAppConnector</name>
            <instance>default</instance>
        </interface>
        <interface>
            <name>IGPAppConnector</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.am</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IQcRilAudio</name>
            <instance>slot1</instance>
            <instance>slot2</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.ims</name>
        <transport>hwbinder</transport>
        <version>1.6</version>
        <interface>
            <name>IImsRadio</name>
            <instance>imsradio0</instance>
            <instance>imsradio1</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.lpa</name>
        <transport>hwbinder</transport>
        <version>1.1</version>
        <interface>
            <name>IUimLpa</name>
            <instance>UimLpa0</instance>
            <instance>UimLpa1</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.qcrilhook</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IQtiOemHook</name>
            <instance>oemhook0</instance>
            <instance>oemhook1</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.qtiradio</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IQtiRadio</name>
            <instance>slot1</instance>
            <instance>slot2</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.qtiradio</name>
        <transport>hwbinder</transport>
        <version>2.4</version>
        <interface>
            <name>IQtiRadio</name>
            <instance>slot1</instance>
            <instance>slot2</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.uim</name>
        <transport>hwbinder</transport>
        <version>1.2</version>
        <interface>
            <name>IUim</name>
            <instance>Uim0</instance>
            <instance>Uim1</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.uim_remote_client</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IUimRemoteServiceClient</name>
            <instance>uimRemoteClient0</instance>
            <instance>uimRemoteClient1</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.radio.uim_remote_server</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IUimRemoteServiceServer</name>
            <instance>uimRemoteServer0</instance>
            <instance>uimRemoteServer1</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.soter</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ISoter</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.hardware.tui_comm</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>ITuiComm</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.ims.callinfo</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IService</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.ims.factory</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IImsFactory</name>
            <instance>default</instance>
        </interface>
    </hal>
    <hal format="hidl">
        <name>vendor.qti.imsrtpservice</name>
        <transport>hwbinder</transport>
        <version>3.0</version>
        <interface>
            <name>IRTPService</name>
            <instance>imsrtpservice</instance>
        </interface>
    </hal>
</manifest>


code:
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>android.hardware.nfc</name>
        <transport>hwbinder</transport>
        <version>1.2</version>
        <interface>
            <name>INfc</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>


code:
# QC framework value-adds
ro.vendor.qti.va_odm.support=1


code:
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2015-2016 The CyanogenMod Project
                   2017-2020 The LineageOS 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.
-->
<resources>

    <!-- Default value for proximity check on screen wake
     NOTE ! - Enable for devices that have a fast response proximity sensor (ideally < 300ms)-->
    <bool name="config_proximityCheckOnWake">true</bool>
    <integer name="config_proximityCheckTimeout">100</integer>
    <bool name="config_proximityCheckOnWakeEnabledByDefault">true</bool>

    <!-- All the capabilities of the LEDs on this device, stored as a bit field.
         This integer should equal the sum of the corresponding value for each
         of the following capabilities present:
         // Device has a color adjustable battery light.
         LIGHTS_RGB_NOTIFICATION_LED = 1
         // Device has a color adjustable notification light.
         LIGHTS_RGB_BATTERY_LED = 2
         LIGHTS_MULTIPLE_NOTIFICATION_LED = 4 (deprecated)
         // The notification light has adjustable pulsing capability.
         LIGHTS_PULSATING_LED = 8
         // Device has a multi-segment battery light that is able to
         // use the light brightness value to determine how many
         // segments to show (in order to represent battery level).
         LIGHTS_SEGMENTED_BATTERY_LED = 16
         // The notification light supports HAL adjustable brightness
         // via the alpha channel.
         // Note: if a device notification light supports LIGHTS_RGB_NOTIFICATION_LED
         // then HAL support is not necessary for brightness control.  In this case,
         // brightness support will be provided by lineage-sdk through the scaling of
         // RGB color values.
         LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32
         // Device has a battery light.
         LIGHTS_BATTERY_LED = 64
         // The battery light supports HAL adjustable brightness via
         // the alpha channel.
         // Note: if a device battery light supports LIGHTS_RGB_BATTERY_LED then HAL
         // support is not necessary for brightness control.  In this case,
         // brightness support will be provided by lineage-sdk through the scaling of
         // RGB color values.
         LIGHTS_ADJUSTABLE_BATTERY_LED_BRIGHTNESS = 128
         For example, a device with notification and battery lights that supports
         pulsating and RGB control would set this config to 75. -->
    <integer name="config_deviceLightCapabilities">232</integer>

    <!-- Whether device needs to wait for Qualcomm MPCTL service to start
         before setting power profiles on boot. -->
    <bool name="config_waitForMpctlOnBoot">true</bool>
</resources>


code:
<?xml version="1.0" encoding="UTF-8"?>
<!--
     Copyright (C) 2020 The LineageOS 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.
-->
<resources>
    <bool name="call_recording_enabled">true</bool>
    <integer name="call_recording_audio_source">4</integer>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2020 The LineageOS 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.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Defines the location of the fingerprint sensor on the device
         0 = back
         1 = front
         2 = left side
         3 = right side
    -->
    <integer name="config_fingerprintSensorLocation">0</integer>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2015, The Linux Foundation. All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are
    met:
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above
          copyright notice, this list of conditions and the following
          disclaimer in the documentation and/or other materials provided
          with the distribution.
        * Neither the name of The Linux Foundation nor the names of its
          contributors may be used to endorse or promote products derived
          from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
    ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
    IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- National Language Identifier codes for the following two config items.
          0  - reserved
          1  - Turkish
          2  - Spanish (single shift table only)
          3  - Portuguese
          4  - Bengali
          5  - Gujarati
          6  - Hindi
          7  - Kannada
          8  - Malayalam
          9  - Oriya
         10  - Punjabi
         11  - Tamil
         12  - Telugu
         13  - Urdu
         14+ - reserved -->

    <!-- National language single shift tables to enable for SMS encoding.
         Decoding is always enabled. Array elements are codes from the table above.
         Example 1: devices sold in Turkey must include table 1
         Example 2: devices sold in India should include tables 4 through 13
           to enable use of the new Release 9 tables for Indic languages. -->
    <integer-array name="config_sms_enabled_single_shift_tables">
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
        <item>6</item>
        <item>7</item>
        <item>8</item>
        <item>9</item>
        <item>10</item>
        <item>11</item>
        <item>12</item>
        <item>13</item>
    </integer-array>

    <!-- National language locking shift tables to enable for SMS encoding.
         Decoding is always enabled. Array elements are codes from the table above.
         Example 1: devices sold in Turkey must include table 1.
         Example 2: devices sold in India should include tables 4 through 13
         to enable use of the new Release 9 tables for Indic languages. -->
    <integer-array name="config_sms_enabled_locking_shift_tables">
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>5</item>
        <item>6</item>
        <item>7</item>
        <item>8</item>
        <item>9</item>
        <item>10</item>
        <item>11</item>
        <item>12</item>
        <item>13</item>
    </integer-array>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (c) 2014, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 this is the value
         that should be used instead. A value of RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means
         there is no replacement value and VoLTE is assumed to be supported -->
    <integer name="config_volte_replacement_rat">6</integer>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (c) 2015, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 this is the value
         that should be used instead. A value of RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means
         there is no replacement value and VoLTE is assumed to be supported -->
    <integer name="config_volte_replacement_rat">6</integer>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (c) 2014, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 this is the value
         that should be used instead. A value of RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means
         there is no replacement value and VoLTE is assumed to be supported -->
    <integer name="config_volte_replacement_rat">3</integer>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (c) 2014, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

    <!-- Overlay config file for Verizon operator -->

    <!-- Flag specifying whether VoLTE & VT should be available for carrier: independent of
         carrier provisioning. If false: hard disabled. If true: then depends on carrier
         provisioning, availability etc -->
    <bool name="config_carrier_volte_available">true</bool>

<!-- If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 this is the value
         that should be used instead. A value of RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means
         there is no replacement value and VoLTE is assumed to be supported -->
    <integer name="config_volte_replacement_rat">6</integer>

</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2018, The Linux Foundation. All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are
    met:
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above
          copyright notice, this list of conditions and the following
          disclaimer in the documentation and/or other materials provided
          with the distribution.
        * Neither the name of The Linux Foundation nor the names of its
          contributors may be used to endorse or promote products derived
          from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
    ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
    IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Do not translate. Defines the slots is Two Digit Number for dialing normally not USSD -->
    <string-array name="config_twoDigitNumberPattern">
        <item>"0"</item>
        <item>"00"</item>
        <item>"*2"</item>
    </string-array>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2018, The Linux Foundation. All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are
    met:
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above
          copyright notice, this list of conditions and the following
          disclaimer in the documentation and/or other materials provided
          with the distribution.
        * Neither the name of The Linux Foundation nor the names of its
          contributors may be used to endorse or promote products derived
          from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
    ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
    BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
    IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- Do not translate. Defines the slots is Two Digit Number for dialing normally not USSD -->
    <string-array name="config_twoDigitNumberPattern">
        <item>"0"</item>
        <item>"00"</item>
        <item>"*0"</item>
        <item>"*1"</item>
        <item>"*2"</item>
        <item>"*3"</item>
        <item>"*4"</item>
        <item>"*5"</item>
        <item>"*6"</item>
        <item>"*7"</item>
        <item>"*8"</item>
        <item>"*9"</item>
        <item>"#0"</item>
        <item>"#1"</item>
        <item>"#2"</item>
        <item>"#3"</item>
        <item>"#4"</item>
        <item>"#5"</item>
        <item>"#6"</item>
        <item>"#7"</item>
        <item>"#8"</item>
        <item>"#9"</item>
    </string-array>
</resources>


code:
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (c) 2015,2017, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- If Voice Radio Technology is RIL_RADIO_TECHNOLOGY_LTE:14 this is the value
         that should be used instead. A value of RIL_RADIO_TECHNOLOGY_UNKNOWN:0 means
         there is no replacement value and VoLTE is assumed to be supported -->
    <integer name="config_volte_replacement_rat">6</integer>
</resources>