sm8450-common: gps: Add new NLP Session Status data item

Change-Id: Idf5b415fe232dbd098bdae392f40a50e0d11584b
CRs-Fixed: 3494806
This commit is contained in:
haohuang 2023-04-12 18:06:40 +08:00 committed by Arian
parent 31084d971e
commit 5e81e4bd4c
6 changed files with 79 additions and 0 deletions

View file

@ -1814,6 +1814,11 @@ bool SystemStatus::eventDataItemNotify(IDataItemCore* dataitem)
SystemStatusLocFeatureStatus( SystemStatusLocFeatureStatus(
*(static_cast<LocFeatureStatusDataItem*>(dataitem)))); *(static_cast<LocFeatureStatusDataItem*>(dataitem))));
break; break;
case NETWORK_POSITIONING_STARTED_DATA_ITEM_ID:
ret = setIteminReport(mCache.mNlpSessionStarted,
SystemStatusNlpSessionStarted(
*(static_cast<NlpSessionStartedDataItem*>(dataitem))));
break;
default: default:
break; break;
} }
@ -2056,5 +2061,18 @@ bool SystemStatus::eventLocFeatureStatus(std::unordered_set<int> fids) {
mSysStatusObsvr.notify({&s.mDataItem}); mSysStatusObsvr.notify({&s.mDataItem});
return true; return true;
} }
/******************************************************************************
@brief API to update network positioning session state
@param[In] session state
@return true when successfully done
******************************************************************************/
bool SystemStatus::eventNlpSessionStatus(bool nlpStarted) {
SystemStatusNlpSessionStarted s(nlpStarted);
mSysStatusObsvr.notify({&s.mDataItem});
return true;
}
} // namespace loc_core } // namespace loc_core

View file

@ -858,6 +858,22 @@ public:
LOC_LOGd("Location feature qwes status: %s", str.c_str()); LOC_LOGd("Location feature qwes status: %s", str.c_str());
} }
}; };
class SystemStatusNlpSessionStarted : public SystemStatusItemBase {
public:
NlpSessionStartedDataItem mDataItem;
inline SystemStatusNlpSessionStarted(bool value = false): mDataItem(value) {}
inline SystemStatusNlpSessionStarted(const NlpSessionStartedDataItem& itemBase):
mDataItem(itemBase) {}
inline bool equals(const SystemStatusItemBase& peer) override {
return mDataItem.mNlpStarted ==
((const SystemStatusNlpSessionStarted&)peer).mDataItem.mNlpStarted;
}
inline void dump(void) override {
LOC_LOGd("NLP Session started: %d", mDataItem.mNlpStarted);
}
};
/****************************************************************************** /******************************************************************************
SystemStatusReports SystemStatusReports
******************************************************************************/ ******************************************************************************/
@ -910,6 +926,7 @@ public:
std::vector<SystemStatusBtDeviceScanDetail> mBtDeviceScanDetail; std::vector<SystemStatusBtDeviceScanDetail> mBtDeviceScanDetail;
std::vector<SystemStatusBtleDeviceScanDetail> mBtLeDeviceScanDetail; std::vector<SystemStatusBtleDeviceScanDetail> mBtLeDeviceScanDetail;
std::vector<SystemStatusLocFeatureStatus> mLocFeatureStatus; std::vector<SystemStatusLocFeatureStatus> mLocFeatureStatus;
std::vector<SystemStatusNlpSessionStarted> mNlpSessionStarted;
}; };
/****************************************************************************** /******************************************************************************
@ -963,6 +980,7 @@ public:
bool eventInEmergencyCall(bool isEmergency); bool eventInEmergencyCall(bool isEmergency);
void setTracking(bool tracking); void setTracking(bool tracking);
bool eventLocFeatureStatus(std::unordered_set<int> fids); bool eventLocFeatureStatus(std::unordered_set<int> fids);
bool eventNlpSessionStatus(bool nlpStarted);
}; };
} // namespace loc_core } // namespace loc_core

View file

@ -128,6 +128,7 @@ SPDX-License-Identifier: BSD-3-Clause-Clear
#define BATTERYLEVEL_FIELD_BATTERY_PCT "BATTERY_PCT" #define BATTERYLEVEL_FIELD_BATTERY_PCT "BATTERY_PCT"
#define IN_EMERGENCY_CALL_FIELD_NAME "IS_EMERGENCY" #define IN_EMERGENCY_CALL_FIELD_NAME "IS_EMERGENCY"
#define NLP_STARTED_FIELD_NAME "NLP_SESSION_STARTED"
#define LOC_FEATURE_STATUS_FIELD_NAME "LOC_FEATURE_STATUS" #define LOC_FEATURE_STATUS_FIELD_NAME "LOC_FEATURE_STATUS"
namespace loc_core namespace loc_core
@ -991,4 +992,31 @@ int32_t LocFeatureStatusDataItem::copyFrom(IDataItemCore* src) {
return result; return result;
} }
void NlpSessionStartedDataItem::stringify(string& valueStr) {
int32_t result = 0;
ENTRY_LOG();
do {
STRINGIFY_ERROR_CHECK_AND_DOWN_CAST(
NlpSessionStartedDataItem, NETWORK_POSITIONING_STARTED_DATA_ITEM_ID);
valueStr.clear ();
valueStr += NLP_STARTED_FIELD_NAME;
valueStr += ": ";
valueStr += (d->mNlpStarted) ? ("true") : ("false");
} while (0);
EXIT_LOG_WITH_ERROR("%d", result);
}
int32_t NlpSessionStartedDataItem::copyFrom(IDataItemCore* src) {
int32_t result = -1;
ENTRY_LOG();
do {
COPIER_ERROR_CHECK_AND_DOWN_CAST(
NlpSessionStartedDataItem, NETWORK_POSITIONING_STARTED_DATA_ITEM_ID);
s->mNlpStarted = d->mNlpStarted;
result = 0;
} while (0);
EXIT_LOG("%d", result);
return result;
}
} //namespace loc_core } //namespace loc_core

View file

@ -662,6 +662,17 @@ class LocFeatureStatusDataItem: public IDataItemCore {
std::unordered_set<int> mFids; std::unordered_set<int> mFids;
}; };
class NlpSessionStartedDataItem: public IDataItemCore {
public:
NlpSessionStartedDataItem(bool nlpStarted = false) :
mNlpStarted(nlpStarted) {mId = NETWORK_POSITIONING_STARTED_DATA_ITEM_ID;}
virtual ~NlpSessionStartedDataItem() {}
virtual void stringify(string& /*valueStr*/) override;
virtual int32_t copyFrom(IDataItemCore* /*src*/) override;
// Data members
bool mNlpStarted;
};
} // namespace loc_core } // namespace loc_core
#endif //DATAITEM_CONCRETETYPES_H #endif //DATAITEM_CONCRETETYPES_H

View file

@ -74,6 +74,7 @@ typedef enum e_DataItemId {
BATTERY_LEVEL_DATA_ITEM_ID, BATTERY_LEVEL_DATA_ITEM_ID,
IN_EMERGENCY_CALL_DATA_ITEM_ID, IN_EMERGENCY_CALL_DATA_ITEM_ID,
LOC_FEATURE_STATUS_DATA_ITEM_ID, LOC_FEATURE_STATUS_DATA_ITEM_ID,
NETWORK_POSITIONING_STARTED_DATA_ITEM_ID,
MAX_DATA_ITEM_ID_1_1, MAX_DATA_ITEM_ID_1_1,
} DataItemId; } DataItemId;

View file

@ -119,6 +119,9 @@ IDataItemCore* DataItemsFactoryProxy::createNewDataItem(IDataItemCore* dataItem)
case LOC_FEATURE_STATUS_DATA_ITEM_ID: case LOC_FEATURE_STATUS_DATA_ITEM_ID:
mydi = new LocFeatureStatusDataItem(*((LocFeatureStatusDataItem*)dataItem)); mydi = new LocFeatureStatusDataItem(*((LocFeatureStatusDataItem*)dataItem));
break; break;
case NETWORK_POSITIONING_STARTED_DATA_ITEM_ID:
mydi = new NlpSessionStartedDataItem(*((NlpSessionStartedDataItem*)dataItem));
break;
case INVALID_DATA_ITEM_ID: case INVALID_DATA_ITEM_ID:
case MAX_DATA_ITEM_ID: case MAX_DATA_ITEM_ID:
default: default: