| diff --git a/common/platform_constants_android.cc b/common/platform_constants_android.cc |
| index 371fe26..ef13058 100644 |
| --- a/common/platform_constants_android.cc |
| +++ b/common/platform_constants_android.cc |
| @@ -30,7 +30,7 @@ const char kUpdatePayloadPublicKeyPath[] = |
| const char kCACertificatesPath[] = "/system/etc/security/cacerts_google"; |
| // No deadline file API support on Android. |
| const char kOmahaResponseDeadlineFile[] = ""; |
| -const char kNonVolatileDirectory[] = "/data/misc/update_engine"; |
| +const char kNonVolatileDirectory[] = "/var/lib/update_engine"; |
| const char kPostinstallMountOptions[] = |
| "context=u:object_r:postinstall_file:s0"; |
| |
| diff --git a/hardware_android.cc b/hardware_android.cc |
| index 947b13a..0ccb161 100644 |
| --- a/hardware_android.cc |
| +++ b/hardware_android.cc |
| @@ -22,10 +22,11 @@ |
| |
| #include <algorithm> |
| #include <memory> |
| - |
| +#if 0 |
| #include <bootloader.h> |
| |
| #include <android-base/properties.h> |
| +#endif |
| #include <base/files/file_util.h> |
| #include <base/strings/stringprintf.h> |
| |
| @@ -34,9 +35,11 @@ |
| #include "update_engine/common/utils.h" |
| #include "update_engine/utils_android.h" |
| |
| +#if 0 |
| using android::base::GetBoolProperty; |
| using android::base::GetIntProperty; |
| using android::base::GetProperty; |
| +#endif |
| using std::string; |
| |
| namespace chromeos_update_engine { |
| @@ -58,7 +61,7 @@ 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"; |
| - |
| +#if 0 |
| // Write a recovery command line |message| to the BCB. The arguments to recovery |
| // must be separated by '\n'. An empty string will erase the BCB. |
| bool WriteBootloaderRecoveryMessage(const string& message) { |
| @@ -91,7 +94,7 @@ bool WriteBootloaderRecoveryMessage(const string& message) { |
| } |
| return true; |
| } |
| - |
| +#endif |
| } // namespace |
| |
| namespace hardware { |
| @@ -124,7 +127,7 @@ bool HardwareAndroid::IsOfficialBuild() const { |
| // |
| // In case of a non-bool value, we take the most restrictive option and |
| // assume we are in an official-build. |
| - return GetBoolProperty("ro.secure", true); |
| + return true;//GetBoolProperty("ro.secure", true); |
| } |
| |
| bool HardwareAndroid::IsNormalBootMode() const { |
| @@ -132,11 +135,11 @@ bool HardwareAndroid::IsNormalBootMode() const { |
| // update_engine will allow extra developers options, such as providing a |
| // different update URL. In case of error, we assume the build is in |
| // normal-mode. |
| - return !GetBoolProperty("ro.debuggable", false); |
| + return true;//!GetBoolProperty("ro.debuggable", false); |
| } |
| |
| bool HardwareAndroid::AreDevFeaturesEnabled() const { |
| - return !IsNormalBootMode(); |
| + return false;//!IsNormalBootMode(); |
| } |
| |
| bool HardwareAndroid::IsOOBEEnabled() const { |
| @@ -152,19 +155,22 @@ bool HardwareAndroid::IsOOBEComplete(base::Time* out_time_of_oobe) const { |
| } |
| |
| string HardwareAndroid::GetHardwareClass() const { |
| - auto manufacturer = GetProperty(kPropProductManufacturer, ""); |
| - auto sku = GetProperty(kPropBootHardwareSKU, ""); |
| - auto revision = GetProperty(kPropBootRevision, ""); |
| + //auto manufacturer = GetProperty(kPropProductManufacturer, ""); |
| + //auto sku = GetProperty(kPropBootHardwareSKU, ""); |
| + //auto revision = GetProperty(kPropBootRevision, ""); |
| |
| - return manufacturer + ":" + sku + ":" + revision; |
| + //return manufacturer + ":" + sku + ":" + revision; |
| + return "manufacturer:sku:revision"; |
| } |
| |
| string HardwareAndroid::GetFirmwareVersion() const { |
| - return GetProperty(kPropBootBootloader, ""); |
| + //return GetProperty(kPropBootBootloader, ""); |
| + return "1.0"; |
| } |
| |
| string HardwareAndroid::GetECVersion() const { |
| - return GetProperty(kPropBootBaseband, ""); |
| + //return GetProperty(kPropBootBaseband, ""); |
| + return "1.0"; |
| } |
| |
| int HardwareAndroid::GetPowerwashCount() const { |
| @@ -174,11 +180,11 @@ int HardwareAndroid::GetPowerwashCount() const { |
| |
| bool HardwareAndroid::SchedulePowerwash() { |
| LOG(INFO) << "Scheduling a powerwash to BCB."; |
| - return WriteBootloaderRecoveryMessage(kAndroidRecoveryPowerwashCommand); |
| + return false;//WriteBootloaderRecoveryMessage(kAndroidRecoveryPowerwashCommand); |
| } |
| |
| bool HardwareAndroid::CancelPowerwash() { |
| - return WriteBootloaderRecoveryMessage(""); |
| + return true;//WriteBootloaderRecoveryMessage(""); |
| } |
| |
| bool HardwareAndroid::GetNonVolatileDirectory(base::FilePath* path) const { |
| @@ -197,7 +203,8 @@ bool HardwareAndroid::GetPowerwashSafeDirectory(base::FilePath* path) const { |
| } |
| |
| int64_t HardwareAndroid::GetBuildTimestamp() const { |
| - return GetIntProperty<int64_t>(kPropBuildDateUTC, 0); |
| + //return GetIntProperty<int64_t>(kPropBuildDateUTC, 0); |
| + return utils::GetIntProperty(kPropBuildDateUTC, 0); |
| } |
| |
| bool HardwareAndroid::GetFirstActiveOmahaPingSent() const { |
| diff --git a/sideload_main.cc b/sideload_main.cc |
| index ddb312e..b983534 100644 |
| --- a/sideload_main.cc |
| +++ b/sideload_main.cc |
| @@ -155,7 +155,7 @@ bool ApplyUpdatePayload(const string& payload, |
| |
| // During the sideload we don't access the prefs persisted on disk but instead |
| // use a temporary memory storage. |
| - MemoryPrefs prefs; |
| + //MemoryPrefs prefs; |
| |
| std::unique_ptr<BootControlInterface> boot_control = |
| boot_control::CreateBootControl(); |
| @@ -169,9 +169,21 @@ bool ApplyUpdatePayload(const string& payload, |
| LOG(ERROR) << "Error initializing the HardwareInterface."; |
| return false; |
| } |
| + base::FilePath non_volatile_path; |
| + if (!hardware->GetNonVolatileDirectory(&non_volatile_path)) { |
| + LOG(ERROR) << "Failed to get a non-volatile directory."; |
| + return false; |
| + } |
| + std::unique_ptr<PrefsInterface> prefsIf; |
| + Prefs* prefs = new Prefs(); |
| + if (!prefs->Init(non_volatile_path.Append(kPrefsSubDirectory))) { |
| + LOG(ERROR) << "Failed to initialize preferences."; |
| + return false; |
| + } |
| + prefsIf.reset(prefs); |
| |
| UpdateAttempterAndroid update_attempter( |
| - &sideload_daemon_state, &prefs, boot_control.get(), hardware.get()); |
| + &sideload_daemon_state, prefsIf.get(), boot_control.get(), hardware.get()); |
| update_attempter.Init(); |
| |
| TEST_AND_RETURN_FALSE(update_attempter.ApplyPayload( |
| diff --git a/update_attempter_android.cc b/update_attempter_android.cc |
| index 04ccb18..60e96ff 100644 |
| --- a/update_attempter_android.cc |
| +++ b/update_attempter_android.cc |
| @@ -21,7 +21,7 @@ |
| #include <memory> |
| #include <utility> |
| |
| -#include <android-base/properties.h> |
| +//#include <android-base/properties.h> |
| #include <base/bind.h> |
| #include <base/logging.h> |
| #include <base/strings/string_number_conversions.h> |
| @@ -29,7 +29,7 @@ |
| #include <brillo/data_encoding.h> |
| #include <brillo/message_loops/message_loop.h> |
| #include <brillo/strings/string_utils.h> |
| -#include <log/log_safetynet.h> |
| +//#include <log/log_safetynet.h> |
| |
| #include "update_engine/common/constants.h" |
| #include "update_engine/common/error_code_utils.h" |
| @@ -449,7 +449,7 @@ void UpdateAttempterAndroid::ProcessingDone(const ActionProcessor* processor, |
| |
| case ErrorCode::kPayloadTimestampError: |
| // SafetyNet logging, b/36232423 |
| - android_errorWriteLog(0x534e4554, "36232423"); |
| + //android_errorWriteLog(0x534e4554, "36232423"); |
| break; |
| |
| default: |
| @@ -599,7 +599,10 @@ void UpdateAttempterAndroid::SetStatusAndNotify(UpdateStatus status) { |
| status_ = status; |
| size_t payload_size = |
| install_plan_.payloads.empty() ? 0 : install_plan_.payloads[0].size; |
| - UpdateEngineStatus status_to_send = {.status = status_, |
| + UpdateEngineStatus status_to_send = {.last_checked_time = 0, |
| + .status = status_, |
| + .current_version = "n", |
| + .current_system_version = "n", |
| .progress = download_progress_, |
| .new_size_bytes = payload_size}; |
| |
| @@ -764,8 +767,8 @@ void UpdateAttempterAndroid::UpdatePrefsAndReportUpdateMetricsOnReboot() { |
| string current_boot_id; |
| TEST_AND_RETURN(utils::GetBootId(¤t_boot_id)); |
| // Example: [ro.build.version.incremental]: [4292972] |
| - string current_version = |
| - android::base::GetProperty("ro.build.version.incremental", ""); |
| + string current_version = "4292972"; |
| + //android::base::GetProperty("ro.build.version.incremental", ""); |
| TEST_AND_RETURN(!current_version.empty()); |
| |
| // If there's no record of previous version (e.g. due to a data wipe), we |
| diff --git a/update_manager/policy.h b/update_manager/policy.h |
| index b60c4da..a57cfa6 100644 |
| --- a/update_manager/policy.h |
| +++ b/update_manager/policy.h |
| @@ -202,7 +202,7 @@ class Policy { |
| std::string*, R*, |
| Args...) const) const { |
| std::string class_name = PolicyName() + "::"; |
| - |
| +#if 0 |
| if (reinterpret_cast<typeof(&Policy::UpdateCheckAllowed)>( |
| policy_method) == &Policy::UpdateCheckAllowed) |
| return class_name + "UpdateCheckAllowed"; |
| @@ -223,6 +223,7 @@ class Policy { |
| return class_name + "P2PEnabledChanged"; |
| |
| NOTREACHED(); |
| +#endif |
| return class_name + "(unknown)"; |
| } |
| |
| diff --git a/utils_android.cc b/utils_android.cc |
| index 393e65a..40c06b7 100644 |
| --- a/utils_android.cc |
| +++ b/utils_android.cc |
| @@ -15,8 +15,10 @@ |
| // |
| |
| #include "update_engine/utils_android.h" |
| +#include <base/strings/string_number_conversions.h> |
| +#include <brillo/key_value_store.h> |
| |
| -#include <fs_mgr.h> |
| +#include <fstab/fstab.h> |
| |
| using std::string; |
| |
| @@ -40,6 +42,9 @@ static struct fstab* OpenFSTab() { |
| namespace utils { |
| |
| bool DeviceForMountPoint(const string& mount_point, base::FilePath* device) { |
| + //*device = base::FilePath("/dev/disk/by-partlabel/misc"); |
| + // return true; |
| +#if 1 |
| struct fstab* fstab; |
| struct fstab_rec* record; |
| |
| @@ -58,8 +63,26 @@ bool DeviceForMountPoint(const string& mount_point, base::FilePath* device) { |
| *device = base::FilePath(record->blk_device); |
| fs_mgr_free_fstab(fstab); |
| return true; |
| +#endif |
| } |
| |
| +int64_t GetIntProperty(const string& key, int64_t default_value){ |
| + brillo::KeyValueStore store; |
| + if(store.Load(base::FilePath("/etc/update_engine/build.prop"))){ |
| + std::string result; |
| + int64_t result_value; |
| + if(!store.GetString(key, &result)){ |
| + LOG(ERROR) << "Error get key" << key; |
| + return default_value; |
| + } |
| + if(base::StringToInt64(result,&result_value)){ |
| + return result_value; |
| + } |
| + }else{ |
| + LOG(ERROR) << "Error opening property file."; |
| + } |
| + return default_value; |
| +} |
| } // namespace utils |
| |
| } // namespace chromeos_update_engine |
| diff --git a/utils_android.h b/utils_android.h |
| index 18dd8ab..9692610 100644 |
| --- a/utils_android.h |
| +++ b/utils_android.h |
| @@ -30,6 +30,7 @@ namespace utils { |
| bool DeviceForMountPoint(const std::string& mount_point, |
| base::FilePath* device); |
| |
| +int64_t GetIntProperty(const std::string& key, int64_t default_value); |
| } // namespace utils |
| |
| } // namespace chromeos_update_engine |