123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- #include "update_engine/hardware_android.h"
- #include <sys/types.h>
- #include <memory>
- #include <android-base/properties.h>
- #include <base/files/file_util.h>
- #include <bootloader_message/bootloader_message.h>
- #include "update_engine/common/hardware.h"
- #include "update_engine/common/platform_constants.h"
- using android::base::GetBoolProperty;
- using android::base::GetIntProperty;
- using android::base::GetProperty;
- using std::string;
- namespace chromeos_update_engine {
- namespace {
- const char kPropBootBootloader[] = "ro.boot.bootloader";
- const char kPropBootBaseband[] = "ro.boot.baseband";
- const char kPropProductManufacturer[] = "ro.product.manufacturer";
- const char kPropBootHardwareSKU[] = "ro.boot.hardware.sku";
- const char kPropBootRevision[] = "ro.boot.revision";
- const char kPropBuildDateUTC[] = "ro.build.date.utc";
- }
- namespace hardware {
- std::unique_ptr<HardwareInterface> CreateHardware() {
- return std::make_unique<HardwareAndroid>();
- }
- }
- bool HardwareAndroid::IsOfficialBuild() const {
-
-
-
-
-
-
-
-
- return GetBoolProperty("ro.secure", true);
- }
- bool HardwareAndroid::IsNormalBootMode() const {
-
-
-
-
- return !GetBoolProperty("ro.debuggable", false);
- }
- bool HardwareAndroid::AreDevFeaturesEnabled() const {
- return !IsNormalBootMode();
- }
- bool HardwareAndroid::IsOOBEEnabled() const {
-
- return false;
- }
- bool HardwareAndroid::IsOOBEComplete(base::Time* out_time_of_oobe) const {
- LOG(WARNING) << "OOBE is not enabled but IsOOBEComplete() called.";
- if (out_time_of_oobe)
- *out_time_of_oobe = base::Time();
- return true;
- }
- string HardwareAndroid::GetHardwareClass() const {
- auto manufacturer = GetProperty(kPropProductManufacturer, "");
- auto sku = GetProperty(kPropBootHardwareSKU, "");
- auto revision = GetProperty(kPropBootRevision, "");
- return manufacturer + ":" + sku + ":" + revision;
- }
- string HardwareAndroid::GetFirmwareVersion() const {
- return GetProperty(kPropBootBootloader, "");
- }
- string HardwareAndroid::GetECVersion() const {
- return GetProperty(kPropBootBaseband, "");
- }
- int HardwareAndroid::GetMinKernelKeyVersion() const {
- LOG(WARNING) << "STUB: No Kernel key version is available.";
- return -1;
- }
- int HardwareAndroid::GetMinFirmwareKeyVersion() const {
- LOG(WARNING) << "STUB: No Firmware key version is available.";
- return -1;
- }
- int HardwareAndroid::GetMaxFirmwareKeyRollforward() const {
- LOG(WARNING) << "STUB: Getting firmware_max_rollforward is not supported.";
- return -1;
- }
- bool HardwareAndroid::SetMaxFirmwareKeyRollforward(
- int firmware_max_rollforward) {
- LOG(WARNING) << "STUB: Setting firmware_max_rollforward is not supported.";
- return false;
- }
- bool HardwareAndroid::SetMaxKernelKeyRollforward(int kernel_max_rollforward) {
- LOG(WARNING) << "STUB: Setting kernel_max_rollforward is not supported.";
- return false;
- }
- int HardwareAndroid::GetPowerwashCount() const {
- LOG(WARNING) << "STUB: Assuming no factory reset was performed.";
- return 0;
- }
- bool HardwareAndroid::SchedulePowerwash(bool is_rollback) {
- LOG(INFO) << "Scheduling a powerwash to BCB.";
- LOG_IF(WARNING, is_rollback) << "is_rollback was true but isn't supported.";
- string err;
- if (!update_bootloader_message({"--wipe_data", "--reason=wipe_data_from_ota"},
- &err)) {
- LOG(ERROR) << "Failed to update bootloader message: " << err;
- return false;
- }
- return true;
- }
- bool HardwareAndroid::CancelPowerwash() {
- string err;
- if (!clear_bootloader_message(&err)) {
- LOG(ERROR) << "Failed to clear bootloader message: " << err;
- return false;
- }
- return true;
- }
- bool HardwareAndroid::GetNonVolatileDirectory(base::FilePath* path) const {
- base::FilePath local_path(constants::kNonVolatileDirectory);
- if (!base::PathExists(local_path)) {
- LOG(ERROR) << "Non-volatile directory not found: " << local_path.value();
- return false;
- }
- *path = local_path;
- return true;
- }
- bool HardwareAndroid::GetPowerwashSafeDirectory(base::FilePath* path) const {
-
- return false;
- }
- int64_t HardwareAndroid::GetBuildTimestamp() const {
- return GetIntProperty<int64_t>(kPropBuildDateUTC, 0);
- }
- bool HardwareAndroid::GetFirstActiveOmahaPingSent() const {
- LOG(WARNING) << "STUB: Assuming first active omaha was never set.";
- return false;
- }
- bool HardwareAndroid::SetFirstActiveOmahaPingSent() {
- LOG(WARNING) << "STUB: Assuming first active omaha is set.";
-
- return true;
- }
- }
|