From b6d0bd3b4a9b1d847ecb86ddb20d3a092aa7361a Mon Sep 17 00:00:00 2001 From: David Ng Date: Mon, 23 Sep 2013 18:50:24 -0700 Subject: [PATCH 01/14] 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 Signed-off-by: Mikazuuu07 --- 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 a57f3a4072e1..af84232194fc 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -82,6 +82,7 @@ init_device_sources = [ "uevent_listener.cpp", "ueventd.cpp", "ueventd_parser.cpp", + "vendor_init.cpp", ] init_host_sources = [ "check_builtins.cpp", @@ -234,6 +235,14 @@ cc_library_static { ], }, }, + + product_variables: { + arrow: { + target_init_vendor_lib: { + whole_static_libs: ["%s"], + }, + }, + }, } phony { 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 2d67bf5d7722..5a8fc5418279 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; @@ -1097,6 +1098,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 9e5e99910ebb031e3897542a7878f068362adbc2 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Mon, 14 Sep 2015 16:35:26 -0700 Subject: [PATCH 02/14] 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 (cherry picked from commit e9b949ddb926a52cc256dbd8cae2c4b835656c3c) Signed-off-by: Mikazuuu07 --- healthd/BatteryMonitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 377acb75e48e..b36cc296b74e 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -190,6 +190,7 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String {"USB", ANDROID_POWER_SUPPLY_TYPE_USB}, {"USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_HVDCP", ANDROID_POWER_SUPPLY_TYPE_AC}, + {"USB_HVDCP_3", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_C", ANDROID_POWER_SUPPLY_TYPE_AC}, From 3224c4708ba555819bbfd0d203cba67155af0416 Mon Sep 17 00:00:00 2001 From: Abhijeet Dharmapurikar Date: Tue, 24 May 2016 15:12:11 -0700 Subject: [PATCH 03/14] 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 (cherry picked from commit 282857e89d591b6704e5d69ec2ae1e53a5de74cf) Signed-off-by: Mikazuuu07 --- healthd/BatteryMonitor.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index b36cc296b74e..2092a405896c 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -205,10 +205,8 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String return ANDROID_POWER_SUPPLY_TYPE_UNKNOWN; 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 = ANDROID_POWER_SUPPLY_TYPE_UNKNOWN; - } return static_cast(*ret); } @@ -302,6 +300,40 @@ 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(BatteryMonitor::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, From d4043cfc7f87135f520265919c8f713ab8a2e4e5 Mon Sep 17 00:00:00 2001 From: Dyneteve Date: Fri, 16 Apr 2021 12:38:37 +0200 Subject: [PATCH 04/14] healthd: Add support for HVDCP_3P5 chargers Change-Id: Ie422840c85c247cba866c370ce8d970058df2c2f Signed-off-by: Mikazuuu07 --- healthd/BatteryMonitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 2092a405896c..1c52ee93ad93 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -191,6 +191,7 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String {"USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_HVDCP", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_HVDCP_3", ANDROID_POWER_SUPPLY_TYPE_AC}, + {"USB_HVDCP_3P5", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_C", ANDROID_POWER_SUPPLY_TYPE_AC}, From 16e194a9d534d3438e4bbc6472908f7aa642f21a Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Thu, 28 Jul 2016 12:17:40 -0700 Subject: [PATCH 05/14] healthd: Add DASH charger type Change-Id: Ie1ca5018c465f6b2c15cbc00bdf3bb866d98ddef Signed-off-by: Mikazuuu07 --- healthd/BatteryMonitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 1c52ee93ad93..9c5ae688ad8c 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -198,6 +198,7 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String {"USB_PD", ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_PD_DRP", ANDROID_POWER_SUPPLY_TYPE_USB}, {"Wireless", ANDROID_POWER_SUPPLY_TYPE_WIRELESS}, + {"DASH", ANDROID_POWER_SUPPLY_TYPE_AC}, {NULL, 0}, }; std::string buf; From aa6a71cb80f05c4fb4560e8bf62fcfaf18523835 Mon Sep 17 00:00:00 2001 From: William Bellavance Date: Tue, 30 Aug 2016 08:04:38 -0400 Subject: [PATCH 06/14] init: don't skip starting a service with no domain if permissive [Adrian DC] Preserve the log while permissive Change-Id: I3f2887930e15d09014c2594141ba4acbbc8d6d9d Former-commit-id: fa9542f0bb4ac8c3da3c0e240a4f9f39e85221cb Change-Id: I03e442859d458ca6badc56d69cf72b75c5035cf4 Signed-off-by: Mikazuuu07 --- init/service.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/init/service.cpp b/init/service.cpp index c3069f5b2b59..a40ebc47c9f3 100644 --- a/init/service.cpp +++ b/init/service.cpp @@ -88,13 +88,18 @@ 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. Note: this " + "error shows up even in permissive mode in order to make auditing " + "denials possible.", + 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 b0536801d8499eb90c4b71096e4fa1873c9d9996 Mon Sep 17 00:00:00 2001 From: Sauhard Pande Date: Wed, 24 Jun 2015 22:38:25 -0700 Subject: [PATCH 07/14] 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 Signed-off-by: Mikazuuu07 --- 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 0e6d90d4df06d0336472e697e2e8b00e8a90684c Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Wed, 19 May 2021 16:39:26 -0700 Subject: [PATCH 08/14] Add exfat utilities for mkfs and fsck Bug: 171854784 Test: Builds, Large sdcards formated as exfat if kernel supports it Change-Id: Ie56b17f55f5027fdf714002b4c307603809fb707 Signed-off-by: Mikazuuu07 --- shell_and_utilities/Android.bp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell_and_utilities/Android.bp b/shell_and_utilities/Android.bp index b7d7490dc202..97e8d8eafb8c 100644 --- a/shell_and_utilities/Android.bp +++ b/shell_and_utilities/Android.bp @@ -18,9 +18,11 @@ phony { "awk", "bc", "bzip2", + "fsck.exfat", "ldd", "logwrapper", "mini-keyctl", + "mkfs.exfat", "mkshrc", "newfs_msdos", "reboot", From d473fff19856f08c195068e806ea101f0057e035 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Wed, 7 Oct 2020 00:24:54 -0700 Subject: [PATCH 09/14] init: Set properties to make SafetyNet pass Google's SafetyNet integrity checks will check the values of these properties when performing basic attestation. Setting fake values helps us pass basic SafetyNet with no Magisk Hide or kernel patches necessary. Note that these properties need to be set very early, before parsing the kernel command-line, as they are read-only properties that the bootloader sets using androidboot kernel arguments. The bootloader's real values cause SafetyNet to fail with an unlocked bootloader and/or custom software because the verified boot chain is broken in that case. Change-Id: I66d23fd91d82906b00d5eb020668f01ae83ec31f Signed-off-by: Mikazuuu07 --- init/property_service.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/init/property_service.cpp b/init/property_service.cpp index 5a8fc5418279..db5f5893abf2 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -1251,6 +1251,13 @@ static void ProcessBootconfig() { }); } +static void SetSafetyNetProps() { + 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; @@ -1265,6 +1272,12 @@ void PropertyInit() { LOG(FATAL) << "Failed to load serialized property info file"; } + // Report a valid verified boot chain to make Google SafetyNet integrity + // checks pass. This needs to be done before parsing the kernel cmdline as + // these properties are read-only and will be set to invalid values with + // androidboot cmdline arguments. + 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(); From 356e3e7abc801a566b2b014ad45377edf413857b Mon Sep 17 00:00:00 2001 From: Guo Weichao Date: Wed, 26 May 2021 11:12:11 +0800 Subject: [PATCH 10/14] init: fix to set sd device label correctly for FS The sysfs node of sd blk_device is /sys/fs/f2fs/sd-, we shouldn't skip partition number at this time. Bug: 189257443 Test: access sd- sysfs correctly Signed-off-by: Guo Weichao Signed-off-by: Huang Jianan Change-Id: Ibcd7bb265f8fca9cd26f8770403f1bafad433acb Signed-off-by: alanndz Signed-off-by: Mikazuuu07 --- init/mount_handler.cpp | 12 +++++++++--- rootdir/init.rc | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/init/mount_handler.cpp b/init/mount_handler.cpp index 46f833104bac..f0d8d45692a0 100644 --- a/init/mount_handler.cpp +++ b/init/mount_handler.cpp @@ -90,12 +90,18 @@ void SetMountProperty(const MountHandlerEntry& entry, bool add) { auto mount_prop = entry.mount_point; if (mount_prop == "/") mount_prop = "/root"; std::replace(mount_prop.begin(), mount_prop.end(), '/', '.'); - mount_prop = "dev.mnt.blk" + mount_prop; + auto blk_mount_prop = "dev.mnt.blk" + mount_prop; + auto dev_mount_prop = "dev.mnt.dev" + mount_prop; // Set property even if its value does not change to trigger 'on property:' // handling, except for clearing non-existent or already clear property. // Goal is reduction of empty properties and associated triggers. - if (value.empty() && android::base::GetProperty(mount_prop, "").empty()) return; - android::base::SetProperty(mount_prop, value); + if (value.empty() && android::base::GetProperty(blk_mount_prop, "").empty()) return; + android::base::SetProperty(blk_mount_prop, value); + if (!value.empty()) { + android::base::SetProperty(dev_mount_prop, entry.blk_device.substr(strlen(devblock))); + } else { + android::base::SetProperty(dev_mount_prop, ""); + } } } // namespace diff --git a/rootdir/init.rc b/rootdir/init.rc index 5116c0fead79..03e99c6c2240 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -1018,11 +1018,11 @@ on boot # to access F2FS sysfs on dm- directly mkdir /dev/sys/fs/by-name 0755 system system - symlink /sys/fs/f2fs/${dev.mnt.blk.data} /dev/sys/fs/by-name/userdata + symlink /sys/fs/f2fs/${dev.mnt.dev.data} /dev/sys/fs/by-name/userdata # to access dm- sysfs mkdir /dev/sys/block/by-name 0755 system system - symlink /sys/devices/virtual/block/${dev.mnt.blk.data} /dev/sys/block/by-name/userdata + symlink /sys/devices/virtual/block/${dev.mnt.dev.data} /dev/sys/block/by-name/userdata # F2FS tuning. Set cp_interval larger than dirty_expire_centisecs, 30 secs, # to avoid power consumption when system becomes mostly idle. Be careful From ae62d0213b0812d20ee3ff34e174d73d8e30de1a Mon Sep 17 00:00:00 2001 From: PIPIPIG23366 Date: Tue, 29 Mar 2022 10:09:48 +0700 Subject: [PATCH 11/14] init: Convert arrow product variables to soong config variables Signed-off-by: Mikazuuu07 --- init/Android.bp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/init/Android.bp b/init/Android.bp index af84232194fc..00ac6a75203c 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -82,7 +82,6 @@ init_device_sources = [ "uevent_listener.cpp", "ueventd.cpp", "ueventd_parser.cpp", - "vendor_init.cpp", ] init_host_sources = [ "check_builtins.cpp", @@ -90,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", @@ -204,6 +211,7 @@ cc_library_static { defaults: [ "init_defaults", "selinux_policy_version", + "vendor_init_defaults", ], srcs: init_common_sources + init_device_sources, generated_sources: [ @@ -235,14 +243,6 @@ cc_library_static { ], }, }, - - product_variables: { - arrow: { - target_init_vendor_lib: { - whole_static_libs: ["%s"], - }, - }, - }, } phony { From dc9efbaf390e2fe9cba0498341a4a1950852bbb2 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Sun, 15 Sep 2019 19:46:14 +0800 Subject: [PATCH 12/14] Add wrapped key support These commits added wrapped key support: https://source.codeaurora.org/quic/la/platform/system/core/commit/?h=LA.UM.8.1.r1-08800-sm8150.0&id=ddd34f7b85ea6701d0c62f1e7c6cb98bbef60738 https://source.codeaurora.org/quic/la/platform/system/core/commit/?h=LA.UM.8.1.r1-08800-sm8150.0&id=98ee612a86f40a862889347a4f3bb6231fcdb0e0 https://source.codeaurora.org/quic/la/platform/system/core/commit/?h=LA.UM.8.1.r1-08800-sm8150.0&id=c69050ee52338339f0eb1a07aa3eeeeeb2e209d9 Although, got either reverted by follow-ups or removed after the big Q merge commit: https://source.codeaurora.org/quic/la/platform/system/core/commit/?h=LA.UM.8.1.r1-08800-sm8150.0&id=dd28b6d7f1f44a529a2262d09834da4ca48937f4 Bring in the relevant bits so that system/vold part compiles. Conflicts: fs_mgr/fs_mgr_fstab.cpp fs_mgr/include_fstab/fstab/fstab.h Change-Id: Ibdf035e548c3f5085401f60df158c9a327947f33 (cherry picked from commit 9f03019be92a1ce86910ef20e6372a4785ba56c1) Signed-off-by: Volodymyr Zhdanov Signed-off-by: Mikazuuu07 --- fs_mgr/fs_mgr_fstab.cpp | 1 + fs_mgr/include_fstab/fstab/fstab.h | 1 + 2 files changed, 2 insertions(+) diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index f5ab5571f944..7fc73bdc5beb 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -181,6 +181,7 @@ void ParseFsMgrFlags(const std::string& flags, FstabEntry* entry) { CheckFlag("fsverity", fs_verity); CheckFlag("metadata_csum", ext_meta_csum); CheckFlag("fscompress", fs_compress); + CheckFlag("wrappedkey", wrapped_key); #undef CheckFlag diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h index f33768b9d674..0d1e935c0e41 100644 --- a/fs_mgr/include_fstab/fstab/fstab.h +++ b/fs_mgr/include_fstab/fstab/fstab.h @@ -86,6 +86,7 @@ struct FstabEntry { bool fs_verity : 1; bool ext_meta_csum : 1; bool fs_compress : 1; + bool wrapped_key : 1; } fs_mgr_flags = {}; bool is_encryptable() const { From dea62ebdf2c04b2b8af7c482fd20fb2989a93cb6 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Wed, 2 Mar 2022 14:18:27 +0100 Subject: [PATCH 13/14] fastboot: Fallback to "raw" partition type if fastboot hal isn't present Fastboot format fails to wipe any partition that doesn't at least return "raw" partition type. Also both android.hardware.fastboot@1.0-impl.pixel and android.hardware.fastboot@1.1-impl-mock return FileSystemType::RAW so I assume this is fine. Change-Id: I5707bddb1ba32edb6359858853d7b1afbf138b9f Signed-off-by: Mikazuuu07 --- fastboot/device/variables.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index ee1eed876a9f..bb54bf2a3bf5 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -339,8 +339,8 @@ bool GetPartitionType(FastbootDevice* device, const std::vector& ar auto fastboot_hal = device->fastboot_hal(); if (!fastboot_hal) { - *message = "Fastboot HAL not found"; - return false; + *message = "raw"; + return true; } FileSystemType type; From b53f9e32f37212b4262ff85d2556fde77079bf43 Mon Sep 17 00:00:00 2001 From: Nolen Johnson Date: Thu, 6 Jan 2022 16:59:08 -0500 Subject: [PATCH 14/14] 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 Signed-off-by: Mikazuuu07 --- 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