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

Commit 1d4fe432 authored by Mickey Keeley's avatar Mickey Keeley Committed by Android (Google) Code Review
Browse files

Merge "BootParameters: Support silent boot."

parents 1db460dc 47d2c027
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ BootAction::~BootAction() {
}

bool BootAction::init(const std::string& libraryPath,
                      const std::vector<ABootActionParameter>& parameters) {
                      const std::unique_ptr<BootParameters>& bootParameters) {
    APeripheralManagerClient* client = nullptr;
    ALOGD("Connecting to peripheralmanager");
    // Wait for peripheral manager to come up.
@@ -77,9 +77,32 @@ bool BootAction::init(const std::string& libraryPath,
        mLibStartPart = reinterpret_cast<libStartPart>(loaded);
    }

    // SilentBoot is considered optional, if it isn't exported by the library
    // and the boot is silent, no method is called.
    loaded = nullptr;
    if (!loadSymbol("boot_action_silent_boot", &loaded) || loaded == nullptr) {
        ALOGW("No boot_action_silent_boot found, boot action will not be "
              "executed during a silent boot.");
    } else {
        mLibSilentBoot = reinterpret_cast<libInit>(loaded);
    }

    bool result = true;
    const auto& parameters = bootParameters->getParameters();
    if (bootParameters->isSilentBoot()) {
        if (mLibSilentBoot != nullptr) {
            ALOGD("Entering boot_action_silent_boot");
            result = mLibSilentBoot(parameters.data(), parameters.size());
            ALOGD("Returned from boot_action_silent_boot");
        } else {
            ALOGW("Skipping missing boot_action_silent_boot");
        }
    } else {
        ALOGD("Entering boot_action_init");
    bool result = mLibInit(parameters.data(), parameters.size());
        result = mLibInit(parameters.data(), parameters.size());
        ALOGD("Returned from boot_action_init");
    }

    return result;
}

+7 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <string>
#include <vector>

#include "BootParameters.h"

#include <boot_action/boot_action.h>  // libandroidthings native API.
#include <utils/RefBase.h>

@@ -31,7 +33,7 @@ public:

    // libraryPath is a fully qualified path to the target .so library.
    bool init(const std::string& libraryPath,
              const std::vector<ABootActionParameter>& parameters);
              const std::unique_ptr<BootParameters>& bootParameters);

    // The animation is going to start playing partNumber for the playCount'th
    // time, update the action as needed.
@@ -45,7 +47,7 @@ public:

private:
    typedef bool (*libInit)(const ABootActionParameter* parameters,
                            size_t num_parameters);
                            size_t numParameters);
    typedef void (*libStartPart)(int partNumber, int playNumber);
    typedef void (*libShutdown)();

@@ -55,6 +57,9 @@ private:
    libInit mLibInit = nullptr;
    libStartPart mLibStartPart = nullptr;
    libShutdown mLibShutdown = nullptr;

    // Called only if the boot is silent.
    libInit mLibSilentBoot = nullptr;
};

}  // namespace android
+11 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public:
        }

        mBootAction = new BootAction();
        if (!mBootAction->init(library_path, mBootParameters->getParameters())) {
        if (!mBootAction->init(library_path, mBootParameters)) {
            mBootAction = NULL;
        }
    };
@@ -116,8 +116,16 @@ int main() {
    sp<ProcessState> proc(ProcessState::self());
    ProcessState::self()->startThreadPool();

    sp<BootAnimation> boot = new BootAnimation(
            new BootActionAnimationCallbacks(std::move(bootParameters)));
    bool isSilentBoot = bootParameters->isSilentBoot();
    sp<BootActionAnimationCallbacks> callbacks =
        new BootActionAnimationCallbacks(std::move(bootParameters));

    // On silent boot, animations aren't displayed.
    if (isSilentBoot) {
        callbacks->init({});
    } else {
        sp<BootAnimation> boot = new BootAnimation(callbacks);
    }

    IPCThreadState::self()->joinThreadPool();
    return 0;