2 * Copyright (c) 2016 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 "ni_common.h"
26 #include <pkgmgr_installer_info.h>
31 #define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
33 static std::string prevInstallPkgId = std::string("");
34 static std::string prevFinishPkgId = std::string("");
36 typedef struct metadata_s {
41 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list)
47 // Can be multiple apps in one package
48 if (strcmp(pkgId, prevInstallPkgId.c_str()) == 0) {
49 _INFO("AOT Plugin already run for same pkgId (%s)", pkgId);
52 prevInstallPkgId = pkgId;
55 if (!pkgmgr_installer_info_get_skip_optimization(&skipOpt)) {
57 _DBG("Skip dotnet AOT");
65 metadata_t* md = static_cast<metadata_t*>(iter->data);
66 if (strcmp(AOT_METADATA_KEY, md->key) == 0) {
67 if (strcmp(METADATA_VALUE_TRUE, md->value) == 0) {
72 iter = g_list_next(iter);
76 _DBG("Prefer dotnet application AOT set TRUE");
78 if (initNICommon() != NI_ERROR_NONE) {
79 _ERR("Fail to initialize NI Common");
83 NIOption* opt = getNIOption();
85 _ERR("Fail to create option structure.");
89 if (createNIUnderPkgRoot(pkgId, opt) != NI_ERROR_NONE) {
90 _ERR("Failed to generate application to native image [%s]", pkgId);
94 _INFO("Complete make application to native image");
99 extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *appId, GList *list)
101 return PKGMGR_MDPARSER_PLUGIN_INSTALL(pkgId, appId, list);
104 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgId, const char *appId, GList *list)
109 extern "C" int PKGMGR_MDPARSER_PLUGIN_REMOVED(const char *pkgId, const char *appId, GList *list)
111 return PKGMGR_MDPARSER_PLUGIN_UPGRADE(pkgId, appId, list);
114 extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(const char *pkgId, const char *appId, GList *list)
120 // Can be multiple apps in one package
121 if (strcmp(pkgId, prevFinishPkgId.c_str()) == 0) {
122 _INFO("AOT Plugin(CLEAN) already run for same pkgId (%s)", pkgId);
125 prevFinishPkgId = pkgId;
131 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNDO(const char *pkgId, const char *appId, GList *list)
137 // Can be multiple apps in one package
138 if (strcmp(pkgId, prevFinishPkgId.c_str()) == 0) {
139 _INFO("AOT Plugin(UNDO) already run for same pkgId (%s)", pkgId);
142 prevFinishPkgId = pkgId;