summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs_mgr/clean_scratch_files.rc2
-rw-r--r--fs_mgr/fs_mgr_roots.cpp9
-rw-r--r--healthd/BatteryMonitor.cpp41
-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
12 files changed, 198 insertions, 22 deletions
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_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 a7571a260..b22cee6d8 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -244,6 +244,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},
@@ -251,6 +253,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;
@@ -260,10 +263,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);
}
@@ -356,6 +357,40 @@ 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:
+ 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;
+ }
+ }
+ }
+
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 dd67d04c0..3df0e917c 100644
--- a/init/Android.bp
+++ b/init/Android.bp
@@ -89,6 +89,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",
@@ -208,6 +216,7 @@ cc_library_static {
defaults: [
"init_defaults",
"selinux_policy_version",
+ "vendor_init_defaults",
],
srcs: init_common_sources + init_device_sources,
generated_sources: [
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 b3e7bc97e..392d35c5b 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -73,6 +73,7 @@
#include "subcontext.h"
#include "system/core/init/property_service.pb.h"
#include "util.h"
+#include "vendor_init.h"
using namespace std::literals;
@@ -1235,6 +1236,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();
@@ -1367,6 +1371,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) {
@@ -1385,6 +1390,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;
@@ -1399,6 +1433,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 c008f74bd..9edc32808 100644
--- a/init/reboot.cpp
+++ b/init/reboot.cpp
@@ -1030,7 +1030,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 bd704cf8e..34e820016 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -88,13 +88,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"],
},
},