1 // Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/pkgmgr/step_check_installable.h"
7 #include <manifest_parser/utils/version_number.h>
8 #include <pkgmgr-info.h>
10 #include <tzplatform_config.h>
16 #include "common/pkgmgr_dependency.h"
17 #include "common/utils/pkgmgr_query.h"
18 #include "common/utils/glist_range.h"
19 #include "common/utils/user_util.h"
23 const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
27 namespace common_installer {
30 Step::Status StepCheckInstallable::process() {
31 switch (context_->request_mode.get()) {
32 case RequestMode::USER: {
33 PkgQueryInterface pkg_query(context_->pkgid.get(), kGlobalUserUid);
34 if (pkg_query.IsPackageInstalled(RequestMode::GLOBAL)) {
35 LOG(ERROR) << "This package is already installed as global package";
36 return Status::OPERATION_NOT_ALLOWED;
40 case RequestMode::GLOBAL: {
41 UserList list = GetUserList();
43 uid_t uid = std::get<0>(l);
44 PkgQueryInterface pkg_query(context_->pkgid.get(), uid);
45 if (pkg_query.IsPackageInstalled(RequestMode::USER)) {
46 LOG(ERROR) << "This package is already installed by user("
48 return Status::OPERATION_NOT_ALLOWED;
58 Step::Status StepCheckInstallable::precheck() {
59 if (context_->pkgid.get().empty())
60 return Status::INVALID_VALUE;
65 } // namespace common_installer