2015-07-31 21:45:25 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INIT_SERVICE_H
|
|
|
|
#define _INIT_SERVICE_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <memory>
|
2017-03-27 19:59:11 +02:00
|
|
|
#include <set>
|
2015-07-31 21:45:25 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-03-24 19:43:02 +01:00
|
|
|
#include <android-base/chrono_utils.h>
|
2017-04-07 01:30:22 +02:00
|
|
|
#include <cutils/iosched_policy.h>
|
2017-03-24 19:43:02 +01:00
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
#include "action.h"
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 16:33:03 +02:00
|
|
|
#include "capabilities.h"
|
2016-10-27 16:45:34 +02:00
|
|
|
#include "descriptors.h"
|
2015-08-26 20:43:36 +02:00
|
|
|
#include "init_parser.h"
|
|
|
|
#include "keyword_map.h"
|
2016-11-11 02:43:47 +01:00
|
|
|
#include "util.h"
|
2015-07-31 21:45:25 +02:00
|
|
|
|
2017-03-13 19:54:47 +01:00
|
|
|
#define SVC_DISABLED 0x001 // do not autostart with class
|
|
|
|
#define SVC_ONESHOT 0x002 // do not restart on exit
|
|
|
|
#define SVC_RUNNING 0x004 // currently active
|
|
|
|
#define SVC_RESTARTING 0x008 // waiting to restart
|
|
|
|
#define SVC_CONSOLE 0x010 // requires console
|
|
|
|
#define SVC_CRITICAL 0x020 // will reboot into recovery if keeps crashing
|
|
|
|
#define SVC_RESET 0x040 // Use when stopping a process,
|
2015-07-31 21:45:25 +02:00
|
|
|
// but not disabling so it can be restarted with its class.
|
2017-03-13 19:54:47 +01:00
|
|
|
#define SVC_RC_DISABLED 0x080 // Remember if the disabled flag was set in the rc script.
|
|
|
|
#define SVC_RESTART 0x100 // Use to safely restart (stop, wait, start) a service.
|
2015-07-31 21:45:25 +02:00
|
|
|
#define SVC_DISABLED_START 0x200 // A start was requested but it was disabled at the time.
|
2017-03-28 01:27:30 +02:00
|
|
|
#define SVC_EXEC 0x400 // This service was started by either 'exec' or 'exec_start' and stops
|
|
|
|
// init from processing more commands until it completes
|
2017-03-13 19:54:47 +01:00
|
|
|
|
|
|
|
#define SVC_SHUTDOWN_CRITICAL 0x800 // This service is critical for shutdown and
|
|
|
|
// should not be killed during shutdown
|
2017-03-28 01:27:30 +02:00
|
|
|
#define SVC_TEMPORARY 0x1000 // This service was started by 'exec' and should be removed from the
|
|
|
|
// service list once it is reaped.
|
2015-07-31 21:45:25 +02:00
|
|
|
|
|
|
|
#define NR_SVC_SUPP_GIDS 12 // twelve supplementary groups
|
|
|
|
|
2017-06-22 21:53:17 +02:00
|
|
|
namespace android {
|
|
|
|
namespace init {
|
2015-07-31 21:45:25 +02:00
|
|
|
|
|
|
|
struct ServiceEnvironmentInfo {
|
|
|
|
ServiceEnvironmentInfo();
|
|
|
|
ServiceEnvironmentInfo(const std::string& name, const std::string& value);
|
|
|
|
std::string name;
|
|
|
|
std::string value;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Service {
|
2017-03-27 19:59:11 +02:00
|
|
|
public:
|
|
|
|
Service(const std::string& name, const std::vector<std::string>& args);
|
2015-07-31 21:45:25 +02:00
|
|
|
|
2017-03-27 19:59:11 +02:00
|
|
|
Service(const std::string& name, unsigned flags, uid_t uid, gid_t gid,
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 16:33:03 +02:00
|
|
|
const std::vector<gid_t>& supp_gids, const CapSet& capabilities,
|
|
|
|
unsigned namespace_flags, const std::string& seclabel,
|
|
|
|
const std::vector<std::string>& args);
|
2015-07-31 21:45:25 +02:00
|
|
|
|
2017-03-13 19:54:47 +01:00
|
|
|
bool IsRunning() { return (flags_ & SVC_RUNNING) != 0; }
|
2016-06-29 20:32:49 +02:00
|
|
|
bool ParseLine(const std::vector<std::string>& args, std::string* err);
|
2017-03-28 01:27:30 +02:00
|
|
|
bool ExecStart(std::unique_ptr<Timer>* exec_waiter);
|
2015-07-31 21:45:25 +02:00
|
|
|
bool Start();
|
|
|
|
bool StartIfNotDisabled();
|
|
|
|
bool Enable();
|
|
|
|
void Reset();
|
|
|
|
void Stop();
|
2015-12-18 20:39:59 +01:00
|
|
|
void Terminate();
|
2015-07-31 21:45:25 +02:00
|
|
|
void Restart();
|
2016-11-11 02:43:47 +01:00
|
|
|
void RestartIfNeeded(time_t* process_needs_restart_at);
|
2017-03-28 01:27:30 +02:00
|
|
|
void Reap();
|
2015-07-31 21:45:25 +02:00
|
|
|
void DumpState() const;
|
2017-03-13 19:54:47 +01:00
|
|
|
void SetShutdownCritical() { flags_ |= SVC_SHUTDOWN_CRITICAL; }
|
2017-03-27 19:59:11 +02:00
|
|
|
bool IsShutdownCritical() const { return (flags_ & SVC_SHUTDOWN_CRITICAL) != 0; }
|
2015-07-31 21:45:25 +02:00
|
|
|
|
|
|
|
const std::string& name() const { return name_; }
|
2017-03-27 19:59:11 +02:00
|
|
|
const std::set<std::string>& classnames() const { return classnames_; }
|
2015-07-31 21:45:25 +02:00
|
|
|
unsigned flags() const { return flags_; }
|
|
|
|
pid_t pid() const { return pid_; }
|
2017-05-01 23:16:41 +02:00
|
|
|
int crash_count() const { return crash_count_; }
|
2015-07-31 21:45:25 +02:00
|
|
|
uid_t uid() const { return uid_; }
|
|
|
|
gid_t gid() const { return gid_; }
|
2017-05-01 23:16:41 +02:00
|
|
|
unsigned namespace_flags() const { return namespace_flags_; }
|
2015-07-31 21:45:25 +02:00
|
|
|
const std::vector<gid_t>& supp_gids() const { return supp_gids_; }
|
|
|
|
const std::string& seclabel() const { return seclabel_; }
|
|
|
|
const std::vector<int>& keycodes() const { return keycodes_; }
|
|
|
|
int keychord_id() const { return keychord_id_; }
|
|
|
|
void set_keychord_id(int keychord_id) { keychord_id_ = keychord_id; }
|
2017-05-01 23:16:41 +02:00
|
|
|
IoSchedClass ioprio_class() const { return ioprio_class_; }
|
|
|
|
int ioprio_pri() const { return ioprio_pri_; }
|
|
|
|
int priority() const { return priority_; }
|
|
|
|
int oom_score_adjust() const { return oom_score_adjust_; }
|
2017-05-04 20:32:36 +02:00
|
|
|
bool process_cgroup_empty() const { return process_cgroup_empty_; }
|
2015-07-31 21:45:25 +02:00
|
|
|
const std::vector<std::string>& args() const { return args_; }
|
|
|
|
|
2017-03-27 19:59:11 +02:00
|
|
|
private:
|
2016-06-29 20:32:49 +02:00
|
|
|
using OptionParser = bool (Service::*) (const std::vector<std::string>& args,
|
|
|
|
std::string* err);
|
|
|
|
class OptionParserMap;
|
2015-08-26 20:43:36 +02:00
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
void NotifyStateChange(const std::string& new_state) const;
|
|
|
|
void StopOrReset(int how);
|
|
|
|
void ZapStdio() const;
|
|
|
|
void OpenConsole() const;
|
2016-06-15 23:49:57 +02:00
|
|
|
void KillProcessGroup(int signal);
|
2016-07-08 19:32:26 +02:00
|
|
|
void SetProcessAttributes();
|
2015-07-31 21:45:25 +02:00
|
|
|
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 16:33:03 +02:00
|
|
|
bool ParseCapabilities(const std::vector<std::string>& args, std::string *err);
|
2016-06-29 20:32:49 +02:00
|
|
|
bool ParseClass(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseConsole(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseCritical(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseDisabled(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseGroup(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParsePriority(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseIoprio(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseKeycodes(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseOneshot(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseOnrestart(const std::vector<std::string>& args, std::string* err);
|
2016-07-22 21:07:06 +02:00
|
|
|
bool ParseOomScoreAdjust(const std::vector<std::string>& args, std::string* err);
|
2016-06-29 20:32:49 +02:00
|
|
|
bool ParseNamespace(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 ParseSocket(const std::vector<std::string>& args, std::string* err);
|
2016-10-27 16:45:34 +02:00
|
|
|
bool ParseFile(const std::vector<std::string>& args, std::string* err);
|
2016-06-29 20:32:49 +02:00
|
|
|
bool ParseUser(const std::vector<std::string>& args, std::string* err);
|
|
|
|
bool ParseWritepid(const std::vector<std::string>& args, std::string* err);
|
2015-08-26 20:43:36 +02:00
|
|
|
|
2016-10-27 16:45:34 +02:00
|
|
|
template <typename T>
|
|
|
|
bool AddDescriptor(const std::vector<std::string>& args, std::string* err);
|
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
std::string name_;
|
2017-03-27 19:59:11 +02:00
|
|
|
std::set<std::string> classnames_;
|
2016-03-21 09:08:07 +01:00
|
|
|
std::string console_;
|
2015-07-31 21:45:25 +02:00
|
|
|
|
|
|
|
unsigned flags_;
|
|
|
|
pid_t pid_;
|
2017-03-24 19:43:02 +01:00
|
|
|
android::base::boot_clock::time_point time_started_; // time of last start
|
|
|
|
android::base::boot_clock::time_point time_crashed_; // first crash within inspection window
|
2016-11-11 02:43:47 +01:00
|
|
|
int crash_count_; // number of times crashed within window
|
2015-07-31 21:45:25 +02:00
|
|
|
|
|
|
|
uid_t uid_;
|
|
|
|
gid_t gid_;
|
|
|
|
std::vector<gid_t> supp_gids_;
|
init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):
"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"
This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.
Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.
I chose to not use Minijail here (though I'm still using libcap) for
two reasons:
1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.
2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.
Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-10-27 16:33:03 +02:00
|
|
|
CapSet capabilities_;
|
2016-04-22 00:35:09 +02:00
|
|
|
unsigned namespace_flags_;
|
2015-07-31 21:45:25 +02:00
|
|
|
|
|
|
|
std::string seclabel_;
|
|
|
|
|
2016-10-27 16:45:34 +02:00
|
|
|
std::vector<std::unique_ptr<DescriptorInfo>> descriptors_;
|
2015-07-31 21:45:25 +02:00
|
|
|
std::vector<ServiceEnvironmentInfo> envvars_;
|
|
|
|
|
|
|
|
Action onrestart_; // Commands to execute on restart.
|
|
|
|
|
|
|
|
std::vector<std::string> writepid_files_;
|
|
|
|
|
|
|
|
// keycodes for triggering this service via /dev/keychord
|
|
|
|
std::vector<int> keycodes_;
|
|
|
|
int keychord_id_;
|
|
|
|
|
|
|
|
IoSchedClass ioprio_class_;
|
|
|
|
int ioprio_pri_;
|
2016-05-19 02:36:30 +02:00
|
|
|
int priority_;
|
2015-07-31 21:45:25 +02:00
|
|
|
|
2016-07-22 21:07:06 +02:00
|
|
|
int oom_score_adjust_;
|
|
|
|
|
2017-05-04 20:32:36 +02:00
|
|
|
bool process_cgroup_empty_ = false;
|
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
std::vector<std::string> args_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ServiceManager {
|
|
|
|
public:
|
|
|
|
static ServiceManager& GetInstance();
|
|
|
|
|
2017-05-01 23:16:41 +02:00
|
|
|
// Exposed for testing
|
|
|
|
ServiceManager();
|
|
|
|
|
2015-08-26 20:43:36 +02:00
|
|
|
void AddService(std::unique_ptr<Service> service);
|
2015-07-31 21:45:25 +02:00
|
|
|
Service* MakeExecOneshotService(const std::vector<std::string>& args);
|
2017-03-28 01:27:30 +02:00
|
|
|
bool Exec(const std::vector<std::string>& args);
|
|
|
|
bool ExecStart(const std::string& name);
|
|
|
|
bool IsWaitingForExec() const;
|
2015-07-31 21:45:25 +02:00
|
|
|
Service* FindServiceByName(const std::string& name) const;
|
|
|
|
Service* FindServiceByPid(pid_t pid) const;
|
|
|
|
Service* FindServiceByKeychord(int keychord_id) const;
|
2016-07-28 01:25:51 +02:00
|
|
|
void ForEachService(const std::function<void(Service*)>& callback) const;
|
2015-07-31 21:45:25 +02:00
|
|
|
void ForEachServiceInClass(const std::string& classname,
|
|
|
|
void (*func)(Service* svc)) const;
|
|
|
|
void ForEachServiceWithFlags(unsigned matchflags,
|
|
|
|
void (*func)(Service* svc)) const;
|
2015-12-18 20:39:59 +01:00
|
|
|
void ReapAnyOutstandingChildren();
|
2015-07-31 21:45:25 +02:00
|
|
|
void RemoveService(const Service& svc);
|
|
|
|
void DumpState() const;
|
2015-08-26 20:43:36 +02:00
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
private:
|
2015-12-18 20:39:59 +01:00
|
|
|
// Cleans up a child process that exited.
|
|
|
|
// Returns true iff a children was cleaned up.
|
|
|
|
bool ReapOneProcess();
|
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
static int exec_count_; // Every service needs a unique name.
|
2017-03-28 01:27:30 +02:00
|
|
|
std::unique_ptr<Timer> exec_waiter_;
|
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
std::vector<std::unique_ptr<Service>> services_;
|
|
|
|
};
|
|
|
|
|
2015-08-26 20:43:36 +02:00
|
|
|
class ServiceParser : public SectionParser {
|
init: Stop combining actions
In the past, I had thought it didn't make sense to have multiple
Action classes with identical triggers within ActionManager::actions_,
and opted to instead combine these into a single action. In theory,
it should reduce memory overhead as only one copy of the triggers
needs to be stored.
In practice, this ends up not being a good idea.
Most importantly, given a file with the below three sections in this
same order:
on boot
setprop a b
on boot && property:true=true
setprop c d
on boot
setprop e f
Assuming that property 'true' == 'true', when the `boot` event
happens, the order of the setprop commands will actually be:
setprop a b
setprop e f
setprop c d
instead of the more intuitive order of:
setprop a b
setprop c d
setprop e f
This is a mistake and this CL fixes it. It also documents this order.
Secondly, with a given 'Action' now spanning multiple files, in order
to keep track of which file a command is run from, the 'Command'
itself needs to store this. Ironically to the original intention,
this increases total ram usage. This change now only stores the file
name in each 'Action' instead of each 'Command'. All in all this is a
negligible trade off of ram usage.
Thirdly, this requires a bunch of extra code and assumptions that
don't help anything else. In particular it forces to keep property triggers
sorted for easy comparison, which I'm using an std::map for currently,
but that is not the best data structure to contain them.
Lastly, I added the filename and line number to the 'processing
action' LOG(INFO) message.
Test: Boot bullhead, observe above changes
Test: Boot sailfish, observe no change in boot time
Change-Id: I3fbcac4ee677351314e33012c758145be82346e9
2017-04-18 22:21:54 +02:00
|
|
|
public:
|
2017-04-20 00:31:58 +02:00
|
|
|
ServiceParser(ServiceManager* service_manager)
|
|
|
|
: service_manager_(service_manager), service_(nullptr) {}
|
|
|
|
bool ParseSection(std::vector<std::string>&& args, const std::string& filename, int line,
|
2015-08-26 20:43:36 +02:00
|
|
|
std::string* err) override;
|
2017-04-20 00:31:58 +02:00
|
|
|
bool ParseLineSection(std::vector<std::string>&& args, int line, std::string* err) override;
|
2015-08-26 20:43:36 +02:00
|
|
|
void EndSection() override;
|
init: Stop combining actions
In the past, I had thought it didn't make sense to have multiple
Action classes with identical triggers within ActionManager::actions_,
and opted to instead combine these into a single action. In theory,
it should reduce memory overhead as only one copy of the triggers
needs to be stored.
In practice, this ends up not being a good idea.
Most importantly, given a file with the below three sections in this
same order:
on boot
setprop a b
on boot && property:true=true
setprop c d
on boot
setprop e f
Assuming that property 'true' == 'true', when the `boot` event
happens, the order of the setprop commands will actually be:
setprop a b
setprop e f
setprop c d
instead of the more intuitive order of:
setprop a b
setprop c d
setprop e f
This is a mistake and this CL fixes it. It also documents this order.
Secondly, with a given 'Action' now spanning multiple files, in order
to keep track of which file a command is run from, the 'Command'
itself needs to store this. Ironically to the original intention,
this increases total ram usage. This change now only stores the file
name in each 'Action' instead of each 'Command'. All in all this is a
negligible trade off of ram usage.
Thirdly, this requires a bunch of extra code and assumptions that
don't help anything else. In particular it forces to keep property triggers
sorted for easy comparison, which I'm using an std::map for currently,
but that is not the best data structure to contain them.
Lastly, I added the filename and line number to the 'processing
action' LOG(INFO) message.
Test: Boot bullhead, observe above changes
Test: Boot sailfish, observe no change in boot time
Change-Id: I3fbcac4ee677351314e33012c758145be82346e9
2017-04-18 22:21:54 +02:00
|
|
|
|
|
|
|
private:
|
2015-08-26 20:43:36 +02:00
|
|
|
bool IsValidName(const std::string& name) const;
|
|
|
|
|
2017-04-20 00:31:58 +02:00
|
|
|
ServiceManager* service_manager_;
|
2015-08-26 20:43:36 +02:00
|
|
|
std::unique_ptr<Service> service_;
|
|
|
|
};
|
|
|
|
|
2017-06-22 21:53:17 +02:00
|
|
|
} // namespace init
|
|
|
|
} // namespace android
|
|
|
|
|
2015-07-31 21:45:25 +02:00
|
|
|
#endif
|