Check VCONF value for Maintenance Mode 89/165589/3 accepted/tizen/4.0/unified/20180111.051205 submit/tizen/20180109.085832 submit/tizen/20180110.012731 submit/tizen_4.0/20180109.085933 tizen_4.0.IoT.p2_release
authorLee Sung Jun <sjun221.lee@samsung.com>
Tue, 2 Jan 2018 08:52:56 +0000 (17:52 +0900)
committerLee Sung Jun <sjun221.lee@samsung.com>
Wed, 3 Jan 2018 02:13:30 +0000 (11:13 +0900)
Change-Id: I7fa4f2c9add5d9b4051ccaad545cda4ed1c00000
Signed-off-by: Lee Sung Jun <sjun221.lee@samsung.com>
libs/CMakeLists.txt
libs/policy-client.cpp
libs/policy-client.h
packaging/device-policy-client.spec

index 3d5f6bd..ec007b1 100755 (executable)
@@ -58,6 +58,7 @@ PKG_CHECK_MODULES(LIBS_DEPS   REQUIRED
                                                        glib-2.0
                                                        capi-base-common
                                                        capi-system-info
+                                                       vconf
 )
 
 INCLUDE_DIRECTORIES(SYSTEM ${LIBS_DEPS_INCLUDE_DIRS} ${DPM_LIBS})
index 5cddb2e..7d39ec2 100644 (file)
 
 #include "policy-client.h"
 
+#include <vconf.h>
+
+#define VCONFKEY_DPM_MODE_STATE "db/dpm/mode_state"
+
 namespace {
 
 const std::string SIGNAL_OBJECT_PATH = "/org/tizen/DevicePolicyManger/PIL";
@@ -29,22 +33,11 @@ const std::string SIGNAL_EVENT_INTERFACE = "org.tizen.DevicePolicyManager.PIL.Ev
 
 const std::string POLICY_MANAGER_ADDRESS = "/tmp/.device-policy-manager.sock";
 
-int GetPolicyEnforceMode()
-{
-       runtime::File policyManagerSocket(POLICY_MANAGER_ADDRESS);
-
-       if (policyManagerSocket.exists()) {
-               return 1;
-       }
-
-       return 0;
-}
-
 } // namespace
 
 
 DevicePolicyClient::DevicePolicyClient() noexcept :
-       maintenanceMode(GetPolicyEnforceMode()), clientAddress(POLICY_MANAGER_ADDRESS)
+       clientAddress(POLICY_MANAGER_ADDRESS)
 {
        mainloop.reset(new ScopedGMainLoop);
 }
@@ -58,7 +51,7 @@ int DevicePolicyClient::subscribeSignal(const std::string& name,
                                                                                const SignalHandler& handler,
                                                                                void* data) noexcept
 {
-       if (!maintenanceMode)
+       if (!getMaintenanceMode())
                return 0;
 
        try {
@@ -79,7 +72,7 @@ int DevicePolicyClient::subscribeSignal(const std::string& name,
 
 int DevicePolicyClient::unsubscribeSignal(int id) noexcept
 {
-       if (!maintenanceMode)
+       if (!getMaintenanceMode())
                return 0;
 
        try {
@@ -91,3 +84,12 @@ int DevicePolicyClient::unsubscribeSignal(int id) noexcept
                return -1;
        }
 }
+
+int DevicePolicyClient::getMaintenanceMode()
+{
+       int value = 0;
+
+       ::vconf_get_bool(VCONFKEY_DPM_MODE_STATE, &value);
+
+       return value;
+}
index 51115e0..f37cdee 100644 (file)
@@ -36,11 +36,12 @@ public:
                                                const SignalHandler& handler,
                                                void* data) noexcept;
        int unsubscribeSignal(int subscriberId) noexcept;
+       int getMaintenanceMode();
 
        template<typename Type, typename... Args>
        Type methodCall(const std::string& method, Args&&... args)
        {
-               if (!maintenanceMode) {
+               if (!getMaintenanceMode()) {
                        errno = EPROTONOSUPPORT;
                        return Type();
                }
@@ -51,7 +52,6 @@ public:
        }
 
 private:
-       int maintenanceMode;
        std::string clientAddress;
        std::unique_ptr<ScopedGMainLoop> mainloop;
 };
index 85cbecb..9df58cf 100755 (executable)
@@ -11,6 +11,7 @@ BuildRequires: pkgconfig(klay)
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(vconf)
 
 %description
 Tizen Device Policy Client Library