Check VCONF value for Maintenance Mode
[platform/core/security/device-policy-client.git] / libs / policy-client.cpp
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;
+}