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 bool aotPluginInstalled = false;
34 static bool aotPluginFinished = false;
36 typedef struct metadata_s {
41 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list)
43 // Can be multiple apps in one package
44 if (aotPluginInstalled) {
45 _INFO("AOT plugin already installed");
48 aotPluginInstalled = true;
51 if (!pkgmgr_installer_info_get_skip_optimization(&skipOpt)) {
53 _DBG("Skip dotnet AOT");
61 metadata_t* md = static_cast<metadata_t*>(iter->data);
62 if (strcmp(AOT_METADATA_KEY, md->key) == 0) {
63 if (strcmp(METADATA_VALUE_TRUE, md->value) == 0) {
68 iter = g_list_next(iter);
72 _DBG("Prefer dotnet application AOT set TRUE");
74 if (initNICommon() != NI_ERROR_NONE) {
75 _ERR("Fail to initialize NI Common");
79 NIOption* opt = getNIOption();
81 _ERR("Fail to create option structure.");
85 if (createNIUnderPkgRoot(pkgId, opt) != NI_ERROR_NONE) {
86 _ERR("Failed to generate application to native image [%s]", pkgId);
90 _INFO("Complete make application to native image");
95 extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *appId, GList *list)
97 return PKGMGR_MDPARSER_PLUGIN_INSTALL(pkgId, appId, list);
100 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgId, const char *appId, GList *list)
105 extern "C" int PKGMGR_MDPARSER_PLUGIN_REMOVED(const char *pkgId, const char *appId, GList *list)
107 return PKGMGR_MDPARSER_PLUGIN_UPGRADE(pkgId, appId, list);
110 extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(const char *pkgId, const char *appId, GList *list)
112 // Can be multiple apps in one package
113 if (aotPluginFinished) {
114 _INFO("AOT plugin already finished(CLEAN)");
117 aotPluginFinished = true;
123 extern "C" int PKGMGR_MDPARSER_PLUGIN_UNDO(const char *pkgId, const char *appId, GList *list)
125 // Can be multiple apps in one package
126 if (aotPluginFinished) {
127 _INFO("AOT plugin already finished(UNDO)");
130 aotPluginFinished = true;