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

Commit bedc5fae authored by Keun-young Park's avatar Keun-young Park Committed by android-build-merger
Browse files

Merge "add "shutdown critical" to service" am: b3915d11 am: a4ad5d03

am: 19ec8e7b

Change-Id: Ide84d7f87a9884068ebc1cc9680c997507727af3
parents 3f10ecab 19ec8e7b
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -260,6 +260,14 @@ runs the service.
> Sets the child's /proc/self/oom\_score\_adj to the specified value,
> Sets the child's /proc/self/oom\_score\_adj to the specified value,
  which must range from -1000 to 1000.
  which must range from -1000 to 1000.


`shutdown <shutdown_behavior>`
> Set shutdown behavior of the service process. When this is not specified,
  the service is killed during shutdown process by using SIGTERM and SIGKILL.
  The service with shutdown_behavior of "critical" is not killed during shutdown
  until shutdown times out. When shutdown times out, even services tagged with
  "shutdown critical" will be killed. When the service tagged with "shutdown critical"
  is not running when shut down starts, it will be started.



Triggers
Triggers
--------
--------
+3 −1
Original line number Original line Diff line number Diff line
@@ -365,13 +365,15 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
    // keep debugging tools until non critical ones are all gone.
    // keep debugging tools until non critical ones are all gone.
    const std::set<std::string> kill_after_apps{"tombstoned", "logd", "adbd"};
    const std::set<std::string> kill_after_apps{"tombstoned", "logd", "adbd"};
    // watchdogd is a vendor specific component but should be alive to complete shutdown safely.
    // watchdogd is a vendor specific component but should be alive to complete shutdown safely.
    const std::set<std::string> to_starts{"watchdogd", "vold", "ueventd"};
    const std::set<std::string> to_starts{"watchdogd"};
    ServiceManager::GetInstance().ForEachService([&kill_after_apps, &to_starts](Service* s) {
    ServiceManager::GetInstance().ForEachService([&kill_after_apps, &to_starts](Service* s) {
        if (kill_after_apps.count(s->name())) {
        if (kill_after_apps.count(s->name())) {
            s->SetShutdownCritical();
            s->SetShutdownCritical();
        } else if (to_starts.count(s->name())) {
        } else if (to_starts.count(s->name())) {
            s->Start();
            s->Start();
            s->SetShutdownCritical();
            s->SetShutdownCritical();
        } else if (s->IsShutdownCritical()) {
            s->Start();  // start shutdown critical service if not started
        }
        }
    });
    });


+9 −0
Original line number Original line Diff line number Diff line
@@ -501,6 +501,14 @@ bool Service::ParseSetenv(const std::vector<std::string>& args, std::string* err
    return true;
    return true;
}
}


bool Service::ParseShutdown(const std::vector<std::string>& args, std::string* err) {
    if (args[1] == "critical") {
        flags_ |= SVC_SHUTDOWN_CRITICAL;
        return true;
    }
    return false;
}

template <typename T>
template <typename T>
bool Service::AddDescriptor(const std::vector<std::string>& args, std::string* err) {
bool Service::AddDescriptor(const std::vector<std::string>& args, std::string* err) {
    int perm = args.size() > 3 ? std::strtoul(args[3].c_str(), 0, 8) : -1;
    int perm = args.size() > 3 ? std::strtoul(args[3].c_str(), 0, 8) : -1;
@@ -604,6 +612,7 @@ const Service::OptionParserMap::Map& Service::OptionParserMap::map() const {
        {"namespace",   {1,     2,    &Service::ParseNamespace}},
        {"namespace",   {1,     2,    &Service::ParseNamespace}},
        {"seclabel",    {1,     1,    &Service::ParseSeclabel}},
        {"seclabel",    {1,     1,    &Service::ParseSeclabel}},
        {"setenv",      {2,     2,    &Service::ParseSetenv}},
        {"setenv",      {2,     2,    &Service::ParseSetenv}},
        {"shutdown",    {1,     1,    &Service::ParseShutdown}},
        {"socket",      {3,     6,    &Service::ParseSocket}},
        {"socket",      {3,     6,    &Service::ParseSocket}},
        {"file",        {2,     2,    &Service::ParseFile}},
        {"file",        {2,     2,    &Service::ParseFile}},
        {"user",        {1,     1,    &Service::ParseUser}},
        {"user",        {1,     1,    &Service::ParseUser}},
+1 −0
Original line number Original line Diff line number Diff line
@@ -138,6 +138,7 @@ class Service {
    bool ParseNamespace(const std::vector<std::string>& args, std::string* err);
    bool ParseNamespace(const std::vector<std::string>& args, std::string* err);
    bool ParseSeclabel(const std::vector<std::string>& args, std::string* err);
    bool ParseSeclabel(const std::vector<std::string>& args, std::string* err);
    bool ParseSetenv(const std::vector<std::string>& args, std::string* err);
    bool ParseSetenv(const std::vector<std::string>& args, std::string* err);
    bool ParseShutdown(const std::vector<std::string>& args, std::string* err);
    bool ParseSocket(const std::vector<std::string>& args, std::string* err);
    bool ParseSocket(const std::vector<std::string>& args, std::string* err);
    bool ParseFile(const std::vector<std::string>& args, std::string* err);
    bool ParseFile(const std::vector<std::string>& args, std::string* err);
    bool ParseUser(const std::vector<std::string>& args, std::string* err);
    bool ParseUser(const std::vector<std::string>& args, std::string* err);
+1 −0
Original line number Original line Diff line number Diff line
@@ -692,6 +692,7 @@ service ueventd /sbin/ueventd
    class core
    class core
    critical
    critical
    seclabel u:r:ueventd:s0
    seclabel u:r:ueventd:s0
    shutdown critical


service healthd /system/bin/healthd
service healthd /system/bin/healthd
    class core
    class core