Snap for 6001391 from d703ac560d0e83961a17b72e1a366f211b08cad7 to qt-aml-tzdata-release
Change-Id: I3e9158a4c21aa1ddedbc5c70191492fb01bc549f
diff --git a/Android.bp b/Android.bp
index 54fd0c2..d6f1090 100644
--- a/Android.bp
+++ b/Android.bp
@@ -339,6 +339,7 @@
"metrics_reporter_stub.cc",
"metrics_utils.cc",
"network_selector_stub.cc",
+ "sideload_logging_android.cc",
"sideload_main.cc",
"update_attempter_android.cc",
"update_boot_flags_action.cc",
diff --git a/binder_bindings/android/os/IUpdateEngineCallback.aidl b/binder_bindings/android/os/IUpdateEngineCallback.aidl
index ee15c8b..4bacf9a 100644
--- a/binder_bindings/android/os/IUpdateEngineCallback.aidl
+++ b/binder_bindings/android/os/IUpdateEngineCallback.aidl
@@ -19,6 +19,7 @@
/** @hide */
oneway interface IUpdateEngineCallback {
/** @hide */
+ @UnsupportedAppUsage
void onStatusUpdate(int status_code, float percentage);
/** @hide */
void onPayloadApplicationComplete(int error_code);
diff --git a/common/fake_hardware.h b/common/fake_hardware.h
index 3e5a66e..8da5326 100644
--- a/common/fake_hardware.h
+++ b/common/fake_hardware.h
@@ -128,6 +128,8 @@
int64_t GetBuildTimestamp() const override { return build_timestamp_; }
+ bool AllowDowngrade() const override { return false; }
+
bool GetFirstActiveOmahaPingSent() const override {
return first_active_omaha_ping_sent_;
}
diff --git a/common/hardware_interface.h b/common/hardware_interface.h
index 0140588..4a64c3e 100644
--- a/common/hardware_interface.h
+++ b/common/hardware_interface.h
@@ -122,6 +122,10 @@
// Returns the timestamp of the current OS build.
virtual int64_t GetBuildTimestamp() const = 0;
+ // Returns true if the current OS build allows installing the payload with an
+ // older timestamp.
+ virtual bool AllowDowngrade() const = 0;
+
// Returns whether the first active ping was sent to Omaha at some point, and
// that the value is persisted across recovery (and powerwash) once set with
// |SetFirstActiveOmahaPingSent()|.
diff --git a/dynamic_partition_control_android.cc b/dynamic_partition_control_android.cc
index e194670..c641a6b 100644
--- a/dynamic_partition_control_android.cc
+++ b/dynamic_partition_control_android.cc
@@ -63,7 +63,7 @@
constexpr std::chrono::milliseconds kMapSnapshotTimeout{5000};
DynamicPartitionControlAndroid::~DynamicPartitionControlAndroid() {
- CleanupInternal(false /* wait */);
+ CleanupInternal();
}
static FeatureFlag GetFeatureFlag(const char* enable_prop,
@@ -212,7 +212,8 @@
return true;
}
-void DynamicPartitionControlAndroid::CleanupInternal(bool wait) {
+void DynamicPartitionControlAndroid::CleanupInternal() {
+ metadata_device_.reset();
if (mapped_devices_.empty()) {
return;
}
@@ -226,7 +227,7 @@
}
void DynamicPartitionControlAndroid::Cleanup() {
- CleanupInternal(true /* wait */);
+ CleanupInternal();
}
bool DynamicPartitionControlAndroid::DeviceExists(const std::string& path) {
@@ -356,6 +357,11 @@
target_supports_snapshot_ =
manifest.dynamic_partition_metadata().snapshot_enabled();
+ if (GetVirtualAbFeatureFlag().IsEnabled()) {
+ metadata_device_ = snapshot_->EnsureMetadataMounted();
+ TEST_AND_RETURN_FALSE(metadata_device_ != nullptr);
+ }
+
if (!update)
return true;
@@ -369,13 +375,6 @@
return PrepareSnapshotPartitionsForUpdate(
source_slot, target_slot, manifest);
}
-
- if (GetVirtualAbFeatureFlag().IsLaunch() && !target_supports_snapshot_) {
- LOG(ERROR) << "Cannot downgrade to a build that does not support "
- << "snapshots because this device launches with Virtual A/B.";
- return false;
- }
-
if (!snapshot_->CancelUpdate()) {
LOG(ERROR) << "Cannot cancel previous update.";
return false;
diff --git a/dynamic_partition_control_android.h b/dynamic_partition_control_android.h
index d70a2aa..07ce281 100644
--- a/dynamic_partition_control_android.h
+++ b/dynamic_partition_control_android.h
@@ -23,6 +23,7 @@
#include <set>
#include <string>
+#include <libsnapshot/auto_device.h>
#include <libsnapshot/snapshot.h>
namespace chromeos_update_engine {
@@ -86,7 +87,7 @@
private:
friend class DynamicPartitionControlAndroidTest;
- void CleanupInternal(bool wait);
+ void CleanupInternal();
bool MapPartitionInternal(const std::string& super_device,
const std::string& target_partition_name,
uint32_t slot,
@@ -115,6 +116,7 @@
const FeatureFlag dynamic_partitions_;
const FeatureFlag virtual_ab_;
std::unique_ptr<android::snapshot::SnapshotManager> snapshot_;
+ std::unique_ptr<android::snapshot::AutoDevice> metadata_device_;
bool target_supports_snapshot_ = false;
DISALLOW_COPY_AND_ASSIGN(DynamicPartitionControlAndroid);
diff --git a/hardware_android.cc b/hardware_android.cc
index 21d4659..9611ba6 100644
--- a/hardware_android.cc
+++ b/hardware_android.cc
@@ -192,6 +192,13 @@
return GetIntProperty<int64_t>(kPropBuildDateUTC, 0);
}
+// Returns true if the device runs an userdebug build, and explicitly allows OTA
+// downgrade.
+bool HardwareAndroid::AllowDowngrade() const {
+ return GetBoolProperty("ro.ota.allow_downgrade", false) &&
+ GetBoolProperty("ro.debuggable", false);
+}
+
bool HardwareAndroid::GetFirstActiveOmahaPingSent() const {
LOG(WARNING) << "STUB: Assuming first active omaha was never set.";
return false;
diff --git a/hardware_android.h b/hardware_android.h
index 5b3c99d..2a8f669 100644
--- a/hardware_android.h
+++ b/hardware_android.h
@@ -53,6 +53,7 @@
bool GetNonVolatileDirectory(base::FilePath* path) const override;
bool GetPowerwashSafeDirectory(base::FilePath* path) const override;
int64_t GetBuildTimestamp() const override;
+ bool AllowDowngrade() const override;
bool GetFirstActiveOmahaPingSent() const override;
bool SetFirstActiveOmahaPingSent() override;
diff --git a/hardware_chromeos.h b/hardware_chromeos.h
index 8829866..57be3b0 100644
--- a/hardware_chromeos.h
+++ b/hardware_chromeos.h
@@ -58,6 +58,7 @@
bool GetNonVolatileDirectory(base::FilePath* path) const override;
bool GetPowerwashSafeDirectory(base::FilePath* path) const override;
int64_t GetBuildTimestamp() const override;
+ bool AllowDowngrade() const override { return false; }
bool GetFirstActiveOmahaPingSent() const override;
bool SetFirstActiveOmahaPingSent() override;
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index 4aec00b..8b3f61c 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -1692,7 +1692,11 @@
<< hardware_->GetBuildTimestamp()
<< ") is newer than the maximum timestamp in the manifest ("
<< manifest_.max_timestamp() << ")";
- return ErrorCode::kPayloadTimestampError;
+ if (!hardware_->AllowDowngrade()) {
+ return ErrorCode::kPayloadTimestampError;
+ }
+ LOG(INFO) << "The current OS build allows downgrade, continuing to apply"
+ " the payload with an older timestamp.";
}
if (major_payload_version_ == kChromeOSMajorPayloadVersion) {
diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc
index 2dd2626..88cca30 100644
--- a/payload_generator/payload_generation_config.cc
+++ b/payload_generator/payload_generation_config.cc
@@ -141,19 +141,23 @@
for (const auto& group_name : group_names) {
DynamicPartitionGroup* group = metadata->add_groups();
group->set_name(group_name);
- if (!store.GetString(group_name + "_size", &buf)) {
- LOG(ERROR) << "Missing " << group_name + "_size.";
+ if (!store.GetString("super_" + group_name + "_group_size", &buf) &&
+ !store.GetString(group_name + "_size", &buf)) {
+ LOG(ERROR) << "Missing super_" << group_name + "_group_size or "
+ << group_name << "_size.";
return false;
}
uint64_t max_size;
if (!base::StringToUint64(buf, &max_size)) {
- LOG(ERROR) << group_name << "_size=" << buf << " is not an integer.";
+ LOG(ERROR) << "Group size for " << group_name << " = " << buf
+ << " is not an integer.";
return false;
}
group->set_size(max_size);
- if (store.GetString(group_name + "_partition_list", &buf)) {
+ if (store.GetString("super_" + group_name + "_partition_list", &buf) ||
+ store.GetString(group_name + "_partition_list", &buf)) {
auto partition_names = brillo::string_utils::Split(buf, " ");
for (const auto& partition_name : partition_names) {
group->add_partition_names()->assign(partition_name);
diff --git a/scripts/update_device.py b/scripts/update_device.py
index 5c19b89..49f766d 100755
--- a/scripts/update_device.py
+++ b/scripts/update_device.py
@@ -83,17 +83,24 @@
# Android OTA package file paths.
OTA_PAYLOAD_BIN = 'payload.bin'
OTA_PAYLOAD_PROPERTIES_TXT = 'payload_properties.txt'
+ SECONDARY_OTA_PAYLOAD_BIN = 'secondary/payload.bin'
+ SECONDARY_OTA_PAYLOAD_PROPERTIES_TXT = 'secondary/payload_properties.txt'
- def __init__(self, otafilename):
+ def __init__(self, otafilename, secondary_payload=False):
self.otafilename = otafilename
otazip = zipfile.ZipFile(otafilename, 'r')
- payload_info = otazip.getinfo(self.OTA_PAYLOAD_BIN)
+ payload_entry = (self.SECONDARY_OTA_PAYLOAD_BIN if secondary_payload else
+ self.OTA_PAYLOAD_BIN)
+ payload_info = otazip.getinfo(payload_entry)
self.offset = payload_info.header_offset
self.offset += zipfile.sizeFileHeader
self.offset += len(payload_info.extra) + len(payload_info.filename)
self.size = payload_info.file_size
- self.properties = otazip.read(self.OTA_PAYLOAD_PROPERTIES_TXT)
+
+ property_entry = (self.SECONDARY_OTA_PAYLOAD_PROPERTIES_TXT if
+ secondary_payload else self.OTA_PAYLOAD_PROPERTIES_TXT)
+ self.properties = otazip.read(property_entry)
class UpdateHandler(BaseHTTPServer.BaseHTTPRequestHandler):
@@ -278,9 +285,9 @@
return t
-def AndroidUpdateCommand(ota_filename, payload_url, extra_headers):
+def AndroidUpdateCommand(ota_filename, secondary, payload_url, extra_headers):
"""Return the command to run to start the update in the Android device."""
- ota = AndroidOTAPackage(ota_filename)
+ ota = AndroidOTAPackage(ota_filename, secondary)
headers = ota.properties
headers += 'USER_AGENT=Dalvik (something, something)\n'
headers += 'NETWORK_ID=0\n'
@@ -363,6 +370,8 @@
help='Override the public key used to verify payload.')
parser.add_argument('--extra-headers', type=str, default='',
help='Extra headers to pass to the device.')
+ parser.add_argument('--secondary', action='store_true',
+ help='Update with the secondary payload in the package.')
args = parser.parse_args()
logging.basicConfig(
level=logging.WARNING if args.no_verbose else logging.INFO)
@@ -398,7 +407,7 @@
# command.
payload_url = 'http://127.0.0.1:%d/payload' % DEVICE_PORT
if use_omaha and zipfile.is_zipfile(args.otafile):
- ota = AndroidOTAPackage(args.otafile)
+ ota = AndroidOTAPackage(args.otafile, args.secondary)
serving_range = (ota.offset, ota.size)
else:
serving_range = (0, os.stat(args.otafile).st_size)
@@ -426,8 +435,8 @@
update_cmd = \
OmahaUpdateCommand('http://127.0.0.1:%d/update' % DEVICE_PORT)
else:
- update_cmd = \
- AndroidUpdateCommand(args.otafile, payload_url, args.extra_headers)
+ update_cmd = AndroidUpdateCommand(args.otafile, args.secondary,
+ payload_url, args.extra_headers)
cmds.append(['shell', 'su', '0'] + update_cmd)
for cmd in cmds:
diff --git a/sideload_logging_android.cc b/sideload_logging_android.cc
new file mode 100644
index 0000000..f82259f
--- /dev/null
+++ b/sideload_logging_android.cc
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "update_engine/sideload_logging_android.h"
+
+#include <android-base/logging.h>
+
+namespace chromeos_update_engine {
+
+void SetupAndroidLogging(char* argv[]) {
+ android::base::InitLogging(argv, android::base::StdioLogger);
+}
+
+} // namespace chromeos_update_engine
diff --git a/sideload_logging_android.h b/sideload_logging_android.h
new file mode 100644
index 0000000..0bb8714
--- /dev/null
+++ b/sideload_logging_android.h
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#pragma once
+
+namespace chromeos_update_engine {
+
+// Some depending modules uses logging functions from android-base.
+// Redirect android-base logging to stdio, which redirects to /tmp/recovery.log.
+void SetupAndroidLogging(char* argv[]);
+
+} // namespace chromeos_update_engine
diff --git a/sideload_main.cc b/sideload_main.cc
index 818fa5c..29d6f2c 100644
--- a/sideload_main.cc
+++ b/sideload_main.cc
@@ -36,6 +36,7 @@
#include "update_engine/common/subprocess.h"
#include "update_engine/common/terminator.h"
#include "update_engine/common/utils.h"
+#include "update_engine/sideload_logging_android.h"
#include "update_engine/update_attempter_android.h"
using std::string;
@@ -196,6 +197,7 @@
chromeos_update_engine::Terminator::Init();
chromeos_update_engine::SetupLogging();
+ chromeos_update_engine::SetupAndroidLogging(argv);
brillo::FlagHelper::Init(argc, argv, "Update Engine Sideload");
LOG(INFO) << "Update Engine Sideloading starting";