[SECARSP-135] - DPM integration
authori.metelytsia <i.metelytsia@samsung.com>
Tue, 6 Mar 2018 12:14:12 +0000 (14:14 +0200)
committerDmytro Lomtiev <d.lomtev@samsung.com>
Fri, 16 Mar 2018 14:18:36 +0000 (16:18 +0200)
Change-Id: I8ae0a20f09cefabf46c6d9b92b4fc25fc9331f6d

device-agent/samonitor/application_service.cpp
device-agent/samonitor/dpm/dpm_api_mapper.cpp
device-agent/scripts/gbs.conf
device-agent/utest/mock/device_policy_manager_mock.h
device-agent/utest/mock/device_policy_manager_stub.cpp
device-agent/utest/mock/device_policy_manager_stub.h
device-agent/utest/test_common_enforce.cpp
device-agent/utest/test_tvext_policy_enforce.cpp

index d40ea86..c15d64e 100644 (file)
@@ -36,6 +36,7 @@ int ApplicationService::install(const std::string& package_path_name)
     device_policy_manager_h handle = dpm_manager_create();
     if (handle) {
         res = dpm_application_install_package(handle, package_path_name.c_str());
+        LOG_D(TAG, "dpm_application_install_package returned %d", res);
         dpm_manager_destroy(handle);
     }
     return res;
index 8e5c6c0..78d1f79 100644 (file)
@@ -26,6 +26,7 @@
 #include <dpm/application.h>
 #include <dpm/security.h>
 #include <dpm/firewall.h>
+#include <dpm/tv.h>
 
 #include "logging.h"
 #include "samonitor_tag.h"
@@ -42,15 +43,15 @@ typedef function<int(dpmh, const char*)>  ApiStr;
 typedef function<int(dpmh, int, const char*)>  ApiIntStr;
 
 const map<const string, ApiNone> m = {
-    {"lockout-screen",  dpm_security_lockout_screen},
+    {"lockout-screen",         dpm_security_lockout_screen},
 };
 
 const map<const string, ApiInt> mi = {
-    {"sound",           dpm_restriction_set_sound_state},
+    {"sound",           dpm_tv_set_sound_state},
     {"bluetooth",       dpm_restriction_set_bluetooth_mode_change_state},
     {"wifi",            dpm_restriction_set_wifi_state},
     {"usb",             dpm_restriction_set_usb_client_state},
-    {"dtv-tunner",      dpm_restriction_set_tuner_state},
+    {"dtv-tunner",      dpm_tv_set_tuner_state},
 
     {"camera",          dpm_restriction_set_camera_state},
     {"microphone",      dpm_restriction_set_microphone_state},
@@ -85,19 +86,6 @@ const map<const string, ApiStr> ms = {
 
 };
 
-#ifdef USE_MIS
-const map<const string, ApiIntStr> mis;
-#endif
-
-
-//      {"wipe external data", dpm_security_wipe_data},
-//      {"wipe internal data", dpm_security_wipe_data},
-//      {"messaging",       dpm_restriction_set_messaging_state},
-//      {"privil-add",      dpm_application_add_privilege_to_blacklist},
-//      {"privil-del",      dpm_application_remove_privilege_from_blacklist},
-//      {"package-set", dpm_application_set_mode_restriction},
-//      {"package-unset", dpm_application_unset_mode_restriction},
-
 Mapper::Mapper() : handle(nullptr)
 {
 }
@@ -201,11 +189,7 @@ dpm_api::ErrorCode Mapper::apply(const std::string& name, const int param, const
     uid_t owner;
 
     try {
-#ifndef __MOCK_THIRDPARTY__
         owner = getUidByName("owner");
-#else
-        owner = root;
-#endif
     } catch (std::runtime_error& e) {
         LOG_E(TAG, "getUidByName(): %s", e.what());
         return NO_DATA;
@@ -260,18 +244,5 @@ dpm_api::ErrorCode Mapper::work(const std::string& name, const int param, const
         return convert_err(res);
     }
 
-#ifdef USE_MIS
-    auto itis = mis.find(name);
-    if (itis != mis.end()) {
-        for (auto& item : items) {
-            res = itis->second((dpmh)handle, param, item.c_str());
-            if (res != DPM_ERROR_NONE) {
-                break;
-            }
-        }
-        return convert_err(res);
-    }
-#endif
-
     return NAME_NOT_FOUND;
 }
index c1e0eef..49f3070 100644 (file)
@@ -56,12 +56,12 @@ buildroot = ~/gbs_root_tm1_tizen4
 url=http://10.103.211.119/220svr/releases/adv-tizen-4.0-product-migration/KantM_ATSC/latest/repos/product/armv7l/packages/
 [repo.base_Main2017_KantM_4.0]
 url=http://10.103.211.119/220svr/base/adv-tizen-4.0-base-migration/standard/latest/repos/base/armv7l/packages
-[repo.KantM_4.0_srk]
-url = http://52.71.167.178:8803/repo/kantm4.0/packages/
+[repo.KantM_4.0_2018_srk]
+url = http://52.71.167.178:8803/repo/kantm4.0_2018/packages/
 
 [profile.kantm_tizen4]
 obs = obs.tizen_org
-repos = repo.base_Main2017_KantM_4.0, repo.KantM_4.0_srk, repo.product_Main2017_KantM_4.0
+repos = repo.base_Main2017_KantM_4.0, repo.KantM_4.0_2018_srk, repo.product_Main2017_KantM_4.0
 buildroot = ~/gbs_root_kantm_tizen4
 
 ############################################# Profile [profile.kantm2_tizen5]
index 4a05c1d..72299a3 100644 (file)
@@ -67,10 +67,10 @@ public:
 
     MOCK_METHOD1(dpm_restriction_set_usb_client_state, int(int allow));
     MOCK_METHOD1(dpm_restriction_get_usb_client_state, int(int* is_allowed));
-    MOCK_METHOD1(dpm_restriction_set_sound_state, int(int allow));
-    MOCK_METHOD1(dpm_restriction_get_sound_state, int(int* is_allowed));
-    MOCK_METHOD1(dpm_restriction_set_tuner_state, int(int allow));
-    MOCK_METHOD1(dpm_restriction_get_tuner_state, int(int* is_allowed));
+    MOCK_METHOD1(dpm_tv_set_sound_state, int(int allow));
+    MOCK_METHOD1(dpm_tv_get_sound_state, int(int* is_allowed));
+    MOCK_METHOD1(dpm_tv_set_tuner_state, int(int allow));
+    MOCK_METHOD1(dpm_tv_get_tuner_state, int(int* is_allowed));
 };
 
 #endif // DEVICEPOLICYMANAGERMOCK_H
index db2c476..b655571 100644 (file)
@@ -6,6 +6,7 @@
 #include <dpm/restriction.h>
 #include <dpm/security.h>
 #include <dpm/wifi.h>
+#include <dpm/tv.h>
 
 #include "device_policy_manager_stub.h"
 
@@ -244,23 +245,23 @@ int dpm_restriction_get_usb_client_state(device_policy_manager_h handle, int* is
     assert(handle != nullptr);
     return reinterpret_cast<DPMInterface*>(handle)->dpm_restriction_get_usb_client_state(is_allowed);
 }
-int dpm_restriction_set_sound_state(device_policy_manager_h handle, int allow)
+int dpm_tv_set_sound_state(device_policy_manager_h handle, int allow)
 {
     assert(handle != nullptr);
-    return reinterpret_cast<DPMInterface*>(handle)->dpm_restriction_set_sound_state(allow);
+    return reinterpret_cast<DPMInterface*>(handle)->dpm_tv_set_sound_state(allow);
 }
-int dpm_restriction_get_sound_state(device_policy_manager_h handle, int* is_allowed)
+int dpm_tv_get_sound_state(device_policy_manager_h handle, int* is_allowed)
 {
     assert(handle != nullptr);
-    return reinterpret_cast<DPMInterface*>(handle)->dpm_restriction_get_sound_state(is_allowed);
+    return reinterpret_cast<DPMInterface*>(handle)->dpm_tv_get_sound_state(is_allowed);
 }
-int dpm_restriction_set_tuner_state(device_policy_manager_h handle, int allow)
+int dpm_tv_set_tuner_state(device_policy_manager_h handle, int allow)
 {
     assert(handle != nullptr);
-    return reinterpret_cast<DPMInterface*>(handle)->dpm_restriction_set_tuner_state(allow);
+    return reinterpret_cast<DPMInterface*>(handle)->dpm_tv_set_tuner_state(allow);
 }
-int dpm_restriction_get_tuner_state(device_policy_manager_h handle, int* is_allowed)
+int dpm_tv_get_tuner_state(device_policy_manager_h handle, int* is_allowed)
 {
     assert(handle != nullptr);
-    return reinterpret_cast<DPMInterface*>(handle)->dpm_restriction_get_tuner_state(is_allowed);
+    return reinterpret_cast<DPMInterface*>(handle)->dpm_tv_get_tuner_state(is_allowed);
 }
index 97d2404..9e6ed50 100644 (file)
@@ -63,10 +63,10 @@ public:
 
     virtual int dpm_restriction_set_usb_client_state(int allow) = 0;
     virtual int dpm_restriction_get_usb_client_state(int* is_allowed) = 0;
-    virtual int dpm_restriction_set_sound_state(int allow) = 0;
-    virtual int dpm_restriction_get_sound_state(int* is_allowed) = 0;
-    virtual int dpm_restriction_set_tuner_state(int allow) = 0;
-    virtual int dpm_restriction_get_tuner_state(int* is_allowed) = 0;
+    virtual int dpm_tv_set_sound_state(int allow) = 0;
+    virtual int dpm_tv_get_sound_state(int* is_allowed) = 0;
+    virtual int dpm_tv_set_tuner_state(int allow) = 0;
+    virtual int dpm_tv_get_tuner_state(int* is_allowed) = 0;
 };
 
 /**
@@ -245,19 +245,19 @@ public:
     {
         return 0;
     }
-    int dpm_restriction_set_sound_state(int allow) override
+    int dpm_tv_set_sound_state(int allow) override
     {
         return 0;
     }
-    int dpm_restriction_get_sound_state(int* is_allowed) override
+    int dpm_tv_get_sound_state(int* is_allowed) override
     {
         return 0;
     }
-    int dpm_restriction_set_tuner_state(int allow) override
+    int dpm_tv_set_tuner_state(int allow) override
     {
         return 0;
     }
-    int dpm_restriction_get_tuner_state(int* is_allowed) override
+    int dpm_tv_get_tuner_state(int* is_allowed) override
     {
         return 0;
     }
index f7897c8..e9d4ce2 100644 (file)
@@ -21,7 +21,7 @@ TEST(Test_CommonPolicyEnforce, test_ParseGroup)
 
     EXPECT_CALL(dpm, dpm_manager_create()).WillOnce(Return(&dpm));
 
-    EXPECT_CALL(dpm, dpm_restriction_set_sound_state(1)).WillOnce(Return(0));
+    EXPECT_CALL(dpm, dpm_tv_set_sound_state(1)).WillOnce(Return(0));
 
     EXPECT_CALL(dpm, dpm_restriction_set_camera_state(0)).WillOnce(Return(0));
     EXPECT_CALL(dpm, dpm_manager_destroy()).Times(1);
index 061ca0b..5be0f82 100644 (file)
@@ -24,12 +24,12 @@ TEST(Test_TvExtPolicyEnforce, test_ParseGroup)
 
     EXPECT_CALL(dpm, dpm_manager_create()).WillOnce(Return(&dpm));
 
-    EXPECT_CALL(dpm, dpm_restriction_set_sound_state(1)).WillOnce(Return(0));
+    EXPECT_CALL(dpm, dpm_tv_set_sound_state(1)).WillOnce(Return(0));
 
     EXPECT_CALL(dpm, dpm_restriction_set_bluetooth_mode_change_state(1)).WillOnce(Return(0));
     EXPECT_CALL(dpm, dpm_restriction_set_wifi_state(0)).WillOnce(Return(0));
     EXPECT_CALL(dpm, dpm_restriction_set_usb_client_state(0)).WillOnce(Return(0));
-    EXPECT_CALL(dpm, dpm_restriction_set_tuner_state(1)).WillOnce(Return(0));
+    EXPECT_CALL(dpm, dpm_tv_set_tuner_state(1)).WillOnce(Return(0));
     EXPECT_CALL(dpm, dpm_manager_destroy()).Times(1);
     EXPECT_CALL(dpm, dpm_firewall_flush_deny_rules()).WillOnce(Return(0));
     EXPECT_CALL(dpm, dpm_firewall_apply_deny_rules(_)).Times(3).WillRepeatedly(Return(0));