1 #pragma once 2 3 #include <map> 4 #include <string> 5 6 #include "android-base/result.h" 7 #include "android_property_manager.h" 8 9 namespace pixel_modem { 10 11 /** 12 * @brief Fake Implementation of AndroidPropertyManager that mocks some of the 13 * property changing behaviour from pixellogger's `modem_logging_control`. 14 */ 15 class FakeAndroidPropertyManager : public AndroidPropertyManager { 16 public: 17 bool GetBoolProperty(const std::string& key, bool default_value) override; 18 19 std::string GetProperty(const std::string& key, 20 const std::string& default_value) override; 21 22 int GetIntProperty(const std::string& key, int default_value) override; 23 24 /** 25 * This function needs to copy the behaviour of `modem_logging_control` to 26 * ensure that the right properties are being set in order. 27 * 28 * More specifically, this function will also set the 29 * `kModemLoggingStatusProperty` whenever `kModemLoggingEnabledProperty` is 30 * set to simulate modem logging stopping / starting. 31 */ 32 bool SetProperty(const std::string& key, const std::string& value) override; 33 ModemLoggingHasRestarted()34 inline bool ModemLoggingHasRestarted() { 35 return modem_logging_has_restarted_; 36 } 37 38 private: 39 /** 40 * @brief Gets android system property if present. 41 * 42 * @param[in] key Name of property. 43 * 44 * @return Status of get operation and value if successful. 45 * @retval EINVAL Key not present in map. 46 */ 47 android::base::Result<std::string> GetProperty(const std::string& key); 48 49 std::map<std::string, std::string> property_map_; 50 bool modem_logging_has_been_off_ = false; 51 bool modem_logging_has_restarted_ = false; 52 }; 53 54 } // namespace pixel_modem 55