diff --git a/fastboot/device/usb_client.cpp b/fastboot/device/usb_client.cpp index d1b38d46c8d6..9cb7aa40a732 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. @@ -146,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 { @@ -169,6 +219,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_v1, + .hs_descs = hs_descriptors_v1, +}; + static struct DescV2 v2_descriptor = { .header = { @@ -205,8 +266,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, 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; + goto err; + } } ret = write(h->control.get(), &strings, sizeof(strings)); 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, 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; } 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/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 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())); 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; 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; } diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index bd7955a7f8b4..75af4402c7e1 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -304,6 +304,8 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path) {"USB", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_USB}, {"USB_DCP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_HVDCP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, + {"USB_HVDCP_3", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, + {"USB_HVDCP_3P5", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_CDP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_ACA", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {"USB_C", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, @@ -311,6 +313,7 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path) {"USB_PD_DRP", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_USB}, {"Wireless", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_WIRELESS}, {"Dock", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_DOCK}, + {"DASH", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC}, {NULL, 0}, }; std::string buf; @@ -320,10 +323,8 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path) } auto ret = mapSysfsString(buf.c_str(), supplyTypeMap); - if (!ret) { - KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str()); + if (!ret) *ret = BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_UNKNOWN; - } return static_cast(*ret); } @@ -442,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, 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/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); diff --git a/init/property_service.cpp b/init/property_service.cpp index 8da69822ccb9..7850bb7c4f5b 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; @@ -127,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); @@ -396,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}; } @@ -830,13 +833,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); @@ -857,6 +860,94 @@ 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.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 + "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() { + std::string build_type = android::base::GetProperty("ro.build.type", ""); + + // 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 (IsRecoveryMode()) { + 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 + LOG(INFO) << "snet: Hiding sensitive props"; + for (int i = 0; snet_prop_key[i]; ++i) { + 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); + 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; +} + // 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() { @@ -1206,6 +1297,12 @@ 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(); + property_initialize_ro_product_props(); property_initialize_build_id(); property_derive_build_fingerprint(); @@ -1213,7 +1310,13 @@ 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(); + + // Workaround SafetyNet + workaround_snet_properties(); } bool LoadPropertyInfoFromFile(const std::string& filename, 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 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"; 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__ */ 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/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, 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. */ 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, 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; } 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); 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"], }, }, diff --git a/rootdir/init.rc b/rootdir/init.rc index 1e6918d0022c..e7a4d0efe232 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 @@ -1312,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