Merge "class_start_post_data also starts disabled services." into qt-dev
This commit is contained in:
commit
5ff7c4b22d
4 changed files with 31 additions and 13 deletions
|
|
@ -414,7 +414,8 @@ Commands
|
||||||
|
|
||||||
`class_start_post_data <serviceclass>`
|
`class_start_post_data <serviceclass>`
|
||||||
> Like `class_start`, but only considers services that were started
|
> Like `class_start`, but only considers services that were started
|
||||||
after /data was mounted. Only used for FDE devices.
|
after /data was mounted, and that were running at the time
|
||||||
|
`class_reset_post_data` was called. Only used for FDE devices.
|
||||||
|
|
||||||
`class_stop <serviceclass>`
|
`class_stop <serviceclass>`
|
||||||
> Stop and disable all services of the specified class if they are
|
> Stop and disable all services of the specified class if they are
|
||||||
|
|
|
||||||
|
|
@ -104,35 +104,36 @@ static void ForEachServiceInClass(const std::string& classname, F function) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<Success> class_start(const std::string& class_name, bool post_data_only) {
|
static Result<Success> do_class_start(const BuiltinArguments& args) {
|
||||||
// Do not start a class if it has a property persist.dont_start_class.CLASS set to 1.
|
// Do not start a class if it has a property persist.dont_start_class.CLASS set to 1.
|
||||||
if (android::base::GetBoolProperty("persist.init.dont_start_class." + class_name, false))
|
if (android::base::GetBoolProperty("persist.init.dont_start_class." + args[1], false))
|
||||||
return Success();
|
return Success();
|
||||||
// Starting a class does not start services which are explicitly disabled.
|
// Starting a class does not start services which are explicitly disabled.
|
||||||
// They must be started individually.
|
// They must be started individually.
|
||||||
for (const auto& service : ServiceList::GetInstance()) {
|
for (const auto& service : ServiceList::GetInstance()) {
|
||||||
if (service->classnames().count(class_name)) {
|
if (service->classnames().count(args[1])) {
|
||||||
if (post_data_only && !service->is_post_data()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (auto result = service->StartIfNotDisabled(); !result) {
|
if (auto result = service->StartIfNotDisabled(); !result) {
|
||||||
LOG(ERROR) << "Could not start service '" << service->name()
|
LOG(ERROR) << "Could not start service '" << service->name()
|
||||||
<< "' as part of class '" << class_name << "': " << result.error();
|
<< "' as part of class '" << args[1] << "': " << result.error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<Success> do_class_start(const BuiltinArguments& args) {
|
|
||||||
return class_start(args[1], false /* post_data_only */);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Result<Success> do_class_start_post_data(const BuiltinArguments& args) {
|
static Result<Success> do_class_start_post_data(const BuiltinArguments& args) {
|
||||||
if (args.context != kInitContext) {
|
if (args.context != kInitContext) {
|
||||||
return Error() << "command 'class_start_post_data' only available in init context";
|
return Error() << "command 'class_start_post_data' only available in init context";
|
||||||
}
|
}
|
||||||
return class_start(args[1], true /* post_data_only */);
|
for (const auto& service : ServiceList::GetInstance()) {
|
||||||
|
if (service->classnames().count(args[1])) {
|
||||||
|
if (auto result = service->StartIfPostData(); !result) {
|
||||||
|
LOG(ERROR) << "Could not start service '" << service->name()
|
||||||
|
<< "' as part of class '" << args[1] << "': " << result.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<Success> do_class_stop(const BuiltinArguments& args) {
|
static Result<Success> do_class_stop(const BuiltinArguments& args) {
|
||||||
|
|
|
||||||
|
|
@ -1154,10 +1154,23 @@ void Service::Reset() {
|
||||||
|
|
||||||
void Service::ResetIfPostData() {
|
void Service::ResetIfPostData() {
|
||||||
if (post_data_) {
|
if (post_data_) {
|
||||||
|
if (flags_ & SVC_RUNNING) {
|
||||||
|
running_at_post_data_reset_ = true;
|
||||||
|
}
|
||||||
StopOrReset(SVC_RESET);
|
StopOrReset(SVC_RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<Success> Service::StartIfPostData() {
|
||||||
|
// Start the service, but only if it was started after /data was mounted,
|
||||||
|
// and it was still running when we reset the post-data services.
|
||||||
|
if (running_at_post_data_reset_) {
|
||||||
|
return Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
|
||||||
void Service::Stop() {
|
void Service::Stop() {
|
||||||
StopOrReset(SVC_DISABLED);
|
StopOrReset(SVC_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ class Service {
|
||||||
Result<Success> ExecStart();
|
Result<Success> ExecStart();
|
||||||
Result<Success> Start();
|
Result<Success> Start();
|
||||||
Result<Success> StartIfNotDisabled();
|
Result<Success> StartIfNotDisabled();
|
||||||
|
Result<Success> StartIfPostData();
|
||||||
Result<Success> Enable();
|
Result<Success> Enable();
|
||||||
void Reset();
|
void Reset();
|
||||||
void ResetIfPostData();
|
void ResetIfPostData();
|
||||||
|
|
@ -248,6 +249,8 @@ class Service {
|
||||||
bool pre_apexd_ = false;
|
bool pre_apexd_ = false;
|
||||||
|
|
||||||
bool post_data_ = false;
|
bool post_data_ = false;
|
||||||
|
|
||||||
|
bool running_at_post_data_reset_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ServiceList {
|
class ServiceList {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue