Don't report errors when trying to delete a non-existing profile dir

Also, put destroy_app_current_profiles behind FLAG_STORAGE_DE flag.

Bug: 27081617
Change-Id: Ib8b9ff292784c659259ceb4339b803e3580da7ed
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp
index 74f4264..d84d9f6 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -341,23 +341,27 @@
     return result;
 }
 
-int delete_dir_contents(const std::string& pathname) {
-    return delete_dir_contents(pathname.c_str(), 0, NULL);
+int delete_dir_contents(const std::string& pathname, bool ignore_if_missing) {
+    return delete_dir_contents(pathname.c_str(), 0, NULL, ignore_if_missing);
 }
 
-int delete_dir_contents_and_dir(const std::string& pathname) {
-    return delete_dir_contents(pathname.c_str(), 1, NULL);
+int delete_dir_contents_and_dir(const std::string& pathname, bool ignore_if_missing) {
+    return delete_dir_contents(pathname.c_str(), 1, NULL, ignore_if_missing);
 }
 
 int delete_dir_contents(const char *pathname,
                         int also_delete_dir,
-                        int (*exclusion_predicate)(const char*, const int))
+                        int (*exclusion_predicate)(const char*, const int),
+                        bool ignore_if_missing)
 {
     int res = 0;
     DIR *d;
 
     d = opendir(pathname);
     if (d == NULL) {
+        if (ignore_if_missing && (errno == ENOENT)) {
+            return 0;
+        }
         ALOGE("Couldn't opendir %s: %s\n", pathname, strerror(errno));
         return -errno;
     }