Add pre sending pkg event to amd 77/280377/9
authorChanggyu Choi <changyu.choi@samsung.com>
Mon, 29 Aug 2022 06:50:31 +0000 (15:50 +0900)
committerChanggyu Choi <changyu.choi@samsung.com>
Tue, 6 Sep 2022 03:57:26 +0000 (12:57 +0900)
Requires:
 - https://review.tizen.org/gerrit/c/platform/core/appfw/aul-1/+/280292

Change-Id: I3c5c2f1b498818edfd59d6a13ad0a072bc6dcda5
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
CMakeLists.txt
src/pkg_cleardata/CMakeLists.txt
src/pkg_cleardata/pkg_cleardata.c
src/pkg_getsize/CMakeLists.txt
tests/mock/aul_mock.cc [new file with mode: 0644]
tests/mock/aul_mock.h [new file with mode: 0644]
tests/unit_tests/CMakeLists.txt
tests/unit_tests/pkg_upgrade/src/test_pkg_upgrader.cc

index f6d0eba..5e21113 100644 (file)
@@ -25,6 +25,7 @@ INCLUDE(ApplyPkgConfig)
 
 PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
 PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0)
+PKG_CHECK_MODULES(AUL_DEPS REQUIRED aul)
 PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
 PKG_CHECK_MODULES(PKGMGR_DEPS REQUIRED pkgmgr)
 PKG_CHECK_MODULES(PKGMGR_PARSER_DEPS REQUIRED pkgmgr-parser)
index 86a056f..daac71b 100644 (file)
@@ -8,6 +8,8 @@ ADD_EXECUTABLE(${TARGET_PKG_CLEARDATA} ${SRCS})
 
 # Dependency
 APPLY_PKG_CONFIG(${TARGET_PKG_CLEARDATA} PUBLIC
+  AUL_DEPS
+  BUNDLE_DEPS
   TZPLATFORM_DEPS
   PKGMGR_DEPS
   GLIB_DEPS
@@ -18,4 +20,4 @@ APPLY_PKG_CONFIG(${TARGET_PKG_CLEARDATA} PUBLIC
 )
 
 # Install
-INSTALL(TARGETS ${TARGET_PKG_CLEARDATA} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TARGET_PKG_CLEARDATA} DESTINATION bin)
index 0ba2f59..ae91ff0 100644 (file)
@@ -30,6 +30,8 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <aul.h>
+#include <bundle.h>
 #include <dlog.h>
 #include <tzplatform_config.h>
 #include <pkgmgr-info.h>
@@ -70,6 +72,20 @@ static int __get_sdcard_path(char **sdpath)
 static void __send_signal(const char *pkgid, const char *event_type,
                const char *key, const char *val)
 {
+       bundle *b;
+       uid_t pi_uid;
+
+       b = bundle_create();
+       bundle_add_str(b, AUL_K_PKGID, pkgid);
+       bundle_add_str(b, AUL_K_PACKAGETYPE, event_type);
+       bundle_add_str(b, AUL_K_PKG_EVENT_NAME, key);
+       bundle_add_str(b, AUL_K_PKG_EVENT_RESULT, val);
+
+       pi_uid = pkgmgr_installer_get_uid(pi);
+       aul_package_pre_event_send(pi_uid, b);
+       aul_package_pre_event_send(uid, b);
+       bundle_free(b);
+
        pkgmgr_installer_send_signal(pi, event_type, pkgid, key, val);
        pkgmgr_installer_send_signal_for_uid(pi, uid, event_type, pkgid, key,
                        val);
index cd1dfe5..3e8bce1 100644 (file)
@@ -17,4 +17,4 @@ APPLY_PKG_CONFIG(${TARGET_PKG_GETSIZE} PUBLIC
 )
 
 # Install
-INSTALL(TARGETS ${TARGET_PKG_GETSIZE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TARGET_PKG_GETSIZE} DESTINATION bin)
diff --git a/tests/mock/aul_mock.cc b/tests/mock/aul_mock.cc
new file mode 100644 (file)
index 0000000..9207502
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * 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 "mock/mock_hook.h"
+#include "mock/aul_mock.h"
+#include "mock/test_fixture.h"
+
+extern "C" int aul_package_event_pre_send(uid_t uid, bundle* b) {
+  return MOCK_HOOK_P2(AulMock, aul_package_event_pre_send, uid, b);
+}
diff --git a/tests/mock/aul_mock.h b/tests/mock/aul_mock.h
new file mode 100644 (file)
index 0000000..df7bc27
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * 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 TESTS_MOCK_AUL_MOCK_H_
+#define TESTS_MOCK_AUL_MOCK_H_
+
+#include <tizen.h>
+#include <gmock/gmock.h>
+#include <aul.h>
+#include <bundle.h>
+
+#include "mock/module_mock.h"
+
+class AulMock : public virtual ModuleMock {
+ public:
+  AulMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+
+    ON_CALL(*this, aul_package_event_pre_send(_, _))
+        .WillByDefault(Return(0));
+  }
+  virtual ~AulMock() {}
+
+  MOCK_METHOD2(aul_package_event_pre_send, int(uid_t, bundle*));
+};
+
+#endif  // TESTS_MOCK_AUL_MOCK_H_
index 8bafa81..6150f1a 100644 (file)
@@ -3,6 +3,8 @@ PROJECT(pkgmgr-tool_unittests C CXX)
 
 INCLUDE(FindPkgConfig)
 PKG_CHECK_MODULES(pkgmgr-tool_unittests REQUIRED
+  aul
+  bundle
   dlog
   gmock
   pkgmgr
index 941899f..e9e3454 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "mock/os_mock.h"
 #include "mock/pkgmgr_info_mock.h"
+#include "mock/aul_mock.h"
 #include "mock/test_fixture.h"
 #include "pkg_finder.hh"
 #include "pkg_upgrader_factory.hh"