--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+
+#include "remove_cache_db_handler.hh"
+
+#include "db_handle_provider.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+RemoveCacheDBHandler::RemoveCacheDBHandler(uid_t uid, int pid)
+ : AbstractDBHandler(uid, pid) {}
+
+int RemoveCacheDBHandler::Execute() {
+ std::unique_lock<std::shared_timed_mutex> u(lock_);
+
+ database::DBHandleProvider::GetInst(GetUID()).UnsetMemoryMode(GetPID());
+
+ return PMINFO_R_OK;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ */
+
+#ifndef REMOVE_CACHE_DB_HANDLER_HH_
+#define REMOVE_CACHE_DB_HANDLER_HH_
+
+#include <sys/types.h>
+
+#include "abstract_db_handler.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+class EXPORT_API RemoveCacheDBHandler : public AbstractDBHandler {
+ public:
+ RemoveCacheDBHandler(uid_t uid, int pid);
+ int Execute() override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // REMOVE_CACHE_DB_HANDLER_HH_
+
#include "db_handle_provider.hh"
#include "parcelable_factory.hh"
#include "pkginfo_parcelable.hh"
+#include "remove_cache_db_handler.hh"
#include "utils/logging.hh"
#include "pkgmgrinfo_debug.h"
}
if (parcel->GetCmd() == CommandType::RemoveCache) {
- database::DBHandleProvider::GetInst(
- parcel->GetUid()).UnsetMemoryMode(GetPID());
+ database::RemoveCacheDBHandler db(parcel->GetUid(), GetPID());
+ int ret = db.Execute();
result_ = std::make_shared<pcp::ResultParcelable>(
- PMINFO_R_OK, std::vector<pcp::StrArgs>{});
+ ret, std::vector<pcp::StrArgs>{});
return true;
}