#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-PROJECT(dpm)
-SET(LIB_VERSION "${VERSION}")
-SET(LIB_SOVERSION "0")
+PROJECT(device-policy-client)
INCLUDE(FindPkgConfig)
SET(CMAKE_BUILD_TYPE "DEBUG")
ENDIF(NOT CMAKE_BUILD_TYPE)
-SET(DPM_POLICY ${PROJECT_SOURCE_DIR}/policy)
-SET(DPM_LIBS ${PROJECT_SOURCE_DIR}/)
+SET(DPM_LIBS ${PROJECT_SOURCE_DIR}/libs)
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
SET(CXX_STD "c++0x")
ADD_DEFINITIONS(-DUG_WAYLAND)
-SET(PC_FILE "${PROJECT_NAME}.pc")
+ADD_SUBDIRECTORY(${DPM_LIBS})
-SET(FOUNDATION policy-client.cpp
- dpm/client-handle.cpp
-)
-
-SET(POLICY administration.cpp
- application.cpp
- bluetooth.cpp
- location.cpp
- restriction.cpp
- security.cpp
- storage.cpp
- wifi.cpp
- password.cpp
- krate.cpp
- dpm/administration.cpp
- dpm/application.cpp
- dpm/bluetooth.cpp
- dpm/restriction.cpp
- dpm/security.cpp
- dpm/wifi.cpp
- dpm/password.cpp
- dpm/zone.cpp
-)
-
-SET(CAPI dpm/device-policy-manager.h
- dpm/administration.h
- dpm/application.h
- dpm/bluetooth.h
- dpm/restriction.h
- dpm/security.h
- dpm/wifi.h
- dpm/password.h
- dpm/password_internal.h
- dpm/zone.h
-)
-
-SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
-
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${FOUNDATION} ${POLICY})
-
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${LIB_SOVERSION})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${LIB_VERSION})
-
-PKG_CHECK_MODULES(LIBS_DEPS REQUIRED
- klay
- glib-2.0
- capi-base-common
- capi-system-info
-)
-
-INCLUDE_DIRECTORIES(SYSTEM ${LIBS_DEPS_INCLUDE_DIRS} ${DPM_POLICY} ${DPM_LIBS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS_DEPS_LIBRARIES} pthread)
-
-CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
-
-INSTALL(FILES ${CMAKE_BINARY_DIR}/${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES ${CAPI} DESTINATION ${INCLUDE_INSTALL_DIR}/dpm)
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "administration.hxx"
-
-namespace DevicePolicyManager {
-
-struct AdministrationPolicy::Private {
- Private(PolicyControlContext& ctx) : context(ctx) {}
- PolicyControlContext& context;
-};
-
-AdministrationPolicy::AdministrationPolicy(AdministrationPolicy&& rhs) = default;
-AdministrationPolicy& AdministrationPolicy::operator=(AdministrationPolicy&& rhs) = default;
-
-AdministrationPolicy::AdministrationPolicy(const AdministrationPolicy& rhs) :
- pimpl(nullptr)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-AdministrationPolicy& AdministrationPolicy::operator=(const AdministrationPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-AdministrationPolicy::AdministrationPolicy(PolicyControlContext& ctx) :
- pimpl(new Private(ctx))
-{
-}
-
-AdministrationPolicy::~AdministrationPolicy()
-{
-}
-
-int AdministrationPolicy::registerPolicyClient(const std::string& name, uid_t uid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("AdministrationPolicy::registerPolicyClient", name, uid);
-
- return status.get();
-}
-
-int AdministrationPolicy::deregisterPolicyClient(const std::string& name, uid_t uid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("AdministrationPolicy::deregisterPolicyClient", name, uid);
-
- return status.get();
-}
-
-} // namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "application.hxx"
-
-namespace DevicePolicyManager {
-
-struct ApplicationPolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-ApplicationPolicy::ApplicationPolicy(ApplicationPolicy&& rhs) = default;
-ApplicationPolicy& ApplicationPolicy::operator=(ApplicationPolicy&& rhs) = default;
-
-ApplicationPolicy::ApplicationPolicy(const ApplicationPolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-ApplicationPolicy& ApplicationPolicy::operator=(const ApplicationPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-ApplicationPolicy::ApplicationPolicy(PolicyControlContext& ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-ApplicationPolicy::~ApplicationPolicy()
-{
-}
-
-int ApplicationPolicy::installPackage(const std::string& pkgpath)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("ApplicationPolicy::installPackage", pkgpath);
-
- return status.get();
-}
-
-int ApplicationPolicy::uninstallPackage(const std::string& pkgid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("ApplicationPolicy::uninstallPackage", pkgid);
-
- return status.get();
-}
-
-int ApplicationPolicy::setModeRestriction(int mode)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("ApplicationPolicy::setModeRestriction", mode);
-
- return status.get();
-}
-
-int ApplicationPolicy::unsetModeRestriction(int mode)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("ApplicationPolicy::unsetModeRestriction", mode);
-
- return status.get();
-}
-
-int ApplicationPolicy::getModeRestriction()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("ApplicationPolicy::getModeRestriction");
-
- return status.get();
-}
-
-int ApplicationPolicy::addPrivilegeToBlacklist(int type, const std::string& privilege)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("ApplicationPolicy::addPrivilegeToBlacklist", type, privilege);
-
- return status.get();
-}
-
-int ApplicationPolicy::removePrivilegeFromBlacklist(int type, const std::string& privilege)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("ApplicationPolicy::removePrivilegeFromBlacklist", type, privilege);
-
- return status.get();
-}
-
-int ApplicationPolicy::checkPrivilegeIsBlacklisted(int type, const std::string& privilege)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("ApplicationPolicy::checkPrivilegeIsBlacklisted", type, privilege);
-
- return status.get();
-}
-} // namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2016 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 "status.h"
-#include "bluetooth.hxx"
-
-namespace DevicePolicyManager {
-
-struct BluetoothPolicy::Private {
- Private(PolicyControlContext& ctx) : context(ctx) {}
- PolicyControlContext& context;
-};
-
-BluetoothPolicy::BluetoothPolicy(BluetoothPolicy&& rhs) = default;
-BluetoothPolicy& BluetoothPolicy::operator=(BluetoothPolicy&& rhs) = default;
-
-BluetoothPolicy::BluetoothPolicy(const BluetoothPolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-BluetoothPolicy& BluetoothPolicy::operator=(const BluetoothPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-BluetoothPolicy::~BluetoothPolicy()
-{
-}
-
-// for restriction CPIs
-int BluetoothPolicy::setModeChangeState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::setModeChangeState", enable);
-
- return status.get();
-}
-
-bool BluetoothPolicy::getModeChangeState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("BluetoothPolicy::getModeChangeState");
-
- return status.get();
-}
-
-int BluetoothPolicy::setDesktopConnectivityState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<bool>("BluetoothPolicy::setDesktopConnectivityState", enable);
-
- return status.get();
-}
-
-bool BluetoothPolicy::getDesktopConnectivityState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("BluetoothPolicy::getDesktopConnectivityState");
-
- return status.get();
-}
-
-int BluetoothPolicy::setTetheringState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::setTetheringState", enable);
-
- return status.get();
-}
-
-bool BluetoothPolicy::getTetheringState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("BluetoothPolicy::getTetheringState");
-
- return status.get();
-}
-
-int BluetoothPolicy::setPairingState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::setPairingState", enable);
-
- return status.get();
-}
-
-bool BluetoothPolicy::getPairingState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("BluetoothPolicy::getPairingState");
-
- return status.get();
-}
-
-int BluetoothPolicy::addDeviceToBlacklist(const std::string& mac)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::addDeviceToBlacklist", mac);
-
- return status.get();
-}
-
-int BluetoothPolicy::removeDeviceFromBlacklist(const std::string& mac)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::removeDeviceFromBlacklist", mac);
-
- return status.get();
-}
-
-int BluetoothPolicy::setDeviceRestriction(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::setDeviceRestriction", enable);
-
- return status.get();
-}
-
-bool BluetoothPolicy::isDeviceRestricted()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { false };
-
- status = context.methodCall<bool>("BluetoothPolicy::isDeviceRestricted");
-
- return status.get();
-}
-
-int BluetoothPolicy::addUuidToBlacklist(const std::string& uuid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::addUuidToBlacklist", uuid);
-
- return status.get();
-}
-
-int BluetoothPolicy::removeUuidFromBlacklist(const std::string& uuid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::removeUuidFromBlacklist", uuid);
-
- return status.get();
-}
-
-int BluetoothPolicy::setUuidRestriction(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("BluetoothPolicy::setUuidRestriction", enable);
-
- return status.get();
-}
-
-bool BluetoothPolicy::isUuidRestricted()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { false };
-
- status = context.methodCall<bool>("BluetoothPolicy::isUuidRestricted");
-
- return status.get();
-}
-
-} // namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "krate.hxx"
-
-namespace DevicePolicyManager {
-
-struct KratePolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-KratePolicy::KratePolicy(KratePolicy&& rhs) = default;
-KratePolicy& KratePolicy::operator=(KratePolicy&& rhs) = default;
-
-KratePolicy::KratePolicy(const KratePolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-KratePolicy& KratePolicy::operator=(const KratePolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-KratePolicy::KratePolicy(PolicyControlContext& ctx) :
- pimpl(new Private(ctx))
-{
-}
-
-KratePolicy::~KratePolicy()
-{
-}
-
-int KratePolicy::createKrate(const std::string& name, const std::string& setupWizAppid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("KratePolicy::createKrate", name, setupWizAppid);
-
- return status.get();
-}
-
-int KratePolicy::removeKrate(const std::string& name)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("KratePolicy::removeKrate", name);
-
- return status.get();
-}
-
-int KratePolicy::getKrateState(const std::string& name)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("KratePolicy::getKrateState", name);
-
- return status.get();
-}
-
-std::vector<std::string> KratePolicy::getKrateList(int state)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<std::vector<std::string>> status { std::vector<std::string>() };
-
- status = context.methodCall<std::vector<std::string>>("KratePolicy::getKrateList", state);
-
- return status.get();
-}
-
-} // namespace DevicePolicyManager
--- /dev/null
+#
+# Copyright (c) 2015 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.
+#
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+SET(TARGET "dpm")
+SET(LIB_VERSION "${VERSION}")
+SET(LIB_SOVERSION "0")
+
+SET(PC_FILE "${TARGET}.pc")
+
+SET(POLICY policy-client.cpp
+ client-handle.cpp
+ administration.cpp
+ application.cpp
+ bluetooth.cpp
+ restriction.cpp
+ security.cpp
+ wifi.cpp
+ password.cpp
+ zone.cpp
+)
+
+SET(CAPI dpm/device-policy-manager.h
+ dpm/administration.h
+ dpm/application.h
+ dpm/bluetooth.h
+ dpm/restriction.h
+ dpm/security.h
+ dpm/wifi.h
+ dpm/password.h
+ dpm/password_internal.h
+ dpm/zone.h
+)
+
+SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack")
+
+ADD_LIBRARY(${TARGET} SHARED ${FOUNDATION} ${POLICY})
+
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${LIB_SOVERSION})
+SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION ${LIB_VERSION})
+
+PKG_CHECK_MODULES(LIBS_DEPS REQUIRED
+ klay
+ glib-2.0
+ capi-base-common
+ capi-system-info
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${LIBS_DEPS_INCLUDE_DIRS} ${DPM_LIBS})
+TARGET_LINK_LIBRARIES(${TARGET} ${LIBS_DEPS_LIBRARIES} pthread)
+
+CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_BINARY_DIR}/${PC_FILE} @ONLY)
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${PC_FILE} DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${TARGET} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CAPI} DESTINATION ${INCLUDE_INSTALL_DIR}/dpm)
#include <cstring>
#include <cassert>
-#include "administration.h"
-#include "administration.hxx"
+#include "dpm/administration.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_admin_register_client(device_policy_manager_h handle, const char* name, uid_t uid)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(uid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return admin.registerPolicyClient(name, uid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("DevicePolicyManager::enroll", name, uid);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(uid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return admin.deregisterPolicyClient(name, uid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("DevicePolicyManager::disenroll", name, uid);
+ return status.get();
} catch (...) {
return -1;
}
* limitations under the License
*/
-#include "application.h"
-#include "application.hxx"
+#include "dpm/application.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_application_set_mode_restriction(device_policy_manager_h handle, int mode)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- return application.setModeRestriction(mode);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Application::setModeRestriction", mode);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- return application.unsetModeRestriction(mode);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Application::unsetModeRestriction", mode);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- int ret = application.getModeRestriction();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Application::getModeRestriction");
+ if (status.get() < 0) {
return -1;
}
- *mode = ret;
+ *mode = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(privilege, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- return application.addPrivilegeToBlacklist(type, privilege);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Application::addPrivilegeToBlacklist", type, privilege);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(privilege, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- return application.removePrivilegeFromBlacklist(type, privilege);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Application::removePrivilegeFromBlacklist", type, privilege);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(privilege, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_blacklisted, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- int ret = application.checkPrivilegeIsBlacklisted(type, privilege);
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Application::checkPrivilegeIsBlacklisted", type, privilege);
+ if (status.get() < 0) {
return -1;
}
- *is_blacklisted = ret;
+ *is_blacklisted = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgpath, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- return application.installPackage(pkgpath);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Application::installPackage", pkgpath);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
try {
- return application.uninstallPackage(pkgid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Application::uninstallPackage", pkgid);
+ return status.get();
} catch (...) {
return -1;
}
* limitations under the License
*/
-#include "bluetooth.h"
-#include "bluetooth.hxx"
+#include "dpm/bluetooth.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_bluetooth_add_device_to_blacklist(device_policy_manager_h handle, const char* mac)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.addDeviceToBlacklist(mac);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::addDeviceToBlacklist", mac);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.removeDeviceFromBlacklist(mac);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::removeDeviceFromBlacklist", mac);
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.setDeviceRestriction(enable);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::setDeviceRestriction", enable);
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *state = bluetooth.isDeviceRestricted();
+ Status<bool> status { false };
+ status = client.methodCall<bool>("Bluetooth::isDeviceRestricted");
+ *state = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.addUuidToBlacklist(uuid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::addUuidToBlacklist", uuid);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.removeUuidFromBlacklist(uuid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::removeUuidFromBlacklist", uuid);
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.setUuidRestriction(enable);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::setUuidRestriction", enable);
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *state = bluetooth.isUuidRestricted();
+ Status<bool> status { false };
+ status = client.methodCall<bool>("Bluetooth::isUuidRestricted");
+ *state = status.get();
} catch (...) {
return -1;
}
#include <cassert>
#include <iostream>
-#include "device-policy-manager.h"
+#include "dpm/device-policy-manager.h"
#include "policy-client.h"
#include "debug.h"
-DevicePolicyContext& GetDevicePolicyContext(void* handle)
+DevicePolicyClient& GetDevicePolicyClient(void* handle)
{
assert(handle);
- return *reinterpret_cast<DevicePolicyContext*>(handle);
+ return *reinterpret_cast<DevicePolicyClient*>(handle);
}
EXPORT_API device_policy_manager_h dpm_manager_create(void)
{
- DevicePolicyContext* client = new(std::nothrow) DevicePolicyContext();
+ DevicePolicyClient* client = new(std::nothrow) DevicePolicyClient();
if (client == nullptr) {
return NULL;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- delete &GetDevicePolicyContext(handle);
+ delete &GetDevicePolicyClient(handle);
return 0;
}
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- int ret = client.subscribePolicyChange(name, callback, user_data);
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
+ int ret = client.subscribeSignal(name, callback, user_data);
if (ret < 0) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- return client.unsubscribePolicyChange(id);
+ DevicePolicyClient& client = GetDevicePolicyClient(handle);
+ return client.unsubscribeSignal(id);
}
EXPORT_API int dpm_add_signal_cb(device_policy_manager_h handle, const char* signal,
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(id, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& context = GetDevicePolicyContext(handle);
+ DevicePolicyClient& context = GetDevicePolicyClient(handle);
int ret = context.subscribeSignal(signal, callback, user_data);
if (ret < 0) {
return -1;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(id >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext& context = GetDevicePolicyContext(handle);
+ DevicePolicyClient& context = GetDevicePolicyClient(handle);
return context.unsubscribeSignal(id);
}
#include <cstring>
#include <cassert>
-#include "password.h"
-#include "password_internal.h"
-#include "password.hxx"
+#include "dpm/password.h"
+#include "dpm/password_internal.h"
#include "array.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_password_set_quality(device_policy_manager_h handle, int quality)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(quality >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setQuality(quality);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setQuality", quality);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(quality, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getQuality();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getQuality");
+ if (status.get() < 0)
return -1;
- }
- *quality = (dpm_password_quality_e)ret;
+ *quality = (dpm_password_quality_e)status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setMinimumLength(value);
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::setMinimumLength", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getMinimumLength();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getMinimumLength");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setMinComplexChars(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setMinComplexChars", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getMinComplexChars();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getMinComplexChars");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setMaximumFailedForWipe(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setMaximumFailedForWipe", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getMaximumFailedForWipe();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getMaximumFailedForWipe");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setExpires(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setExpires", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getExpires();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getExpires");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setHistory(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setHistory", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getHistory();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getHistory");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setPattern(pattern);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setPattern", pattern);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(passwd, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.reset(passwd);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::reset", passwd);
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.enforceChange();
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::enforceChange");
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setMaxInactivityTimeDeviceLock(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setMaxInactivityTimeDeviceLock", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getMaxInactivityTimeDeviceLock();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getMaxInactivityTimeDeviceLock");;
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
return DPM_ERROR_NONE;
}
-EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e status)
+EXPORT_API int dpm_password_set_status(device_policy_manager_h handle, dpm_password_status_e stat)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(status >= DPM_PASSWORD_STATUS_NORMAL &&
- status <= DPM_PASSWORD_STATUS_PATTERN_CHANGED,
+ RET_ON_FAILURE(stat >= DPM_PASSWORD_STATUS_NORMAL &&
+ stat <= DPM_PASSWORD_STATUS_PATTERN_CHANGED,
DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setStatus(status);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setStatus", (int)stat);
+ return status.get();
} catch (...) {
return -1;
}
}
-EXPORT_API int dpm_password_get_status(device_policy_manager_h handle, dpm_password_status_e *status)
+EXPORT_API int dpm_password_get_status(device_policy_manager_h handle, dpm_password_status_e *stat)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(status, DPM_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(stat, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getStatus();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getStatus");
+ if (status.get() < 0)
return -1;
- }
- *status = (dpm_password_status_e)ret;
+ *stat = (dpm_password_status_e)status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.deletePattern();
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::deletePattern");
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *pattern = ::strdup(password.getPattern().c_str());
+ Status<std::string> status { std::string() };
+ status = client.methodCall<std::string>("Password::getPattern");
+ *pattern = ::strdup(status.get().c_str());
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setMaximumCharacterOccurrences(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setMaximumCharacterOccurrences", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getMaximumCharacterOccurrences();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getMaximumCharacterOccurrences");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value >= 0, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setMaximumNumericSequenceLength(value);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setMaximumNumericSequenceLength", value);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getMaximumNumericSequenceLength();
- if (ret < 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Password::getMaximumNumericSequenceLength");
+ if (status.get() < 0)
return -1;
- }
- *value = ret;
+ *value = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, NULL);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
+
+ Status<std::vector<std::string>> status { std::vector<std::string>() };
+ status = client.methodCall<std::vector<std::string>>("Password::getForbiddenStrings");
- return reinterpret_cast<dpm_password_iterator_h>(new dpm_password_iterator(password.getForbiddenStrings()));
+ dpm_password_iterator *iter = new dpm_password_iterator(status.get());
+ return reinterpret_cast<dpm_password_iterator_h>(iter);
}
EXPORT_API int dpm_password_iterator_next(dpm_password_iterator_h iter, const char **result)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(strings, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
for (iter = 0; iter < length; iter++)
forbiddenStrings.push_back(strings[iter]);
try {
- return password.setForbiddenStrings(forbiddenStrings);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setForbiddenStrings", forbiddenStrings);
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return password.setRecovery(enable);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Password::setRecovery", enable);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int ret = password.getRecovery();
- if (ret < 0) {
+ Status<int> status { false };
+ status = client.methodCall<int>("Password::getRecovery");
+ if (status.get() < 0)
return -1;
- }
- *enable = ret;
+ *enable = status.get();
} catch (...) {
return -1;
}
--- /dev/null
+/*
+ * Copyright (c) 2015 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 <system_info.h>
+#include <klay/filesystem.h>
+
+#include "policy-client.h"
+
+namespace {
+
+const std::string SIGNAL_INTERFACE = "DevicePolicyManager::subscribeSignal";
+
+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())
+{
+}
+
+DevicePolicyClient::~DevicePolicyClient() noexcept
+{
+ disconnect();
+}
+
+int DevicePolicyClient::connect(const std::string& address) noexcept
+{
+ try {
+ client.reset(new rmi::Client(address));
+ if (maintenanceMode) {
+ client->connect();
+ }
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+
+ return 0;
+}
+
+int DevicePolicyClient::connect() noexcept
+{
+ return connect(POLICY_MANAGER_ADDRESS);
+}
+
+void DevicePolicyClient::disconnect() noexcept
+{
+ client.reset();
+}
+
+int DevicePolicyClient::subscribeSignal(const std::string& name,
+ const SignalHandler& handler,
+ void* data)
+{
+ auto dispatch = [handler, data](const std::string &name, const std::string &object) {
+ handler(name.c_str(), object.c_str(), data);
+ };
+
+ if (!maintenanceMode) {
+ return 0;
+ }
+
+ try {
+ return client->subscribe<std::string, std::string>(SIGNAL_INTERFACE, name, dispatch);
+ } catch (runtime::Exception& e) {
+ std::cout << e.what() << std::endl;
+ return -1;
+ }
+}
+
+int DevicePolicyClient::unsubscribeSignal(int id)
+{
+ if (!maintenanceMode) {
+ return 0;
+ }
+
+ return client->unsubscribe("", id);
+}
#include <klay/rmi/client.h>
-typedef std::function<void(const char*, const char*, void*)> PolicyChangeListener;
-typedef std::function<void(const char*, const char*, void*)> SignalListener;
+typedef std::function<void(const char*, const char*, void*)> SignalHandler;
-class DevicePolicyContext {
+class DevicePolicyClient {
public:
- typedef DevicePolicyContext PolicyControlContext;
-
- DevicePolicyContext() noexcept;
- ~DevicePolicyContext() noexcept;
+ DevicePolicyClient() noexcept;
+ ~DevicePolicyClient() noexcept;
int connect() noexcept;
int connect(const std::string& address) noexcept;
void disconnect() noexcept;
- int subscribePolicyChange(const std::string& name, const PolicyChangeListener& listener, void* data);
- int unsubscribePolicyChange(int subscriberId);
-
- int subscribeSignal(const std::string& name, const SignalListener& listener, void* data);
+ int subscribeSignal(const std::string& name, const SignalHandler& handler, void* data);
int unsubscribeSignal(int subscriberId);
- template<typename Policy, typename... Args>
- Policy createPolicyInterface(Args&&... args) noexcept
- {
- return Policy(getPolicyControlContext(), std::forward<Args>(args)...);
- }
-
template<typename Type, typename... Args>
Type methodCall(const std::string& method, Args&&... args)
{
}
private:
- PolicyControlContext& getPolicyControlContext()
- {
- return *this;
- }
-
-private:
int maintenanceMode;
std::unique_ptr<rmi::Client> client;
};
-DevicePolicyContext& GetDevicePolicyContext(void* handle);
+DevicePolicyClient& GetDevicePolicyClient(void* handle);
#endif //__POLICY_CLIENT_H__
* limitations under the License
*/
-#include "restriction.h"
-#include "restriction.hxx"
-#include "location.hxx"
-#include "bluetooth.hxx"
-#include "wifi.hxx"
+#include "dpm/restriction.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_restriction_set_camera_state(device_policy_manager_h handle, int allow)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setCameraState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Media::setCameraState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getCameraState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Media::getCameraState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setMicrophoneState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Media::setMicrophoneState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getMicrophoneState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Media::getMicrophoneState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return location.setLocationState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Location::setState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = location.getLocationState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Location::getState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setUsbDebuggingState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Usb::setDebuggingState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getUsbDebuggingState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Usb::getDebuggingState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setUsbTetheringState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Usb::setTetheringState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getUsbTetheringState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Usb::getTetheringState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setExternalStorageState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Storage::setExternalStorageState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getExternalStorageState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Storage::getExternalStorageState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setClipboardState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Media::setClipboardState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getClipboardState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Media::getClipboardState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return wifi.setState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Wifi::setState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = wifi.getState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Wifi::getState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return wifi.setHotspotState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Wifi::setHotspotState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = wifi.getHotspotState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Wifi::getHotspotState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.setTetheringState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::setTetheringState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = bluetooth.getTetheringState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Bluetooth::getTetheringState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.setModeChangeState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::setModeChangeState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = bluetooth.getModeChangeState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Bluetooth::getModeChangeState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.setDesktopConnectivityState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<bool>("Bluetooth::setDesktopConnectivityState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = bluetooth.getDesktopConnectivityState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Bluetooth::getDesktopConnectivityState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return bluetooth.setPairingState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Bluetooth::setPairingState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = bluetooth.getPairingState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Bluetooth::getPairingState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setPopImapEmailState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("EMail::setPopImapState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getPopImapEmailState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("EMail::getPopImapState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setMessagingState(sim_id, allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Telephony::setMessagingState", sim_id, allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getMessagingState(sim_id);
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Telephony::getMessagingState", sim_id);
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return restriction.setBrowserState(allow);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Browser::setState", allow);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_allowed, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_allowed = restriction.getBrowserState();
+ Status<bool> status { true };
+ status = client.methodCall<bool>("Browser::getState");
+ *is_allowed = status.get();
} catch (...) {
return -1;
}
* limitations under the License
*/
-#include "security.h"
-#include "security.hxx"
-#include "storage.hxx"
+#include "dpm/security.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_security_lockout_screen(device_policy_manager_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &context = GetDevicePolicyContext(handle);
- SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return security.lockoutScreen();
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Security::lockoutScreen");
+ return status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &context = GetDevicePolicyContext(handle);
- SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return security.setInternalStorageEncryption(encrypt);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Security::setInternalStorageEncryption", encrypt);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &context = GetDevicePolicyContext(handle);
- SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_encrypted = security.isInternalStorageEncrypted();
+ Status<bool> status { false };
+ status = client.methodCall<int>("Security::isInternalStorageEncrypted");
+ *is_encrypted = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &context = GetDevicePolicyContext(handle);
- SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return security.setExternalStorageEncryption(encrypt);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Security::setExternalStorageEncryption", encrypt);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(is_encrypted, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &context = GetDevicePolicyContext(handle);
- SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *is_encrypted = security.isExternalStorageEncrypted();
+ Status<bool> status { false };
+ status = client.methodCall<int>("Security::isExternalStorageEncrypted");
+ *is_encrypted = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return storage.wipeData(type);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Security::wipeData", (int)type);
+ return status.get();
} catch (...) {
return -1;
}
* limitations under the License
*/
-#include "storage.h"
-#include "storage.hxx"
+#include "dpm/storage.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
-dpm_storage_policy_h dpm_context_acquire_storage_policy(dpm_context_h handle)
+dpm_storage_policy_h dpm_client_acquire_storage_policy(dpm_client_h handle)
{
return handle;
}
-int dpm_context_release_storage_policy(dpm_storage_policy_h handle)
+int dpm_client_release_storage_policy(dpm_storage_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
return DPM_ERROR_NONE;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
return storage.wipeData(type);
} catch (...) {
* limitations under the License
*/
-#include "wifi.h"
-#include "wifi.hxx"
+#include "dpm/wifi.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_wifi_set_profile_change_restriction(device_policy_manager_h handle, int enable)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return wifi.setProfileChangeRestriction(enable);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Wifi::setProfileChangeRestriction", enable);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *enable = wifi.isProfileChangeRestricted();
+ Status<bool> status { false };
+ status = client.methodCall<bool>("Wifi::isProfileChangeRestricted");
+ *enable = status.get();
} catch (...) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return wifi.setNetworkAccessRestriction(enable);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Wifi::setNetworkAccessRestriction", enable);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- *enable = wifi.isNetworkAccessRestricted();
+ Status<bool> status { false };
+ status = client.methodCall<bool>("Wifi::isNetworkAccessRestricted");
+ *enable = status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return wifi.addSsidToBlocklist(ssid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Wifi::addSsidToBlocklist", ssid);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return wifi.removeSsidFromBlocklist(ssid);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Wifi::removeSsidFromBlocklist", ssid);
+ return status.get();
} catch (...) {
return -1;
}
* limitations under the License
*/
-#include "zone.h"
-#include "krate.hxx"
+#include "dpm/zone.h"
#include "array.h"
#include "debug.h"
+#include "status.h"
#include "policy-client.h"
-using namespace DevicePolicyManager;
-
EXPORT_API int dpm_zone_create(device_policy_manager_h handle, const char* name, const char* pkgname)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgname, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return krate.createKrate(name, pkgname);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Zone::create", name, pkgname);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- return krate.removeKrate(name);
+ Status<int> status { -1 };
+ status = client.methodCall<int>("Zone::remove", name);
+ return status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- int result = krate.getKrateState(name);
- if (result == 0) {
+ Status<int> status { 0 };
+ status = client.methodCall<int>("Zone::getState", name);
+ if (status.get() == 0)
return DPM_ERROR_NO_DATA;
- }
- *state = (dpm_zone_state_e)result;
+ *state = (dpm_zone_state_e)status.get();
} catch (...) {
return -1;
}
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mask, DPM_ERROR_INVALID_PARAMETER);
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- KratePolicy krate = client.createPolicyInterface<KratePolicy>();
+ DevicePolicyClient &client = GetDevicePolicyClient(handle);
try {
- std::vector<std::string> list = krate.getKrateList(state);
- for (const std::string& name : list) {
+ Status<std::vector<std::string>> status { std::vector<std::string>() };
+ status = client.methodCall<std::vector<std::string>>("Zone::enumerate", (int)state);
+ for (const std::string& name : status.get()) {
if (!callback(name.c_str(), user_data))
break;
}
+++ /dev/null
-/*
- * Copyright (c) 2016 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 "status.h"
-#include "location.hxx"
-
-namespace DevicePolicyManager {
-
-struct LocationPolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-LocationPolicy::LocationPolicy(LocationPolicy&& rhs) = default;
-LocationPolicy& LocationPolicy::operator=(LocationPolicy&& rhs) = default;
-
-LocationPolicy::LocationPolicy(const LocationPolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-LocationPolicy& LocationPolicy::operator=(const LocationPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-LocationPolicy::LocationPolicy(PolicyControlContext& ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-LocationPolicy::~LocationPolicy()
-{
-}
-
-int LocationPolicy::setLocationState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("LocationPolicy::setLocationState", enable);
-
- return status.get();
-}
-
-bool LocationPolicy::getLocationState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("LocationPolicy::getLocationState");
-
- return status.get();
-}
-
-} //namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "password.hxx"
-
-namespace DevicePolicyManager {
-
-struct PasswordPolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-PasswordPolicy::PasswordPolicy(PasswordPolicy&& rhs) = default;
-PasswordPolicy& PasswordPolicy::operator=(PasswordPolicy&& rhs) = default;
-
-PasswordPolicy::PasswordPolicy(const PasswordPolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-PasswordPolicy& PasswordPolicy::operator=(const PasswordPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-PasswordPolicy::PasswordPolicy(PolicyControlContext &ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-PasswordPolicy::~PasswordPolicy()
-{
-}
-
-int PasswordPolicy::setQuality(const int quality)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setQuality", quality);
-
- return status.get();
-}
-
-int PasswordPolicy::getQuality()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getQuality");
-
- return status.get();
-}
-
-int PasswordPolicy::setMinimumLength(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::setMinimumLength", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getMinimumLength()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getMinimumLength");
-
- return status.get();
-}
-
-int PasswordPolicy::setMinComplexChars(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setMinComplexChars", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getMinComplexChars()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getMinComplexChars");
-
- return status.get();
-}
-
-int PasswordPolicy::setMaximumFailedForWipe(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setMaximumFailedForWipe", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getMaximumFailedForWipe()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getMaximumFailedForWipe");
-
- return status.get();
-}
-
-int PasswordPolicy::setExpires(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setExpires", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getExpires()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getExpires");
-
- return status.get();
-}
-
-int PasswordPolicy::setHistory(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setHistory", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getHistory()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getHistory");
-
- return status.get();
-}
-
-int PasswordPolicy::setPattern(const std::string &pattern)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setPattern", pattern);
-
- return status.get();
-}
-
-int PasswordPolicy::reset(const std::string &passwd)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::reset", passwd);
-
- return status.get();
-}
-
-int PasswordPolicy::enforceChange()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::enforceChange");
-
- return status.get();
-}
-
-int PasswordPolicy::setMaxInactivityTimeDeviceLock(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setMaxInactivityTimeDeviceLock", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getMaxInactivityTimeDeviceLock()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getMaxInactivityTimeDeviceLock");;
-
- return status.get();
-}
-
-int PasswordPolicy::setStatus(int status)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> rstatus { -1 };
-
- rstatus = context.methodCall<int>("PasswordPolicy::setStatus", status);
-
- return rstatus.get();
-}
-
-int PasswordPolicy::getStatus()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getStatus");
-
- return status.get();
-}
-
-int PasswordPolicy::deletePattern()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::deletePattern");
-
- return status.get();
-}
-
-std::string PasswordPolicy::getPattern()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<std::string> status { std::string() };
-
- status = context.methodCall<std::string>("PasswordPolicy::getPattern");
-
- return status.get();
-}
-
-int PasswordPolicy::setMaximumCharacterOccurrences(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setMaximumCharacterOccurrences", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getMaximumCharacterOccurrences()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getMaximumCharacterOccurrences");
-
- return status.get();
-}
-
-int PasswordPolicy::setMaximumNumericSequenceLength(int value)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setMaximumNumericSequenceLength", value);
-
- return status.get();
-}
-
-int PasswordPolicy::getMaximumNumericSequenceLength()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { 0 };
-
- status = context.methodCall<int>("PasswordPolicy::getMaximumNumericSequenceLength");
-
- return status.get();
-}
-
-int PasswordPolicy::setForbiddenStrings(const std::vector<std::string> &forbiddenStrings)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setForbiddenStrings", forbiddenStrings);
-
- return status.get();
-}
-
-std::vector<std::string> PasswordPolicy::getForbiddenStrings()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<std::vector<std::string>> status { std::vector<std::string>() };
-
- status = context.methodCall<std::vector<std::string>>("PasswordPolicy::getForbiddenStrings");
-
- return status.get();
-}
-
-int PasswordPolicy::setRecovery(int enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("PasswordPolicy::setRecovery", enable);
-
- return status.get();
-}
-
-int PasswordPolicy::getRecovery()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { false };
-
- status = context.methodCall<int>("PasswordPolicy::getRecovery");
-
- return status.get();
-}
-} /* namespace DevicePolicyManager */
+++ /dev/null
-/*
- * Copyright (c) 2015 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 <system_info.h>
-#include <klay/filesystem.h>
-
-#include "policy-client.h"
-
-namespace {
-
-const std::string SUBSCRIBER_REGISTER = "Server::registerNotificationSubscriber";
-const std::string SUBSCRIBER_UNREGISTER = "Server::unregisterNotificationSubscriber";
-
-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
-
-
-DevicePolicyContext::DevicePolicyContext() noexcept :
- maintenanceMode(GetPolicyEnforceMode())
-{
-}
-
-DevicePolicyContext::~DevicePolicyContext() noexcept
-{
- disconnect();
-}
-
-int DevicePolicyContext::connect(const std::string& address) noexcept
-{
- try {
- client.reset(new rmi::Client(address));
- if (maintenanceMode) {
- client->connect();
- }
- } catch (runtime::Exception& e) {
- return -1;
- }
-
- return 0;
-}
-
-int DevicePolicyContext::connect() noexcept
-{
- return connect(POLICY_MANAGER_ADDRESS);
-}
-
-void DevicePolicyContext::disconnect() noexcept
-{
- client.reset();
-}
-
-int DevicePolicyContext::subscribePolicyChange(const std::string& name,
- const PolicyChangeListener& listener,
- void* data)
-{
- auto listenerDispatcher = [listener, data](const std::string& policy, std::string &state) {
- listener(policy.c_str(), state.c_str(), data);
- };
-
- if (!maintenanceMode) {
- return 0;
- }
-
- try {
- return client->subscribe<std::string, std::string>(SUBSCRIBER_REGISTER,
- name, listenerDispatcher);
- } catch (runtime::Exception& e) {
- std::cout << e.what() << std::endl;
- return -1;
- }
-}
-
-int DevicePolicyContext::unsubscribePolicyChange(int subscriberId)
-{
- if (!maintenanceMode) {
- return 0;
- }
-
- return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
-}
-
-int DevicePolicyContext::subscribeSignal(const std::string& name,
- const SignalListener& listener,
- void* data)
-{
- auto listenerDispatcher = [listener, data](std::string &name, std::string &from, std::string &object) {
- listener(from.c_str(), object.c_str(), data);
- };
-
- if (!maintenanceMode) {
- return 0;
- }
-
- try {
- return client->subscribe<std::string, std::string, std::string>(SUBSCRIBER_REGISTER,
- name, listenerDispatcher);
- } catch (runtime::Exception& e) {
- std::cout << e.what() << std::endl;
- return -1;
- }
-}
-
-int DevicePolicyContext::unsubscribeSignal(int subscriberId)
-{
- if (!maintenanceMode) {
- return 0;
- }
-
- return client->unsubscribe(SUBSCRIBER_UNREGISTER, subscriberId);
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __DEVICE_POLICY_CONTEXT__
-#define __DEVICE_POLICY_CONTEXT__
-
-#include <memory>
-
-#include "policy-client.h"
-
-using PolicyControlContext = ::DevicePolicyContext::PolicyControlContext;
-
-#endif //!__DEVICE_POLICY_CONTEXT__
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __ADMINISTRATION_POLICY__
-#define __ADMINISTRATION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class AdministrationPolicy {
-public:
- AdministrationPolicy(PolicyControlContext& ctxt);
- ~AdministrationPolicy();
-
- AdministrationPolicy(const AdministrationPolicy& rhs);
- AdministrationPolicy(AdministrationPolicy&& rhs);
-
- AdministrationPolicy& operator=(const AdministrationPolicy& rhs);
- AdministrationPolicy& operator=(AdministrationPolicy&& rhs);
-
- int registerPolicyClient(const std::string& name, uid_t uid);
- int deregisterPolicyClient(const std::string& name, uid_t uid);
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __ADMINISTRATION_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __APPLICATION_POLICY__
-#define __APPLICATION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class ApplicationPolicy {
-public:
- enum PrivilegeType {
- PRIVILEGE_TYPE_WRT = 0,
- PRIVILEGE_TYPE_CORE = 1
- };
-
- enum RestrictionMode {
- RESTRICTION_MODE_ALL = 0x0F,
- RESTRICTION_MODE_INSTALL = 0x01,
- RESTRICTION_MODE_UNINSTALL = 0x02,
- RESTRICTION_MODE_REINSTALL = 0x04,
- RESTRICTION_MODE_MVOE = 0x08
- };
-
- ApplicationPolicy(PolicyControlContext& ctxt);
- ~ApplicationPolicy();
-
- ApplicationPolicy(const ApplicationPolicy& rhs);
- ApplicationPolicy(ApplicationPolicy&& rhs);
-
- ApplicationPolicy& operator=(const ApplicationPolicy& rhs);
- ApplicationPolicy& operator=(ApplicationPolicy&& rhs);
-
-
- int installPackage(const std::string& pkgpath);
- int uninstallPackage(const std::string& pkgid);
-
- int setModeRestriction(int mode);
- int unsetModeRestriction(int mode);
- int getModeRestriction();
-
- int addPrivilegeToBlacklist(int type, const std::string& privilege);
- int removePrivilegeFromBlacklist(int type, const std::string& privilege);
- int checkPrivilegeIsBlacklisted(int type, const std::string& privilege);
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __APPLICATION_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2016 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 __BLUETOOTH_POLICY__
-#define __BLUETOOTH_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to control bluetooth functionalities
- * such as bluetooth device or uuid restriction
- */
-
-class BluetoothPolicy {
-public:
- BluetoothPolicy(PolicyControlContext& ctxt);
- ~BluetoothPolicy();
-
- BluetoothPolicy(const BluetoothPolicy& rhs);
- BluetoothPolicy(BluetoothPolicy&& rhs);
-
- BluetoothPolicy& operator=(const BluetoothPolicy& rhs);
- BluetoothPolicy& operator=(BluetoothPolicy&& rhs);
-
- // for restriction CPIs
- int setModeChangeState(bool enable);
- bool getModeChangeState();
- int setDesktopConnectivityState(bool enable);
- bool getDesktopConnectivityState();
- int setTetheringState(bool enable);
- bool getTetheringState();
- int setPairingState(bool enable);
- bool getPairingState();
-
- // for bluetooth CAPIs
- int addDeviceToBlacklist(const std::string& mac);
- int removeDeviceFromBlacklist(const std::string& mac);
- int setDeviceRestriction(bool enable);
- bool isDeviceRestricted();
-
- int addUuidToBlacklist(const std::string& uuid);
- int removeUuidFromBlacklist(const std::string& uuid);
- int setUuidRestriction(bool enable);
- bool isUuidRestricted();
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __BLUETOOTH_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __KRATE_POLICY__
-#define __KRATE_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class KratePolicy {
-public:
- enum State {
- Locked = 0x01,
- Running = 0x02,
- };
-
- KratePolicy(PolicyControlContext& ctxt);
- ~KratePolicy();
-
- KratePolicy(const KratePolicy& rhs);
- KratePolicy(KratePolicy&& rhs);
-
- KratePolicy& operator=(const KratePolicy& rhs);
- KratePolicy& operator=(KratePolicy&& rhs);
-
- int createKrate(const std::string& name, const std::string& setupWizardAppid);
- int removeKrate(const std::string& name);
-
- int getKrateState(const std::string& name);
-
- std::vector<std::string> getKrateList(int state);
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __KRATE_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2016 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 __LOCATION_POLICY__
-#define __LOCATION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class LocationPolicy {
-public:
- LocationPolicy(PolicyControlContext& ctxt);
- ~LocationPolicy();
-
- LocationPolicy(const LocationPolicy& rhs);
- LocationPolicy(LocationPolicy&& rhs);
-
- LocationPolicy& operator=(const LocationPolicy& rhs);
- LocationPolicy& operator=(LocationPolicy&& rhs);
-
- int setLocationState(bool enable);
- bool getLocationState();
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-
-#endif /* __LOCATION_POLICY__ */
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __PASSWORD_POLICY__
-#define __PASSWORD_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class PasswordPolicy {
-public:
- typedef enum {
- DPM_PASSWORD_QUALITY_UNSPECIFIED = 0x00, /**< No requirements for password. */
- DPM_PASSWORD_QUALITY_SIMPLE_PASSWORD = 0x01, /**< Eas requirement for simple password */
- DPM_PASSWORD_QUALITY_SOMETHING = 0x10, /**< Some kind password is required, but doesn't care what it is */
- DPM_PASSWORD_QUALITY_NUMERIC = 0x20, /**< Containing at least numeric characters */
- DPM_PASSWORD_QUALITY_ALPHABETIC = 0x40, /**< Containing at least alphabetic (or other symbol) characters */
- DPM_PASSWORD_QUALITY_ALPHANUMERIC = 0x80, /**< Containing at least numeric and alphabetic characters */
- } PasswordPolicyQuality;
-
- typedef enum {
- DPM_PASSWORD_STATUS_NORMAL, /**< Password normal status */
- DPM_PASSWORD_STATUS_CHANGED, /**< Password successfully changed */
- DPM_PASSWORD_STATUS_NOT_CHANGED, /**< Password not changed */
- DPM_PASSWORD_STATUS_CHANGE_REQUIRED , /**< Password change required */
- DPM_PASSWORD_STATUS_MAX_ATTEMPTS_EXCEEDED, /**< Password Max Attempts Exceeded*/
-
- DPM_PASSWORD_STATUS_EXPIRED, /**< Password expired */
- DPM_PASSWORD_STATUS_RECOVERY_PASSWORD_FAILED, /**< Device unlock failed by Password Recovery */
- DPM_PASSWORD_STATUS_RECOVERY_PASSWORD_SUCCEEDED,/**< Device unlock succeeded by Password Recovery */
-
- DPM_PASSWORD_STATUS_QUALITY_CHANGED, /**< Password quality successfully changed */
- DPM_PASSWORD_STATUS_MIN_LENGTH_CHANGED, /**< Password min_length successfully changed */
- DPM_PASSWORD_STATUS_COMPLEX_CHAR_CHANGED, /**< Password complex_char successfully changed */
- DPM_PASSWORD_STATUS_PATTERN_CHANGED, /**< Password pattern successfully changed */
- DPM_PASSWORD_STATUS_MAX
- } PasswordPolicyStatus;
-
- PasswordPolicy(PolicyControlContext &ctxt);
- ~PasswordPolicy();
-
- PasswordPolicy(const PasswordPolicy& rhs);
- PasswordPolicy(PasswordPolicy&& rhs);
-
- PasswordPolicy& operator=(const PasswordPolicy& rhs);
- PasswordPolicy& operator=(PasswordPolicy&& rhs);
-
- int setQuality(int quality);
- int getQuality();
- int setMinimumLength(int value);
- int getMinimumLength();
- int setMinComplexChars(int value);
- int getMinComplexChars();
- int setMaximumFailedForWipe(int value);
- int getMaximumFailedForWipe();
- int setExpires(int value);
- int getExpires();
- int setHistory(int value);
- int getHistory();
- int setPattern(const std::string &pattern);
- int reset(const std::string &passwd);
- int enforceChange();
- int setMaxInactivityTimeDeviceLock(int value);
- int getMaxInactivityTimeDeviceLock();
- int setStatus(int status);
- int getStatus();
- int deletePattern();
- std::string getPattern();
- int setMaximumCharacterOccurrences(int value);
- int getMaximumCharacterOccurrences();
- int setMaximumNumericSequenceLength(int value);
- int getMaximumNumericSequenceLength();
- int setForbiddenStrings(const std::vector<std::string> &forbiddenStrings);
- std::vector<std::string> getForbiddenStrings();
- int setRecovery(int enable);
- int getRecovery();
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} /* namespace DevicePolicyManager */
-#endif /* __PASSWORD_POLICY__ */
+++ /dev/null
-/*
- * Copyright (c) 2016 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 __RESTRICTION_POLICY__
-#define __RESTRICTION_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class RestrictionPolicy {
-public:
- RestrictionPolicy(PolicyControlContext& ctxt);
- ~RestrictionPolicy();
-
- RestrictionPolicy(const RestrictionPolicy& rhs);
- RestrictionPolicy(RestrictionPolicy&& rhs);
-
- RestrictionPolicy& operator=(const RestrictionPolicy& rhs);
- RestrictionPolicy& operator=(RestrictionPolicy&& rhs);
-
- int setCameraState(bool enable);
- bool getCameraState();
-
- int setMicrophoneState(bool enable);
- bool getMicrophoneState();
-
- int setClipboardState(bool enable);
- bool getClipboardState();
-
- int setUsbDebuggingState(bool enable);
- bool getUsbDebuggingState();
-
- int setUsbTetheringState(bool enable);
- bool getUsbTetheringState();
-
- int setExternalStorageState(bool enable);
- bool getExternalStorageState();
-
- int setPopImapEmailState(bool enable);
- bool getPopImapEmailState();
-
- int setMessagingState(const std::string& sim_id, bool enable);
- bool getMessagingState(const std::string& sim_id);
-
- int setBrowserState(bool enable);
- bool getBrowserState();
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-
-#endif /* __RESTRICTION_POLICY__ */
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __SECURITY_POLICY__
-#define __SECURITY_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to control security functionalities
- * such as certificate installation, encryption and wipe
- */
-
-class SecurityPolicy {
-public:
- SecurityPolicy(PolicyControlContext& ctxt);
- ~SecurityPolicy();
-
- SecurityPolicy(const SecurityPolicy& rhs);
- SecurityPolicy(SecurityPolicy&& rhs);
-
- SecurityPolicy& operator=(const SecurityPolicy& rhs);
- SecurityPolicy& operator=(SecurityPolicy&& rhs);
-
- int lockoutScreen();
- int wipeData(int id);
- int setInternalStorageEncryption(bool encrypt);
- bool isInternalStorageEncrypted();
- int setExternalStorageEncryption(bool encrypt);
- bool isExternalStorageEncrypted();
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __SECURITY_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2017 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
- */
-
-/**
- * @file smack.hxx
- * @brief SMACK agent internal interface.
- * @author Dmytro Logachev (d.logachev@samsung.com)
- * @date Created Oct 13, 2016
- * @par In Samsung Ukraine R&D Center (SRK) under a contract between
- * @par LLC "Samsung Electronics Ukraine Company" (Kyiv, Ukraine)
- * @par and "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
- * @par Copyright: (c) Samsung Electronics Co, Ltd 2016. All rights reserved.
-**/
-
-#ifndef __SMACK_SECURITY_MONITOR__
-#define __SMACK_SECURITY_MONITOR__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to control smack security monitor functionalities
- */
-
-class SmackSecurityMonitor {
-public:
- SmackSecurityMonitor(PolicyControlContext &ctxt);
- ~SmackSecurityMonitor();
-
- SmackSecurityMonitor(const SmackSecurityMonitor &rhs);
- SmackSecurityMonitor(SmackSecurityMonitor &&rhs);
-
- SmackSecurityMonitor &operator=(const SmackSecurityMonitor &rhs);
- SmackSecurityMonitor &operator=(SmackSecurityMonitor &&rhs);
-
- /**
- * @brief Returns SMACK report.
- * @details This API can be used for requesting current SMACK report
- * @return String contains SMACK report
- */
- std::string getReport();
-
- /**
- * @brief Returns number of SMACK issues.
- * @details This API can be used for requesting current number of of SMACK issues
- * @return Number of threats
- */
- int getIssueCount();
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __SMACK_SECURITY_MONITOR__
+++ /dev/null
-/*
- * Copyright (c) 2016 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 __STORAGE_POLICY__
-#define __STORAGE_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-class StoragePolicy {
-public:
- enum {
- WIPE_INTERNAL_STORAGE = (1 << 0),
- WIPE_EXTERNAL_STORAGE = (1 << 1)
- };
-
- StoragePolicy(PolicyControlContext& ctxt);
- ~StoragePolicy();
-
- StoragePolicy(const StoragePolicy& rhs);
- StoragePolicy(StoragePolicy&& rhs);
-
- StoragePolicy& operator=(const StoragePolicy& rhs);
- StoragePolicy& operator=(StoragePolicy&& rhs);
-
- int wipeData(int id);
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DeivcePolicyManager
-
-#endif //!__STORAGE_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2015 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 __WIFI_POLICY__
-#define __WIFI_POLICY__
-
-#include "policy-context.hxx"
-
-namespace DevicePolicyManager {
-
-/**
- * This class provides APIs to configure Wi-Fi related settings and manage Wi-Fi profiles.
- */
-
-class WifiPolicy {
-public:
- WifiPolicy(PolicyControlContext& ctxt);
- ~WifiPolicy();
-
- WifiPolicy(const WifiPolicy& rhs);
- WifiPolicy(WifiPolicy&& rhs);
-
- WifiPolicy& operator=(const WifiPolicy& rhs);
- WifiPolicy& operator=(WifiPolicy&& rhs);
-
- int setState(bool enable);
- bool getState();
-
- int setHotspotState(bool enable);
- bool getHotspotState();
-
- int setProfileChangeRestriction(bool restrict);
- bool isProfileChangeRestricted();
-
- int setNetworkAccessRestriction(bool restrict);
- bool isNetworkAccessRestricted();
-
- int addSsidToBlocklist(const std::string& ssid);
- int removeSsidFromBlocklist(const std::string& ssid);
-
-private:
- struct Private;
- std::unique_ptr<Private> pimpl;
-};
-
-} // namespace DevicePolicyManager
-#endif // __WIFI_POLICY__
+++ /dev/null
-/*
- * Copyright (c) 2016 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 "status.h"
-#include "restriction.hxx"
-
-namespace DevicePolicyManager {
-
-struct RestrictionPolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-RestrictionPolicy::RestrictionPolicy(RestrictionPolicy&& rhs) = default;
-RestrictionPolicy& RestrictionPolicy::operator=(RestrictionPolicy&& rhs) = default;
-
-RestrictionPolicy::RestrictionPolicy(const RestrictionPolicy& rhs)
-{
- std::cout << "Copy Constructor" << std::endl;
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-RestrictionPolicy& RestrictionPolicy::operator=(const RestrictionPolicy& rhs)
-{
- std::cout << "Copy Operator" << std::endl;
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-RestrictionPolicy::RestrictionPolicy(PolicyControlContext& ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-RestrictionPolicy::~RestrictionPolicy()
-{
-}
-
-int RestrictionPolicy::setMicrophoneState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setMicrophoneState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getMicrophoneState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getMicrophoneState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setCameraState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setCameraState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getCameraState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getCameraState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setClipboardState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setClipboardState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getClipboardState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getClipboardState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setUsbDebuggingState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setUsbDebuggingState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getUsbDebuggingState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getUsbDebuggingState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setUsbTetheringState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setUsbTetheringState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getUsbTetheringState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getUsbTetheringState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setExternalStorageState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setExternalStorageState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getExternalStorageState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getExternalStorageState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setPopImapEmailState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setPopImapEmailState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getPopImapEmailState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getPopImapEmailState");
-
- return status.get();
-}
-
-int RestrictionPolicy::setMessagingState(const std::string &sim_id, bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setMessagingState", sim_id, enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getMessagingState(const std::string &sim_id)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getMessagingState", sim_id);
-
- return status.get();
-}
-
-int RestrictionPolicy::setBrowserState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("RestrictionPolicy::setBrowserState", enable);
-
- return status.get();
-}
-
-bool RestrictionPolicy::getBrowserState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("RestrictionPolicy::getBrowserState");
-
- return status.get();
-}
-
-} //namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "security.hxx"
-
-namespace DevicePolicyManager {
-
-struct SecurityPolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-SecurityPolicy::SecurityPolicy(SecurityPolicy&& rhs) = default;
-SecurityPolicy& SecurityPolicy::operator=(SecurityPolicy&& rhs) = default;
-
-SecurityPolicy::SecurityPolicy(const SecurityPolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-SecurityPolicy& SecurityPolicy::operator=(const SecurityPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-SecurityPolicy::SecurityPolicy(PolicyControlContext& ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-SecurityPolicy::~SecurityPolicy()
-{
-}
-
-int SecurityPolicy::lockoutScreen()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("SecurityPolicy::lockoutScreen");
-
- return status.get();
-}
-
-int SecurityPolicy::setInternalStorageEncryption(bool encrypt)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("SecurityPolicy::setInternalStorageEncryption", encrypt);
-
- return status.get();
-}
-
-bool SecurityPolicy::isInternalStorageEncrypted()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { false };
-
- status = context.methodCall<int>("SecurityPolicy::isInternalStorageEncrypted");
-
- return status.get();
-}
-
-int SecurityPolicy::setExternalStorageEncryption(bool encrypt)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("SecurityPolicy::setExternalStorageEncryption", encrypt);
-
- return status.get();
-}
-
-bool SecurityPolicy::isExternalStorageEncrypted()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { false };
-
- status = context.methodCall<int>("SecurityPolicy::isExternalStorageEncrypted");
-
- return status.get();
-}
-
-} // namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "storage.hxx"
-
-namespace DevicePolicyManager {
-
-struct StoragePolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-StoragePolicy::StoragePolicy(StoragePolicy&& rhs) = default;
-StoragePolicy& StoragePolicy::operator=(StoragePolicy&& rhs) = default;
-
-StoragePolicy::StoragePolicy(const StoragePolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-StoragePolicy& StoragePolicy::operator=(const StoragePolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-StoragePolicy::StoragePolicy(PolicyControlContext& ctx) :
- pimpl(new Private(ctx))
-{
-}
-
-StoragePolicy::~StoragePolicy()
-{
-}
-
-int StoragePolicy::wipeData(int type)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("StoragePolicy::wipeData", type);
-
- return status.get();
-}
-
-} //namespace DevicePolicyManager
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "status.h"
-#include "wifi.hxx"
-
-namespace DevicePolicyManager {
-
-struct WifiPolicy::Private {
- Private(PolicyControlContext& ctxt) : context(ctxt) {}
- PolicyControlContext& context;
-};
-
-WifiPolicy::WifiPolicy(WifiPolicy&& rhs) = default;
-WifiPolicy& WifiPolicy::operator=(WifiPolicy&& rhs) = default;
-
-WifiPolicy::WifiPolicy(const WifiPolicy& rhs)
-{
- if (rhs.pimpl) {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-}
-
-
-WifiPolicy& WifiPolicy::operator=(const WifiPolicy& rhs)
-{
- if (!rhs.pimpl) {
- pimpl.reset();
- } else {
- pimpl.reset(new Private(*rhs.pimpl));
- }
-
- return *this;
-}
-
-WifiPolicy::WifiPolicy(PolicyControlContext& ctxt) :
- pimpl(new Private(ctxt))
-{
-}
-
-WifiPolicy::~WifiPolicy()
-{
-}
-
-int WifiPolicy::setState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("WifiPolicy::setState", enable);
-
- return status.get();
-}
-
-bool WifiPolicy::getState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("WifiPolicy::getState");
-
- return status.get();
-}
-
-int WifiPolicy::setHotspotState(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("WifiPolicy::setHotspotState", enable);
-
- return status.get();
-}
-
-bool WifiPolicy::getHotspotState()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { true };
-
- status = context.methodCall<bool>("WifiPolicy::getHotspotState");
-
- return status.get();
-}
-
-int WifiPolicy::setProfileChangeRestriction(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("WifiPolicy::setProfileChangeRestriction", enable);
-
- return status.get();
-}
-
-bool WifiPolicy::isProfileChangeRestricted()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { false };
-
- status = context.methodCall<bool>("WifiPolicy::isProfileChangeRestricted");
-
- return status.get();
-}
-
-int WifiPolicy::setNetworkAccessRestriction(bool enable)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("WifiPolicy::setNetworkAccessRestriction", enable);
-
- return status.get();
-}
-
-bool WifiPolicy::isNetworkAccessRestricted()
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<bool> status { false };
-
- status = context.methodCall<bool>("WifiPolicy::isNetworkAccessRestricted");
-
- return status.get();
-}
-
-int WifiPolicy::addSsidToBlocklist(const std::string& ssid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("WifiPolicy::addSsidToBlocklist", ssid);
-
- return status.get();
-}
-
-int WifiPolicy::removeSsidFromBlocklist(const std::string& ssid)
-{
- PolicyControlContext& context = pimpl->context;
-
- Status<int> status { -1 };
-
- status = context.methodCall<int>("WifiPolicy::removeSsidFromBlocklist", ssid);
-
- return status.get();
-}
-
-} // namespace DevicePolicyManager