Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6cb4311f authored by Bowgo Tsai's avatar Bowgo Tsai
Browse files

init: adding fallback paths for debug ramdisk

Currently the gki_4_19_pixel5 presubmit test uses an old
vendor_boot-debug.img from a release branch. Adding fallback
paths to load debug resources from /first_stage_ramdisk dir to
pass the presubmit.

This CL should be reverted later once the vendor_boot-debug.img
gets updated to store the debug resources on the root dir.

Bug: 186082603
Test: boot a device with boot-debug.img
Test: boot a device with vendor_boot-debug.img
Change-Id: I9fcd77fc5a60a15cff254e432e05f1c9122ad80d
parent 64e92f94
Loading
Loading
Loading
Loading
+15 −2
Original line number Original line Diff line number Diff line
@@ -329,10 +329,23 @@ int FirstStageMain(int argc, char** argv) {


    // If "/force_debuggable" is present, the second-stage init will use a userdebug
    // If "/force_debuggable" is present, the second-stage init will use a userdebug
    // sepolicy and load adb_debug.prop to allow adb root, if the device is unlocked.
    // sepolicy and load adb_debug.prop to allow adb root, if the device is unlocked.
    bool found_debuggable = false;
    std::string adb_debug_prop("/adb_debug.prop");
    std::string userdebug_sepolicy("/userdebug_plat_sepolicy.cil");
    if (access("/force_debuggable", F_OK) == 0) {
    if (access("/force_debuggable", F_OK) == 0) {
        found_debuggable = true;
    } else if (access("/first_stage_ramdisk/force_debuggable", F_OK) == 0) {
        // Fallback to legacy debug resource paths.
        // TODO(b/186485355): removes the fallback path once it is not needed.
        found_debuggable = true;
        adb_debug_prop.insert(0, "/first_stage_ramdisk");
        userdebug_sepolicy.insert(0, "/first_stage_ramdisk");
    }

    if (found_debuggable) {
        std::error_code ec;  // to invoke the overloaded copy_file() that won't throw.
        std::error_code ec;  // to invoke the overloaded copy_file() that won't throw.
        if (!fs::copy_file("/adb_debug.prop", kDebugRamdiskProp, ec) ||
        if (!fs::copy_file(adb_debug_prop, kDebugRamdiskProp, ec) ||
            !fs::copy_file("/userdebug_plat_sepolicy.cil", kDebugRamdiskSEPolicy, ec)) {
            !fs::copy_file(userdebug_sepolicy, kDebugRamdiskSEPolicy, ec)) {
            LOG(ERROR) << "Failed to setup debug ramdisk";
            LOG(ERROR) << "Failed to setup debug ramdisk";
        } else {
        } else {
            // setenv for second-stage init to read above kDebugRamdisk* files.
            // setenv for second-stage init to read above kDebugRamdisk* files.