diff options
| author | 2020-02-13 18:10:45 -0800 | |
|---|---|---|
| committer | 2020-05-18 13:16:59 +0100 | |
| commit | e82eaa845b117565ca02367a73161631f6b914b8 (patch) | |
| tree | 6fdc5b904fe2d46a6dff67070137764358fe516c /cmds/cmd/cmd.cpp | |
| parent | 196feae68804cf20f85fd64cd43728fc30c4313d (diff) | |
Add flag to cmd for dynamic services
When cmd is called with the -w flag, it will call ServiceManager::waitForService instead of checkService. This will make dynamic services start and block until they are ready for use.
Bug: 149526916
Test: atest ApexRollbackTests (with and without this flag applied within for dynamic apexd)
Change-Id: Iad0c3d7aa75e5830da10a84bd753d3011438259f
Merged-In: Iad0c3d7aa75e5830da10a84bd753d3011438259f
(cherry picked from commit 77f83368b1292557b70ff82b16a27a96ab424b04)
Diffstat (limited to 'cmds/cmd/cmd.cpp')
| -rw-r--r-- | cmds/cmd/cmd.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cmds/cmd/cmd.cpp b/cmds/cmd/cmd.cpp index 8dad47502f..be2c702034 100644 --- a/cmds/cmd/cmd.cpp +++ b/cmds/cmd/cmd.cpp @@ -185,7 +185,7 @@ int cmdMain(const std::vector<std::string_view>& argv, TextOutput& outputLog, Te int argc = argv.size(); if (argc == 0) { - errorLog << "cmd: No service specified; use -l to list all services" << endl; + errorLog << "cmd: No service specified; use -l to list all running services. Use -w to start and wait for a service." << endl; return 20; } @@ -203,14 +203,22 @@ int cmdMain(const std::vector<std::string_view>& argv, TextOutput& outputLog, Te return 0; } - const auto cmd = argv[0]; + bool waitForService = ((argc > 1) && (argv[0] == "-w")); + int serviceIdx = (waitForService) ? 1 : 0; + const auto cmd = argv[serviceIdx]; Vector<String16> args; String16 serviceName = String16(cmd.data(), cmd.size()); - for (int i = 1; i < argc; i++) { + for (int i = serviceIdx + 1; i < argc; i++) { args.add(String16(argv[i].data(), argv[i].size())); } - sp<IBinder> service = sm->checkService(serviceName); + sp<IBinder> service; + if(waitForService) { + service = sm->waitForService(serviceName); + } else { + service = sm->checkService(serviceName); + } + if (service == nullptr) { if (runMode == RunMode::kStandalone) { ALOGW("Can't find service %.*s", static_cast<int>(cmd.size()), cmd.data()); |