SET(POLICY administration.cpp
application.cpp
bluetooth.cpp
+ location.cpp
restriction.cpp
security.cpp
storage.cpp
}
}
+int BluetoothPolicy::setBluetoothTetheringState(bool enable)
+{
+ try {
+ return context->methodCall<int>("BluetoothPolicy::setBluetoothTetheringState", enable);
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+bool BluetoothPolicy::getBluetoothTetheringState()
+{
+ try {
+ return context->methodCall<bool>("BluetoothPolicy::getBluetoothTetheringState");
+ } catch (runtime::Exception &e) {
+ return -1;
+ }
+}
+
} // namespace DevicePolicyManager
dpm_admin_policy_h dpm_context_acquire_admin_policy(dpm_context_h handle)
{
- assert(handle);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<AdministrationPolicy>();
+ return handle;
}
int dpm_context_release_admin_policy(dpm_admin_policy_h handle)
{
- assert(handle);
- delete &GetPolicyInterface<AdministrationPolicy>(handle);
return DPM_ERROR_NONE;
}
int dpm_admin_register_client(dpm_admin_policy_h handle, const char* name)
{
- AdministrationPolicy& admin = GetPolicyInterface<AdministrationPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
return admin.registerPolicyClient(name);
}
int dpm_admin_deregister_client(dpm_admin_policy_h handle, const char* name)
{
- AdministrationPolicy& admin = GetPolicyInterface<AdministrationPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ AdministrationPolicy admin = client.createPolicyInterface<AdministrationPolicy>();
return admin.deregisterPolicyClient(name);
}
dpm_application_policy_h dpm_context_acquire_application_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext& client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<ApplicationPolicy>();
+ return handle;
}
int dpm_context_release_application_policy(dpm_context_h context, dpm_application_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
- delete &GetPolicyInterface<ApplicationPolicy>(handle);
return DPM_ERROR_NONE;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
return application.setApplicationInstallationMode(mode);
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
return application.setApplicationUninstallationMode(mode);
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
int ret = application.getApplicationInstallationMode();
if (ret < 0) {
return -1;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mode, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
int ret = application.getApplicationUninstallationMode();
if (ret < 0) {
return -1;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
return application.setApplicationState(pkgid, state);
}
RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
int ret = application.getApplicationState(pkgid);
if (ret < 0) {
return -1;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
return application.addPackageToBlacklist(pkgid);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
return application.removePackageFromBlacklist(pkgid);
}
RET_ON_FAILURE(pkgid, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(blacklisted, DPM_ERROR_INVALID_PARAMETER);
- ApplicationPolicy& application = GetPolicyInterface<ApplicationPolicy>(handle);
+ DevicePolicyContext& client = GetDevicePolicyContext(handle);
+ ApplicationPolicy application = client.createPolicyInterface<ApplicationPolicy>();
int ret = application.checkPackageIsBlacklisted(pkgid);
if (ret < 0) {
return -1;
dpm_bluetooth_policy_h dpm_context_acquire_bluetooth_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<BluetoothPolicy>();
+ return handle;
}
int dpm_context_release_bluetooth_policy(dpm_context_h context, dpm_bluetooth_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
- delete &GetPolicyInterface<BluetoothPolicy>(handle);
return DPM_ERROR_NONE;
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.addDeviceToBlacklist(mac);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(mac, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.removeDeviceFromBlacklist(mac);
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.setDeviceRestriction(enable);
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
int ret = bluetooth.isDeviceRestricted();
if (ret < 0) {
return -1;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.addUuidToBlacklist(uuid);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(uuid, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.removeUuidFromBlacklist(uuid);
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.setUuidRestriction(enable);
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
int ret = bluetooth.isUuidRestricted();
if (ret < 0) {
return -1;
dpm_password_policy_h dpm_context_acquire_password_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<PasswordPolicy>();
+ return handle;
}
int dpm_context_release_password_policy(dpm_context_h context, dpm_password_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
- delete &GetPolicyInterface<PasswordPolicy>(handle);
- return 0;
+ return DPM_ERROR_NONE;
}
int dpm_password_set_quality(dpm_password_policy_h handle, dpm_password_quality_e quality)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setPasswordPolicyQuality(quality) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
password_quality = password.getPasswordPolicyQuality();
switch (password_quality) {
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setPasswordPolicyMinimumLength(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
*value = password.getPasswordPolicyMinimumLength();
if (*value >= 0)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setMinPasswordPolicyComplexChars(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
*value = password.getMinPasswordPolicyComplexChars();
if (*value >= 0)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setMaximumFailedPasswordPolicyForWipe(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
*value = password.getMaximumFailedPasswordPolicyForWipe();
if (*value >= 0)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setPasswordPolicyExpires(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
*value = password.getPasswordPolicyExpires();
if (*value >= 0)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setPasswordPolicyHistory(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
*value = password.getPasswordPolicyHistory();
if (*value >= 0)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pattern, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setPasswordPolicyPattern(pattern) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(passwd, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.resetPasswordPolicy(passwd) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.enforcePasswordPolicyChange() == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setMaxInactivityTimeDeviceLock(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
*value = password.getMaxInactivityTimeDeviceLock();
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setPasswordPolicyStatus(status) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.deletePasswordPolicyPattern() == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(*pattern, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.getPasswordPolicyPattern().size() > 0) {
*pattern = ::strdup(password.getPasswordPolicyPattern().c_str());
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setMaximumCharacterOccurrences(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
- *value = password.getMaximumCharacterOccurrences();
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ *value = password.getMaximumCharacterOccurrences();
if (*value >= 0)
ret = DPM_ERROR_NONE;
else
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
if (password.setMaximumNumericSequenceLength(value) == 0)
ret = DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(value, DPM_ERROR_INVALID_PARAMETER);
- PasswordPolicy &password = GetPolicyInterface<PasswordPolicy>(handle);
- *value = password.getMaximumNumericSequenceLength();
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ PasswordPolicy password = client.createPolicyInterface<PasswordPolicy>();
+ *value = password.getMaximumNumericSequenceLength();
if (*value >= 0)
ret = DPM_ERROR_NONE;
else
#include "restriction.h"
#include "restriction.hxx"
+#include "location.hxx"
#include "bluetooth.hxx"
#include "debug.h"
dpm_restriction_policy_h dpm_context_acquire_restriction_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<RestrictionPolicy>();
+ return handle;
}
int dpm_context_release_restriction_policy(dpm_context_h context, dpm_restriction_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
- delete &GetPolicyInterface<RestrictionPolicy>(handle);
return DPM_ERROR_NONE;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restrict = GetPolicyInterface<RestrictionPolicy>(handle);
- return restrict.setCameraState(enable);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ return restriction.setCameraState(enable);
}
int dpm_restriction_get_camera_state(dpm_restriction_policy_h handle, int *state)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getCameraState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
- return restriction.setMicrophoneState(enable);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
+ return restriction.setMicrophoneState(enable);
}
int dpm_restriction_get_microphone_state(dpm_restriction_policy_h handle, int *state)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getMicrophoneState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
- return restriction.setLocationState(enable);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+ return location.setLocationState(enable);
}
int dpm_restriction_get_location_state(dpm_restriction_policy_h handle, int *state)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
- int ret = restriction.getLocationState();
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ LocationPolicy location = client.createPolicyInterface<LocationPolicy>();
+ int ret = location.getLocationState();
if (ret < 0) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setUsbDebuggingState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getUsbDebuggingState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setUsbTetheringState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getUsbTetheringState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setSettingsChangesState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getSettingsChangesState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setExternalStorageState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getExternalStorageState();
if (ret < 0) {
return 0;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setClipboardState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getClipboardState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setWifiState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getWifiState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
return restriction.setWifiHotspotState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ RestrictionPolicy restriction = client.createPolicyInterface<RestrictionPolicy>();
int ret = restriction.getWifiHotspotState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
- return restriction.setBluetoothTetheringState(enable);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ return bluetooth.setBluetoothTetheringState(enable);
}
int dpm_restriction_get_bluetooth_tethering_state(dpm_restriction_policy_h handle, int *state)
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- RestrictionPolicy& restriction = GetPolicyInterface<RestrictionPolicy>(handle);
- int ret = restriction.getBluetoothTetheringState();
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
+ int ret = bluetooth.getBluetoothTetheringState();
if (ret < 0) {
return -1;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.setModeChangeState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
int ret = bluetooth.getModeChangeState();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
return bluetooth.setDesktopConnectivityState(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- BluetoothPolicy& bluetooth = GetPolicyInterface<BluetoothPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ BluetoothPolicy bluetooth = client.createPolicyInterface<BluetoothPolicy>();
int ret = bluetooth.getDesktopConnectivityState();
if (ret < 0) {
return -1;
dpm_security_policy_h dpm_context_acquire_security_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<SecurityPolicy>();
+ return handle;
}
int dpm_context_release_security_policy(dpm_context_h context, dpm_security_policy_h handle)
{
- RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- delete &GetPolicyInterface<SecurityPolicy>(handle);
return DPM_ERROR_NONE;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
return security.lockoutDevice();
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
return security.lockoutScreen();
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
return security.setInternalStorageEncryption(encrypt);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
int ret = security.isInternalStorageEncrypted();
if (ret < 0) {
return -1;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
return security.setExternalStorageEncryption(encrypt);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(state, DPM_ERROR_INVALID_PARAMETER);
- SecurityPolicy& security = GetPolicyInterface<SecurityPolicy>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ SecurityPolicy security = context.createPolicyInterface<SecurityPolicy>();
int ret = security.isExternalStorageEncrypted();
if (ret < 0) {
return -1;
dpm_storage_policy_h dpm_context_acquire_storage_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<StoragePolicy>();
+ return handle;
}
int dpm_context_release_storage_policy(dpm_storage_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- delete &GetPolicyInterface<StoragePolicy>(handle);
return DPM_ERROR_NONE;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- StoragePolicy& storagePolicy = GetPolicyInterface<StoragePolicy>(handle);
- return storagePolicy.wipeData(type);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ StoragePolicy storage = client.createPolicyInterface<StoragePolicy>();
+ return storage.wipeData(type);
}
dpm_wifi_policy_h dpm_context_acquire_wifi_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<WifiPolicy>();
+ return handle;
}
int dpm_context_release_wifi_policy(dpm_context_h context, dpm_wifi_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
- delete &GetPolicyInterface<WifiPolicy>(handle);
return DPM_ERROR_NONE;
}
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
return wifi.setProfileChangeRestriction(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
*enable = wifi.isProfileChangeRestricted();
return DPM_ERROR_NONE;
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
- WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
return wifi.setNetworkAccessRestriction(enable);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(enable, DPM_ERROR_INVALID_PARAMETER);
- WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
*enable = wifi.isNetworkAccessRestricted();
return DPM_ERROR_NONE;
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
- WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
return wifi.addSsidToBlocklist(ssid);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(ssid, DPM_ERROR_INVALID_PARAMETER);
- WifiPolicy& wifi = GetPolicyInterface<WifiPolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ WifiPolicy wifi = client.createPolicyInterface<WifiPolicy>();
return wifi.removeSsidFromBlocklist(ssid);
}
dpm_zone_policy_h dpm_context_acquire_zone_policy(dpm_context_h handle)
{
- RET_ON_FAILURE(handle, NULL);
-
- DevicePolicyContext &client = GetDevicePolicyContext(handle);
- return client.createPolicyInterface<ZonePolicy>();
+ return handle;
}
int dpm_context_release_zone_policy(dpm_context_h context, dpm_zone_policy_h handle)
{
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
-
- delete &GetPolicyInterface<ZonePolicy>(handle);
- return 0;
+ return DPM_ERROR_NONE;
}
int dpm_zone_create(dpm_zone_policy_h handle, const char* name, const char* pkgname)
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(pkgname, DPM_ERROR_INVALID_PARAMETER);
- ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
return zone.createZone(name, pkgname);
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(name, DPM_ERROR_INVALID_PARAMETER);
- ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
return zone.removeZone(name);
}
{
RET_ON_FAILURE(handle, NULL);
- ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
return reinterpret_cast<dpm_zone_iterator_h>(new dpm_zone_iterator(zone.getZoneList()));
}
RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
- ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
+ DevicePolicyContext &client = GetDevicePolicyContext(handle);
+ ZonePolicy zone = client.createPolicyInterface<ZonePolicy>();
std::vector<std::string> list = zone.getZoneList();
for (std::vector<std::string>::iterator it = list.begin();
it != list.end(); it++) {
--- /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 "location.hxx"
+#include "audit/logger.h"
+
+namespace DevicePolicyManager {
+
+LocationPolicy::LocationPolicy(PolicyControlContext& ctxt)
+ : context(ctxt)
+{
+}
+
+LocationPolicy::~LocationPolicy()
+{
+}
+
+int LocationPolicy::setLocationState(int enable)
+{
+ try {
+ return context->methodCall<int>("LocationPolicy::setLocationState", enable);
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+int LocationPolicy::getLocationState()
+{
+ try {
+ return context->methodCall<int>("LocationPolicy::getLocationState");
+ } catch (runtime::Exception& e) {
+ return -1;
+ }
+}
+
+} //namespace DevicePolicyManager
int unsubscribeSignal(int subscriberId);
template<typename Policy, typename... Args>
- Policy* createPolicyInterface(Args&&... args) noexcept
+ Policy createPolicyInterface(Args&&... args) noexcept
{
- return new Policy(getPolicyControlContext(), std::forward<Args>(args)...);
+ return Policy(getPolicyControlContext(), std::forward<Args>(args)...);
}
private:
PolicyControlContext client;
};
-template<typename Policy>
-Policy& GetPolicyInterface(void* handle)
-{
- return *reinterpret_cast<Policy*>(handle);
-}
-
DevicePolicyContext& GetDevicePolicyContext(void* handle);
#endif //__POLICY_CLIENT_H__
}
}
-int RestrictionPolicy::setLocationState(int enable)
-{
- try {
- return context->methodCall<int>("RestrictionPolicy::setLocationState", enable);
- } catch (runtime::Exception& e) {
- return -1;
- }
-}
-
-int RestrictionPolicy::getLocationState()
-{
- try {
- return context->methodCall<int>("RestrictionPolicy::getLocationState");
- } catch (runtime::Exception& e) {
- return -1;
- }
-}
-
int RestrictionPolicy::setWifiState(bool enable)
{
try {
}
}
-int RestrictionPolicy::setBluetoothTetheringState(bool enable)
-{
- try {
- return context->methodCall<int>("RestrictionPolicy::setBluetoothTetheringState", enable);
- } catch (runtime::Exception& e) {
- return -1;
- }
-}
-
-bool RestrictionPolicy::getBluetoothTetheringState()
-{
- try {
- return context->methodCall<bool>("RestrictionPolicy::getBluetoothTetheringState");
- } catch (runtime::Exception &e) {
- return -1;
- }
-}
-
} //namespace DevicePolicyManager
int setUuidRestriction(const bool enable);
bool isUuidRestricted();
+ int setBluetoothTetheringState(bool enable);
+ bool getBluetoothTetheringState();
+
private:
PolicyControlContext& context;
};
--- /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 "data-type.h"
+#include "policy-context.hxx"
+
+namespace DevicePolicyManager {
+
+class LocationPolicy {
+public:
+ LocationPolicy(PolicyControlContext& ctxt);
+ ~LocationPolicy();
+
+ int setLocationState(int enable);
+ int getLocationState();
+
+private:
+ PolicyControlContext& context;
+};
+
+} // namespace DevicePolicyManager
+
+#endif /* __LOCATION_POLICY__ */
int setExternalStorageState(int enable);
int getExternalStorageState();
- int setLocationState(int enable);
- int getLocationState();
-
int setWifiState(bool enable);
bool getWifiState();
int setWifiHotspotState(bool enable);
bool getWifiHotspotState();
- int setBluetoothTetheringState(bool enable);
- bool getBluetoothTetheringState();
-
private:
PolicyControlContext& context;
};
} // namespace
-#define CONSTRUCTOR __attribute__ ((constructor))
-
namespace DevicePolicyManager {
-extern RestrictionPolicy restrictionPolicy;
-
-static void CONSTRUCTOR ContributeRestrictionPolicy()
-{
- PolicyControlContext& context = Server::instance();
-
- context.registerParametricMethod(&restrictionPolicy, (int)(RestrictionPolicy::setBluetoothTetheringState)(bool));
- context.registerNonparametricMethod(&restrictionPolicy, (bool)(RestrictionPolicy::getBluetoothTetheringState));
-
- context.createNotification("bluetooth-tethering");
-}
-
-int RestrictionPolicy::setBluetoothTetheringState(bool enable)
-{
- SetPolicyAllowed(context, "bluetooth-tethering", enable);
- return 0;
-}
-
-bool RestrictionPolicy::getBluetoothTetheringState()
-{
- return IsPolicyAllowed(context, "bluetooth-tethering");
-}
-
-
BluetoothPolicy::BluetoothPolicy(PolicyControlContext& ctxt) :
context(ctxt)
{
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::removeUuidFromBlacklist)(std::string));
ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setUuidRestriction)(bool));
ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::isUuidRestricted));
+ ctxt.registerParametricMethod(this, (int)(BluetoothPolicy::setBluetoothTetheringState)(bool));
+ ctxt.registerNonparametricMethod(this, (bool)(BluetoothPolicy::getBluetoothTetheringState));
+
ctxt.createNotification("bluetooth");
+ ctxt.createNotification("bluetooth-tethering");
ctxt.createNotification("bluetooth-desktop-connectivity");
ctxt.createNotification("bluetooth-uuid-restriction");
ctxt.createNotification("bluetooth-device-restriction");
bt_deinitialize();
}
+int BluetoothPolicy::setBluetoothTetheringState(bool enable)
+{
+ SetPolicyAllowed(context, "bluetooth-tethering", enable);
+ return 0;
+}
+
+bool BluetoothPolicy::getBluetoothTetheringState()
+{
+ return IsPolicyAllowed(context, "bluetooth-tethering");
+}
+
int BluetoothPolicy::setModeChangeState(const bool enable)
{
int ret = BLUETOOTH_DPM_RESULT_SUCCESS;
#include <location_batch.h>
-#include "restriction.hxx"
+#include "location.hxx"
+
#include "policy-helper.h"
#include "audit/logger.h"
-#define CONSTRUCTOR __attribute__ ((constructor))
-
namespace DevicePolicyManager {
-extern RestrictionPolicy restrictionPolicy;
-
-static void CONSTRUCTOR ContributeRestrictionPolicy()
+LocationPolicy::LocationPolicy(PolicyControlContext& ctxt) :
+ context(ctxt)
{
- PolicyControlContext& context = Server::instance();
-
- context.registerParametricMethod(&restrictionPolicy, (int)(RestrictionPolicy::setLocationState)(int));
- context.registerNonparametricMethod(&restrictionPolicy, (int)(RestrictionPolicy::getLocationState));
+ context.registerParametricMethod(this, (int)(LocationPolicy::setLocationState)(int));
+ context.registerNonparametricMethod(this, (int)(LocationPolicy::getLocationState));
context.createNotification("location");
}
-int RestrictionPolicy::setLocationState(int enable)
+LocationPolicy::~LocationPolicy()
+{
+}
+
+int LocationPolicy::setLocationState(int enable)
{
if (location_manager_enable_restriction(!enable) != LOCATIONS_ERROR_NONE)
- return -1;
+ return -1;
SetPolicyAllowed(context, "location", enable);
return 0;
}
-int RestrictionPolicy::getLocationState()
+int LocationPolicy::getLocationState()
{
return IsPolicyAllowed(context, "location");
}
+LocationPolicy locationPolicy(Server::instance());
} // namespace DevicePolicyManager
<< "Options :" << std::endl
<< " -a, --attach=zone execute command in the zone" << std::endl
<< " -p, --pkginfo=zone show all packages in the zone" << std::endl
- << " -n, --appinfo=zone show all applications in the zone" << std::endl
- << " -m, --monitor monitor all zone related events" << std::endl
+ << " -q, --appinfo=zone show all applications in the zone" << std::endl
+ << " -m, --zone-monitor monitor all zone events" << std::endl
+ << " -n, --pkg-monitor monitor all package events in the zone" << std::endl
<< " -l, --list show all zone instances" << std::endl
<< " -h, --help show this" << std::endl
<< std::endl;
zone_package_proxy_h pkgProxy;
zone_manager_create(&zoneMgr);
- zone_package_proxy_create(zoneMgr, &pkgProxy);
- zone_package_proxy_foreach_package_info(pkgProxy, name.c_str(), packgeListCallback, &num);
+ zone_package_proxy_create(zoneMgr, name.c_str(), &pkgProxy);
+ zone_package_proxy_foreach_package_info(pkgProxy, packgeListCallback, &num);
std::cout << num << " packages are found" << std::endl;
zone_package_proxy_destroy(pkgProxy);
zone_manager_destroy(zoneMgr);
zone_app_proxy_h appMgr;
zone_manager_create(&zoneMgr);
- zone_app_proxy_create(zoneMgr, &appMgr);
- zone_app_proxy_foreach_app_info(appMgr, name.c_str(), applicationListCallback, &num);
+ zone_app_proxy_create(zoneMgr, name.c_str(), &appMgr);
+ zone_app_proxy_foreach_app_info(appMgr, applicationListCallback, &num);
std::cout << num << " applications are found" << std::endl;
zone_app_proxy_destroy(appMgr);
zone_manager_destroy(zoneMgr);
return 0;
}
+GMainLoop *gmainloop = NULL;
+
+void monitorSigHandler(int sig)
+{
+ g_main_loop_quit(gmainloop);
+}
+
void zoneCallback(const char* name, const char* object, void *user_data)
{
std::cout << "--- Zone event ---" << std::endl;
std::cout << std::endl;
}
-void packageEventCallback(const char *zone, const char *type,
+int monitorEvent()
+{
+ int zoneCallbackId[2];
+ zone_manager_h zoneMgr;
+ zone_manager_create(&zoneMgr);
+
+ zone_manager_add_event_cb(zoneMgr, "created", zoneCallback,
+ (void*)"created", &zoneCallbackId[0]);
+ zone_manager_add_event_cb(zoneMgr, "removed", zoneCallback,
+ (void*)"removed", &zoneCallbackId[1]);
+
+ std::cout << "=== Monitoring start ===" << std::endl << std::endl;
+
+ signal(SIGINT, monitorSigHandler);
+
+ gmainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(gmainloop);
+ g_main_loop_unref(gmainloop);
+
+ zone_manager_remove_event_cb(zoneMgr, zoneCallbackId[0]);
+ zone_manager_remove_event_cb(zoneMgr, zoneCallbackId[1]);
+
+ std::cout << "=== Monitoring end ===" << std::endl;
+
+ zone_manager_destroy(zoneMgr);
+
+ return 0;
+}
+
+void packageEventCallback(const char *type,
const char *package,
package_manager_event_type_e event_type,
package_manager_event_state_e event_state,
void *user_data)
{
std::cout << "--- Package event ---" << std::endl;
- std::cout << "Zone : " << zone <<std::endl;
std::cout << "Pacakge : " << package << std::endl;
std::cout << "Pacakge type : " << type << std::endl;
std::cout << std::endl;
}
-GMainLoop *gmainloop = NULL;
-
-void monitorSigHandler(int sig)
+int monitorPkgEvent(const std::string& name)
{
- g_main_loop_quit(gmainloop);
-}
-
-int monitorEvent()
-{
- int zoneCallbackId;
-
zone_manager_h zoneMgr;
zone_package_proxy_h pkgProxy;
zone_manager_create(&zoneMgr);
- zone_package_proxy_create(zoneMgr, &pkgProxy);
-
- zone_manager_add_event_cb(zoneMgr, "created", zoneCallback,
- (void*)"created", &zoneCallbackId);
- zone_manager_add_event_cb(zoneMgr, "removed", zoneCallback,
- (void*)"removed", &zoneCallbackId);
+ zone_package_proxy_create(zoneMgr, name.c_str(), &pkgProxy);
zone_package_proxy_set_event_cb(pkgProxy, packageEventCallback, NULL);
g_main_loop_unref(gmainloop);
zone_package_proxy_unset_event_cb(pkgProxy);
- zone_manager_remove_event_cb(zoneMgr, zoneCallbackId);
std::cout << "=== Monitoring end ===" << std::endl;
{"attach", required_argument, 0, 'a'},
{"list", no_argument, 0, 'l'},
{"pkginfo", required_argument, 0, 'p'},
- {"appinfo", required_argument, 0, 'n'},
- {"monitor", no_argument, 0, 'm'},
+ {"appinfo", required_argument, 0, 'q'},
+ {"zone-monitor", no_argument, 0, 'm'},
+ {"pkg-monitor", no_argument, 0, 'n'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
return EXIT_SUCCESS;
}
- while ((opt = getopt_long(argc, argv, "a:p:n:mlh", options, &index)) != -1) {
+ while ((opt = getopt_long(argc, argv, "a:p:q:mn:lh", options, &index)) != -1) {
switch (opt) {
case 'a':
ret = attachToZone(optarg, optind >= argc ? NULL : argv + optind);
case 'p':
ret = showPkgInfo(optarg);
break;
- case 'n':
+ case 'q':
ret = showAppInfo(optarg);
break;
case 'm':
ret = monitorEvent();
break;
+ case 'n':
+ ret = monitorPkgEvent(optarg);
+ break;
case 'l':
ret = showZoneInstances();
break;
using namespace DevicePolicyManager;
-inline ZoneAppProxy* getManager(zone_app_proxy_h handle)
+struct zone_app_proxy_s {
+ ZoneAppProxy proxy;
+ std::string zoneName;
+};
+
+static inline zone_app_proxy_s* getInstance(zone_app_proxy_h handle)
{
- return reinterpret_cast<ZoneAppProxy*>(handle);
+ return reinterpret_cast<zone_app_proxy_s *>(handle);
}
static app_info_h make_app_info_handle(const ZoneAppProxy::AppInfo& info)
return reinterpret_cast<app_info_h>(appinfo);
}
-int zone_app_proxy_create(zone_manager_h manager, zone_app_proxy_h *handle)
+int zone_app_proxy_create(zone_manager_h manager, const char* name, zone_app_proxy_h *handle)
{
RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- auto& client = GetDevicePolicyContext(manager);
- *handle = reinterpret_cast<zone_app_proxy_h*>(client.createPolicyInterface<ZoneAppProxy>());
+ zone_app_proxy_s* instance = new zone_app_proxy_s {
+ GetDevicePolicyContext(manager).createPolicyInterface<ZoneAppProxy>(),
+ name
+ };
+ *handle = reinterpret_cast<zone_app_proxy_h>(instance);
return ZONE_ERROR_NONE;
}
return ZONE_ERROR_NONE;
}
-int zone_app_proxy_get_app_info(zone_app_proxy_h handle, const char* name, const char* app_id, app_info_h* app_info)
+int zone_app_proxy_get_app_info(zone_app_proxy_h handle, const char* app_id, app_info_h* app_info)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(app_info, ZONE_ERROR_INVALID_PARAMETER);
- const auto info = getManager(handle)->getAppInfo(name, app_id);
- app_info_h ret = make_app_info_handle(info);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+ const auto info = proxy.getAppInfo(name, app_id);
+ app_info_h ret = make_app_info_handle(info);
if (ret == NULL) {
return ZONE_ERROR_INVALID_PARAMETER;
}
return ZONE_ERROR_NONE;
}
-int zone_app_proxy_foreach_app_info(zone_app_proxy_h handle, const char* name, app_manager_app_info_cb callback, void *user_data)
+int zone_app_proxy_foreach_app_info(zone_app_proxy_h handle, app_manager_app_info_cb callback, void *user_data)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
- auto manager = getManager(handle);
- for (const auto& appid : manager->getAppList(name)) {
- app_info_h info_h = make_app_info_handle(manager->getAppInfo(name, appid));
- int ret = callback(info_h, user_data);
- app_info_destroy(info_h);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ for (const auto& appid : proxy.getAppList(name)) {
+ app_info_h info = make_app_info_handle(proxy.getAppInfo(name, appid));
+ int ret = callback(info, user_data);
+ app_info_destroy(info);
if (!ret) {
continue;
}
return ZONE_ERROR_NONE;
}
-int zone_app_proxy_launch(zone_app_proxy_h handle, const char* name, const char* app_id)
+int zone_app_proxy_launch(zone_app_proxy_h handle, const char* app_id)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
- return getManager(handle)->launch(name, app_id);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ return proxy.launch(name, app_id);
}
-int zone_app_proxy_is_running(zone_app_proxy_h handle, const char* name, const char* app_id, int *result)
+int zone_app_proxy_is_running(zone_app_proxy_h handle, const char* app_id, int *result)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(app_id, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(result, ZONE_ERROR_INVALID_PARAMETER);
- *result = getManager(handle)->isRunning(name, app_id);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ *result = proxy.isRunning(name, app_id);
return ZONE_ERROR_NONE;
}
* the zone application manager APIs.
* @since_tizen 3.0
* @param[in] manager The zone manager handle
+ * @param[in] name The zone name
* @param[out] handle The zone app proxy handle
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @retval #ZONE_ERROR_NONE Successful
* @see zone_app_proxy_create()
* @see get_last_result()
*/
-ZONE_API int zone_app_proxy_create(zone_manager_h manager, zone_app_proxy_h* handle);
+ZONE_API int zone_app_proxy_create(zone_manager_h manager, const char* name, zone_app_proxy_h* handle);
/**
* @brief Releases the zone application manager handle
* information of the application in the zone
* @since_tizen 3.0
* @param[in] handle The zone application manager handle
- * @param[in] name The zone name
* @param[in] appid The application ID
* @return Zone application handle on success, otherwise NULL
* @remark The specific error code can be obtained by using the
* @see application_manager_get_application_info()
* @see get_last_result()
*/
-ZONE_API int zone_app_proxy_get_app_info(zone_app_proxy_h handle, const char* name, const char* appid, app_info_h* app_info);
+ZONE_API int zone_app_proxy_get_app_info(zone_app_proxy_h handle, const char* appid, app_info_h* app_info);
/**
* @brief Retrieves all the handles of the application in the zone.
* ID with traversing the installed application list in the zone.
* @since_tizen 3.0
* @param[in] handle The zone application manager handle
- * @param[in] name The zone name
* @param[in] callback The iteration callback function
* @param[in] user_data The user data passed to the callback function
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @see zone_app_proxy_create()
* @see application_manager_foreach_app_info()
*/
-ZONE_API int zone_app_proxy_foreach_app_info(zone_app_proxy_h handle, const char* name, app_manager_app_info_cb callback, void *user_data);
+ZONE_API int zone_app_proxy_foreach_app_info(zone_app_proxy_h handle, app_manager_app_info_cb callback, void *user_data);
/**
* @brief Launch the application located at the given path into the zone.
* zone.
* @since_tizen 3.0
* @param[in] handle The zone application manager handle
- * @param[in] name The zone name
* @param[in] appid The application ID to be launched
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @retval #ZONE_ERROR_NONE Successful
* @see zone_is_running_app()
* @see app_control_send_launch_request()
*/
-ZONE_API int zone_app_proxy_launch(zone_app_proxy_h handle, const char* name, const char* appid);
+ZONE_API int zone_app_proxy_launch(zone_app_proxy_h handle, const char* appid);
/**
* @brief Resume the application located at the given path into the zone.
* zone.
* @since_tizen 3.0
* @param[in] handle The zone application manager handle
- * @param[in] name The zone name
* @param[in] appid The application ID to be resumed
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @retval #ZONE_ERROR_NONE Successful
* @see zone_terminate_app()
* @see zone_is_running_app()
*/
-ZONE_API int zone_app_proxy_resume(zone_app_proxy_h handle, const char* name, const char* appid);
+ZONE_API int zone_app_proxy_resume(zone_app_proxy_h handle, const char* appid);
/**
* @brief Terminate the application located at the given path into the zone.
* the zone.
* @since_tizen 3.0
* @param[in] handle The zone application manager handle
- * @param[in] name The zone name
* @param[in] appid The application ID to be terminated
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @retval #ZONE_ERROR_NONE Successful
* @see zone_is_running_app()
* @see app_control_send_terminate_request()
*/
-ZONE_API int zone_app_proxy_terminate(zone_app_proxy_h handle, const char* name, const char* appid);
+ZONE_API int zone_app_proxy_terminate(zone_app_proxy_h handle, const char* appid);
/**
* @brief Checks whether the application in the zone is running.
* is running.
* @since_tizen 3.0
* @param[in] handle The zone application manager handle
- * @param[in] name The zone name
* @param[in] appid The application ID
* @param[out] result true if the application is running,
* otherwise false if the application is not running
* @see zone_launch_app()
* @see zone_terminate_app()
*/
-ZONE_API int zone_app_proxy_is_running(zone_app_proxy_h handle, const char* name, const char* appid, int* result);
+ZONE_API int zone_app_proxy_is_running(zone_app_proxy_h handle, const char* appid, int* result);
/**
* @}
using namespace DevicePolicyManager;
-typedef struct zone_package_proxy_s {
- std::unique_ptr<ZonePackageProxy> pManager;
+struct zone_package_proxy_s {
+ ZonePackageProxy proxy;
+ std::string zoneName;
pkgmgr_client* pNativeHandle;
- zone_package_proxy_event_cb pCallback;
+ package_manager_event_cb pCallback;
void *pCallbackUserData;
-} zone_package_proxy_s;
+};
static inline zone_package_proxy_s* getInstance(zone_package_proxy_h handle)
{
return reinterpret_cast<zone_package_proxy_s *>(handle);
}
-static inline ZonePackageProxy* getProxy(zone_package_proxy_h handle)
-{
- return getInstance(handle)->pManager.get();
-}
-
static int packageEventHandler(uid_t target_uid, int req_id,
const char *pkg_type, const char *pkg_name,
const char *key, const char *val,
{
static auto event_type = (package_manager_event_type_e)-1;
auto event_state = PACKAGE_MANAGER_EVENT_STATE_FAILED;
- std::string keystr = key, zone_name;
auto instance = getInstance(data);
+ std::string keystr = key;
int progress = 0;
if (target_uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER))
try {
runtime::User pkgOwner(target_uid);
- zone_name = pkgOwner.getName();
+ if (pkgOwner.getName() == instance->zoneName) {
+ return PACKAGE_MANAGER_ERROR_NONE;
+ }
} catch (runtime::Exception &e) {
return PACKAGE_MANAGER_ERROR_NONE;
}
progress = 100;
}
- instance->pCallback(zone_name.c_str(), pkg_type, pkg_name,
+ instance->pCallback(pkg_type, pkg_name,
event_type, event_state, progress,
PACKAGE_MANAGER_ERROR_NONE,
instance->pCallbackUserData);
return reinterpret_cast<package_info_h>(packageinfo);
}
-int zone_package_proxy_create(zone_manager_h manager, zone_package_proxy_h *handle)
+int zone_package_proxy_create(zone_manager_h manager, const char* name, zone_package_proxy_h *handle)
{
RET_ON_FAILURE(manager, ZONE_ERROR_INVALID_PARAMETER);
+ RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- zone_package_proxy_s* instance = new zone_package_proxy_s;
-
- instance->pManager.reset(GetDevicePolicyContext(manager).
- createPolicyInterface<ZonePackageProxy>());
-
- instance->pNativeHandle = ::pkgmgr_client_new(PC_LISTENING);
+ zone_package_proxy_s* instance = new zone_package_proxy_s {
+ GetDevicePolicyContext(manager).
+ createPolicyInterface<ZonePackageProxy>(),
+ name, ::pkgmgr_client_new(PC_LISTENING), NULL, NULL
+ };
*handle = reinterpret_cast<zone_package_proxy_h>(instance);
return ZONE_ERROR_NONE;
return ZONE_ERROR_NONE;
}
-int zone_package_proxy_get_package_info(zone_package_proxy_h handle, const char* name, const char* package_id, package_info_h* package_info)
+int zone_package_proxy_get_package_info(zone_package_proxy_h handle, const char* package_id, package_info_h* package_info)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(package_id, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(package_info, ZONE_ERROR_INVALID_PARAMETER);
- const auto& info = getProxy(handle)->getPackageInfo(name, package_id);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ const auto& info = proxy.getPackageInfo(name, package_id);
package_info_h ret = make_package_info_handle(info);
if (ret == NULL) {
return ZONE_ERROR_NONE;
}
-int zone_package_proxy_foreach_package_info(zone_package_proxy_h handle, const char* name, package_manager_package_info_cb callback, void *user_data)
+int zone_package_proxy_foreach_package_info(zone_package_proxy_h handle, package_manager_package_info_cb callback, void *user_data)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
- auto manager = getProxy(handle);
- for (const auto& pkgid : manager->getPackageList(name)) {
- package_info_h info_h = make_package_info_handle(manager->getPackageInfo(name, pkgid));
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ for (const auto& pkgid : proxy.getPackageList(name)) {
+ package_info_h info_h = make_package_info_handle(proxy.getPackageInfo(name, pkgid));
int ret = callback(info_h, user_data);
package_info_destroy(info_h);
if (!ret) {
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+ auto instance = getInstance(handle);
+
int ret;
- ret = pkgmgrinfo_client_set_status_type(getInstance(handle)->pNativeHandle, status_type);
+ ret = pkgmgrinfo_client_set_status_type(instance->pNativeHandle, status_type);
if (ret != PACKAGE_MANAGER_ERROR_NONE)
return ZONE_ERROR_INVALID_PARAMETER;
return ZONE_ERROR_NONE;
}
-int zone_package_proxy_set_event_cb(zone_package_proxy_h handle, zone_package_proxy_event_cb callback, void *user_data)
+int zone_package_proxy_set_event_cb(zone_package_proxy_h handle, package_manager_event_cb callback, void *user_data)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
int ret;
ret = pkgmgr_client_listen_status(instance->pNativeHandle, packageEventHandler, handle);
- if (ret != PACKAGE_MANAGER_ERROR_NONE)
+ if (ret < 0)
return ZONE_ERROR_INVALID_PARAMETER;
return ZONE_ERROR_NONE;
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
+ auto instance = getInstance(handle);
+
int ret;
- ret = pkgmgr_client_remove_listen_status(getInstance(handle)->pNativeHandle);
+ ret = pkgmgr_client_remove_listen_status(instance->pNativeHandle);
- if (ret != PACKAGE_MANAGER_ERROR_NONE)
+ if (ret < 0)
return ZONE_ERROR_INVALID_PARAMETER;
return ZONE_ERROR_NONE;
}
-int zone_package_proxy_install(zone_package_proxy_h handle, const char* name, const char* package_path)
+int zone_package_proxy_install(zone_package_proxy_h handle, const char* package_path)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(package_path, ZONE_ERROR_INVALID_PARAMETER);
- return getProxy(handle)->install(name, package_path);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ return proxy.install(name, package_path);
}
-int zone_package_proxy_uninstall(zone_package_proxy_h handle, const char* name, const char* package_id)
+int zone_package_proxy_uninstall(zone_package_proxy_h handle, const char* package_id)
{
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(package_id, ZONE_ERROR_INVALID_PARAMETER);
- return getProxy(handle)->uninstall(name, package_id);
+ auto instance = getInstance(handle);
+ auto& proxy = instance->proxy;
+ const std::string& name = instance->zoneName;
+
+ return proxy.uninstall(name, package_id);
}
* the zone package_manager APIs.
* @since_tizen 3.0
* @param[in] manager The zone manager handle
+ * @param[in] name The zone name
* @param[out] handle The zone package proxy handle
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @retval #ZONE_ERROR_NONE Successful
* @see zone_package_proxy_destroy()
* @see get_last_result()
*/
-ZONE_API int zone_package_proxy_create(zone_manager_h manager, zone_package_proxy_h *handle);
+ZONE_API int zone_package_proxy_create(zone_manager_h manager, const char* name, zone_package_proxy_h *handle);
/**
* @brief Releases the zone package proxy handle.
* information of the pacakge in the zone.
* @since_tizen 3.0
* @param[in] handle The zone package proxy handle
- * @param[in] name The zone name
* @param[in] pakcage_id The package ID
* @return Zone package information handle on success, otherwise NULL
* @remark The specific error code can be obtained by using the
* @see package_manager_destroy()
* @see get_last_result()
*/
-ZONE_API int zone_package_proxy_get_package_info(zone_package_proxy_h handle, const char* name, const char* pakcage_id, package_info_h* package_info);
+ZONE_API int zone_package_proxy_get_package_info(zone_package_proxy_h handle, const char* pakcage_id, package_info_h* package_info);
/**
* @brief Retrieves all the IDs of the installed package in the zone.
* package list in the zone.
* @since_tizen 3.0
* @param[in] handle The zone package proxy handle
- * @param[in] name The zone name
* @param[in] callback The iteration callback function
* @param[in] user_data The user data passed to the callback function
* @return #ZONE_ERROR_NONE on success, otherwise a negative value
* @see zone_package_proxy_destroy()
* @see package_manager_foreach_package_info()
*/
-ZONE_API int zone_package_proxy_foreach_package_info(zone_package_proxy_h handle, const char* name, package_manager_package_info_cb callback, void *user_data);
+ZONE_API int zone_package_proxy_foreach_package_info(zone_package_proxy_h handle, package_manager_package_info_cb callback, void *user_data);
/**
* @brief Installs the package located at the given path into the zone.
* @see zone_package_proxy_uninstall()
* @see package_manager_request_install()
*/
-ZONE_API int zone_package_proxy_install(zone_package_proxy_h handle, const char* name, const char* package_path);
+ZONE_API int zone_package_proxy_install(zone_package_proxy_h handle, const char* package_path);
/**
* @brief Uinstalls the package with the given ID from the zone.
* @see zone_package_proxy_install()
* @see package_manager_request_uninstall()
*/
-ZONE_API int zone_package_proxy_uninstall(zone_package_proxy_h handle, const char* name, const char* pakcage_id);
+ZONE_API int zone_package_proxy_uninstall(zone_package_proxy_h handle, const char* pakcage_id);
/**
* @brief Sets the event status that presents the package has been
* @see zone_package_proxy_uninstall()
* @see zone_package_proxy_set_event_cb()
* @see zone_package_proxy_unset_event_cb()
+ * @see package_manager_set_event_status()
*/
ZONE_API int zone_package_proxy_set_event_status(zone_package_proxy_h handle, int status_type);
/**
- * @brief Called when the package in the zone is installed, uninstalled or
- * updated, and the progress of the request to the package manager
- * changes.
- * @since_tizen 3.0
- * @param[in] zone The name of zone that the package is in
- * @param[in] type The type of the package to be installed, uninstalled or
- * updated
- * @param[in] package The name of the package to be installed, uninstalled or
- * updated
- * @param[in] event_type The type of the request to the package manager
- * @param[in] event_state The current state of the request to the package
- manager
- * @param[in] progress The progress for the request that is being processed by
- * the package manager. The range of progress is from @c 0 to
- * @c 100.
- * @param[in] error The error code when the package manager failed to process
- * the request
- * @param[in] user_data The user data passed from zone_package_proxy_set_event_cb()
- *
- * @see zone_package_proxy_set_event_cb()
- * @see zone_package_proxy_unset_event_cb()
- */
-typedef void (*zone_package_proxy_event_cb) (
- const char *zone,
- const char *type,
- const char *package,
- package_manager_event_type_e event_type,
- package_manager_event_state_e event_state,
- int progress,
- package_manager_error_e error,
- void *user_data);
-/**
* @brief Registers a callback function for package event.
* @details This API sets a callback function to be invoked when the package
* has been installed, uninstalled or updated.
* @see zone_package_proxy_set_event_status()
* @see zone_package_proxy_unset_event_cb()
* @see package_manager_event_cb()
+ * @see package_manager_set_event_cb()
*/
-ZONE_API int zone_package_proxy_set_event_cb(zone_package_proxy_h handle, zone_package_proxy_event_cb callback, void *user_data);
+ZONE_API int zone_package_proxy_set_event_cb(zone_package_proxy_h handle, package_manager_event_cb callback, void *user_data);
/**
* @brief Unregisters the callback function.
* @see zone_package_proxy_uninstall()
* @see zone_package_proxy_set_event_status()
* @see zone_package_proxy_set_event_cb()
- * @see package_manager_event_cb()
+ * @see package_manager_unset_event_cb()
*/
ZONE_API int zone_package_proxy_unset_event_cb(zone_package_proxy_h handle);
RET_ON_FAILURE(event, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback, ZONE_ERROR_INVALID_PARAMETER);
- auto& context = GetDevicePolicyContext(handle);
- int ret = context.subscribeSignal(std::string("ZonePolicy::") +event,
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
+ int ret = context.subscribeSignal(std::string("ZonePolicy::") + event,
callback, user_data);
if (ret < 0)
return ZONE_ERROR_INVALID_PARAMETER;
RET_ON_FAILURE(handle, ZONE_ERROR_INVALID_PARAMETER);
RET_ON_FAILURE(callback_id >= 0, ZONE_ERROR_INVALID_PARAMETER);
- auto& context = *reinterpret_cast<DevicePolicyContext*>(handle);
+ DevicePolicyContext &context = GetDevicePolicyContext(handle);
int ret = context.unsubscribeSignal(callback_id);
if (ret)
return ZONE_ERROR_INVALID_PARAMETER;