summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/ContextBase.h5
-rw-r--r--core/LBSProxyBase.h3
-rw-r--r--core/gps_extended_c.h2
-rw-r--r--loc_api/libloc_api_50001/LocEngAdapter.cpp71
-rw-r--r--loc_api/libloc_api_50001/LocEngAdapter.h3
-rw-r--r--loc_api/libloc_api_50001/loc.cpp3
6 files changed, 82 insertions, 5 deletions
diff --git a/core/ContextBase.h b/core/ContextBase.h
index ff7a4b3..fe0b860 100644
--- a/core/ContextBase.h
+++ b/core/ContextBase.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-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
@@ -63,6 +63,9 @@ public:
unsigned long capabilities) {
mLBSProxy->requestUlp(adapter, capabilities);
}
+ inline IzatDevId_t getIzatDevId() const {
+ return mLBSProxy->getIzatDevId();
+ }
inline void sendMsg(const LocMsg *msg) { getMsgTask()->sendMsg(msg); }
};
diff --git a/core/LBSProxyBase.h b/core/LBSProxyBase.h
index 75ae992..0faf801 100644
--- a/core/LBSProxyBase.h
+++ b/core/LBSProxyBase.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* 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
@@ -55,6 +55,7 @@ public:
inline virtual bool hasCPIExtendedCapabilities() const { return false; }
inline virtual void modemPowerVote(bool power) const {}
virtual void injectFeatureConfig(ContextBase* context) const {}
+ inline virtual IzatDevId_t getIzatDevId() const { return 0; }
};
typedef LBSProxyBase* (getLBSProxy_t)();
diff --git a/core/gps_extended_c.h b/core/gps_extended_c.h
index 0573014..06764cf 100644
--- a/core/gps_extended_c.h
+++ b/core/gps_extended_c.h
@@ -400,6 +400,8 @@ typedef enum loc_api_adapter_msg_to_check_supported {
LOC_API_ADAPTER_MESSAGE_MAX
} LocCheckingMessagesID;
+typedef int IzatDevId_t;
+
typedef uint32_t LOC_GPS_LOCK_MASK;
#define isGpsLockNone(lock) ((lock) == 0)
#define isGpsLockMO(lock) ((lock) & ((LOC_GPS_LOCK_MASK)1))
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.cpp b/loc_api/libloc_api_50001/LocEngAdapter.cpp
index fd6f9b0..1afa0a8 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.cpp
+++ b/loc_api/libloc_api_50001/LocEngAdapter.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-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
@@ -29,10 +29,13 @@
#define LOG_NDDEBUG 0
#define LOG_TAG "LocSvc_EngAdapter"
+#include <cutils/properties.h>
#include <LocEngAdapter.h>
#include "loc_eng_msg.h"
#include "loc_log.h"
+#define CHIPSET_SERIAL_NUMBER_MAX_LEN 16
+
using namespace loc_core;
LocInternalAdapter::LocInternalAdapter(LocEngAdapter* adapter) :
@@ -82,6 +85,72 @@ LocEngAdapter::~LocEngAdapter()
LOC_LOGV("LocEngAdapter deleted");
}
+void LocEngAdapter::setXtraUserAgent() {
+ struct LocSetXtraUserAgent : public LocMsg {
+ const ContextBase* const mContext;
+ inline LocSetXtraUserAgent(ContextBase* context) :
+ LocMsg(), mContext(context) {
+ }
+ virtual void proc() const {
+ char release[PROPERTY_VALUE_MAX];
+ char manufacture[PROPERTY_VALUE_MAX];
+ char model[PROPERTY_VALUE_MAX];
+ char carrier[PROPERTY_VALUE_MAX];
+ char board[PROPERTY_VALUE_MAX];
+ char brand[PROPERTY_VALUE_MAX];
+ char chipsetsn[CHIPSET_SERIAL_NUMBER_MAX_LEN];
+ char userAgent[PROPERTY_VALUE_MAX];
+ const char defVal[] = "-";
+
+ property_get("ro.build.version.release", release, defVal);
+ property_get("ro.product.manufacturer", manufacture, defVal);
+ property_get("ro.product.model", model, defVal);
+ property_get("ro.carrier", carrier, defVal);
+ property_get("ro.product.board", board, defVal);
+ property_get("ro.product.brand", brand, defVal);
+ getChipsetSerialNo(chipsetsn, sizeof(chipsetsn), defVal);
+
+ snprintf(userAgent, sizeof(userAgent), "A/%s/%s/%s/%s/%s/QCX3/s%u/-/%s/-/%s/-/-/-",
+ release, manufacture, model, board, carrier,
+ mContext->getIzatDevId(), chipsetsn, brand);
+
+ for (int i = 0; i < sizeof(userAgent) && userAgent[i]; i++) {
+ if (' ' == userAgent[i]) userAgent[i] = '#';
+ }
+
+ property_set("location.XTRA_USER_AGENT", userAgent);
+ LOC_LOGV("%s] UserAgent %s", __func__, userAgent);
+ }
+
+ void getChipsetSerialNo(char buf[], int buflen, const char def[]) const {
+ const char SOC_SERIAL_NUMBER[] = "/sys/devices/soc0/serial_number";
+
+ FILE* file = fopen(SOC_SERIAL_NUMBER, "rt");
+ if (file == NULL) {
+ // use default upon unreadable file
+ strlcpy(buf, def, buflen);
+
+ } else {
+ size_t size = fread(buf, 1, buflen - 1, file);
+ if (size == 0) {
+ // use default upon empty file
+ strlcpy(buf, def, buflen);
+
+ } else {
+ buf[size] = '\0';
+ }
+
+ fclose(file);
+ }
+
+ return;
+ }
+
+ };
+
+ sendMsg(new LocSetXtraUserAgent(mContext));
+}
+
void LocInternalAdapter::setUlpProxy(UlpProxyBase* ulp) {
struct LocSetUlpProxy : public LocMsg {
LocAdapterBase* mAdapter;
diff --git a/loc_api/libloc_api_50001/LocEngAdapter.h b/loc_api/libloc_api_50001/LocEngAdapter.h
index 9e01b98..b119d99 100644
--- a/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-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
@@ -92,6 +92,7 @@ public:
virtual ~LocEngAdapter();
virtual void setUlpProxy(UlpProxyBase* ulp);
+ void setXtraUserAgent();
inline void requestUlp(unsigned long capabilities) {
mContext->requestUlp(mInternalAdapter, capabilities);
}
diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp
index a1ae993..f7d7cb4 100644
--- a/loc_api/libloc_api_50001/loc.cpp
+++ b/loc_api/libloc_api_50001/loc.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-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
@@ -313,6 +313,7 @@ static int loc_init(GpsCallbacks* callbacks)
loc_afw_data.adapter->mSupportsTimeInjection = !loc_afw_data.adapter->hasCPIExtendedCapabilities();
loc_afw_data.adapter->setGpsLockMsg(0);
loc_afw_data.adapter->requestUlp(getCarrierCapabilities());
+ loc_afw_data.adapter->setXtraUserAgent();
if(retVal) {
LOC_LOGE("loc_eng_init() fail!");