/* Copyright (c) 2015-2017, 2019, 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 * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of The Linux Foundation, nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #ifndef __DATAITEMCONCRETEBASETYPES__ #define __DATAITEMCONCRETEBASETYPES__ #include #include #include #include #include #define MAC_ADDRESS_LENGTH 6 // MAC address length in bytes // QMI_LOC_SRN_MAC_ADDR_LENGTH_V02 #define SRN_MAC_ADDRESS_LENGTH 6 #define WIFI_SUPPLICANT_DEFAULT_STATE 0 namespace loc_core { using namespace std; class AirplaneModeDataItemBase : public IDataItemCore { public: AirplaneModeDataItemBase(bool mode): mMode(mode), mId(AIRPLANEMODE_DATA_ITEM_ID) {} virtual ~AirplaneModeDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mMode; protected: DataItemId mId; }; class ENHDataItemBase : public IDataItemCore { public: ENHDataItemBase(bool enabled) : mEnabled(enabled), mId(ENH_DATA_ITEM_ID) {} virtual ~ENHDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mEnabled; protected: DataItemId mId; }; class GPSStateDataItemBase : public IDataItemCore { public: GPSStateDataItemBase(bool enabled) : mEnabled(enabled), mId(GPSSTATE_DATA_ITEM_ID) {} virtual ~GPSStateDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mEnabled; protected: DataItemId mId; }; class NLPStatusDataItemBase : public IDataItemCore { public: NLPStatusDataItemBase(bool enabled) : mEnabled(enabled), mId(NLPSTATUS_DATA_ITEM_ID) {} virtual ~NLPStatusDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mEnabled; protected: DataItemId mId; }; class WifiHardwareStateDataItemBase : public IDataItemCore { public: WifiHardwareStateDataItemBase(bool enabled) : mEnabled(enabled), mId(WIFIHARDWARESTATE_DATA_ITEM_ID) {} virtual ~WifiHardwareStateDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mEnabled; protected: DataItemId mId; }; class ScreenStateDataItemBase : public IDataItemCore { public: ScreenStateDataItemBase(bool state) : mState(state), mId(SCREEN_STATE_DATA_ITEM_ID) {} virtual ~ScreenStateDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mState; protected: DataItemId mId; }; class PowerConnectStateDataItemBase : public IDataItemCore { public: PowerConnectStateDataItemBase(bool state) : mState(state), mId(POWER_CONNECTED_STATE_DATA_ITEM_ID) {} virtual ~PowerConnectStateDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mState; protected: DataItemId mId; }; class TimeZoneChangeDataItemBase : public IDataItemCore { public: TimeZoneChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) : mCurrTimeMillis (currTimeMillis), mRawOffsetTZ (rawOffset), mDstOffsetTZ (dstOffset), mId(TIMEZONE_CHANGE_DATA_ITEM_ID) {} virtual ~TimeZoneChangeDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members int64_t mCurrTimeMillis; int32_t mRawOffsetTZ; int32_t mDstOffsetTZ; protected: DataItemId mId; }; class TimeChangeDataItemBase : public IDataItemCore { public: TimeChangeDataItemBase(int64_t currTimeMillis, int32_t rawOffset, int32_t dstOffset) : mCurrTimeMillis (currTimeMillis), mRawOffsetTZ (rawOffset), mDstOffsetTZ (dstOffset), mId(TIME_CHANGE_DATA_ITEM_ID) {} virtual ~TimeChangeDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members int64_t mCurrTimeMillis; int32_t mRawOffsetTZ; int32_t mDstOffsetTZ; protected: DataItemId mId; }; class ShutdownStateDataItemBase : public IDataItemCore { public: ShutdownStateDataItemBase(bool state) : mState (state), mId(SHUTDOWN_STATE_DATA_ITEM_ID) {} virtual ~ShutdownStateDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mState; protected: DataItemId mId; }; class AssistedGpsDataItemBase : public IDataItemCore { public: AssistedGpsDataItemBase(bool enabled) : mEnabled(enabled), mId(ASSISTED_GPS_DATA_ITEM_ID) {} virtual ~AssistedGpsDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} // Data members bool mEnabled; protected: DataItemId mId; }; class NetworkInfoDataItemBase : public IDataItemCore { public: enum NetworkType { TYPE_MOBILE = 0, TYPE_WIFI, TYPE_ETHERNET, TYPE_BLUETOOTH, TYPE_MMS, TYPE_SUPL, TYPE_DUN, TYPE_HIPRI, TYPE_WIMAX, TYPE_PROXY, TYPE_UNKNOWN, }; NetworkInfoDataItemBase( NetworkType initialType, int32_t type, string typeName, string subTypeName, bool available, bool connected, bool roaming, uint64_t networkHandle ): mAllTypes(typeToAllTypes(initialType)), mType(type), mTypeName(typeName), mSubTypeName(subTypeName), mAvailable(available), mConnected(connected), mRoaming(roaming), mNetworkHandle(networkHandle), mId(NETWORKINFO_DATA_ITEM_ID) { memset (&mAllNetworkHandles, NETWORK_HANDLE_UNKNOWN, sizeof (mAllNetworkHandles)); mAllNetworkHandles[initialType] = networkHandle; } virtual ~NetworkInfoDataItemBase() {} inline virtual DataItemId getId() { return mId; } virtual void stringify(string& /*valueStr*/) {} virtual int32_t copy(IDataItemCore* /*src*/, bool* /*dataItemCopied = NULL*/) {return 1;} inline virtual NetworkType getType(void) const { return (NetworkType)mType; } inline uint64_t getAllTypes() { return mAllTypes; } inline uint64_t getNetworkHandle(NetworkType type) { return mAllNetworkHandles[type]; } // Data members uint64_t mAllTypes; int32_t mType; string mTypeName; string mSubTypeName; bool mAvailable; bool mConnected; bool mRoaming; uint64_t mAllNetworkHandles[TYPE_UNKNOWN + 1]; uint64_t mNetworkHandle; protected: DataItemId mId; inline uint64_t typeToAllTypes(NetworkType type) { return (type >= TYPE_UNKNOWN || type < TYPE_MOBILE) ? 0 : (1<