/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved\r
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */\r
-\r
+ */
+
#include "log.h"
-#include "utils.h"\r
-#include "profile_common.h"\r
-#include "launcher_env.h"\r
-\r
-#include <sys/types.h>\r
-#include <pwd.h>\r
-#include <tzplatform_config.h>\r
-\r
-static std::vector<uid_t> getUserIds()\r
+#include "utils.h"
+#include "profile_common.h"
+#include "launcher_env.h"
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <tzplatform_config.h>
+
+static std::vector<uid_t> getUserIds()
{
std::vector<uid_t> list;
tzplatform_reset_user();
return pDataFile;
-}\r
-\r
-profile_error_e removeAppProfileData(const std::string& pkgId)\r
+}
+
+profile_error_e removeAppProfileData(const std::string& pkgId)
{
if (pkgId.empty()) {
- return PROFILE_ERROR_INVALID_PARAMETER;\r
+ return PROFILE_ERROR_INVALID_PARAMETER;
}
std::vector<uid_t> uidList = getUserIds();
if (exist(pDataFile)) {
if (!removeFile(pDataFile)) {
- _SERR("Failed to remove profile data file (%s).", pDataFile.c_str());\r
- return PROFILE_ERROR_UNKNOWN;\r
+ _SERR("Failed to remove profile data file (%s).", pDataFile.c_str());
+ return PROFILE_ERROR_UNKNOWN;
}
_SOUT("Profile data (%s) is removed successfully", pDataFile.c_str());
}
}
}
- return PROFILE_ERROR_NONE;\r
-}
-
-static int removeAppProfileListCb(pkgmgrinfo_appinfo_h handle, void *user_data)\r
-{
- char *pkgId = NULL;
- int ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
- if (ret != PMINFO_R_OK || pkgId == NULL) {
- _SERR("Failed to get package id");\r
- return 0;
- }
-
- if (removeAppProfileData(pkgId) != PROFILE_ERROR_NONE) {\r
- _SERR("Failed to remove profile data for (%s)", pkgId);\r
- }
-
- return 0;
+ return PROFILE_ERROR_NONE;
}
-static void removeAppProfileByAppType(const char* type)\r
+static int removeAppProfileListCb(pkgmgrinfo_appinfo_h handle, void *user_data)
{
- pkgmgrinfo_appinfo_filter_h filter;\r
+ int ret = 0;
+ char* appType = NULL;
- int ret = pkgmgrinfo_appinfo_filter_create(&filter);\r
+ ret = pkgmgrinfo_appinfo_get_apptype(handle, &appType);
if (ret != PMINFO_R_OK) {
- _SERR("Failed to create appinfo filter");\r
- return;\r
+ _SERR("Failed to get apptype");
+ return 0;
}
- ret = pkgmgrinfo_appinfo_filter_add_string(filter, PMINFO_APPINFO_PROP_APP_TYPE, type);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- _SERR("Failed to add appinfo filter (%s)", type);\r
- return;\r
+ // skip if appType is NULL or appType does not contains "dotnet",
+ if (appType == NULL || (appType != NULL && strstr(appType, "dotnet") == NULL)) {
+ return 0;
}
- ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(filter, removeAppProfileListCb, NULL);\r
- if (ret != PMINFO_R_OK) {
- _SERR("Failed to pkgmgrinfo_pkginfo_filter_foreach_pkginfo");\r
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return;\r
+ char *pkgId = NULL;
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
+ if (ret != PMINFO_R_OK || pkgId == NULL) {
+ _SERR("Failed to get package id");
+ return 0;
}
- pkgmgrinfo_appinfo_filter_destroy(filter);
+ if (removeAppProfileData(pkgId) != PROFILE_ERROR_NONE) {
+ _SERR("Failed to remove profile data for (%s)", pkgId);
+ }
- return;\r
+ return 0;
}
void removeAllAppProfileData()
{
- std::vector<const char*> appTypeList = {"dotnet", "dotnet-nui", "dotnet-inhouse"};
-
- for (auto& type : appTypeList) {
- removeAppProfileByAppType(type);\r
+ int ret = pkgmgrinfo_appinfo_get_installed_list(removeAppProfileListCb, NULL);
+ if (ret != PMINFO_R_OK) {
+ _SERR("Failed to get installed list");
}
-}\r
-\r
+}