ECSDKOTAManager.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #ifndef ECSDKOTAMANAGER_H
  2. #define ECSDKOTAMANAGER_H
  3. #include "ECSDKTypes.h"
  4. namespace ECSDKFrameWork {
  5. class EC_DLL_EXPORT IECOTAManagerListener
  6. {
  7. public:
  8. virtual ~IECOTAManagerListener();
  9. /**
  10. * @brief Called when checkOTAUpdate was called, it will tell the result of checkOTAUpdate.
  11. *
  12. * @param downloadableSoftwares A array of ECOTAUpdateSoftware, which is downloadable software.
  13. * *
  14. * @param downloadedSoftwares A array of ECOTAUpdateSoftware, which is downloaded software.
  15. *
  16. */
  17. virtual void onOTAUpdateCheckResult(const vector<ECOTAUpdateSoftware>& downloadableSoftwares, const vector<ECOTAUpdateSoftware>& downloadedSoftwares) = 0;
  18. /*
  19. * @brief Called when remote downloadable software has been downloaded to phone.
  20. *
  21. * @param downloadableSoftwares It pointer to a array of ECOTAUpdateSoftware, which has been in phone, can be downloaded from phone to HU.
  22. *
  23. * @param downloadableLength The length of the downloadable array.
  24. */
  25. virtual void onOTAUpdateRequestDownload(const vector<ECOTAUpdateSoftware>& downloadableSoftwares) {};
  26. /**
  27. * @brief Called when startOTAUpdate is called, it will notify the progress of downloading.
  28. *
  29. * @param downloadingSoftwareId The id of the downloading software.
  30. *
  31. * @param progress The progress of the downloading software,which is a percentage.
  32. *
  33. * @param softwareLeftTime The left time of the downloading software.
  34. *
  35. * @param otaLeftTime The left time of all the specified software by startOTAUpdate.
  36. */
  37. virtual void onOTAUpdateProgress(const string& downloadingSoftwareId, float progress, uint32_t softwareLeftTime, uint32_t otaLeftTime) = 0;
  38. /**
  39. * @brief Called when startOTAUpdate is called, it will notify software is downloaded.
  40. *
  41. * @param downloadedSoftwareId The id of the downloaded software.
  42. *
  43. * @param md5Path The md5 file path.
  44. *
  45. * @param packagePath The software path.
  46. *
  47. * @param iconPath The icon path.
  48. *
  49. * @param leftSoftwareNum The amount of software remaining to be downloaded.
  50. */
  51. virtual void onOTAUpdateCompleted(const string& downloadedSoftwareId, const string& md5Path, const string& packagePath, const string& iconPath, uint32_t leftSoftwareNum) = 0;
  52. /**
  53. * @brief Called when checkOTAUpdate or startOTAUpdate failed.
  54. *
  55. * @param errCode error code, see ECOTAUpdateErrorCode.
  56. *
  57. * @param softwarId the id of software.
  58. */
  59. virtual void onOTAUpdateError(int32_t errCode, const string& softwareId) = 0;
  60. };
  61. class EC_DLL_EXPORT ECSDKOTAManager
  62. {
  63. public:
  64. /*!
  65. * \brief Singleton function.
  66. *
  67. * \return The instance of derived class.
  68. *
  69. */
  70. static ECSDKOTAManager *getInstance();
  71. /*!
  72. * \brief initialize
  73. * \param listener
  74. * \param cfg
  75. * \return
  76. */
  77. virtual bool initialize(IECOTAManagerListener* listener, const ECOTAConfig& cfg) = 0;
  78. /**
  79. * @brief release
  80. * @return
  81. */
  82. virtual void release() = 0;
  83. /**
  84. * @brief This method will trigger a check to ota update.
  85. *
  86. * @param language Which language's description of software will be gained when HU's network is used for ota update.
  87. *
  88. * @param mode Specify which way to check ota update.
  89. *
  90. * @return ECSDK_OK on success, others on fail.
  91. *
  92. * @note IECOTAManagerListener::onOTAUpdateCheckResult will tell the result.
  93. */
  94. virtual int32_t checkOTAUpdate(ECLanguage language, ECOTAUpdateCheckMode mode = EC_OTA_CHECK_VIA_DEFAULT) = 0;
  95. /**
  96. * @brief This method will download specified softwares sequentially.
  97. *
  98. * @param softwareIds The array save the software id.
  99. *
  100. * @return ECSDK_OK on success, others on fail.
  101. *
  102. * @note The software id would gained from IECOTAManagerListener::onOTAUpdateCheckResult
  103. * after ECSDKOTAManager::checkOTAUpdate was called.
  104. * The software id also can be gained from IECOTAManagerListener::onOTAUpdateRequestDownload.
  105. * If softwareIds length is zero , all downloadable software will be downloaded.
  106. * The method can download remote software to phone or download phone's software to HU.
  107. */
  108. virtual int32_t startOTAUpdate(const vector<string>& softwareIds) = 0;
  109. /**
  110. * @brief This method will stop downloading softwares.
  111. *
  112. * @note OTA update doesn't support breakpoint continuation. The software which haven't been completed
  113. * would be removed.
  114. */
  115. virtual void stopOTAUpdate() = 0;
  116. protected:
  117. ECSDKOTAManager();
  118. virtual ~ECSDKOTAManager();
  119. };
  120. }
  121. #endif // ECSDKOTAMANAGER_H