2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "status_once_operation.hh"
23 #include "boot_sequence/boot_sequence_manager.hh"
24 #include "aul_app_context.h"
25 #include "aul_boot_sequence.h"
29 StatusOnceOperation::StatusOnceOperation(std::string appid)
30 : appid_(std::move(appid)) {
33 bool StatusOnceOperation::Process() {
34 auto& manager = internal::boot_sequence::BootSequenceManager::GetInst();
35 auto app_list = manager.GetAppInfoList(getuid());
36 if (app_list.empty()) {
37 std::cerr << "Failed to get boot sequence app list." << std::endl;
41 for (const auto& app : app_list) {
42 if (app->GetAppId() != appid_)
45 std::cout << "appid: " << app->GetAppId() << std::endl;
47 std::cout << "status: " << app->GetActiveState() << std::endl;
48 std::cout << "sub status: " << app->GetSubState() << std::endl;
49 if (app->GetSubState() == "fail")
50 std::cout << " message: " << app->GetStatusMessage() << std::endl;
52 aul_app_context_h context;
53 int ret = aul_app_context_create(app->GetAppId().c_str(), &context);
55 const char* val = nullptr;
56 aul_app_context_get_app_path(context, const_cast<char**>(&val));
57 std::cout << "app path: " << val << std::endl;
58 std::free(const_cast<char*>(val));
60 aul_app_context_get_pid(context, &pid);
61 std::cout << "pid: " << pid << std::endl;
62 aul_app_context_destroy(context);
65 std::cout << "begin: " << app->GetBeginTimestamp() << std::endl;
66 std::cout << "end: " << app->GetEndTimestamp() << std::endl;
68 std::cout << "started time: " << app->GetSocketReadyTimestamp()
71 std::cout << "termiated time: " << app->GetTerminatedTimestamp()
74 std::cout << "requires: ";
75 for (auto& appid : app->RequiresGet())
76 std::cout << appid << " ";
78 std::cout << std::endl;
80 std::cout << "before: ";
81 for (auto& appid : app->BeforeGet())
82 std::cout << appid << " ";
84 std::cout << std::endl;
86 std::cout << "after: ";
87 for (auto& appid : app->AfterGet())
88 std::cout << appid << " ";
90 std::cout << std::endl;
92 std::cout << "conflict: ";
93 for (auto& appid : app->ConflictsGet())
94 std::cout << appid << " ";
96 std::cout << std::endl;
98 std::cout << "args: {\n";
99 auto& b = app->GetArgs();
102 [](const char* key, const int type,
103 const bundle_keyval_t* kv, void* data) {
104 auto& kb = *static_cast<tizen_base::Bundle*>(data);
105 std::cout << key << ": ";
107 case BUNDLE_TYPE_STR:
108 std::cout << kb.GetString(key) << std::endl;
110 case BUNDLE_TYPE_STR_ARRAY:
112 for (auto& val : kb.GetStringArray(key))
113 std::cout << val << ", ";
115 std::cout << "]" << std::endl;
121 const_cast<tizen_base::Bundle*>(&b));
122 std::cout << "}" << std::endl;
124 std::cout << "bg-launch: " << app->IsBackgroundLaunch() << std::endl;
128 std::cerr << "Not found app info." << std::endl;