summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fastboot/device/fastboot_device.cpp3
-rw-r--r--fastboot/fastboot.cpp7
-rw-r--r--fs_mgr/clean_scratch_files.rc2
-rw-r--r--fs_mgr/fs_mgr_remount.cpp4
-rw-r--r--fs_mgr/fs_mgr_roots.cpp9
-rw-r--r--healthd/BatteryMonitor.cpp53
-rw-r--r--init/Android.bp9
-rw-r--r--init/NOTICE26
-rw-r--r--init/property_service.cpp37
-rw-r--r--init/reboot.cpp3
-rw-r--r--init/service.cpp17
-rw-r--r--init/vendor_init.cpp37
-rw-r--r--init/vendor_init.h33
-rw-r--r--libsysutils/src/NetlinkListener.cpp4
-rw-r--r--llkd/Android.bp2
15 files changed, 220 insertions, 26 deletions
diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp
index 6b6a9820e..0dc4e9764 100644
--- a/fastboot/device/fastboot_device.cpp
+++ b/fastboot/device/fastboot_device.cpp
@@ -151,7 +151,8 @@ std::string FastbootDevice::GetCurrentSlot() {
}
BootControlClient* FastbootDevice::boot1_1() const {
- if (boot_control_hal_->GetVersion() >= android::hal::BootControlVersion::BOOTCTL_V1_1) {
+ if (boot_control_hal_ &&
+ boot_control_hal_->GetVersion() >= android::hal::BootControlVersion::BOOTCTL_V1_1) {
return boot_control_hal_.get();
}
return nullptr;
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index cdcd0363a..48f443c5a 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -1786,7 +1786,6 @@ void FlashAllTool::Flash() {
}
DetermineSlot();
- CollectImages();
CancelSnapshotIfNeeded();
@@ -1950,7 +1949,6 @@ static void do_update(const char* filename, FlashingPlan* fp) {
}
ZipImageSource zp = ZipImageSource(zip);
fp->source = &zp;
- fp->wants_wipe = false;
FlashAllTool tool(fp);
tool.Flash();
@@ -2603,10 +2601,13 @@ int FastBootTool::Main(int argc, char* argv[]) {
if (fp->force_flash) {
CancelSnapshotIfNeeded();
}
+ std::vector<std::unique_ptr<Task>> wipe_tasks;
std::vector<std::string> partitions = {"userdata", "cache", "metadata"};
for (const auto& partition : partitions) {
- tasks.emplace_back(std::make_unique<WipeTask>(fp.get(), partition));
+ wipe_tasks.emplace_back(std::make_unique<WipeTask>(fp.get(), partition));
}
+ tasks.insert(tasks.begin(), std::make_move_iterator(wipe_tasks.begin()),
+ std::make_move_iterator(wipe_tasks.end()));
}
if (fp->wants_set_active) {
fb->SetActive(next_active);
diff --git a/fs_mgr/clean_scratch_files.rc b/fs_mgr/clean_scratch_files.rc
index 25a7e690a..71708f8c1 100644
--- a/fs_mgr/clean_scratch_files.rc
+++ b/fs_mgr/clean_scratch_files.rc
@@ -1,2 +1,2 @@
-on post-fs-data && property:ro.debuggable=1
+on post-fs-data && property:ro.debuggable=1 && property:ro.boot.dynamic_partitions=true
exec_background - root root -- /system/bin/clean_scratch_files
diff --git a/fs_mgr/fs_mgr_remount.cpp b/fs_mgr/fs_mgr_remount.cpp
index 5a9f391a4..44c556085 100644
--- a/fs_mgr/fs_mgr_remount.cpp
+++ b/fs_mgr/fs_mgr_remount.cpp
@@ -630,10 +630,14 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
+#if 0
+ // Green state is always reported due to SafetyNet hacks.
+ // Remove this check completely.
if (android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange") {
LOG(ERROR) << "Device must be bootloader unlocked";
return EXIT_FAILURE;
}
+#endif
// Start a threadpool to service waitForService() callbacks as
// fs_mgr_overlayfs_* might call waitForService() to get the image service.
diff --git a/fs_mgr/fs_mgr_roots.cpp b/fs_mgr/fs_mgr_roots.cpp
index 2ad8125e7..79910a286 100644
--- a/fs_mgr/fs_mgr_roots.cpp
+++ b/fs_mgr/fs_mgr_roots.cpp
@@ -123,15 +123,6 @@ bool TryPathMount(FstabEntry* rec, const std::string& mount_pt) {
}
int result = fs_mgr_do_mount_one(*rec, mount_point);
- if (result == -1 && rec->fs_mgr_flags.formattable) {
- PERROR << "Failed to mount " << mount_point << "; formatting";
- if (fs_mgr_do_format(*rec) != 0) {
- PERROR << "Failed to format " << mount_point;
- return false;
- }
- result = fs_mgr_do_mount_one(*rec, mount_point);
- }
-
if (result == -1) {
PERROR << "Failed to mount " << mount_point;
return false;
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index bd7955a7f..75af4402c 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -304,6 +304,8 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path)
{"USB", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_USB},
{"USB_DCP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
{"USB_HVDCP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
+ {"USB_HVDCP_3", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
+ {"USB_HVDCP_3P5", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
{"USB_CDP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
{"USB_ACA", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
{"USB_C", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
@@ -311,6 +313,7 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path)
{"USB_PD_DRP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_USB},
{"Wireless", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_WIRELESS},
{"Dock", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_DOCK},
+ {"DASH", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
{NULL, 0},
};
std::string buf;
@@ -320,10 +323,8 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path)
}
auto ret = mapSysfsString(buf.c_str(), supplyTypeMap);
- if (!ret) {
- KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str());
+ if (!ret)
*ret = BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
- }
return static_cast<BatteryMonitor::PowerSupplyType>(*ret);
}
@@ -442,6 +443,52 @@ void BatteryMonitor::updateValues(void) {
double MaxPower = 0;
+ // Rescan for the available charger types
+ std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(POWER_SUPPLY_SYSFS_PATH), closedir);
+ if (dir == NULL) {
+ KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH);
+ } else {
+ struct dirent* entry;
+ String8 path;
+
+ mChargerNames.clear();
+
+ while ((entry = readdir(dir.get()))) {
+ const char* name = entry->d_name;
+
+ if (!strcmp(name, ".") || !strcmp(name, ".."))
+ continue;
+
+ // Look for "type" file in each subdirectory
+ path.clear();
+ path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name);
+ switch(readPowerSupplyType(path)) {
+ case ANDROID_POWER_SUPPLY_TYPE_AC:
+ case ANDROID_POWER_SUPPLY_TYPE_USB:
+ case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
+ case ANDROID_POWER_SUPPLY_TYPE_DOCK:
+ path.clear();
+ path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
+ if (access(path.string(), R_OK) == 0)
+ mChargerNames.add(String8(name));
+ break;
+ default:
+ break;
+ }
+
+ // Look for "is_dock" file
+ path.clear();
+ path.appendFormat("%s/%s/is_dock", POWER_SUPPLY_SYSFS_PATH, name);
+ if (access(path.string(), R_OK) == 0) {
+ path.clear();
+ path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
+ if (access(path.string(), R_OK) == 0)
+ mChargerNames.add(String8(name));
+
+ }
+ }
+ }
+
for (size_t i = 0; i < mChargerNames.size(); i++) {
String8 path;
path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH,
diff --git a/init/Android.bp b/init/Android.bp
index 7b529033a..e9d12985d 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -91,6 +91,14 @@ init_host_sources = [
"host_init_verifier.cpp",
]
+cc_library_static {
+ name: "vendor_init",
+ recovery_available: true,
+ srcs: [
+ "vendor_init.cpp",
+ ],
+}
+
soong_config_module_type {
name: "libinit_cc_defaults",
module_type: "cc_defaults",
@@ -219,6 +227,7 @@ cc_library_static {
defaults: [
"init_defaults",
"selinux_policy_version",
+ "vendor_init_defaults",
],
srcs: init_common_sources + init_device_sources,
export_include_dirs: ["."],
diff --git a/init/NOTICE b/init/NOTICE
index c5b1efa7a..383d0f541 100644
--- a/init/NOTICE
+++ b/init/NOTICE
@@ -188,3 +188,29 @@
END OF TERMS AND CONDITIONS
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 203ae7379..effdbd753 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -74,6 +74,7 @@
#include "subcontext.h"
#include "system/core/init/property_service.pb.h"
#include "util.h"
+#include "vendor_init.h"
using namespace std::literals;
@@ -1309,6 +1310,9 @@ void PropertyLoadBootDefaults() {
}
}
+ // Update with vendor-specific property runtime overrides
+ vendor_load_properties();
+
property_initialize_ro_product_props();
property_initialize_build_id();
property_derive_build_props();
@@ -1441,6 +1445,7 @@ static void ProcessKernelDt() {
}
constexpr auto ANDROIDBOOT_PREFIX = "androidboot."sv;
+constexpr auto ANDROIDBOOT_MODE = "androidboot.mode"sv;
static void ProcessKernelCmdline() {
ImportKernelCmdline([&](const std::string& key, const std::string& value) {
@@ -1459,6 +1464,35 @@ static void ProcessBootconfig() {
});
}
+static void SetSafetyNetProps() {
+ // Check whether this is a normal boot, and whether the bootloader is actually locked
+ auto isNormalBoot = true; // no prop = normal boot
+ // This runs before keys are set as props, so we need to process them ourselves.
+ ImportKernelCmdline([&](const std::string& key, const std::string& value) {
+ if (key == ANDROIDBOOT_MODE && value != "normal") {
+ isNormalBoot = false;
+ }
+ });
+ ImportBootconfig([&](const std::string& key, const std::string& value) {
+ if (key == ANDROIDBOOT_MODE && value != "normal") {
+ isNormalBoot = false;
+ }
+ });
+
+ // Bail out if this is recovery, fastbootd, or anything other than a normal boot.
+ // fastbootd, in particular, needs the real values so it can allow flashing on
+ // unlocked bootloaders.
+ if (!isNormalBoot) {
+ return;
+ }
+
+ // Spoof properties
+ InitPropertySet("ro.boot.flash.locked", "1");
+ InitPropertySet("ro.boot.verifiedbootstate", "green");
+ InitPropertySet("ro.boot.veritymode", "enforcing");
+ InitPropertySet("ro.boot.vbmeta.device_state", "locked");
+}
+
void PropertyInit() {
selinux_callback cb;
cb.func_audit = PropertyAuditCallback;
@@ -1473,6 +1507,9 @@ void PropertyInit() {
LOG(FATAL) << "Failed to load serialized property info file";
}
+ // Report valid verified boot chain to help pass Google SafetyNet integrity checks
+ SetSafetyNetProps();
+
// If arguments are passed both on the command line and in DT,
// properties set in DT always have priority over the command-line ones.
ProcessKernelDt();
diff --git a/init/reboot.cpp b/init/reboot.cpp
index cff9ba024..6d67ac4c1 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -1065,7 +1065,8 @@ void HandlePowerctlMessage(const std::string& command) {
// adb reboot fastboot should boot into bootloader for devices not
// supporting logical partitions.
if (reboot_target == "fastboot" &&
- !android::base::GetBoolProperty("ro.boot.dynamic_partitions", false)) {
+ !android::base::GetBoolProperty("ro.boot.dynamic_partitions", false) &&
+ !android::base::GetBoolProperty("ro.fastbootd.available", false)) {
reboot_target = "bootloader";
}
// When rebooting to the bootloader notify the bootloader writing
diff --git a/init/service.cpp b/init/service.cpp
index 35beaad33..caf971c4e 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -98,13 +98,16 @@ static Result<std::string> ComputeContextFromExecutable(const std::string& servi
free(new_con);
}
if (rc == 0 && computed_context == mycon.get()) {
- return Error() << "File " << service_path << "(labeled \"" << filecon.get()
- << "\") has incorrect label or no domain transition from " << mycon.get()
- << " to another SELinux domain defined. Have you configured your "
- "service correctly? https://source.android.com/security/selinux/"
- "device-policy#label_new_services_and_address_denials. Note: this "
- "error shows up even in permissive mode in order to make auditing "
- "denials possible.";
+ std::string error = StringPrintf(
+ "File %s (labeled \"%s\") has incorrect label or no domain transition from %s to "
+ "another SELinux domain defined. Have you configured your "
+ "service correctly? https://source.android.com/security/selinux/"
+ "device-policy#label_new_services_and_address_denials",
+ service_path.c_str(), filecon.get(), mycon.get());
+ if (security_getenforce() != 0) {
+ return Error() << error;
+ }
+ LOG(ERROR) << error;
}
if (rc < 0) {
return Error() << "Could not get process context";
diff --git a/init/vendor_init.cpp b/init/vendor_init.cpp
new file mode 100644
index 000000000..d3fd5ffe2
--- /dev/null
+++ b/init/vendor_init.cpp
@@ -0,0 +1,37 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "vendor_init.h"
+
+/* init vendor override stubs */
+
+__attribute__ ((weak))
+void vendor_load_properties()
+{
+}
diff --git a/init/vendor_init.h b/init/vendor_init.h
new file mode 100644
index 000000000..9afb449be
--- /dev/null
+++ b/init/vendor_init.h
@@ -0,0 +1,33 @@
+/*
+Copyright (c) 2013, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __INIT_VENDOR__H__
+#define __INIT_VENDOR__H__
+extern void vendor_load_properties(void);
+#endif /* __INIT_VENDOR__H__ */
diff --git a/libsysutils/src/NetlinkListener.cpp b/libsysutils/src/NetlinkListener.cpp
index aad0394da..3dc2e4355 100644
--- a/libsysutils/src/NetlinkListener.cpp
+++ b/libsysutils/src/NetlinkListener.cpp
@@ -57,7 +57,11 @@ bool NetlinkListener::onDataAvailable(SocketClient *cli)
count = TEMP_FAILURE_RETRY(uevent_kernel_recv(socket,
mBuffer, sizeof(mBuffer), require_group, &uid));
if (count < 0) {
+#ifdef __ANDROID_RECOVERY__
+ SLOGW("recvmsg failed (%s)", strerror(errno));
+#else
SLOGE("recvmsg failed (%s)", strerror(errno));
+#endif
return false;
}
diff --git a/llkd/Android.bp b/llkd/Android.bp
index 1c0e0f0a0..fc4be0062 100644
--- a/llkd/Android.bp
+++ b/llkd/Android.bp
@@ -50,7 +50,7 @@ cc_binary {
init_rc: ["llkd.rc"],
product_variables: {
- debuggable: {
+ eng: {
init_rc: ["llkd-debuggable.rc"],
},
},