1 /* Copyright (c) 2015-2017, 2019, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation, nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __DATAITEMCONCRETEBASETYPES__ 31 #define __DATAITEMCONCRETEBASETYPES__ 32 33 #include <string> 34 #include <cstring> 35 #include <sstream> 36 #include <DataItemId.h> 37 #include <IDataItemCore.h> 38 #include <gps_extended_c.h> 39 #include <inttypes.h> 40 41 #define MAC_ADDRESS_LENGTH 6 42 // MAC address length in bytes 43 // QMI_LOC_SRN_MAC_ADDR_LENGTH_V02 44 #define SRN_MAC_ADDRESS_LENGTH 6 45 #define WIFI_SUPPLICANT_DEFAULT_STATE 0 46 47 static constexpr char sDelimit = ':'; 48 49 namespace loc_core 50 { 51 using namespace std; 52 53 enum NetworkType { 54 TYPE_MOBILE = 0, 55 TYPE_WIFI, 56 TYPE_ETHERNET, 57 TYPE_BLUETOOTH, 58 TYPE_MMS, 59 TYPE_SUPL, 60 TYPE_DUN, 61 TYPE_HIPRI, 62 TYPE_WIMAX, 63 TYPE_PROXY, 64 TYPE_UNKNOWN, 65 }; 66 67 typedef struct NetworkInfoType 68 { 69 // Unique network handle ID 70 uint64_t networkHandle; 71 // Type of network for corresponding network handle 72 NetworkType networkType; NetworkInfoTypeNetworkInfoType73 NetworkInfoType() : networkHandle(NETWORK_HANDLE_UNKNOWN), networkType(TYPE_UNKNOWN) {} NetworkInfoTypeNetworkInfoType74 NetworkInfoType(string strObj) { 75 size_t posDelimit = strObj.find(sDelimit); 76 77 if ( posDelimit != string::npos) { 78 int32_t type = TYPE_UNKNOWN; 79 string handleStr = strObj.substr(0, posDelimit); 80 string typeStr = strObj.substr(posDelimit + 1, strObj.length() - posDelimit - 1); 81 stringstream(handleStr) >> networkHandle; 82 stringstream(typeStr) >> type; 83 networkType = (NetworkType) type; 84 } else { 85 networkHandle = NETWORK_HANDLE_UNKNOWN; 86 networkType = TYPE_UNKNOWN; 87 } 88 } 89 bool operator== (const NetworkInfoType& other) { 90 return ((networkHandle == other.networkHandle) && (networkType == other.networkType)); 91 } toStringNetworkInfoType92 string toString() { 93 string valueStr; 94 valueStr.clear (); 95 char nethandle [32]; 96 memset (nethandle, 0, 32); 97 snprintf(nethandle, sizeof(nethandle), "%" PRIu64, networkHandle); 98 valueStr += string(nethandle); 99 valueStr += sDelimit; 100 char type [12]; 101 memset (type, 0, 12); 102 snprintf (type, 12, "%u", networkType); 103 valueStr += string (type); 104 return valueStr; 105 } 106 } NetworkInfoType; 107 108 109 class AirplaneModeDataItemBase : public IDataItemCore { 110 public: AirplaneModeDataItemBase(bool mode)111 AirplaneModeDataItemBase(bool mode): 112 mMode(mode), 113 mId(AIRPLANEMODE_DATA_ITEM_ID) {} ~AirplaneModeDataItemBase()114 virtual ~AirplaneModeDataItemBase() {} getId()115 inline virtual DataItemId getId() { return mId; } stringify(string &)116 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)117 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 118 // Data members 119 bool mMode; 120 121 protected: 122 DataItemId mId; 123 }; 124 125 class ENHDataItemBase : public IDataItemCore { 126 public: ENHDataItemBase(bool enabled)127 ENHDataItemBase(bool enabled) : 128 mEnabled(enabled), 129 mId(ENH_DATA_ITEM_ID) {} ~ENHDataItemBase()130 virtual ~ENHDataItemBase() {} getId()131 inline virtual DataItemId getId() { return mId; } stringify(string &)132 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)133 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 134 // Data members 135 bool mEnabled; 136 protected: 137 DataItemId mId; 138 }; 139 140 class GPSStateDataItemBase : public IDataItemCore { 141 public: GPSStateDataItemBase(bool enabled)142 GPSStateDataItemBase(bool enabled) : 143 mEnabled(enabled), 144 mId(GPSSTATE_DATA_ITEM_ID) {} ~GPSStateDataItemBase()145 virtual ~GPSStateDataItemBase() {} getId()146 inline virtual DataItemId getId() { return mId; } stringify(string &)147 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)148 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 149 // Data members 150 bool mEnabled; 151 protected: 152 DataItemId mId; 153 }; 154 155 class NLPStatusDataItemBase : public IDataItemCore { 156 public: NLPStatusDataItemBase(bool enabled)157 NLPStatusDataItemBase(bool enabled) : 158 mEnabled(enabled), 159 mId(NLPSTATUS_DATA_ITEM_ID) {} ~NLPStatusDataItemBase()160 virtual ~NLPStatusDataItemBase() {} getId()161 inline virtual DataItemId getId() { return mId; } stringify(string &)162 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)163 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 164 // Data members 165 bool mEnabled; 166 protected: 167 DataItemId mId; 168 }; 169 170 class WifiHardwareStateDataItemBase : public IDataItemCore { 171 public: WifiHardwareStateDataItemBase(bool enabled)172 WifiHardwareStateDataItemBase(bool enabled) : 173 mEnabled(enabled), 174 mId(WIFIHARDWARESTATE_DATA_ITEM_ID) {} ~WifiHardwareStateDataItemBase()175 virtual ~WifiHardwareStateDataItemBase() {} getId()176 inline virtual DataItemId getId() { return mId; } stringify(string &)177 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)178 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 179 // Data members 180 bool mEnabled; 181 protected: 182 DataItemId mId; 183 }; 184 185 class ScreenStateDataItemBase : public IDataItemCore { 186 public: ScreenStateDataItemBase(bool state)187 ScreenStateDataItemBase(bool state) : 188 mState(state), 189 mId(SCREEN_STATE_DATA_ITEM_ID) {} ~ScreenStateDataItemBase()190 virtual ~ScreenStateDataItemBase() {} getId()191 inline virtual DataItemId getId() { return mId; } stringify(string &)192 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)193 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 194 // Data members 195 bool mState; 196 protected: 197 DataItemId mId; 198 }; 199 200 class PowerConnectStateDataItemBase : public IDataItemCore { 201 public: PowerConnectStateDataItemBase(bool state)202 PowerConnectStateDataItemBase(bool state) : 203 mState(state), 204 mId(POWER_CONNECTED_STATE_DATA_ITEM_ID) {} ~PowerConnectStateDataItemBase()205 virtual ~PowerConnectStateDataItemBase() {} getId()206 inline virtual DataItemId getId() { return mId; } stringify(string &)207 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)208 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 209 // Data members 210 bool mState; 211 protected: 212 DataItemId mId; 213 }; 214 215 class TimeZoneChangeDataItemBase : public IDataItemCore { 216 public: TimeZoneChangeDataItemBase(int64_t currTimeMillis,int32_t rawOffset,int32_t dstOffset)217 TimeZoneChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) : 218 mCurrTimeMillis (currTimeMillis), 219 mRawOffsetTZ (rawOffset), 220 mDstOffsetTZ (dstOffset), 221 mId(TIMEZONE_CHANGE_DATA_ITEM_ID) {} ~TimeZoneChangeDataItemBase()222 virtual ~TimeZoneChangeDataItemBase() {} getId()223 inline virtual DataItemId getId() { return mId; } stringify(string &)224 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)225 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 226 // Data members 227 int64_t mCurrTimeMillis; 228 int32_t mRawOffsetTZ; 229 int32_t mDstOffsetTZ; 230 protected: 231 DataItemId mId; 232 }; 233 234 class TimeChangeDataItemBase : public IDataItemCore { 235 public: TimeChangeDataItemBase(int64_t currTimeMillis,int32_t rawOffset,int32_t dstOffset)236 TimeChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) : 237 mCurrTimeMillis (currTimeMillis), 238 mRawOffsetTZ (rawOffset), 239 mDstOffsetTZ (dstOffset), 240 mId(TIME_CHANGE_DATA_ITEM_ID) {} ~TimeChangeDataItemBase()241 virtual ~TimeChangeDataItemBase() {} getId()242 inline virtual DataItemId getId() { return mId; } stringify(string &)243 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)244 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 245 // Data members 246 int64_t mCurrTimeMillis; 247 int32_t mRawOffsetTZ; 248 int32_t mDstOffsetTZ; 249 protected: 250 DataItemId mId; 251 }; 252 253 class ShutdownStateDataItemBase : public IDataItemCore { 254 public: ShutdownStateDataItemBase(bool state)255 ShutdownStateDataItemBase(bool state) : 256 mState (state), 257 mId(SHUTDOWN_STATE_DATA_ITEM_ID) {} ~ShutdownStateDataItemBase()258 virtual ~ShutdownStateDataItemBase() {} getId()259 inline virtual DataItemId getId() { return mId; } stringify(string &)260 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)261 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 262 // Data members 263 bool mState; 264 protected: 265 DataItemId mId; 266 }; 267 268 class AssistedGpsDataItemBase : public IDataItemCore { 269 public: AssistedGpsDataItemBase(bool enabled)270 AssistedGpsDataItemBase(bool enabled) : 271 mEnabled(enabled), 272 mId(ASSISTED_GPS_DATA_ITEM_ID) {} ~AssistedGpsDataItemBase()273 virtual ~AssistedGpsDataItemBase() {} getId()274 inline virtual DataItemId getId() { return mId; } stringify(string &)275 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)276 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 277 // Data members 278 bool mEnabled; 279 protected: 280 DataItemId mId; 281 }; 282 283 class NetworkInfoDataItemBase : public IDataItemCore { 284 public: NetworkInfoDataItemBase(NetworkType initialType,int32_t type,string typeName,string subTypeName,bool available,bool connected,bool roaming,uint64_t networkHandle)285 NetworkInfoDataItemBase( 286 NetworkType initialType, int32_t type, string typeName, string subTypeName, 287 bool available, bool connected, bool roaming, uint64_t networkHandle ): 288 mAllTypes(typeToAllTypes(initialType)), 289 mType(type), 290 mTypeName(typeName), 291 mSubTypeName(subTypeName), 292 mAvailable(available), 293 mConnected(connected), 294 mRoaming(roaming), 295 mNetworkHandle(networkHandle), 296 mId(NETWORKINFO_DATA_ITEM_ID) { 297 mAllNetworkHandles[0].networkHandle = networkHandle; 298 mAllNetworkHandles[0].networkType = initialType; 299 } ~NetworkInfoDataItemBase()300 virtual ~NetworkInfoDataItemBase() {} getId()301 inline virtual DataItemId getId() { return mId; } stringify(string &)302 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)303 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} getType(void)304 inline virtual NetworkType getType(void) const { 305 return (NetworkType)mType; 306 } getAllTypes()307 inline uint64_t getAllTypes() { return mAllTypes; } getNetworkHandle()308 inline NetworkInfoType* getNetworkHandle() { 309 return &mAllNetworkHandles[0]; 310 } 311 // Data members 312 uint64_t mAllTypes; 313 int32_t mType; 314 string mTypeName; 315 string mSubTypeName; 316 bool mAvailable; 317 bool mConnected; 318 bool mRoaming; 319 NetworkInfoType mAllNetworkHandles[MAX_NETWORK_HANDLES]; 320 uint64_t mNetworkHandle; 321 protected: 322 DataItemId mId; typeToAllTypes(NetworkType type)323 inline uint64_t typeToAllTypes(NetworkType type) { 324 return (type >= TYPE_UNKNOWN || type < TYPE_MOBILE) ? 0 : (1<<type); 325 } 326 }; 327 328 class ServiceStatusDataItemBase : public IDataItemCore { 329 public: ServiceStatusDataItemBase(int32_t serviceState)330 ServiceStatusDataItemBase(int32_t serviceState) : 331 mServiceState (serviceState), 332 mId(SERVICESTATUS_DATA_ITEM_ID) {} ~ServiceStatusDataItemBase()333 virtual ~ServiceStatusDataItemBase() {} getId()334 inline virtual DataItemId getId() { return mId; } stringify(string &)335 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)336 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 337 // Data members 338 int32_t mServiceState; 339 protected: 340 DataItemId mId; 341 }; 342 343 class ModelDataItemBase : public IDataItemCore { 344 public: ModelDataItemBase(const string & name)345 ModelDataItemBase(const string & name) : 346 mModel (name), 347 mId(MODEL_DATA_ITEM_ID) {} ~ModelDataItemBase()348 virtual ~ModelDataItemBase() {} getId()349 inline virtual DataItemId getId() { return mId; } stringify(string &)350 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)351 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 352 // Data members 353 string mModel; 354 protected: 355 DataItemId mId; 356 }; 357 358 class ManufacturerDataItemBase : public IDataItemCore { 359 public: ManufacturerDataItemBase(const string & name)360 ManufacturerDataItemBase(const string & name) : 361 mManufacturer (name), 362 mId(MANUFACTURER_DATA_ITEM_ID) {} ~ManufacturerDataItemBase()363 virtual ~ManufacturerDataItemBase() {} getId()364 inline virtual DataItemId getId() { return mId; } stringify(string &)365 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)366 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 367 // Data members 368 string mManufacturer; 369 protected: 370 DataItemId mId; 371 }; 372 373 class RilServiceInfoDataItemBase : public IDataItemCore { 374 public: RilServiceInfoDataItemBase()375 inline RilServiceInfoDataItemBase() : 376 mData(nullptr), mId(RILSERVICEINFO_DATA_ITEM_ID) {} ~RilServiceInfoDataItemBase()377 inline virtual ~RilServiceInfoDataItemBase() { if (nullptr != mData) free(mData); } getId()378 inline virtual DataItemId getId() { return mId; } stringify(string &)379 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)380 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} RilServiceInfoDataItemBase(const RilServiceInfoDataItemBase & peer)381 inline RilServiceInfoDataItemBase(const RilServiceInfoDataItemBase& peer) : 382 RilServiceInfoDataItemBase() { 383 peer.setPeerData(*this); 384 } 385 inline virtual bool operator==(const RilServiceInfoDataItemBase& other) const { 386 return other.mData == mData; 387 } setPeerData(RilServiceInfoDataItemBase &)388 inline virtual void setPeerData(RilServiceInfoDataItemBase& /*peer*/) const {} 389 void* mData; 390 protected: 391 DataItemId mId; 392 }; 393 394 class RilCellInfoDataItemBase : public IDataItemCore { 395 public: RilCellInfoDataItemBase()396 inline RilCellInfoDataItemBase() : 397 mData(nullptr), mId(RILCELLINFO_DATA_ITEM_ID) {} ~RilCellInfoDataItemBase()398 inline virtual ~RilCellInfoDataItemBase() { if (nullptr != mData) free(mData); } getId()399 inline virtual DataItemId getId() { return mId; } stringify(string &)400 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)401 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} RilCellInfoDataItemBase(const RilCellInfoDataItemBase & peer)402 inline RilCellInfoDataItemBase(const RilCellInfoDataItemBase& peer) : 403 RilCellInfoDataItemBase() { 404 peer.setPeerData(*this); 405 } 406 inline virtual bool operator==(const RilCellInfoDataItemBase& other) const { 407 return other.mData == mData; 408 } setPeerData(RilCellInfoDataItemBase &)409 inline virtual void setPeerData(RilCellInfoDataItemBase& /*peer*/) const {} 410 void* mData; 411 protected: 412 DataItemId mId; 413 }; 414 415 class WifiSupplicantStatusDataItemBase : public IDataItemCore { 416 public: WifiSupplicantStatusDataItemBase()417 WifiSupplicantStatusDataItemBase() : 418 mState((WifiSupplicantState)WIFI_SUPPLICANT_DEFAULT_STATE), 419 mApMacAddressValid(false), 420 mWifiApSsidValid(false), 421 mId(WIFI_SUPPLICANT_STATUS_DATA_ITEM_ID) { 422 memset (&mApMacAddress, 0, sizeof (mApMacAddress)); 423 mWifiApSsid.clear(); 424 } ~WifiSupplicantStatusDataItemBase()425 virtual ~WifiSupplicantStatusDataItemBase() {} getId()426 inline virtual DataItemId getId() { return mId; } stringify(string &)427 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)428 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 429 // Data members 430 typedef enum WifiSupplicantState { 431 DISCONNECTED, 432 INTERFACE_DISABLED, 433 INACTIVE, 434 SCANNING, 435 AUTHENTICATING, 436 ASSOCIATING, 437 ASSOCIATED, 438 FOUR_WAY_HANDSHAKE, 439 GROUP_HANDSHAKE, 440 COMPLETED, 441 DORMANT, 442 UNINITIALIZED, 443 INVALID 444 } WifiSupplicantState; 445 /* Represents whether access point attach state*/ 446 WifiSupplicantState mState; 447 /* Represents info on whether ap mac address is valid */ 448 bool mApMacAddressValid; 449 /* Represents mac address of the wifi access point*/ 450 uint8_t mApMacAddress[MAC_ADDRESS_LENGTH]; 451 /* Represents info on whether ap SSID is valid */ 452 bool mWifiApSsidValid; 453 /* Represents Wifi SSID string*/ 454 string mWifiApSsid; 455 protected: 456 DataItemId mId; 457 }; 458 459 class TacDataItemBase : public IDataItemCore { 460 public: TacDataItemBase(const string & name)461 TacDataItemBase(const string & name) : 462 mValue (name), 463 mId(TAC_DATA_ITEM_ID) {} ~TacDataItemBase()464 virtual ~TacDataItemBase() {} getId()465 inline virtual DataItemId getId() { return mId; } stringify(string &)466 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)467 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 468 // Data members 469 string mValue; 470 protected: 471 DataItemId mId; 472 }; 473 474 class MccmncDataItemBase : public IDataItemCore { 475 public: MccmncDataItemBase(const string & name)476 MccmncDataItemBase(const string & name) : 477 mValue(name), 478 mId(MCCMNC_DATA_ITEM_ID) {} ~MccmncDataItemBase()479 virtual ~MccmncDataItemBase() {} getId()480 inline virtual DataItemId getId() { return mId; } stringify(string &)481 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)482 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 483 // Data members 484 string mValue; 485 protected: 486 DataItemId mId; 487 }; 488 489 class SrnDeviceScanDetailsDataItemBase : public IDataItemCore { 490 public: SrnDeviceScanDetailsDataItemBase(DataItemId Id)491 SrnDeviceScanDetailsDataItemBase(DataItemId Id) : 492 mValidSrnData(false), 493 mApSrnRssi(-1), 494 mApSrnTimestamp(0), 495 mRequestTimestamp(0), 496 mReceiveTimestamp(0), 497 mErrorCause(-1), 498 mId(Id) {} ~SrnDeviceScanDetailsDataItemBase()499 virtual ~SrnDeviceScanDetailsDataItemBase() {} getId()500 inline virtual DataItemId getId() { return mId; } 501 // Data members common to all SRN tech types 502 /* Represents info on whether SRN data is valid (no error)*/ 503 bool mValidSrnData; 504 /* SRN device RSSI reported */ 505 int32_t mApSrnRssi; 506 /* MAC adress of SRN device */ 507 uint8_t mApSrnMacAddress[SRN_MAC_ADDRESS_LENGTH]; 508 /* UTC timestamp at which the scan was requested.for this SRN device*/ 509 int64_t mApSrnTimestamp; 510 /* UTC timestamp at which the scan was started. */ 511 int64_t mRequestTimestamp; 512 /* UTC timestamp at which the scan was received.*/ 513 int64_t mReceiveTimestamp; 514 /* Reason for the error/failure if SRN details are not valid */ 515 int32_t mErrorCause; 516 protected: 517 DataItemId mId; 518 }; 519 520 class BtDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase { 521 522 public: BtDeviceScanDetailsDataItemBase()523 BtDeviceScanDetailsDataItemBase() : 524 SrnDeviceScanDetailsDataItemBase(BT_SCAN_DATA_ITEM_ID) {} ~BtDeviceScanDetailsDataItemBase()525 virtual ~BtDeviceScanDetailsDataItemBase() {} stringify(string &)526 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)527 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 528 }; 529 530 class BtLeDeviceScanDetailsDataItemBase : public SrnDeviceScanDetailsDataItemBase { 531 532 public: BtLeDeviceScanDetailsDataItemBase()533 BtLeDeviceScanDetailsDataItemBase() : 534 SrnDeviceScanDetailsDataItemBase(BTLE_SCAN_DATA_ITEM_ID) {} ~BtLeDeviceScanDetailsDataItemBase()535 virtual ~BtLeDeviceScanDetailsDataItemBase() {} stringify(string &)536 virtual void stringify(string& /*valueStr*/) {} copy(IDataItemCore *,bool *)537 virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} 538 }; 539 540 class BatteryLevelDataItemBase : public IDataItemCore { 541 public: BatteryLevelDataItemBase(uint8_t batteryPct)542 inline BatteryLevelDataItemBase(uint8_t batteryPct) : 543 mBatteryPct(batteryPct), mId(BATTERY_LEVEL_DATA_ITEM_ID) {} ~BatteryLevelDataItemBase()544 inline ~BatteryLevelDataItemBase() {} getId()545 inline virtual DataItemId getId() { return mId; } 546 // Data members 547 uint8_t mBatteryPct; 548 protected: 549 DataItemId mId; 550 }; 551 552 } // namespace loc_core 553 554 #endif //__DATAITEMCONCRETEBASETYPES__ 555