dotnettool: Add --rm-app-profile <app_id> option
authorTimur <t.mustafin@partner.samsung.com>
Fri, 30 Apr 2021 15:06:59 +0000 (18:06 +0300)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Fri, 11 Jun 2021 01:25:30 +0000 (10:25 +0900)
Signed-off-by: Timur <t.mustafin@partner.samsung.com>
NativeLauncher/tool/dotnettool.cc

index 7fcb6ee..3269ee4 100644 (file)
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/time.h>
+#include <app_common.h>
 
 void DisplayUsage() {
        _SOUT(
@@ -50,6 +51,8 @@ void DisplayUsage() {
                "       --ibc-dir                 - Specify a directory containing IBC files\n"
                "       --resolve-all-app         - Remove unused multi-targeting files of all apps\n"
                "                                   (this option is used for FOTA script or test)\n"
+               "       --rm-app-profile          - Remove application profile for all users\n"
+               "                                   (this option should be run as root)\n"
                "\n"
                "Options:\n"
                "       --r2r                     - Generate a Ready-To-Run image (disable: /FragileNonVersionable)\n"
@@ -71,6 +74,8 @@ void DisplayUsage() {
                "   # dotnettool --r2r --ni-regen-all-app\n"
                "5. Create native image for dll based on the IBC data\n"
                "   # dotnettool --ibc-dir /tmp/ibcdata/ --ni-dll /usr/bin/Tizen.Runtime.dll\n"
+               "6. Remove profile for package\n"
+               "   # dotnettool --rm-app-profile org.tizen.FormsGallery\n"
                "\n");
 }
 
@@ -315,6 +320,28 @@ int main(int argc, char* argv[])
                        _SERR("Failed to remove unused multi-targeting files");
                }
        }
+       //sh-3.2# dotnettool --rm-app-profile [pkgId] [pkgId] ...
+       else if (cmd == "--rm-app-profile") {
+               if (args.size() < 1) {
+                       fprintf(stderr, "Package name is missing\n");
+               }
+               while (it != args.end()) {
+                       std::string pkg = std::string(*it);
+                       setenv("AUL_APPID", pkg.c_str(), 1);
+                       char *localDataPath = app_get_data_path(); // /root/apps_rw/<app_id>/data/
+                       if (localDataPath != NULL) {
+                               char *home = getenv("HOME"); // /root
+                               std::string rmCMD = std::string("rm -f /home/*");
+                               rmCMD.append(localDataPath + strlen(home)); // rm /home/*/apps_rw/<app_id>/data/
+                               rmCMD.append(PROFILE_BASENAME); // rm /home/*/apps_rw/<app_id>/data/.__tizen_specific_profile_data
+                               system(rmCMD.c_str());
+                               free(localDataPath);
+                       } else {
+                               fprintf(stderr, "Application not found [%s], skip to remove profile\n", pkg.c_str());
+                       }
+                       it = args.erase(it);
+               }
+       }
        else {
                _SERR("Unknown option [%s]", cmd.c_str());
                DisplayUsage();