Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and fixed cam services for somes devices #4

Open
wants to merge 38 commits into
base: 14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fae18c4
init: Add vendor-specific initialization hooks.
Sep 24, 2013
e1dc509
init: don't skip starting a service with no domain if permissive
flintman Aug 30, 2016
c5cd3fb
fs_mgr: mount: don't set the block device as ro for recovery
aleasto Oct 6, 2019
4f8fe97
Revert "Format formattable partitions if mount fails"
tdm Sep 6, 2017
121d5b5
core: mark libsysutils and libdiskconfig recovery_available
aleasto Apr 6, 2020
718441a
reboot: allow opting-in to fastbootd
aleasto Feb 26, 2020
8ac1579
healthd: Add DASH charger type
ryzenforce990 Jul 28, 2016
8b70f2f
healthd: Add support for HVDCP_3 chargers
Sep 14, 2015
6430534
healthd: Add support for HVDCP_3P5 chargers
Dyneteve Dec 1, 2021
b386bb2
healthd: Reinitialize mChargerNames for every battery update
May 24, 2016
883cf9c
llkd: Include llkd-debuggable.rc in eng builds only
moetayuko Feb 20, 2022
6e7e4cd
fs_mgr: Don't run clean_scratch_files on non-dynamic devices
npjohnson Jan 6, 2022
0404a88
libsparse: Add simg2img_static target for host
chirayudesai Mar 16, 2022
5c1162f
libsysutils: Hide NetlinkListener error in recovery
mikeNG Apr 9, 2022
aa81777
fastboot: Prefer ro.boot.hardware.revision for hw-revision
mikeNG May 11, 2022
b41673f
liblp: Allow to flash on bigger block device
me-cafebabe Jul 16, 2022
3df718b
init: Don't enable ADB by default on userdebug builds
webgeek1234 Jan 30, 2023
f0aa64b
first_stage_mount: Skip dm-verity setup if AVB is not enabled
me-cafebabe Oct 4, 2022
3e16129
fastbootd: usb: fallback to v1 descriptors
aleasto Feb 26, 2020
a7d4885
fastbootd: hacks for legacy
aleasto Feb 26, 2020
ea1b3bb
init.rc: Disable native stats collection service
kdrag0n Apr 6, 2021
7578de9
init.rc: don't start console unless asked to
TheCrazyLex Dec 22, 2016
4b9e03f
init: Weaken property override security for the init extension
TheCrazyLex Apr 8, 2017
71e6359
init: Weaken property override security for the init extension
TheCrazyLex Apr 8, 2017
829617f
init: workaround SafetyNet check
arter97 Nov 6, 2017
fb2b7a3
init: add vendor.* keys to spoof safetynet
osm0sis May 9, 2020
8ca80f9
init: Weaken property override security only when spoofing safetynet
jhenrique09 Nov 20, 2020
a7b0807
init: Only set safetynet props if not eng build
jhenrique09 Nov 20, 2020
2da0fcf
core: Add more props for snet spoofing
jhenrique09 Mar 19, 2022
beb18ae
init: Check for fastbootd before spoofing safetynet props
kdrag0n Oct 7, 2020
96501a6
core: Don't spoof props in recovery mode
JarlPenguin Jun 16, 2021
a8ddd77
core: Treat reboot boot mode same as normal one
zlewchan Oct 26, 2022
69f202a
Revert "core: Treat reboot boot mode same as normal one"
dereference23 Dec 31, 2022
fa9405a
Revert "core: Don't spoof props in recovery mode"
dereference23 Dec 31, 2022
0542db4
init: Use `IsRecoveryMode()` for normal boot checks
krasCGQ Apr 29, 2022
1941532
init: Replace PropertySet with PropertySetNoSocket
xyyx Oct 6, 2023
847b353
Camera: Add feature extensions
Jun 25, 2015
4918008
utils: Threads: Handle empty thread names
raymanfx Sep 4, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions fastboot/device/usb_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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 =
{
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion fastboot/device/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ std::vector<std::string> 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,
Expand Down
5 changes: 4 additions & 1 deletion fastboot/device/variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ std::vector<std::vector<std::string>> GetAllPartitionArgsNoSlot(FastbootDevice*

bool GetHardwareRevision(FastbootDevice* /* device */, const std::vector<std::string>& /* 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;
}

Expand Down
5 changes: 5 additions & 0 deletions fs_mgr/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ cc_library {
srcs: [
":libfiemap_passthrough_srcs",
],
target: {
recovery: {
cflags: ["-DSKIP_SET_BLK_RO"],
},
},
}

cc_library {
Expand Down
2 changes: 1 addition & 1 deletion fs_mgr/clean_scratch_files.rc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions fs_mgr/fs_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
9 changes: 0 additions & 9 deletions fs_mgr/fs_mgr_roots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions fs_mgr/liblp/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
53 changes: 50 additions & 3 deletions healthd/BatteryMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,16 @@ 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},
{"USB_PD", BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_AC},
{"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;
Expand All @@ -320,10 +323,8 @@ static BatteryMonitor::PowerSupplyType readPowerSupplyType(const String8& path)
}

auto ret = mapSysfsString(buf.c_str(), supplyTypeMap);
if (!ret) {
KLOG_WARNING(LOG_TAG, "Unknown power supply type '%s'\n", buf.c_str());
if (!ret)
*ret = BatteryMonitor::ANDROID_POWER_SUPPLY_TYPE_UNKNOWN;
}

return static_cast<BatteryMonitor::PowerSupplyType>(*ret);
}
Expand Down Expand Up @@ -442,6 +443,52 @@ void BatteryMonitor::updateValues(void) {

double MaxPower = 0;

// Rescan for the available charger types
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(POWER_SUPPLY_SYSFS_PATH), closedir);
if (dir == NULL) {
KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH);
} else {
struct dirent* entry;
String8 path;

mChargerNames.clear();

while ((entry = readdir(dir.get()))) {
const char* name = entry->d_name;

if (!strcmp(name, ".") || !strcmp(name, ".."))
continue;

// Look for "type" file in each subdirectory
path.clear();
path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name);
switch(readPowerSupplyType(path)) {
case ANDROID_POWER_SUPPLY_TYPE_AC:
case ANDROID_POWER_SUPPLY_TYPE_USB:
case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
case ANDROID_POWER_SUPPLY_TYPE_DOCK:
path.clear();
path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
if (access(path.string(), R_OK) == 0)
mChargerNames.add(String8(name));
break;
default:
break;
}

// Look for "is_dock" file
path.clear();
path.appendFormat("%s/%s/is_dock", POWER_SUPPLY_SYSFS_PATH, name);
if (access(path.string(), R_OK) == 0) {
path.clear();
path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
if (access(path.string(), R_OK) == 0)
mChargerNames.add(String8(name));

}
}
}

for (size_t i = 0; i < mChargerNames.size(); i++) {
String8 path;
path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH,
Expand Down
9 changes: 9 additions & 0 deletions init/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: ["."],
Expand Down
26 changes: 26 additions & 0 deletions init/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 8 additions & 3 deletions init/first_stage_mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading