Merge "agps cert install api implementation"
This commit is contained in:
commit
b39a4aaa01
9 changed files with 178 additions and 18 deletions
|
@ -478,6 +478,12 @@ int LocApiBase::
|
||||||
setGpsLock(unsigned int lock)
|
setGpsLock(unsigned int lock)
|
||||||
DEFAULT_IMPL(-1)
|
DEFAULT_IMPL(-1)
|
||||||
|
|
||||||
|
void LocApiBase::
|
||||||
|
installAGpsCert(const DerEncodedCertificate* pData,
|
||||||
|
size_t length,
|
||||||
|
uint32_t slotBitMask)
|
||||||
|
DEFAULT_IMPL()
|
||||||
|
|
||||||
int LocApiBase::
|
int LocApiBase::
|
||||||
getGpsLock()
|
getGpsLock()
|
||||||
DEFAULT_IMPL(-1)
|
DEFAULT_IMPL(-1)
|
||||||
|
|
|
@ -208,7 +208,9 @@ public:
|
||||||
virtual int openAndStartDataCall();
|
virtual int openAndStartDataCall();
|
||||||
virtual void stopDataCall();
|
virtual void stopDataCall();
|
||||||
virtual void closeDataCall();
|
virtual void closeDataCall();
|
||||||
|
virtual void installAGpsCert(const DerEncodedCertificate* pData,
|
||||||
|
size_t length,
|
||||||
|
uint32_t slotBitMask);
|
||||||
inline virtual void setInSession(bool inSession) {}
|
inline virtual void setInSession(bool inSession) {}
|
||||||
|
|
||||||
/*Values for lock
|
/*Values for lock
|
||||||
|
|
|
@ -68,6 +68,9 @@ extern "C" {
|
||||||
/*Emergency SUPL*/
|
/*Emergency SUPL*/
|
||||||
#define GPS_NI_TYPE_EMERGENCY_SUPL 4
|
#define GPS_NI_TYPE_EMERGENCY_SUPL 4
|
||||||
|
|
||||||
|
#define AGPS_CERTIFICATE_MAX_LENGTH 2000
|
||||||
|
#define AGPS_CERTIFICATE_MAX_SLOTS 10
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** set to sizeof(UlpLocation) */
|
/** set to sizeof(UlpLocation) */
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -102,16 +105,6 @@ typedef int16_t AGpsBearerType;
|
||||||
#define AGPS_APN_BEARER_IPV6 1
|
#define AGPS_APN_BEARER_IPV6 1
|
||||||
#define AGPS_APN_BEARER_IPV4V6 2
|
#define AGPS_APN_BEARER_IPV4V6 2
|
||||||
|
|
||||||
#define GPS_DELETE_ALMANAC_CORR 0x00001000
|
|
||||||
#define GPS_DELETE_FREQ_BIAS_EST 0x00002000
|
|
||||||
#define GPS_DELETE_EPHEMERIS_GLO 0x00004000
|
|
||||||
#define GPS_DELETE_ALMANAC_GLO 0x00008000
|
|
||||||
#define GPS_DELETE_SVDIR_GLO 0x00010000
|
|
||||||
#define GPS_DELETE_SVSTEER_GLO 0x00020000
|
|
||||||
#define GPS_DELETE_ALMANAC_CORR_GLO 0x00040000
|
|
||||||
#define GPS_DELETE_TIME_GPS 0x00080000
|
|
||||||
#define GPS_DELETE_TIME_GLO 0x00100000
|
|
||||||
|
|
||||||
/** GPS extended callback structure. */
|
/** GPS extended callback structure. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/** set to sizeof(GpsCallbacks) */
|
/** set to sizeof(GpsCallbacks) */
|
||||||
|
|
|
@ -118,13 +118,20 @@ static loc_name_val_s_type loc_eng_aiding_data_bits[] =
|
||||||
NAME_VAL( GPS_DELETE_CELLDB_INFO ),
|
NAME_VAL( GPS_DELETE_CELLDB_INFO ),
|
||||||
NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
|
NAME_VAL( GPS_DELETE_ALMANAC_CORR ),
|
||||||
NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
|
NAME_VAL( GPS_DELETE_FREQ_BIAS_EST ),
|
||||||
NAME_VAL( GPS_DELETE_EPHEMERIS_GLO ),
|
NAME_VAL( GLO_DELETE_EPHEMERIS ),
|
||||||
NAME_VAL( GPS_DELETE_ALMANAC_GLO ),
|
NAME_VAL( GLO_DELETE_ALMANAC ),
|
||||||
NAME_VAL( GPS_DELETE_SVDIR_GLO ),
|
NAME_VAL( GLO_DELETE_SVDIR ),
|
||||||
NAME_VAL( GPS_DELETE_SVSTEER_GLO ),
|
NAME_VAL( GLO_DELETE_SVSTEER ),
|
||||||
NAME_VAL( GPS_DELETE_ALMANAC_CORR_GLO ),
|
NAME_VAL( GLO_DELETE_ALMANAC_CORR ),
|
||||||
NAME_VAL( GPS_DELETE_TIME_GPS ),
|
NAME_VAL( GPS_DELETE_TIME_GPS ),
|
||||||
NAME_VAL( GPS_DELETE_TIME_GLO )
|
NAME_VAL( GLO_DELETE_TIME ),
|
||||||
|
NAME_VAL( BDS_DELETE_SVDIR ),
|
||||||
|
NAME_VAL( BDS_DELETE_SVSTEER ),
|
||||||
|
NAME_VAL( BDS_DELETE_TIME ),
|
||||||
|
NAME_VAL( BDS_DELETE_ALMANAC_CORR ),
|
||||||
|
NAME_VAL( BDS_DELETE_EPHEMERIS ),
|
||||||
|
NAME_VAL( BDS_DELETE_ALMANAC ),
|
||||||
|
NAME_VAL( GPS_DELETE_ALL)
|
||||||
};
|
};
|
||||||
static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
|
static int loc_eng_aiding_data_bit_num = sizeof(loc_eng_aiding_data_bits) / sizeof(loc_name_val_s_type);
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,14 @@ CAPABILITIES=0x37
|
||||||
# C2K_HOST=c2k.pde.com or IP
|
# C2K_HOST=c2k.pde.com or IP
|
||||||
# C2K_PORT=1234
|
# C2K_PORT=1234
|
||||||
|
|
||||||
|
# Bitmask of slots that are available
|
||||||
|
# for write/install to, where 1s indicate writable,
|
||||||
|
# and the default value is 0 where no slots
|
||||||
|
# are writable. For example, AGPS_CERT_WRITABLE_MASK
|
||||||
|
# of b1000001010 makes 3 slots available
|
||||||
|
# and the remaining 7 slots unwritable.
|
||||||
|
#AGPS_CERT_WRITABLE_MASK=0
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# LTE Positioning Profile Settings
|
# LTE Positioning Profile Settings
|
||||||
####################################
|
####################################
|
||||||
|
|
|
@ -257,6 +257,12 @@ public:
|
||||||
return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask);
|
return mLocApi->getBestAvailableZppFix(zppLoc, tech_mask);
|
||||||
}
|
}
|
||||||
enum loc_api_adapter_err setXtraVersionCheck(int check);
|
enum loc_api_adapter_err setXtraVersionCheck(int check);
|
||||||
|
inline virtual void installAGpsCert(const DerEncodedCertificate* pData,
|
||||||
|
size_t length,
|
||||||
|
uint32_t slotBitMask)
|
||||||
|
{
|
||||||
|
mLocApi->installAGpsCert(pData, length, slotBitMask);
|
||||||
|
}
|
||||||
virtual void handleEngineDownEvent();
|
virtual void handleEngineDownEvent();
|
||||||
virtual void handleEngineUpEvent();
|
virtual void handleEngineUpEvent();
|
||||||
virtual void reportPosition(UlpLocation &location,
|
virtual void reportPosition(UlpLocation &location,
|
||||||
|
|
|
@ -148,6 +148,18 @@ static const AGpsRilInterface sLocEngAGpsRilInterface =
|
||||||
loc_agps_ril_update_network_availability
|
loc_agps_ril_update_network_availability
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int loc_agps_install_certificates(const DerEncodedCertificate* certificates,
|
||||||
|
size_t length);
|
||||||
|
static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
|
static const SuplCertificateInterface sLocEngAGpsCertInterface =
|
||||||
|
{
|
||||||
|
sizeof(SuplCertificateInterface),
|
||||||
|
loc_agps_install_certificates,
|
||||||
|
loc_agps_revoke_certificates
|
||||||
|
};
|
||||||
|
|
||||||
static loc_eng_data_s_type loc_afw_data;
|
static loc_eng_data_s_type loc_afw_data;
|
||||||
static int gss_fd = -1;
|
static int gss_fd = -1;
|
||||||
|
|
||||||
|
@ -658,6 +670,10 @@ const void* loc_get_extension(const char* name)
|
||||||
ret_val = get_geofence_interface();
|
ret_val = get_geofence_interface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp(name, SUPL_CERTIFICATE_INTERFACE) == 0)
|
||||||
|
{
|
||||||
|
ret_val = &sLocEngAGpsCertInterface;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOC_LOGE ("get_extension: Invalid interface passed in\n");
|
LOC_LOGE ("get_extension: Invalid interface passed in\n");
|
||||||
|
@ -938,6 +954,24 @@ static void loc_agps_ril_update_network_availability(int available, const char*
|
||||||
EXIT_LOG(%s, VOID_RET);
|
EXIT_LOG(%s, VOID_RET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int loc_agps_install_certificates(const DerEncodedCertificate* certificates,
|
||||||
|
size_t length)
|
||||||
|
{
|
||||||
|
ENTRY_LOG();
|
||||||
|
int ret_val = loc_eng_agps_install_certificates(loc_afw_data, certificates, length);
|
||||||
|
EXIT_LOG(%d, ret_val);
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
static int loc_agps_revoke_certificates(const Sha1CertificateFingerprint* fingerprints,
|
||||||
|
size_t length)
|
||||||
|
{
|
||||||
|
ENTRY_LOG();
|
||||||
|
LOC_LOGE("%s:%d]: agps_revoke_certificates not supported");
|
||||||
|
int ret_val = AGPS_CERTIFICATE_ERROR_GENERIC;
|
||||||
|
EXIT_LOG(%d, ret_val);
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
static void local_loc_cb(UlpLocation* location, void* locExt)
|
static void local_loc_cb(UlpLocation* location, void* locExt)
|
||||||
{
|
{
|
||||||
ENTRY_LOG();
|
ENTRY_LOG();
|
||||||
|
|
|
@ -119,6 +119,7 @@ static loc_param_s_type loc_parameter_table[] =
|
||||||
{"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
|
{"A_GLONASS_POS_PROTOCOL_SELECT", &gps_conf.A_GLONASS_POS_PROTOCOL_SELECT, NULL, 'n'},
|
||||||
{"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'},
|
{"SENSOR_PROVIDER", &sap_conf.SENSOR_PROVIDER, NULL, 'n'},
|
||||||
{"XTRA_VERSION_CHECK", &gps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
|
{"XTRA_VERSION_CHECK", &gps_conf.XTRA_VERSION_CHECK, NULL, 'n'},
|
||||||
|
{"AGPS_CERT_WRITABLE_MASK", &gps_conf.AGPS_CERT_WRITABLE_MASK, NULL, 'n'}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void loc_default_parameters(void)
|
static void loc_default_parameters(void)
|
||||||
|
@ -162,6 +163,9 @@ static void loc_default_parameters(void)
|
||||||
sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
|
sap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID = 0;
|
||||||
/* default provider is SSC */
|
/* default provider is SSC */
|
||||||
sap_conf.SENSOR_PROVIDER = 1;
|
sap_conf.SENSOR_PROVIDER = 1;
|
||||||
|
|
||||||
|
/* None of the 10 slots for agps certificates are writable by default */
|
||||||
|
gps_conf.AGPS_CERT_WRITABLE_MASK = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd half of init(), singled out for
|
// 2nd half of init(), singled out for
|
||||||
|
@ -1476,6 +1480,51 @@ struct LocEngDataClientInit : public LocMsg {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LocEngInstallAGpsCert : public LocMsg {
|
||||||
|
LocEngAdapter* mpAdapter;
|
||||||
|
const size_t mNumberOfCerts;
|
||||||
|
const uint32_t mSlotBitMask;
|
||||||
|
DerEncodedCertificate* mpData;
|
||||||
|
inline LocEngInstallAGpsCert(LocEngAdapter* adapter,
|
||||||
|
const DerEncodedCertificate* pData,
|
||||||
|
size_t numberOfCerts,
|
||||||
|
uint32_t slotBitMask) :
|
||||||
|
LocMsg(), mpAdapter(adapter),
|
||||||
|
mNumberOfCerts(numberOfCerts), mSlotBitMask(slotBitMask),
|
||||||
|
mpData(new DerEncodedCertificate[mNumberOfCerts])
|
||||||
|
{
|
||||||
|
for (int i=0; i < mNumberOfCerts; i++) {
|
||||||
|
mpData[i].data = new u_char[pData[i].length];
|
||||||
|
if (mpData[i].data) {
|
||||||
|
memcpy(mpData[i].data, (void*)pData[i].data, pData[i].length);
|
||||||
|
mpData[i].length = pData[i].length;
|
||||||
|
} else {
|
||||||
|
LOC_LOGE("malloc failed for cert#%d", i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
locallog();
|
||||||
|
}
|
||||||
|
inline ~LocEngInstallAGpsCert()
|
||||||
|
{
|
||||||
|
for (int i=0; i < mNumberOfCerts; i++) {
|
||||||
|
if (mpData[i].data) {
|
||||||
|
delete[] mpData[i].data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] mpData;
|
||||||
|
}
|
||||||
|
inline virtual void proc() const {
|
||||||
|
mpAdapter->installAGpsCert(mpData, mNumberOfCerts, mSlotBitMask);
|
||||||
|
}
|
||||||
|
inline void locallog() const {
|
||||||
|
LOC_LOGV("LocEngInstallAGpsCert - certs=%u mask=%u",
|
||||||
|
mNumberOfCerts, mSlotBitMask);
|
||||||
|
}
|
||||||
|
inline virtual void log() const {
|
||||||
|
locallog();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* Initialization checking macros
|
* Initialization checking macros
|
||||||
|
@ -2448,6 +2497,57 @@ void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_d
|
||||||
EXIT_LOG(%s, VOID_RET);
|
EXIT_LOG(%s, VOID_RET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data,
|
||||||
|
const DerEncodedCertificate* certificates,
|
||||||
|
size_t numberOfCerts)
|
||||||
|
{
|
||||||
|
ENTRY_LOG_CALLFLOW();
|
||||||
|
int ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS;
|
||||||
|
|
||||||
|
uint32_t slotBitMask = gps_conf.AGPS_CERT_WRITABLE_MASK;
|
||||||
|
uint32_t slotCount = 0;
|
||||||
|
for (uint32_t slotBitMaskCounter=slotBitMask; slotBitMaskCounter; slotCount++) {
|
||||||
|
slotBitMaskCounter &= slotBitMaskCounter - 1;
|
||||||
|
}
|
||||||
|
LOC_LOGD("SlotBitMask=%u SlotCount=%u NumberOfCerts=%u",
|
||||||
|
slotBitMask, slotCount, numberOfCerts);
|
||||||
|
|
||||||
|
LocEngAdapter* adapter = loc_eng_data.adapter;
|
||||||
|
|
||||||
|
if (numberOfCerts == 0) {
|
||||||
|
LOC_LOGE("No certs to install, since numberOfCerts is zero");
|
||||||
|
ret_val = AGPS_CERTIFICATE_OPERATION_SUCCESS;
|
||||||
|
} else if (!adapter) {
|
||||||
|
LOC_LOGE("adapter is null!");
|
||||||
|
ret_val = AGPS_CERTIFICATE_ERROR_GENERIC;
|
||||||
|
} else if (slotCount < numberOfCerts) {
|
||||||
|
LOC_LOGE("Not enough cert slots (%u) to install %u certs!",
|
||||||
|
slotCount, numberOfCerts);
|
||||||
|
ret_val = AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES;
|
||||||
|
} else {
|
||||||
|
for (int i=0; i < numberOfCerts; ++i)
|
||||||
|
{
|
||||||
|
if (certificates[i].length > AGPS_CERTIFICATE_MAX_LENGTH) {
|
||||||
|
LOC_LOGE("cert#(%u) length of %u is too big! greater than %u",
|
||||||
|
certificates[i].length, AGPS_CERTIFICATE_MAX_LENGTH);
|
||||||
|
ret_val = AGPS_CERTIFICATE_ERROR_GENERIC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret_val == AGPS_CERTIFICATE_OPERATION_SUCCESS) {
|
||||||
|
adapter->sendMsg(new LocEngInstallAGpsCert(adapter,
|
||||||
|
certificates,
|
||||||
|
numberOfCerts,
|
||||||
|
slotBitMask));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EXIT_LOG(%d, ret_val);
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*===========================================================================
|
/*===========================================================================
|
||||||
FUNCTION loc_eng_report_status
|
FUNCTION loc_eng_report_status
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ typedef struct loc_gps_cfg_s
|
||||||
uint8_t NMEA_PROVIDER;
|
uint8_t NMEA_PROVIDER;
|
||||||
unsigned long A_GLONASS_POS_PROTOCOL_SELECT;
|
unsigned long A_GLONASS_POS_PROTOCOL_SELECT;
|
||||||
unsigned long XTRA_VERSION_CHECK;
|
unsigned long XTRA_VERSION_CHECK;
|
||||||
|
unsigned long AGPS_CERT_WRITABLE_MASK;
|
||||||
} loc_gps_cfg_s_type;
|
} loc_gps_cfg_s_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -210,9 +211,11 @@ int loc_eng_agps_open(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType,
|
||||||
const char* apn, AGpsBearerType bearerType);
|
const char* apn, AGpsBearerType bearerType);
|
||||||
int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
|
int loc_eng_agps_closed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
|
||||||
int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
|
int loc_eng_agps_open_failed(loc_eng_data_s_type &loc_eng_data, AGpsExtType agpsType);
|
||||||
|
|
||||||
void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
|
void loc_eng_agps_ril_update_network_availability(loc_eng_data_s_type &loc_eng_data,
|
||||||
int avaiable, const char* apn);
|
int avaiable, const char* apn);
|
||||||
|
int loc_eng_agps_install_certificates(loc_eng_data_s_type &loc_eng_data,
|
||||||
|
const DerEncodedCertificate* certificates,
|
||||||
|
size_t length);
|
||||||
|
|
||||||
//loc_eng_xtra functions
|
//loc_eng_xtra functions
|
||||||
int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
|
int loc_eng_xtra_init (loc_eng_data_s_type &loc_eng_data,
|
||||||
|
@ -231,6 +234,7 @@ extern void loc_eng_ni_request_handler(loc_eng_data_s_type &loc_eng_data,
|
||||||
const GpsNiNotification *notif,
|
const GpsNiNotification *notif,
|
||||||
const void* passThrough);
|
const void* passThrough);
|
||||||
extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
|
extern void loc_eng_ni_reset_on_engine_restart(loc_eng_data_s_type &loc_eng_data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
Loading…
Reference in a new issue