image_properties.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // Copyright (C) 2015 The Android Open Source Project
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. // This module abstracts the properties tied to the current running image. These
  17. // properties are meant to be constant during the life of this daemon, but can
  18. // be modified in dev-move or non-official builds.
  19. #ifndef UPDATE_ENGINE_IMAGE_PROPERTIES_H_
  20. #define UPDATE_ENGINE_IMAGE_PROPERTIES_H_
  21. #include <string>
  22. namespace chromeos_update_engine {
  23. class SystemState;
  24. // The read-only system properties of the running image.
  25. struct ImageProperties {
  26. // The product id of the image used for all channels, except canary.
  27. std::string product_id;
  28. // The canary-channel product id.
  29. std::string canary_product_id;
  30. // The system id for the Android Things SoM, empty for Chrome OS.
  31. std::string system_id;
  32. // The product version of this image.
  33. std::string version;
  34. // The system version of this image.
  35. std::string system_version;
  36. // The version of all product components in key values pairs.
  37. std::string product_components;
  38. // A unique string that identifies this build. Normally a combination of the
  39. // the version, signing keys and build target.
  40. std::string build_fingerprint;
  41. // The Android build type, should be either 'user', 'userdebug' or 'eng'.
  42. // It's empty string on other platform.
  43. std::string build_type;
  44. // The board name this image was built for.
  45. std::string board;
  46. // The release channel this image was obtained from.
  47. std::string current_channel;
  48. // Whether we allow arbitrary channels instead of just the ones listed in
  49. // kChannelsByStability.
  50. bool allow_arbitrary_channels = false;
  51. // The Omaha URL this image should get updates from.
  52. std::string omaha_url;
  53. };
  54. // The mutable image properties are read-write image properties, initialized
  55. // with values from the image but can be modified by storing them in the
  56. // stateful partition.
  57. struct MutableImageProperties {
  58. // The release channel we are tracking.
  59. std::string target_channel;
  60. // Whether powerwash is allowed when downloading an update for the selected
  61. // target_channel.
  62. bool is_powerwash_allowed{false};
  63. };
  64. // Loads all the image properties from the running system. In case of error
  65. // loading any of these properties from the read-only system image a default
  66. // value may be returned instead.
  67. ImageProperties LoadImageProperties(SystemState* system_state);
  68. // Loads the mutable image properties from the stateful partition if found or
  69. // the system image otherwise.
  70. MutableImageProperties LoadMutableImageProperties(SystemState* system_state);
  71. // Stores the mutable image properties in the stateful partition. Returns
  72. // whether the operation succeeded.
  73. bool StoreMutableImageProperties(SystemState* system_state,
  74. const MutableImageProperties& properties);
  75. // Logs the image properties.
  76. void LogImageProperties();
  77. // Sets the root_prefix used to load files from during unittests to
  78. // |test_root_prefix|. Passing a nullptr value resets it to the default.
  79. namespace test {
  80. void SetImagePropertiesRootPrefix(const char* test_root_prefix);
  81. } // namespace test
  82. } // namespace chromeos_update_engine
  83. #endif // UPDATE_ENGINE_IMAGE_PROPERTIES_H_