From fae18c442d86c0ba80ab7473dd551ce5f01b0137 Mon Sep 17 00:00:00 2001 From: David Ng Date: Mon, 23 Sep 2013 18:50:24 -0700 Subject: [PATCH 01/38] init: Add vendor-specific initialization hooks. Allow optional vendor-specific initializations within init. This can be used for runtime initialization setup that init rc scripts do not support. Change-Id: I7623a0d59b18f9ec8e3623958e2f7ccd72b877bf --- init/Android.bp | 9 +++++++++ init/NOTICE | 26 ++++++++++++++++++++++++++ init/property_service.cpp | 4 ++++ init/vendor_init.cpp | 37 +++++++++++++++++++++++++++++++++++++ init/vendor_init.h | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 init/vendor_init.cpp create mode 100644 init/vendor_init.h diff --git a/init/Android.bp b/init/Android.bp index 7b529033a968..e9d12985df82 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 c5b1efa7aac7..383d0f5418a6 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 8da69822ccb9..e6ef33dee4e8 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; @@ -1206,6 +1207,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_fingerprint(); diff --git a/init/vendor_init.cpp b/init/vendor_init.cpp new file mode 100644 index 000000000000..d3fd5ffe2be9 --- /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 000000000000..9afb449be013 --- /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__ */ From e1dc5097c9ca34a714064ce32bdd11805d89e044 Mon Sep 17 00:00:00 2001 From: William Bellavance Date: Tue, 30 Aug 2016 08:04:38 -0400 Subject: [PATCH 02/38] init: don't skip starting a service with no domain if permissive [Adrian DC] Preserve the log while permissive Change-Id: I3f2887930e15d09014c2594141ba4acbbc8d6d9d --- init/service.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/init/service.cpp b/init/service.cpp index 35beaad33d02..caf971c4ece0 100644 --- a/init/service.cpp +++ b/init/service.cpp @@ -98,13 +98,16 @@ static Result 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"; From c5cd3fb3f1905ff29f3888d461eab3ac3b2eb984 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Sun, 6 Oct 2019 23:52:16 +0200 Subject: [PATCH 03/38] fs_mgr: mount: don't set the block device as ro for recovery * In recovery we need to be able to edit the block device after it's been mounted. This allows, for example, to wipe system after mounting it Change-Id: Ie536d275643e9d6063bba789e4cd2fa2671fc8fa --- fs_mgr/Android.bp | 5 +++++ fs_mgr/fs_mgr.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/fs_mgr/Android.bp b/fs_mgr/Android.bp index dd612720f26d..f4410112f140 100644 --- a/fs_mgr/Android.bp +++ b/fs_mgr/Android.bp @@ -161,6 +161,11 @@ cc_library { srcs: [ ":libfiemap_passthrough_srcs", ], + target: { + recovery: { + cflags: ["-DSKIP_SET_BLK_RO"], + }, + }, } cc_library { diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 742cdfab012a..9fed1aa3e9a4 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -845,9 +845,11 @@ static int __mount(const std::string& source, const std::string& target, const F } PINFO << __FUNCTION__ << "(source=" << source << source_missing << ",target=" << target << target_missing << ",type=" << entry.fs_type << ")=" << ret; +#ifndef SKIP_SET_BLK_RO if ((ret == 0) && (mountflags & MS_RDONLY) != 0) { fs_mgr_set_blk_ro(source); } +#endif if (ret == 0) { android::base::SetProperty("ro.boottime.init.mount." + Basename(target), std::to_string(t.duration().count())); From 4f8fe9743f8323bf952b1797e0412f4eeeb85c61 Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Wed, 6 Sep 2017 17:49:04 +0000 Subject: [PATCH 04/38] Revert "Format formattable partitions if mount fails" This reverts commit 29dd6b6c01295222fee5ef2fc70692b2ecb12504. Change-Id: I7b76cd920019ae8cb7270b3f83e777ea9de7f7a4 --- fs_mgr/fs_mgr_roots.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/fs_mgr/fs_mgr_roots.cpp b/fs_mgr/fs_mgr_roots.cpp index 2ad8125e78ff..79910a286811 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; From 121d5b594e279a2a6a6c1b3e106d7eea3f3c019c Mon Sep 17 00:00:00 2001 From: Alessandro Date: Mon, 6 Apr 2020 19:04:11 +0200 Subject: [PATCH 05/38] core: mark libsysutils and libdiskconfig recovery_available Change-Id: I4e64c6d3951dac4a424617d8fdf6d37962d3b4f2 --- libdiskconfig/Android.bp | 1 + libsysutils/Android.bp | 1 + 2 files changed, 2 insertions(+) diff --git a/libdiskconfig/Android.bp b/libdiskconfig/Android.bp index f523d4e70c28..bf8d8946d55a 100644 --- a/libdiskconfig/Android.bp +++ b/libdiskconfig/Android.bp @@ -4,6 +4,7 @@ package { cc_library { name: "libdiskconfig", + recovery_available: true, vendor_available: true, vndk: { enabled: true, diff --git a/libsysutils/Android.bp b/libsysutils/Android.bp index 5f472b2abd2c..aadaaf8858b8 100644 --- a/libsysutils/Android.bp +++ b/libsysutils/Android.bp @@ -4,6 +4,7 @@ package { cc_library { name: "libsysutils", + recovery_available: true, vendor_available: true, vndk: { enabled: true, From 718441af520d8f560622f56c83630a73e0be1423 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Wed, 26 Feb 2020 17:30:50 +0100 Subject: [PATCH 06/38] reboot: allow opting-in to fastbootd Change-Id: Iaf5eb813e848ef05b1b455ebfe3643f4a8b4f80d --- init/reboot.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init/reboot.cpp b/init/reboot.cpp index 27a7876db881..361a84aa13de 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -1057,7 +1057,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 From 8ac15796be5881dd69ec85173bb5a6dd5f3b0db7 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Thu, 28 Jul 2016 12:17:40 -0700 Subject: [PATCH 07/38] healthd: Add DASH charger type Change-Id: Ie1ca5018c465f6b2c15cbc00bdf3bb866d98ddef --- healthd/BatteryMonitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index bd7955a7f8b4..74240e953773 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -311,6 +311,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; From 8b70f2f48cb8284582ffc3cdcaea2591e9f9c085 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Mon, 14 Sep 2015 16:35:26 -0700 Subject: [PATCH 08/38] healthd: Add support for HVDCP_3 chargers HVDCP_3 is a high voltage DCP charger where the charger's voltage can be changed by issuing pulses on the D+/D- lines. Add support to recognize it and treat it as an AC power source. Change-Id: Ib719529904e8b7a676bbdc5f5953f0f9da6df3fa --- healthd/BatteryMonitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 74240e953773..fe06800a0b38 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -304,6 +304,7 @@ 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_CDP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_ACA", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_C", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, From 643053433adb0adb94b775861a7e19a71653d574 Mon Sep 17 00:00:00 2001 From: Dyneteve Date: Wed, 1 Dec 2021 14:42:39 +0100 Subject: [PATCH 09/38] healthd: Add support for HVDCP_3P5 chargers Change-Id: I810e2e051329edeec54fc24255d785993066eece --- healthd/BatteryMonitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index fe06800a0b38..41ac1dee213e 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -305,6 +305,7 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path) {"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}, From b386bb23f765f8a2c23dc9f5227d228d025455f3 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Tue, 24 May 2016 15:12:11 -0700 Subject: [PATCH 10/38] healthd: Reinitialize mChargerNames for every battery update Booting up the device without usb, the kernel sets the usb power supply type as UNKNOWN. The type of usb power supply changes at run-time as various chargers are plugged in/out. However, healthd initilizes the charger list only at bootup. Change it such that it checks for charger type changes with every battery or usb uevent. While at it, the kernel may have a power supply type which is not known to healthd. This is perfectly fine. Update healthd to not print a warning. Change-Id: I2ec9f9a420ca61814d43c316b418ce94de3691bc --- healthd/BatteryMonitor.cpp | 50 +++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 41ac1dee213e..75af4402c7e1 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -323,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(*ret); } @@ -445,6 +443,52 @@ void BatteryMonitor::updateValues(void) { double MaxPower = 0; + // Rescan for the available charger types + std::unique_ptr 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, From 883cf9c84ea454643b693fb8bb3df2b1e8643681 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Sun, 20 Feb 2022 22:50:06 +0800 Subject: [PATCH 11/38] llkd: Include llkd-debuggable.rc in eng builds only * Some (poorly written?) apps are continuously detected as Z state and killed by llkd even though they work just fine, leading to extremely bad UX and false positive bug reports. * llkd is disabled by default but enabled by llkd-debuggable.rc on ro.debuggable=1. Exclude it on userdebug builds to replicate user build behavior. Change-Id: I8365149e7896e03e58808bbead208b8d4fca6a8c --- llkd/Android.bp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llkd/Android.bp b/llkd/Android.bp index 1c0e0f0a0e94..fc4be0062eb1 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"], }, }, From 6e7e4cde87fac8b4456d98fb6d6cca45b84f503f Mon Sep 17 00:00:00 2001 From: Nolen Johnson Date: Thu, 6 Jan 2022 16:59:08 -0500 Subject: [PATCH 12/38] fs_mgr: Don't run clean_scratch_files on non-dynamic devices * This results in a metric ton of denials on some devices and eats up valuable resources on boot, plus there's 0 need for it, so kill it. Change-Id: Ic52d5b3f06724430e9505345024cf0041b37ca49 --- fs_mgr/clean_scratch_files.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs_mgr/clean_scratch_files.rc b/fs_mgr/clean_scratch_files.rc index 25a7e690ac05..71708f8c1dff 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 From 0404a88f22f01c8a5f157b52b889261e87fab848 Mon Sep 17 00:00:00 2001 From: Chirayu Desai Date: Thu, 17 Mar 2022 04:32:31 +0530 Subject: [PATCH 13/38] libsparse: Add simg2img_static target for host * For extract-tools Change-Id: I15772394a24c2ff1fdd6eece86548a72a5d4d748 --- libsparse/Android.bp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libsparse/Android.bp b/libsparse/Android.bp index 8e83e1670ecd..a7289836f0c8 100644 --- a/libsparse/Android.bp +++ b/libsparse/Android.bp @@ -54,6 +54,23 @@ cc_binary { cflags: ["-Werror"], } +cc_binary_host { + name: "simg2img_static", + srcs: [ + "simg2img.cpp", + "sparse_crc32.cpp", + ], + static_libs: [ + "libsparse", + "libz", + "libbase", + ], + + cflags: ["-Werror"], + stl: "libc++_static", + static_executable: true, +} + cc_binary { name: "img2simg", host_supported: true, From 5c1162f6e64e2d1ab5bb951ebda527928e9393e6 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Sat, 9 Apr 2022 19:37:39 +0300 Subject: [PATCH 14/38] libsysutils: Hide NetlinkListener error in recovery * Prevents users from seeing this message in recovery: `E:recvmsg failed (No buffer space available)` * This is caused by volume_manager (our addition in recovery) and hiding this error does not seem to have any negative side effect. Change-Id: I0d65796961c3036289ed13c0b8949a27b5b97ad6 --- libsysutils/src/NetlinkListener.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libsysutils/src/NetlinkListener.cpp b/libsysutils/src/NetlinkListener.cpp index aad0394dac28..3dc2e4355c1c 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; } From aa81777e67bb439edb5735b50735a1d1bbf8bb72 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Wed, 11 May 2022 04:47:15 +0300 Subject: [PATCH 15/38] fastboot: Prefer ro.boot.hardware.revision for hw-revision ro.revision defaults to 0 if it's not set in cmdline. Some devices might want to set it in their device specific init files, however it's not possible to override ro properties. Test: Set ro.boot.hardware.revision in device specific init.rc and observe fastboot getvar hw-revision in fastbootd Change-Id: I6e785c3fe3a49409e815af269a9a8db732b80ada --- fastboot/device/variables.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index d2a794715ba8..879a038e4766 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -421,7 +421,10 @@ std::vector> GetAllPartitionArgsNoSlot(FastbootDevice* bool GetHardwareRevision(FastbootDevice* /* device */, const std::vector& /* args */, std::string* message) { - *message = android::base::GetProperty("ro.revision", ""); + *message = android::base::GetProperty("ro.boot.hardware.revision", ""); + if (message->empty()) { + *message = android::base::GetProperty("ro.revision", ""); + } return true; } From b41673f9e1bf8f4ed813127cf9f5dc87a1760de1 Mon Sep 17 00:00:00 2001 From: me-cafebabe Date: Sat, 16 Jul 2022 20:10:52 +0000 Subject: [PATCH 16/38] liblp: Allow to flash on bigger block device Needed for using Retrofit Dynamic Partitions on unified targets, which has different partition sizes on different devices. Change-Id: I2b4c05401569ce5fc301ebafa7d130c3b0d87c64 --- fs_mgr/liblp/writer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs_mgr/liblp/writer.cpp b/fs_mgr/liblp/writer.cpp index 2708efa1564b..7db0b787e463 100644 --- a/fs_mgr/liblp/writer.cpp +++ b/fs_mgr/liblp/writer.cpp @@ -138,8 +138,8 @@ static bool ValidateAndSerializeMetadata([[maybe_unused]] const IPartitionOpener PERROR << partition_name << ": ioctl"; return false; } - if (info.size != block_device.size) { - LERROR << "Block device " << partition_name << " size mismatch (expected" + if (info.size < block_device.size) { + LERROR << "Block device " << partition_name << " size is too small (expected" << block_device.size << ", got " << info.size << ")"; return false; } From 3df718b4ba4dceaee2473c0ddeb46e035c0d7d2e Mon Sep 17 00:00:00 2001 From: Aaron Kling Date: Sun, 29 Jan 2023 19:20:33 -0600 Subject: [PATCH 17/38] init: Don't enable ADB by default on userdebug builds This is to match the changes in post_process_props made in I33ae5c6f2787017a62e679aa0c28d4b909d45935 Change-Id: If521a8abb4810f8b5d4e3164a06969af4fc12374 --- init/property_service.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index e6ef33dee4e8..c8e1e14c35d3 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -831,13 +831,13 @@ static void LoadPropertiesFromSecondStageRes(std::map* // So we need to apply the same rule of build/make/tools/post_process_props.py // on runtime. static void update_sys_usb_config() { - bool is_debuggable = android::base::GetBoolProperty("ro.debuggable", false); + bool is_eng = !android::base::GetBoolProperty("ro.adb.secure", true); std::string config = android::base::GetProperty("persist.sys.usb.config", ""); // b/150130503, add (config == "none") condition here to prevent appending // ",adb" if "none" is explicitly defined in default prop. if (config.empty() || config == "none") { - InitPropertySet("persist.sys.usb.config", is_debuggable ? "adb" : "none"); - } else if (is_debuggable && config.find("adb") == std::string::npos && + InitPropertySet("persist.sys.usb.config", is_eng ? "adb" : "none"); + } else if (is_eng && config.find("adb") == std::string::npos && config.length() + 4 < PROP_VALUE_MAX) { config.append(",adb"); InitPropertySet("persist.sys.usb.config", config); From f0aa64b09d8f79f6267abe2854fab6e173b93f81 Mon Sep 17 00:00:00 2001 From: me-cafebabe Date: Tue, 4 Oct 2022 12:41:16 +0000 Subject: [PATCH 18/38] first_stage_mount: Skip dm-verity setup if AVB is not enabled Change-Id: Ia06e94e91cf5fdce14ce37eb85fdd95df1d059bc --- init/first_stage_mount.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp index 07ce4588d039..977cf7a01615 100644 --- a/init/first_stage_mount.cpp +++ b/init/first_stage_mount.cpp @@ -419,9 +419,14 @@ bool FirstStageMount::MountPartition(const Fstab::iterator& begin, bool erase_sa return false; } } - if (!SetUpDmVerity(&(*begin))) { - PLOG(ERROR) << "Failed to setup verity for '" << begin->mount_point << "'"; - return false; + + if (begin->fs_mgr_flags.avb) { + if (!SetUpDmVerity(&(*begin))) { + PLOG(ERROR) << "Failed to setup verity for '" << begin->mount_point << "'"; + return false; + } + } else { + LOG(INFO) << "AVB is not enabled, skip verity setup for '" << begin->mount_point << "'"; } bool mounted = (fs_mgr_do_mount_one(*begin) == 0); From 3e16129b575472d46365c055ea564adb0f054011 Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Wed, 26 Feb 2020 20:09:32 +0100 Subject: [PATCH 19/38] fastbootd: usb: fallback to v1 descriptors Change-Id: Ibe8ae5ca8ffd44c3871a8855b06849034c74eb2f --- fastboot/device/usb_client.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/fastboot/device/usb_client.cpp b/fastboot/device/usb_client.cpp index d1b38d46c8d6..8ec7cc1c9878 100644 --- a/fastboot/device/usb_client.cpp +++ b/fastboot/device/usb_client.cpp @@ -53,6 +53,16 @@ struct SsFuncDesc { struct usb_ss_ep_comp_descriptor sink_comp; } __attribute__((packed)); +struct DescV1 { + struct usb_functionfs_descs_head_v1 { + __le32 magic; + __le32 length; + __le32 fs_count; + __le32 hs_count; + } __attribute__((packed)) header; + struct FuncDesc fs_descs, hs_descs; +} __attribute__((packed)); + struct DescV2 { struct usb_functionfs_descs_head_v2 header; // The rest of the structure depends on the flags in the header. @@ -169,6 +179,17 @@ static const struct { }, }; +static struct DescV1 v1_descriptor = { + .header = { + .magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC), + .length = htole32(sizeof(v1_descriptor)), + .fs_count = 3, + .hs_count = 3, + }, + .fs_descs = fs_descriptors, + .hs_descs = hs_descriptors, +}; + static struct DescV2 v2_descriptor = { .header = { @@ -205,8 +226,12 @@ static bool InitFunctionFs(usb_handle* h) { auto ret = write(h->control.get(), &v2_descriptor, sizeof(v2_descriptor)); if (ret < 0) { - PLOG(ERROR) << "cannot write descriptors " << kUsbFfsFastbootEp0; - goto err; + // fallback to v1 descriptor + ret = write(h->control.get(), &v1_descriptor, sizeof(v1_descriptor)); + if (ret < 0) { + PLOG(ERROR) << "cannot write descriptors " << kUsbFfsFastbootEp0; + goto err; + } } ret = write(h->control.get(), &strings, sizeof(strings)); From a7d488583a994a466740b0bc565e40d433439fac Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Wed, 26 Feb 2020 20:10:35 +0100 Subject: [PATCH 20/38] fastbootd: hacks for legacy * Use different endpoint addresses for sinks and sources * Consider locked only explicitely `green` devices * [npjohnson] Updated for 12's logic Change-Id: If093556e8e839cadf29f9e8f995f09ed3f188ed1 --- fastboot/device/usb_client.cpp | 46 +++++++++++++++++++++++++++++++--- fastboot/device/utility.cpp | 2 +- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/fastboot/device/usb_client.cpp b/fastboot/device/usb_client.cpp index 8ec7cc1c9878..9cb7aa40a732 100644 --- a/fastboot/device/usb_client.cpp +++ b/fastboot/device/usb_client.cpp @@ -156,6 +156,46 @@ static struct SsFuncDesc ss_descriptors = { }, }; +static struct FuncDesc fs_descriptors_v1 = { + .intf = fastboot_interface, + .source = + { + .bLength = sizeof(fs_descriptors_v1.source), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 1 | USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = kMaxPacketSizeFs, + }, + .sink = + { + .bLength = sizeof(fs_descriptors_v1.sink), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 2 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = kMaxPacketSizeFs, + }, +}; + +static struct FuncDesc hs_descriptors_v1 = { + .intf = fastboot_interface, + .source = + { + .bLength = sizeof(hs_descriptors_v1.source), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 1 | USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = kMaxPacketSizeHs, + }, + .sink = + { + .bLength = sizeof(hs_descriptors_v1.sink), + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 2 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = kMaxPacketSizeHs, + }, +}; + #define STR_INTERFACE_ "fastbootd" static const struct { @@ -186,8 +226,8 @@ static struct DescV1 v1_descriptor = { .fs_count = 3, .hs_count = 3, }, - .fs_descs = fs_descriptors, - .hs_descs = hs_descriptors, + .fs_descs = fs_descriptors_v1, + .hs_descs = hs_descriptors_v1, }; static struct DescV2 v2_descriptor = { @@ -226,7 +266,7 @@ static bool InitFunctionFs(usb_handle* h) { auto ret = write(h->control.get(), &v2_descriptor, sizeof(v2_descriptor)); if (ret < 0) { - // fallback to v1 descriptor + // fallback to v1 descriptor, with different endpoint addresses for source and sink ret = write(h->control.get(), &v1_descriptor, sizeof(v1_descriptor)); if (ret < 0) { PLOG(ERROR) << "cannot write descriptors " << kUsbFfsFastbootEp0; diff --git a/fastboot/device/utility.cpp b/fastboot/device/utility.cpp index e12ee64790ff..d374305e39ad 100644 --- a/fastboot/device/utility.cpp +++ b/fastboot/device/utility.cpp @@ -195,7 +195,7 @@ std::vector ListPartitions(FastbootDevice* device) { } bool GetDeviceLockStatus() { - return android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange"; + return android::base::GetProperty("ro.boot.verifiedbootstate", "") == "green"; } bool UpdateAllPartitionMetadata(FastbootDevice* device, const std::string& super_name, From ea1b3bbbe7c873e4e3bf399d9d7f057e0f7f1566 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Mon, 5 Apr 2021 23:20:49 -0700 Subject: [PATCH 21/38] init.rc: Disable native stats collection service When opening and closing activities in Settings, a measurably significant amount of CPU time is spent processing and logging stats events in statsd: 0.02% /apex/com.android.os.statsd/lib64/libstatspull.so @plt 0.01% /apex/com.android.os.statsd/bin/statsd @plt 0.01% /apex/com.android.os.statsd/bin/statsd SocketListener::runListener() 0.01% /apex/com.android.os.statsd/bin/statsd android::os::statsd::LogEvent::parseBuffer(unsigned char*, unsigned long) 0.01% /apex/com.android.os.statsd/bin/statsd android::os::statsd::LogEvent::parseAnnotations(unsigned char, int) Over longer device uptimes with real-world usage, statsd uses a substantial amount of total CPU time. We have no use for the stats recorded by statsd, so disable the service entirely to save CPU in potential hotpaths. This is the system/core part of the change; changes to frameworks/base are also required. Test: simpleperf record -a; verify that statsd no longer appears in sample hits Change-Id: Idf6fdb0eff987169bd5f370dd72315e831a669e6 --- rootdir/init.rc | 3 --- 1 file changed, 3 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index 1e6918d0022c..3ef3e1ca11c5 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -1073,7 +1073,6 @@ on zygote-start && property:ro.crypto.state=unencrypted wait_for_prop odsign.verification.done 1 # A/B update verifier that marks a successful boot. exec_start update_verifier_nonencrypted - start statsd start netd start zygote start zygote_secondary @@ -1082,7 +1081,6 @@ on zygote-start && property:ro.crypto.state=unsupported wait_for_prop odsign.verification.done 1 # A/B update verifier that marks a successful boot. exec_start update_verifier_nonencrypted - start statsd start netd start zygote start zygote_secondary @@ -1091,7 +1089,6 @@ on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type wait_for_prop odsign.verification.done 1 # A/B update verifier that marks a successful boot. exec_start update_verifier_nonencrypted - start statsd start netd start zygote start zygote_secondary From 7578de93be48b5fd22be48f99ca56247b76f1c16 Mon Sep 17 00:00:00 2001 From: Alex Naidis Date: Thu, 22 Dec 2016 22:04:42 +0100 Subject: [PATCH 22/38] init.rc: don't start console unless asked to This can have a major impact on performance. We don't want this, even on userdebug/eng builds. Use the new property "ro.console.enable" to enable the console service explicitly. Change-Id: I93e7c65e92261443d1c9c70cfef9aa2ed5ff328a Signed-off-by: Alex Naidis --- rootdir/init.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index 3ef3e1ca11c5..e7a4d0efe232 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -1309,7 +1309,7 @@ on property:ro.debuggable=1 # Give reads to anyone for the accessibility trace folder on debug builds. chmod 0775 /data/misc/a11ytrace -on init && property:ro.debuggable=1 +on init && property:ro.debuggable=1 && property:ro.console.enable=1 start console on userspace-reboot-requested From 4b9e03f2c1b42e97b9be12a8f1dbdcda954b478c Mon Sep 17 00:00:00 2001 From: Alex Naidis Date: Sun, 9 Apr 2017 01:29:27 +0200 Subject: [PATCH 23/38] init: Weaken property override security for the init extension Sometimes we need to override ro.* properties by using our vendor init extension. Previously there was a security check which was blocking that. To resolve the issue, we need to weaken the security check during the execution of our vendor init extension. This is safe because the vendor init extension gets executed as part of init construction and it is considered a trusted system component. Change-Id: I6198b453745cb92c65d3e3d49e3262354cddd2a2 Signed-off-by: Alex Naidis Signed-off-by: Park Ju Hyung Former-commit-id: 15aafc0c179544dd173a7afdce8d4d24b19219e7 Former-commit-id: d5ce44bfdf41cbe51f7432a04409bb11147b35a4 Former-commit-id: ff0763ca639d4987d1130f9838474b935f9b9950 Former-commit-id: 760b30eff74a6e212f57b09be8505ae8283ef3c8 Former-commit-id: 259b97b043c0769d4c8886c9ace9686ca2188536 Former-commit-id: b2022a67efa74fb7bc00e52fdac4a545599104a2 Former-commit-id: 16a827cae1ccc17f2b3fc0b35b979619c1c195be Former-commit-id: 3f64b3f7a1c4ba677bc02d172f8565e00ad803d7 --- init/property_service.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index c8e1e14c35d3..446ec096388d 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -128,6 +128,8 @@ struct PropertyAuditData { const char* name; }; +static bool weaken_prop_override_security = false; + static int PropertyAuditCallback(void* data, security_class_t /*cls*/, char* buf, size_t len) { auto* d = reinterpret_cast(data); @@ -397,8 +399,8 @@ static std::optional PropertySet(const std::string& name, const std::s prop_info* pi = (prop_info*)__system_property_find(name.c_str()); if (pi != nullptr) { - // ro.* properties are actually "write-once". - if (StartsWith(name, "ro.")) { + // ro.* properties are actually "write-once", unless the system decides to + if (StartsWith(name, "ro.") && !weaken_prop_override_security) { *error = "Read-only property was already set"; return {PROP_ERROR_READ_ONLY_PROPERTY}; } @@ -1207,6 +1209,9 @@ void PropertyLoadBootDefaults() { } } + // Weaken property override security during execution of the vendor init extension + weaken_prop_override_security = true; + // Update with vendor-specific property runtime overrides vendor_load_properties(); @@ -1217,6 +1222,9 @@ void PropertyLoadBootDefaults() { property_initialize_ro_cpu_abilist(); property_initialize_ro_vendor_api_level(); + // Restore the normal property override security after init extension is executed + weaken_prop_override_security = false; + update_sys_usb_config(); } From 71e63597a000f5b1d550d7907946f0741f06e15a Mon Sep 17 00:00:00 2001 From: Alex Naidis Date: Sun, 9 Apr 2017 01:29:27 +0200 Subject: [PATCH 24/38] init: Weaken property override security for the init extension Sometimes we need to override ro.* properties by using our vendor init extension. Previously there was a security check which was blocking that. To resolve the issue, we need to weaken the security check during the execution of our vendor init extension. This is safe because the vendor init extension gets executed as part of init construction and it is considered a trusted system component. Change-Id: Ia7d60686968695f1fb43be4ed58770ce10da88c5 Former-commit-id: 91d12168b9500a44211a7d5a092e0ebcfed48d4d Change-Id: I07629b6c19b5ebfa019307c497c18d8bcc719685 Former-commit-id: afc71394f9bbdd04589380bb4ef52df27f1baa26 Former-commit-id: 6bd10f8e34a25a4652b25d76326d48e38721ff5e Former-commit-id: 0cdd630eae8e659533be3331c03452662c8f3e97 --- init/property_service.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init/property_service.cpp b/init/property_service.cpp index 446ec096388d..c2f8623ccdaa 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -1226,6 +1226,9 @@ void PropertyLoadBootDefaults() { weaken_prop_override_security = false; update_sys_usb_config(); + + // Restore the normal property override security after init extension is executed + weaken_prop_override_security = false; } bool LoadPropertyInfoFromFile(const std::string& filename, From 829617f759c5b4acc882d60bbfbcb3f3fc9eedb0 Mon Sep 17 00:00:00 2001 From: Park Ju Hyung Date: Mon, 6 Nov 2017 20:30:39 +0900 Subject: [PATCH 25/38] init: workaround SafetyNet check Doing this in the userspace allows more properties to be spoofed and eliminate the needs for a hack in the kernel. Former-commit-id: e036a461c7dd4d97e1df77979c85f3c198e1e784 Change-Id: I76f6e210247a032b764dea2f5a23a184745f59a0 Former-commit-id: 74af52f30476991814fff83b850af1883e3944ee Former-commit-id: 0709c6917bbd814ae88fc04ff82425c2892ef4ad Former-commit-id: 00e6bc4f619eaad5b7fcd0524c99cf31bcc5b5e1 --- init/property_service.cpp | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/init/property_service.cpp b/init/property_service.cpp index c2f8623ccdaa..6ad6ea839189 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -860,6 +860,50 @@ static void load_override_properties() { } } +static const char *snet_prop_key[] = { + "ro.boot.vbmeta.device_state", + "ro.boot.verifiedbootstate", + "ro.boot.flash.locked", + "ro.boot.selinux", + "ro.boot.veritymode", + "ro.boot.warranty_bit", + "ro.warranty_bit", + "ro.debuggable", + "ro.secure", + "ro.build.type", + "ro.build.keys", + "ro.build.tags", + "ro.system.build.tags", + NULL +}; + +static const char *snet_prop_value[] = { + "locked", // ro.boot.vbmeta.device_state + "green", // ro.boot.verifiedbootstate + "1", // ro.boot.flash.locked + "enforcing", // ro.boot.selinux + "enforcing", // ro.boot.veritymode + "0", // ro.boot.warranty_bit + "0", // ro.warranty_bit + "0", // ro.debuggable + "1", // ro.secure + "user", // ro.build.type + "release-keys", // ro.build.keys + "release-keys", // ro.build.tags + "release-keys", // ro.system.build.tags + NULL +}; + +static void workaround_snet_properties() { + std::string error; + LOG(INFO) << "snet: Hiding sensitive props"; + + // Hide all sensitive props + for (int i = 0; snet_prop_key[i]; ++i) { + PropertySet(snet_prop_key[i], snet_prop_value[i], &error); + } +} + // If the ro.product.[brand|device|manufacturer|model|name] properties have not been explicitly // set, derive them from ro.product.${partition}.* properties static void property_initialize_ro_product_props() { @@ -1227,6 +1271,9 @@ void PropertyLoadBootDefaults() { update_sys_usb_config(); + // Workaround SafetyNet + workaround_snet_properties(); + // Restore the normal property override security after init extension is executed weaken_prop_override_security = false; } From fb2b7a31cf8c02b93247efd234fded645bae8f8b Mon Sep 17 00:00:00 2001 From: Chris Renshaw Date: Sat, 9 May 2020 06:53:32 -0300 Subject: [PATCH 26/38] init: add vendor.* keys to spoof safetynet aswinas@pixysos: add some more props from magisk hide to userspace hack by arter97 Former-commit-id: fc79269db601c9cd0dad3781d4e6ee8f209c55fc Change-Id: I8a88862674ca5a9eb8df5050e04344a2acb0a79f Former-commit-id: bd20ecc029c4d82226b40f7c56185abdd59955fc Former-commit-id: 10d57a483aca29386196d4284085c35f84d7cff9 Former-commit-id: af9890ace1d4df6eb040be59a7fe5dcbed2749f9 --- init/property_service.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/init/property_service.cpp b/init/property_service.cpp index 6ad6ea839189..d63f41df21d2 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -874,6 +874,10 @@ static const char *snet_prop_key[] = { "ro.build.keys", "ro.build.tags", "ro.system.build.tags", + "ro.vendor.boot.warranty_bit", + "ro.vendor.warranty_bit", + "vendor.boot.vbmeta.device_state", + "vendor.boot.verifiedbootstate", NULL }; @@ -891,6 +895,10 @@ static const char *snet_prop_value[] = { "release-keys", // ro.build.keys "release-keys", // ro.build.tags "release-keys", // ro.system.build.tags + "0", // ro.vendor.boot.warranty_bit + "0", // ro.vendor.warranty_bit + "locked", // vendor.boot.vbmeta.device_state + "green", // vendor.boot.verifiedbootstate NULL }; From 8ca80f9ed702e4e453680eb138a53a55443ddad9 Mon Sep 17 00:00:00 2001 From: jhenrique09 Date: Fri, 20 Nov 2020 11:34:54 -0300 Subject: [PATCH 27/38] init: Weaken property override security only when spoofing safetynet Change-Id: I740afaa27de82bec1e6d58b58d431141ca6b4e3f Former-commit-id: ca62a22d017f44c9f63553a44f5017eb5b8e9095 Change-Id: Icea7076c6c0ffc2ab3d66899335a5a477ccc519a Former-commit-id: 688821317d5bed7701362875143dc43c4b152630 Former-commit-id: ba856e490845683ea08fc22183e12ee419f064a2 Former-commit-id: 2eb3d3e12d17668c17f1f2ccb9a5149bda5ea479 --- init/property_service.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index d63f41df21d2..f25a87e32768 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -903,6 +903,9 @@ static const char *snet_prop_value[] = { }; static void workaround_snet_properties() { + // Weaken property override security to set safetynet props + weaken_prop_override_security = true; + std::string error; LOG(INFO) << "snet: Hiding sensitive props"; @@ -910,6 +913,9 @@ static void workaround_snet_properties() { for (int i = 0; snet_prop_key[i]; ++i) { PropertySet(snet_prop_key[i], snet_prop_value[i], &error); } + + // Restore the normal property override security after safetynet props have been set + weaken_prop_override_security = false; } // If the ro.product.[brand|device|manufacturer|model|name] properties have not been explicitly @@ -1281,9 +1287,6 @@ void PropertyLoadBootDefaults() { // Workaround SafetyNet workaround_snet_properties(); - - // Restore the normal property override security after init extension is executed - weaken_prop_override_security = false; } bool LoadPropertyInfoFromFile(const std::string& filename, From a7b08077dd968205df17582a4e09a4065204adb4 Mon Sep 17 00:00:00 2001 From: jhenrique09 Date: Fri, 20 Nov 2020 20:33:21 -0300 Subject: [PATCH 28/38] init: Only set safetynet props if not eng build Change-Id: Ic07539b4a7a97316720defd000425d1b6d15fd67 Former-commit-id: 9d4ca9403943feecd6f902e69d581aad3ee84839 Change-Id: Ic34d95c23afd8caf95c7b2a2517650dbf116fdde Former-commit-id: 1b99c0d0cc89f113d35eb065e435f61b51408b12 Former-commit-id: 6a32cd3778d9aca584751d7acd092be95cb85985 Former-commit-id: 6bcf9412a4f3def6c2bb49507045e685df2e55a4 --- init/property_service.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index f25a87e32768..283d29a908f4 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -903,16 +903,20 @@ static const char *snet_prop_value[] = { }; static void workaround_snet_properties() { + std::string build_type = android::base::GetProperty("ro.build.type", ""); + // Weaken property override security to set safetynet props weaken_prop_override_security = true; std::string error; - LOG(INFO) << "snet: Hiding sensitive props"; - // Hide all sensitive props - for (int i = 0; snet_prop_key[i]; ++i) { - PropertySet(snet_prop_key[i], snet_prop_value[i], &error); - } + // Hide all sensitive props if not eng build + if (build_type != "eng") { + LOG(INFO) << "snet: Hiding sensitive props"; + for (int i = 0; snet_prop_key[i]; ++i) { + PropertySet(snet_prop_key[i], snet_prop_value[i], &error); + } + } // Restore the normal property override security after safetynet props have been set weaken_prop_override_security = false; From 2da0fcf5b76fc36112a84cd5f0bb1388ee6c3d50 Mon Sep 17 00:00:00 2001 From: jhenrique09 Date: Sat, 19 Mar 2022 19:40:40 +0000 Subject: [PATCH 29/38] core: Add more props for snet spoofing Also reformat code Change-Id: I98aafcc2c1d8dae1448ecf3c18981fb7945599ba Former-commit-id: 72351d5aebdd5ed340429bb7228ec0ce5fc55318 Former-commit-id: acefb8c963d303ba91fbe861728860b51c7c5917 Former-commit-id: 0ccf4976491b9e85a1293ccd1f062a79656cbf90 --- init/property_service.cpp | 98 +++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 283d29a908f4..a9195f9952bd 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -861,45 +861,55 @@ static void load_override_properties() { } static const char *snet_prop_key[] = { - "ro.boot.vbmeta.device_state", - "ro.boot.verifiedbootstate", - "ro.boot.flash.locked", - "ro.boot.selinux", - "ro.boot.veritymode", - "ro.boot.warranty_bit", - "ro.warranty_bit", - "ro.debuggable", - "ro.secure", - "ro.build.type", - "ro.build.keys", - "ro.build.tags", - "ro.system.build.tags", - "ro.vendor.boot.warranty_bit", - "ro.vendor.warranty_bit", - "vendor.boot.vbmeta.device_state", - "vendor.boot.verifiedbootstate", - NULL + "ro.boot.vbmeta.device_state", + "ro.boot.verifiedbootstate", + "ro.boot.flash.locked", + "ro.boot.selinux", + "ro.boot.veritymode", + "ro.boot.warranty_bit", + "ro.warranty_bit", + "ro.debuggable", + "ro.secure", + "ro.build.type", + "ro.system.build.type", + "ro.system_ext.build.type", + "ro.vendor.build.type", + "ro.product.build.type", + "ro.odm.build.type", + "ro.build.keys", + "ro.build.tags", + "ro.system.build.tags", + "ro.vendor.boot.warranty_bit", + "ro.vendor.warranty_bit", + "vendor.boot.vbmeta.device_state", + "vendor.boot.verifiedbootstate", + NULL }; static const char *snet_prop_value[] = { - "locked", // ro.boot.vbmeta.device_state - "green", // ro.boot.verifiedbootstate - "1", // ro.boot.flash.locked - "enforcing", // ro.boot.selinux - "enforcing", // ro.boot.veritymode - "0", // ro.boot.warranty_bit - "0", // ro.warranty_bit - "0", // ro.debuggable - "1", // ro.secure - "user", // ro.build.type - "release-keys", // ro.build.keys - "release-keys", // ro.build.tags - "release-keys", // ro.system.build.tags - "0", // ro.vendor.boot.warranty_bit - "0", // ro.vendor.warranty_bit - "locked", // vendor.boot.vbmeta.device_state - "green", // vendor.boot.verifiedbootstate - NULL + "locked", // ro.boot.vbmeta.device_state + "green", // ro.boot.verifiedbootstate + "1", // ro.boot.flash.locked + "enforcing", // ro.boot.selinux + "enforcing", // ro.boot.veritymode + "0", // ro.boot.warranty_bit + "0", // ro.warranty_bit + "0", // ro.debuggable + "1", // ro.secure + "user", // ro.build.type + "user", // ro.system.build.type + "user", // ro.system_ext.build.type + "user", // ro.vendor.build.type + "user", // ro.product.build.type + "user", // ro.odm.build.type + "release-keys", // ro.build.keys + "release-keys", // ro.build.tags + "release-keys", // ro.system.build.tags + "0", // ro.vendor.boot.warranty_bit + "0", // ro.vendor.warranty_bit + "locked", // vendor.boot.vbmeta.device_state + "green", // vendor.boot.verifiedbootstate + NULL }; static void workaround_snet_properties() { @@ -908,16 +918,22 @@ static void workaround_snet_properties() { // Weaken property override security to set safetynet props weaken_prop_override_security = true; - std::string error; + std::string error; - // Hide all sensitive props if not eng build + // Hide all sensitive props if not eng build if (build_type != "eng") { - LOG(INFO) << "snet: Hiding sensitive props"; - for (int i = 0; snet_prop_key[i]; ++i) { + LOG(INFO) << "snet: Hiding sensitive props"; + for (int i = 0; snet_prop_key[i]; ++i) { PropertySet(snet_prop_key[i], snet_prop_value[i], &error); - } + } } + // Extra pops + std::string build_flavor_key = "ro.build.flavor"; + std::string build_flavor_value = android::base::GetProperty(build_flavor_key, ""); + build_flavor_value = android::base::StringReplace(build_flavor_value, "userdebug", "user", false); + PropertySet(build_flavor_key, build_flavor_value, &error); + // Restore the normal property override security after safetynet props have been set weaken_prop_override_security = false; } From beb18ae2ccb69e578c56c1cd34863711228d82ce Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Wed, 7 Oct 2020 00:24:54 -0700 Subject: [PATCH 30/38] init: Check for fastbootd before spoofing safetynet props The real prop values must be retained in recovery/fastbootd in order for fastbootd to allow/deny flashing correctly based on the bootloader lock state. This is accomplished by checking androidboot keys in the kernel cmdline and bootconfig (necessary on Pixel 6), and not spoofing anything if the boot isn't a normal full-blown Android boot. @jhenrique09 - Adapt to PE Change-Id: I66d23fd91d82906b00d5eb020668f01ae83ec31f Former-commit-id: 33d4578679733fb2d6fd0fd9b7baba8fd5f0be57 Former-commit-id: b929a87f6ee30e21f795442d52c6a9ece2822c66 --- init/property_service.cpp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index a9195f9952bd..346449490060 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -860,6 +860,8 @@ static void load_override_properties() { } } +constexpr auto ANDROIDBOOT_MODE = "androidboot.mode"sv; + static const char *snet_prop_key[] = { "ro.boot.vbmeta.device_state", "ro.boot.verifiedbootstate", @@ -915,17 +917,41 @@ static const char *snet_prop_value[] = { static void workaround_snet_properties() { std::string build_type = android::base::GetProperty("ro.build.type", ""); + // 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; + } + + // Exit if eng build + if (build_type == "eng") { + return; + } + // Weaken property override security to set safetynet props weaken_prop_override_security = true; std::string error; - // Hide all sensitive props if not eng build - if (build_type != "eng") { - LOG(INFO) << "snet: Hiding sensitive props"; - for (int i = 0; snet_prop_key[i]; ++i) { - PropertySet(snet_prop_key[i], snet_prop_value[i], &error); - } + // Hide all sensitive props + LOG(INFO) << "snet: Hiding sensitive props"; + for (int i = 0; snet_prop_key[i]; ++i) { + PropertySet(snet_prop_key[i], snet_prop_value[i], &error); } // Extra pops From 96501a6772aa768bd7cafb21c3ff1fbb0b9cb586 Mon Sep 17 00:00:00 2001 From: Jarl-Penguin Date: Wed, 16 Jun 2021 11:28:46 +0000 Subject: [PATCH 31/38] core: Don't spoof props in recovery mode Signed-off-by: Jarl-Penguin Change-Id: Ib6d3808c3b8f3e0cffab685a24d3cdd436b0fe9b Former-commit-id: 739111e6414984ad9dc0d30358e2370bfb4edc29 Former-commit-id: 8bd32066ec64aa48270ba7e11042b4cca19a35e8 Former-commit-id: 8686645611965f468ee635c1e81f6f743385fb91 --- init/property_service.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 346449490060..42e3bcfd7f4b 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -934,7 +934,7 @@ static void workaround_snet_properties() { // 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) { + if (!isNormalBoot || IsRecoveryMode()) { return; } @@ -1332,7 +1332,9 @@ void PropertyLoadBootDefaults() { update_sys_usb_config(); // Workaround SafetyNet - workaround_snet_properties(); + if (!IsRecoveryMode()) { + workaround_snet_properties(); + } } bool LoadPropertyInfoFromFile(const std::string& filename, From a8ddd77ed0adede18d24765ccd8e54ff3af76709 Mon Sep 17 00:00:00 2001 From: zlewchan Date: Wed, 26 Oct 2022 21:59:10 +0200 Subject: [PATCH 32/38] core: Treat reboot boot mode same as normal one OnePlus SM8250 sets this as a value while rebooting the OS for some reason. This causes the checks to fail and finally SafetyNet to fail after reboot. Signed-off-by: zlewchan Change-Id: Idc8cbd084c86b83815616be17f2a0828aa16f3af --- init/property_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 42e3bcfd7f4b..b65e6ae84760 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -921,12 +921,12 @@ static void workaround_snet_properties() { 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") { + if (key == ANDROIDBOOT_MODE && value != "normal" && value != "reboot") { isNormalBoot = false; } }); ImportBootconfig([&](const std::string& key, const std::string& value) { - if (key == ANDROIDBOOT_MODE && value != "normal") { + if (key == ANDROIDBOOT_MODE && value != "normal" && value != "reboot") { isNormalBoot = false; } }); From 69f202a212119985e55f861a420d5af6c2ed5500 Mon Sep 17 00:00:00 2001 From: Alexander Winkowski Date: Sat, 31 Dec 2022 18:56:20 +0000 Subject: [PATCH 33/38] Revert "core: Treat reboot boot mode same as normal one" This reverts commit 10a8c2c9c499571b217af9552623dade9d7e3e4a. Change-Id: Ie085871215d08ab022da3b410a9f44f5344ba8ff --- init/property_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index b65e6ae84760..42e3bcfd7f4b 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -921,12 +921,12 @@ static void workaround_snet_properties() { 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" && value != "reboot") { + if (key == ANDROIDBOOT_MODE && value != "normal") { isNormalBoot = false; } }); ImportBootconfig([&](const std::string& key, const std::string& value) { - if (key == ANDROIDBOOT_MODE && value != "normal" && value != "reboot") { + if (key == ANDROIDBOOT_MODE && value != "normal") { isNormalBoot = false; } }); From fa9405a74e8e695755736e0ffd00e690d46a705c Mon Sep 17 00:00:00 2001 From: Alexander Winkowski Date: Sat, 31 Dec 2022 18:59:05 +0000 Subject: [PATCH 34/38] Revert "core: Don't spoof props in recovery mode" This reverts commit 6fb5a48277ff81fd9a72a8b0dc278582c91a17e5. Change-Id: Ic7ed201729c7fb1d860fb687658c27826a0a855d --- init/property_service.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 42e3bcfd7f4b..346449490060 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -934,7 +934,7 @@ static void workaround_snet_properties() { // 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 || IsRecoveryMode()) { + if (!isNormalBoot) { return; } @@ -1332,9 +1332,7 @@ void PropertyLoadBootDefaults() { update_sys_usb_config(); // Workaround SafetyNet - if (!IsRecoveryMode()) { - workaround_snet_properties(); - } + workaround_snet_properties(); } bool LoadPropertyInfoFromFile(const std::string& filename, From 0542db414cc314cbbdbde105f2a6393af8f4448f Mon Sep 17 00:00:00 2001 From: Albert I Date: Fri, 29 Apr 2022 23:42:44 +0800 Subject: [PATCH 35/38] init: Use `IsRecoveryMode()` for normal boot checks Checking androidboot.mode properties will never work on devices where this property is always absent, primarily non-Pixel devices. Use existing IsRecoveryMode() check instead which is ugly, but works for this very purpose. Change-Id: Idc79fb2bf45f0416b242a1e1aa12bdb07bcf56b9 Signed-off-by: Albert I Signed-off-by: Alexander Winkowski --- init/property_service.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 346449490060..c3d13a6f7f49 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -860,8 +860,6 @@ static void load_override_properties() { } } -constexpr auto ANDROIDBOOT_MODE = "androidboot.mode"sv; - static const char *snet_prop_key[] = { "ro.boot.vbmeta.device_state", "ro.boot.verifiedbootstate", @@ -917,24 +915,10 @@ static const char *snet_prop_value[] = { static void workaround_snet_properties() { std::string build_type = android::base::GetProperty("ro.build.type", ""); - // 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) { + if (IsRecoveryMode()) { return; } From 194153204456f0c6d226297bd644c1baea27e1c1 Mon Sep 17 00:00:00 2001 From: xyyx Date: Fri, 6 Oct 2023 22:09:52 +0300 Subject: [PATCH 36/38] init: Replace PropertySet with PropertySetNoSocket --- init/property_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index c3d13a6f7f49..7850bb7c4f5b 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -935,14 +935,14 @@ static void workaround_snet_properties() { // Hide all sensitive props LOG(INFO) << "snet: Hiding sensitive props"; for (int i = 0; snet_prop_key[i]; ++i) { - PropertySet(snet_prop_key[i], snet_prop_value[i], &error); + PropertySetNoSocket(snet_prop_key[i], snet_prop_value[i], &error); } // Extra pops std::string build_flavor_key = "ro.build.flavor"; std::string build_flavor_value = android::base::GetProperty(build_flavor_key, ""); build_flavor_value = android::base::StringReplace(build_flavor_value, "userdebug", "user", false); - PropertySet(build_flavor_key, build_flavor_value, &error); + PropertySetNoSocket(build_flavor_key, build_flavor_value, &error); // Restore the normal property override security after safetynet props have been set weaken_prop_override_security = false; From 847b353a6aa6e415df7f6e89cfe675c7eebe75a0 Mon Sep 17 00:00:00 2001 From: Sauhard Pande Date: Wed, 24 Jun 2015 22:38:25 -0700 Subject: [PATCH 37/38] Camera: Add feature extensions This change includes below commits: Camera bringup changes system-core Change-Id: I1cf98641eca9096bd27645e07ea802646ea1fb96 system/core: Fix for HAL compilation issues while integrating HAL 1.0 Change-Id: Iead9c1ade279b64c5cbdf4d2de1a8b695939c52a Camera: Add enum to specify the frame type Added enum to specify the frame type of either fd/data buffer CRs-fixed: 654901 Change-Id: I1c0b1a2c6a1425cdb6650cdfc20ca65835a1b81f Change-Id: I654a40661e6e101da2a06986abeceb20639cccd9 --- libsystem/include/system/camera.h | 53 ++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/libsystem/include/system/camera.h b/libsystem/include/system/camera.h index 2ca90c395ba1..990edcf326f3 100644 --- a/libsystem/include/system/camera.h +++ b/libsystem/include/system/camera.h @@ -88,9 +88,20 @@ enum { // Notify on autofocus start and stop. This is useful in continuous // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback + CAMERA_MSG_VENDOR_START = 0x1000, + CAMERA_MSG_STATS_DATA = CAMERA_MSG_VENDOR_START, + CAMERA_MSG_META_DATA = 0x2000, + CAMERA_MSG_VENDOR_END = 0x8000, CAMERA_MSG_ALL_MSGS = 0xFFFF }; +/** meta data type in CameraMetaDataCallback */ +enum { + CAMERA_META_DATA_ASD = 0x001, //ASD data + CAMERA_META_DATA_FD = 0x002, //FD/FP data + CAMERA_META_DATA_HDR = 0x003, //Auto HDR data +}; + /** cmdType in sendCommand functions */ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, @@ -189,7 +200,25 @@ enum { * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags * of SW_READ_OFTEN. */ - CAMERA_CMD_SET_VIDEO_FORMAT = 11 + CAMERA_CMD_SET_VIDEO_FORMAT = 11, + + CAMERA_CMD_VENDOR_START = 20, + /** + * Commands to enable/disable preview histogram + * + * Based on user's input to enable/disable histogram from the camera + * UI, send the appropriate command to the HAL to turn on/off the histogram + * stats and start sending the data to the application. + */ + CAMERA_CMD_HISTOGRAM_ON = CAMERA_CMD_VENDOR_START, + CAMERA_CMD_HISTOGRAM_OFF = CAMERA_CMD_VENDOR_START + 1, + CAMERA_CMD_HISTOGRAM_SEND_DATA = CAMERA_CMD_VENDOR_START + 2, + CAMERA_CMD_LONGSHOT_ON = CAMERA_CMD_VENDOR_START + 3, + CAMERA_CMD_LONGSHOT_OFF = CAMERA_CMD_VENDOR_START + 4, + CAMERA_CMD_STOP_LONGSHOT = CAMERA_CMD_VENDOR_START + 5, + CAMERA_CMD_METADATA_ON = CAMERA_CMD_VENDOR_START + 6, + CAMERA_CMD_METADATA_OFF = CAMERA_CMD_VENDOR_START + 7, + CAMERA_CMD_VENDOR_END = 200, }; /** camera fatal errors */ @@ -284,9 +313,31 @@ typedef struct camera_face { * -2000, -2000 if this is not supported. */ int32_t mouth[2]; + int32_t smile_degree; + int32_t smile_score; + int32_t blink_detected; + int32_t face_recognised; + int32_t gaze_angle; + int32_t updown_dir; + int32_t leftright_dir; + int32_t roll_dir; + int32_t left_right_gaze; + int32_t top_bottom_gaze; + int32_t leye_blink; + int32_t reye_blink; } camera_face_t; +/** + * The information of a data type received in a camera frame. + */ +typedef enum { + /** Data buffer */ + CAMERA_FRAME_DATA_BUF = 0x000, + /** File descriptor */ + CAMERA_FRAME_DATA_FD = 0x100 +} camera_frame_data_type_t; + /** * The metadata of the frame data. */ From 49180082e3c8565eed685c9116dca98f5675a4ea Mon Sep 17 00:00:00 2001 From: "Christopher N. Hesse" Date: Sun, 4 Sep 2016 12:26:32 +0200 Subject: [PATCH 38/38] utils: Threads: Handle empty thread names * Fixes camera for Samsung Exynos devices: 08-30 18:07:03.585 2729 2729 I ExynosCameraFrameFactory: INFO(startThread[1608]):pipeId=0 08-30 18:07:03.585 2729 2729 F libutils.threads: thread name not provided to Thread::run 08-30 18:07:03.586 2729 2729 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 2729 (cameraserver) 08-30 18:07:03.587 2548 2548 W : debuggerd: handling request: pid=2729 uid=1047 gid=1005 tid=2729 08-30 18:07:03.656 6489 6489 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 08-30 18:07:03.656 6489 6489 F DEBUG : Build fingerprint: 'samsung/aosp_gts210ltexx/gts210ltexx:7.0/NYC/chris08292135:userdebug/test-keys' 08-30 18:07:03.656 6489 6489 F DEBUG : Revision: '0' 08-30 18:07:03.657 6489 6489 F DEBUG : ABI: 'arm' 08-30 18:07:03.657 6489 6489 F DEBUG : pid: 2729, tid: 2729, name: cameraserver >>> /system/bin/cameraserver <<< 08-30 18:07:03.658 6489 6489 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 08-30 18:07:03.673 6489 6489 F DEBUG : Abort message: 'thread name not provided to Thread::run' 08-30 18:07:03.673 6489 6489 F DEBUG : r0 00000000 r1 00000aa9 r2 00000006 r3 00000008 08-30 18:07:03.674 6489 6489 F DEBUG : r4 b5a2c58c r5 00000006 r6 b5a2c534 r7 0000010c 08-30 18:07:03.674 6489 6489 F DEBUG : r8 b28b5380 r9 00000000 sl 00000000 fp b2a92800 08-30 18:07:03.674 6489 6489 F DEBUG : ip 00000016 sp be90b350 lr b4f7e537 pc b4f80d94 cpsr 200f0010 08-30 18:07:03.694 6489 6489 F DEBUG : 08-30 18:07:03.694 6489 6489 F DEBUG : backtrace: 08-30 18:07:03.694 6489 6489 F DEBUG : #00 pc 00049d94 /system/lib/libc.so (tgkill+12) 08-30 18:07:03.694 6489 6489 F DEBUG : #01 pc 00047533 /system/lib/libc.so (pthread_kill+34) 08-30 18:07:03.694 6489 6489 F DEBUG : #02 pc 0001d885 /system/lib/libc.so (raise+10) 08-30 18:07:03.694 6489 6489 F DEBUG : #03 pc 000193d1 /system/lib/libc.so (__libc_android_abort+34) 08-30 18:07:03.694 6489 6489 F DEBUG : #04 pc 00017014 /system/lib/libc.so (abort+4) 08-30 18:07:03.695 6489 6489 F DEBUG : #05 pc 0000bfd5 /system/lib/libcutils.so (__android_log_assert+112) 08-30 18:07:03.695 6489 6489 F DEBUG : #06 pc 0000e265 /system/lib/libutils.so (_ZN7android6Thread3runEPKcij+212) 08-30 18:07:03.695 6489 6489 F DEBUG : #07 pc 00045903 /system/lib/libexynoscamera.so (_ZN7android16ExynosCameraPipe11startThreadEv+74) 08-30 18:07:03.695 6489 6489 F DEBUG : #08 pc 0007b1c3 /system/lib/libexynoscamera.so (_ZN7android24ExynosCameraFrameFactory11startThreadEj+70) 08-30 18:07:03.695 6489 6489 F DEBUG : #09 pc 0007bcef /system/lib/libexynoscamera.so (_ZN7android24ExynosCameraFrameFactory19startInitialThreadsEv+70) 08-30 18:07:03.695 6489 6489 F DEBUG : #10 pc 0006231d /system/lib/libexynoscamera.so (_ZN7android12ExynosCamera22m_startPreviewInternalEv+1140) 08-30 18:07:03.695 6489 6489 F DEBUG : #11 pc 0006b897 /system/lib/libexynoscamera.so (_ZN7android12ExynosCamera12startPreviewEv+1666) 08-30 18:07:03.695 6489 6489 F DEBUG : #12 pc 000037b1 /system/lib/hw/camera.universal5433.so 08-30 18:07:03.695 6489 6489 F DEBUG : #13 pc 0006094f /system/lib/libcameraservice.so (_ZN7android12CameraClient16startPreviewModeEv+102) 08-30 18:07:03.695 6489 6489 F DEBUG : #14 pc 00060825 /system/lib/libcameraservice.so (_ZN7android12CameraClient15startCameraModeENS0_11camera_modeE+68) 08-30 18:07:03.695 6489 6489 F DEBUG : #15 pc 000282f9 /system/lib/libcamera_client.so (_ZN7android8hardware8BnCamera10onTransactEjRKNS_6ParcelEPS2_j+724) 08-30 18:07:03.695 6489 6489 F DEBUG : #16 pc 000359b3 /system/lib/libbinder.so (_ZN7android7BBinder8transactEjRKNS_6ParcelEPS1_j+70) 08-30 18:07:03.695 6489 6489 F DEBUG : #17 pc 0003d159 /system/lib/libbinder.so (_ZN7android14IPCThreadState14executeCommandEi+684) 08-30 18:07:03.695 6489 6489 F DEBUG : #18 pc 0003cdb7 /system/lib/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+114) 08-30 18:07:03.695 6489 6489 F DEBUG : #19 pc 0003d2bb /system/lib/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+46) 08-30 18:07:03.695 6489 6489 F DEBUG : #20 pc 00000b4d /system/bin/cameraserver 08-30 18:07:03.696 6489 6489 F DEBUG : #21 pc 00016c2d /system/lib/libc.so (__libc_init+48) 08-30 18:07:03.696 6489 6489 F DEBUG : #22 pc 00000a18 /system/bin/cameraserver Change-Id: Ib6234260a5fc5798eea580e0ac594313650de933 Signed-off-by: SagarMakhar --- libutils/Threads.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp index e756fecca001..d9a5eaee09b0 100644 --- a/libutils/Threads.cpp +++ b/libutils/Threads.cpp @@ -657,7 +657,10 @@ status_t Thread::readyToRun() status_t Thread::run(const char* name, int32_t priority, size_t stack) { - LOG_ALWAYS_FATAL_IF(name == nullptr, "thread name not provided to Thread::run"); + if (name == nullptr) { + ALOGW("Thread name not provided to Thread::run"); + name = 0; + } Mutex::Autolock _l(mLock);