Add HAL support for network handle

Add HAL support for modifications to the
network status information passed in.

Change-Id: I99defc6a419d9f21ce74469a1aa016cc7fade4a5
CRs-Fixed: 2397433
This commit is contained in:
Kevin Tang 2019-03-26 18:40:03 -07:00
parent 01869b4004
commit 546e88fc04
9 changed files with 75 additions and 25 deletions

View file

@ -102,7 +102,7 @@ Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool
} }
break; break;
} }
mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout); mGnss->getGnssInterface()->updateConnectionStatus(connected, false, typeout, 0);
} }
return true; return true;
} }
@ -111,12 +111,17 @@ Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttr
if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) { if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) {
int8_t typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN; int8_t typeout = loc_core::NetworkInfoDataItemBase::TYPE_UNKNOWN;
bool roaming = false;
if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) { if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) {
typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI; typeout = loc_core::NetworkInfoDataItemBase::TYPE_WIFI;
} else { } else {
typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE; typeout = loc_core::NetworkInfoDataItemBase::TYPE_MOBILE;
} }
mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected, typeout); if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) {
roaming = false;
}
mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected,
typeout, roaming, (NetworkHandle) attributes.networkHandle);
} }
return true; return true;
} }

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017, 2019, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -1682,10 +1682,12 @@ bool SystemStatus::setDefaultGnssEngineStates(void)
@return true when successfully done @return true when successfully done
******************************************************************************/ ******************************************************************************/
bool SystemStatus::eventConnectionStatus(bool connected, int8_t type) bool SystemStatus::eventConnectionStatus(bool connected, int8_t type,
bool roaming, NetworkHandle networkHandle)
{ {
// send networkinof dataitem to systemstatus observer clients // send networkinof dataitem to systemstatus observer clients
SystemStatusNetworkInfo s(type, "", "", connected); SystemStatusNetworkInfo s(type, "", "", connected, roaming,
(uint64_t) networkHandle);
mSysStatusObsvr.notify({&s}); mSysStatusObsvr.notify({&s});
return true; return true;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -32,6 +32,8 @@
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #include <sys/time.h>
#include <vector> #include <vector>
#include <algorithm>
#include <iterator>
#include <loc_pla.h> #include <loc_pla.h>
#include <log_util.h> #include <log_util.h>
#include <MsgTask.h> #include <MsgTask.h>
@ -467,7 +469,8 @@ public:
std::string typeName="", std::string typeName="",
string subTypeName="", string subTypeName="",
bool connected=false, bool connected=false,
bool roaming=false) : bool roaming=false,
uint64_t networkHandle=NETWORK_HANDLE_UNKNOWN) :
NetworkInfoDataItemBase( NetworkInfoDataItemBase(
(NetworkType)type, (NetworkType)type,
type, type,
@ -475,7 +478,8 @@ public:
subTypeName, subTypeName,
connected && (!roaming), connected && (!roaming),
connected, connected,
roaming), roaming,
networkHandle),
mSrcObjPtr(nullptr) {} mSrcObjPtr(nullptr) {}
inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) : inline SystemStatusNetworkInfo(const NetworkInfoDataItemBase& itemBase) :
NetworkInfoDataItemBase(itemBase), NetworkInfoDataItemBase(itemBase),
@ -487,16 +491,24 @@ public:
} }
inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) { inline virtual SystemStatusItemBase& collate(SystemStatusItemBase& curInfo) {
uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes; uint64_t allTypes = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mAllTypes;
uint64_t networkHandle =
(static_cast<SystemStatusNetworkInfo&>(curInfo)).mNetworkHandle;
int32_t type = (static_cast<SystemStatusNetworkInfo&>(curInfo)).mType;
if (mConnected) { if (mConnected) {
mAllTypes |= allTypes; mAllTypes |= allTypes;
mAllNetworkHandles[type] = networkHandle;
} else if (0 != mAllTypes) { } else if (0 != mAllTypes) {
mAllTypes = (allTypes & (~mAllTypes)); mAllTypes = (allTypes & (~mAllTypes));
mAllNetworkHandles[type] = NETWORK_HANDLE_UNKNOWN;
} // else (mConnected == false && mAllTypes == 0) } // else (mConnected == false && mAllTypes == 0)
// we keep mAllTypes as 0, which means no more connections. // we keep mAllTypes as 0, which means no more connections.
if (nullptr != mSrcObjPtr) { if (nullptr != mSrcObjPtr) {
// this is critical, changing mAllTypes of the original obj // this is critical, changing mAllTypes of the original obj
mSrcObjPtr->mAllTypes = mAllTypes; mSrcObjPtr->mAllTypes = mAllTypes;
memcpy(mSrcObjPtr->mAllNetworkHandles,
mAllNetworkHandles,
sizeof(mSrcObjPtr->mAllNetworkHandles));
} }
return *this; return *this;
} }
@ -830,7 +842,8 @@ public:
bool setNmeaString(const char *data, uint32_t len); bool setNmeaString(const char *data, uint32_t len);
bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const; bool getReport(SystemStatusReports& reports, bool isLatestonly = false) const;
bool setDefaultGnssEngineStates(void); bool setDefaultGnssEngineStates(void);
bool eventConnectionStatus(bool connected, int8_t type); bool eventConnectionStatus(bool connected, int8_t type,
bool roaming, NetworkHandle networkHandle);
}; };
} // namespace loc_core } // namespace loc_core

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2017, 2019, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -34,6 +34,7 @@
#include <cstring> #include <cstring>
#include <DataItemId.h> #include <DataItemId.h>
#include <IDataItemCore.h> #include <IDataItemCore.h>
#include <gps_extended_c.h>
#define MAC_ADDRESS_LENGTH 6 #define MAC_ADDRESS_LENGTH 6
// MAC address length in bytes // MAC address length in bytes
@ -222,7 +223,7 @@ protected:
class NetworkInfoDataItemBase : public IDataItemCore { class NetworkInfoDataItemBase : public IDataItemCore {
public: public:
enum NetworkType { enum NetworkType {
TYPE_MOBILE, TYPE_MOBILE = 0,
TYPE_WIFI, TYPE_WIFI,
TYPE_ETHERNET, TYPE_ETHERNET,
TYPE_BLUETOOTH, TYPE_BLUETOOTH,
@ -236,7 +237,7 @@ public:
}; };
NetworkInfoDataItemBase( NetworkInfoDataItemBase(
NetworkType initialType, int32_t type, string typeName, string subTypeName, NetworkType initialType, int32_t type, string typeName, string subTypeName,
bool available, bool connected, bool roaming ): bool available, bool connected, bool roaming, uint64_t networkHandle ):
mAllTypes(typeToAllTypes(initialType)), mAllTypes(typeToAllTypes(initialType)),
mType(type), mType(type),
mTypeName(typeName), mTypeName(typeName),
@ -244,7 +245,12 @@ public:
mAvailable(available), mAvailable(available),
mConnected(connected), mConnected(connected),
mRoaming(roaming), mRoaming(roaming),
mId(NETWORKINFO_DATA_ITEM_ID) {} mNetworkHandle(networkHandle),
mId(NETWORKINFO_DATA_ITEM_ID) {
memset (&mAllNetworkHandles, NETWORK_HANDLE_UNKNOWN,
sizeof (mAllNetworkHandles));
mAllNetworkHandles[type] = networkHandle;
}
virtual ~NetworkInfoDataItemBase() {} virtual ~NetworkInfoDataItemBase() {}
inline virtual DataItemId getId() { return mId; } inline virtual DataItemId getId() { return mId; }
virtual void stringify(string& /*valueStr*/) {} virtual void stringify(string& /*valueStr*/) {}
@ -253,6 +259,9 @@ public:
return (NetworkType)mType; return (NetworkType)mType;
} }
inline uint64_t getAllTypes() { return mAllTypes; } inline uint64_t getAllTypes() { return mAllTypes; }
inline uint64_t getNetworkHandle(NetworkType type) {
return mAllNetworkHandles[type];
}
// Data members // Data members
uint64_t mAllTypes; uint64_t mAllTypes;
int32_t mType; int32_t mType;
@ -261,6 +270,8 @@ public:
bool mAvailable; bool mAvailable;
bool mConnected; bool mConnected;
bool mRoaming; bool mRoaming;
uint64_t mAllNetworkHandles[TYPE_UNKNOWN + 1];
uint64_t mNetworkHandle;
protected: protected:
DataItemId mId; DataItemId mId;
inline uint64_t typeToAllTypes(NetworkType type) { inline uint64_t typeToAllTypes(NetworkType type) {

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017, 2019, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -69,17 +69,21 @@ bool XtraSystemStatusObserver::updateLockStatus(GnssConfigGpsLock lock) {
return ( send(LOC_IPC_XTRA, ss.str()) ); return ( send(LOC_IPC_XTRA, ss.str()) );
} }
bool XtraSystemStatusObserver::updateConnections(uint64_t allConnections) { bool XtraSystemStatusObserver::updateConnections(uint64_t allConnections,
uint64_t wifiNetworkHandle, uint64_t mobileNetworkHandle) {
mIsConnectivityStatusKnown = true; mIsConnectivityStatusKnown = true;
mConnections = allConnections; mConnections = allConnections;
mWifiNetworkHandle = wifiNetworkHandle;
mMobileNetworkHandle = mobileNetworkHandle;
if (!mReqStatusReceived) { if (!mReqStatusReceived) {
return true; return true;
} }
stringstream ss; stringstream ss;
ss << "connection"; ss << "connection" << endl << mConnections << endl << wifiNetworkHandle
ss << " " << mConnections; << endl << mobileNetworkHandle;
return ( send(LOC_IPC_XTRA, ss.str()) ); return ( send(LOC_IPC_XTRA, ss.str()) );
} }
@ -134,6 +138,7 @@ inline bool XtraSystemStatusObserver::onStatusRequested(int32_t xtraStatusUpdate
ss << "respondStatus" << endl; ss << "respondStatus" << endl;
(mGpsLock == -1 ? ss : ss << mGpsLock) << endl; (mGpsLock == -1 ? ss : ss << mGpsLock) << endl;
(mConnections == (uint64_t)~0 ? ss : ss << mConnections) << endl (mConnections == (uint64_t)~0 ? ss : ss << mConnections) << endl
<< mWifiNetworkHandle << endl << mMobileNetworkHandle << endl
<< mTac << endl << mMccmnc << endl << mIsConnectivityStatusKnown; << mTac << endl << mMccmnc << endl << mIsConnectivityStatusKnown;
return ( send(LOC_IPC_XTRA, ss.str()) ); return ( send(LOC_IPC_XTRA, ss.str()) );
@ -235,7 +240,11 @@ void XtraSystemStatusObserver::notify(const list<IDataItemCore*>& dlist)
{ {
NetworkInfoDataItemBase* networkInfo = NetworkInfoDataItemBase* networkInfo =
static_cast<NetworkInfoDataItemBase*>(each); static_cast<NetworkInfoDataItemBase*>(each);
mXtraSysStatObj->updateConnections(networkInfo->getAllTypes()); mXtraSysStatObj->updateConnections(networkInfo->getAllTypes(),
(NetworkHandle) networkInfo->getNetworkHandle(
loc_core::NetworkInfoDataItemBase::TYPE_WIFI),
(NetworkHandle) networkInfo->getNetworkHandle(
loc_core::NetworkInfoDataItemBase::TYPE_MOBILE));
} }
break; break;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -61,7 +61,8 @@ public :
virtual void notify(const list<IDataItemCore*>& dlist); virtual void notify(const list<IDataItemCore*>& dlist);
bool updateLockStatus(GnssConfigGpsLock lock); bool updateLockStatus(GnssConfigGpsLock lock);
bool updateConnections(uint64_t allConnections); bool updateConnections(uint64_t allConnections,
uint64_t wifiNetworkHandle, uint64_t mobileNetworkHandle);
bool updateTac(const string& tac); bool updateTac(const string& tac);
bool updateMccMnc(const string& mccmnc); bool updateMccMnc(const string& mccmnc);
bool updateXtraThrottle(const bool enabled); bool updateXtraThrottle(const bool enabled);
@ -76,6 +77,8 @@ private:
const MsgTask* mMsgTask; const MsgTask* mMsgTask;
GnssConfigGpsLock mGpsLock; GnssConfigGpsLock mGpsLock;
uint64_t mConnections; uint64_t mConnections;
uint64_t mWifiNetworkHandle;
uint64_t mMobileNetworkHandle;
string mTac; string mTac;
string mMccmnc; string mMccmnc;
bool mXtraThrottle; bool mXtraThrottle;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2017, 2019 The Linux Foundation. All rights reserved. /* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
@ -65,7 +65,8 @@ static void agpsDataConnOpen(AGpsExtType agpsType, const char* apnName, int apnL
static void agpsDataConnClosed(AGpsExtType agpsType); static void agpsDataConnClosed(AGpsExtType agpsType);
static void agpsDataConnFailed(AGpsExtType agpsType); static void agpsDataConnFailed(AGpsExtType agpsType);
static void getDebugReport(GnssDebugReport& report); static void getDebugReport(GnssDebugReport& report);
static void updateConnectionStatus(bool connected, int8_t type); static void updateConnectionStatus(bool connected, int8_t type, bool roaming = false,
NetworkHandle networkHandle = NETWORK_HANDLE_UNKNOWN);
static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb); static void getGnssEnergyConsumed(GnssEnergyConsumedCallback energyConsumedCb);
static void enableNfwLocationAccess(bool enable); static void enableNfwLocationAccess(bool enable);
static void nfwInit(const NfwCbInfo& cbInfo); static void nfwInit(const NfwCbInfo& cbInfo);
@ -319,9 +320,11 @@ static void getDebugReport(GnssDebugReport& report) {
} }
} }
static void updateConnectionStatus(bool connected, int8_t type) { static void updateConnectionStatus(bool connected, int8_t type,
bool roaming, NetworkHandle networkHandle) {
if (NULL != gGnssAdapter) { if (NULL != gGnssAdapter) {
gGnssAdapter->getSystemStatus()->eventConnectionStatus(connected, type); gGnssAdapter->getSystemStatus()->eventConnectionStatus(
connected, type, roaming, networkHandle);
} }
} }

View file

@ -76,7 +76,8 @@ struct GnssInterface {
void (*agpsDataConnClosed)(AGpsExtType agpsType); void (*agpsDataConnClosed)(AGpsExtType agpsType);
void (*agpsDataConnFailed)(AGpsExtType agpsType); void (*agpsDataConnFailed)(AGpsExtType agpsType);
void (*getDebugReport)(GnssDebugReport& report); void (*getDebugReport)(GnssDebugReport& report);
void (*updateConnectionStatus)(bool connected, int8_t type); void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming,
NetworkHandle networkHandle);
void (*odcpiInit)(const OdcpiRequestCallback& callback); void (*odcpiInit)(const OdcpiRequestCallback& callback);
void (*odcpiInject)(const Location& location); void (*odcpiInject)(const Location& location);
void (*blockCPI)(double latitude, double longitude, float accuracy, void (*blockCPI)(double latitude, double longitude, float accuracy,

View file

@ -2134,6 +2134,9 @@ typedef void (*LocAgpsCloseResultCb)(bool isSuccess, AGpsExtType agpsType, void*
#define SOCKET_TO_LOCATION_CLIENT_BASE "/dev/socket/loc_client/toclient" #define SOCKET_TO_LOCATION_CLIENT_BASE "/dev/socket/loc_client/toclient"
#define SOCKET_TO_EXTERANL_AP_LOCATION_CLIENT_BASE "/dev/socket/loc_client/extap.toclient" #define SOCKET_TO_EXTERANL_AP_LOCATION_CLIENT_BASE "/dev/socket/loc_client/extap.toclient"
typedef uint64_t NetworkHandle;
#define NETWORK_HANDLE_UNKNOWN ~0
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */