adding dev id into xtra user agent

setting XTRA_USER_AGENT at GPS HAL init time, incorporating
Android sw version, manufacturer, model, board.

CRs-Fixed: 788356

Change-Id: I8d9dcc80a0769796a25a0477f5f1598a292fe8b0
This commit is contained in:
Kevin Tang 2015-01-19 16:22:28 -08:00 committed by Gerrit - the friendly Code Review server
parent 5e77108972
commit 623f5a6fc5
6 changed files with 82 additions and 5 deletions

View file

@ -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); }
};

View file

@ -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)();

View file

@ -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))

View file

@ -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;

View file

@ -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);
}

View file

@ -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!");