From 3c5807df2bd8766e004af9b8062f089712b41994 Mon Sep 17 00:00:00 2001 From: y01k <44759543+y01k@users.noreply.github.com> Date: Wed, 30 Jan 2019 13:29:06 +0900 Subject: [PATCH] [DevicePolicyManager] Add new DevicePolicyManager API (#632) * Initial Commit - Interop - DevicePolicyManager class Signed-off-by: yeji kim * Add policies - Email Policy - Password Policy - Telephony Policy - Wifi Policy Signed-off-by: yeji kim * Fix library name Signed-off-by: yeji kim * Modify solution file Signed-off-by: yeji kim * Add policy change callback api Signed-off-by: yeji kim * Implement policy change apis Signed-off-by: yeji kim * Fix field names Signed-off-by: yeji kim * Add documentation comments Signed-off-by: yeji kim * Add Logs Signed-off-by: yeji kim * Apply coding style Signed-off-by: yeji kim * PasswordPolicy: Modify return type of GetQuality Signed-off-by: yeji kim * Add a period to the comments. Signed-off-by: yeji kim * Add Namespace documentation Signed-off-by: yeji kim * Modify retrun statements Signed-off-by: yeji kim * Modify exception handling - Change enum name : DpmError -> ErrorCode - Change method name : GetException -> CreateException - remove OutOfMemoryException - remove throw exception in Dispose() - Modify exception handling in DevicePolicyManager() Signed-off-by: yeji kim * Modify Policy classes - Add an abstraction class + DevicePolicy.cs - Add inheritance to each policy class - Modify GetPolicy function in DevicePolicyManager : class -> DevicePolicy Signed-off-by: yeji kim * Add Dispose Pattern to Policy classes Signed-off-by: yeji kim * Fix an invalid value name Signed-off-by: yeji kim * Modify methods into properties. - Add PolicyState class - Modify method -> property : EmailPolicy, PasswordPolicy, WifiPolicy Signed-off-by: yeji kim * TelephonyPolicy: Modify function name and return type Signed-off-by: yeji kim * Add space. Signed-off-by: yeji kim * WifiPolicy : Add IDisposable Signed-off-by: yeji kim * Remove unnecessary default constructor Signed-off-by: yeji kim * Events : Fix passing sender "null" to "this" pass null as the sender when raising nonstatic event. Signed-off-by: yeji kim * DevicePolicyManager : Modify GetPolicy method Remove checking null and Add try-catch statement. Signed-off-by: yeji kim * PasswordQuality : Apply capitalization conventions Signed-off-by: yeji kim * PolicyState : Apply capitalization conventions Signed-off-by: yeji kim * PolicyChangedEventArgs: Change "State" type string -> PolicyState Signed-off-by: yeji kim * PasswordPolicy: Replace default value of properties Signed-off-by: yeji kim * DevicePolicy: Add protected keyword Signed-off-by: yeji kim * Policy Classes: Add new properties. Add missing properties. Signed-off-by: yeji kim * UsbPolicy: Fix property name Signed-off-by: yeji kim * Remove PolicyState type Replace PolicyState type to bool type. Signed-off-by: yeji kim * Policy classes: Add policy name value. Signed-off-by: yeji kim * MediaPolicy: Fix typos Signed-off-by: yeji kim * PasswordPolicy: Change name of a property ExpiresDay -> DaysToExpiration Signed-off-by: yeji kim * Policy Class: Add remarks Signed-off-by: yeji kim * Policy Classes: Change const to static Signed-off-by: yeji kim * Policy Names: Add the readonly Signed-off-by: yeji kim --- .../Interop/Interop.DevicePolicyManager.cs | 130 ++++++++++ .../Interop/Interop.Libraries.cs | 23 ++ .../Tizen.Security.DevicePolicyManager.csproj | 10 + .../Tizen.Security.DevicePolicyManager.sln | 65 +++++ .../BluetoothPolicy.cs | 273 ++++++++++++++++++++ .../BrowserPolicy.cs | 171 +++++++++++++ .../DevicePolicy.cs | 32 +++ .../DevicePolicyManager.cs | 148 +++++++++++ .../EmailPolicy.cs | 171 +++++++++++++ .../LocationPolicy.cs | 171 +++++++++++++ .../MediaPolicy.cs | 273 ++++++++++++++++++++ .../PasswordPolicy.cs | 191 ++++++++++++++ .../PasswordQuality.cs | 56 +++++ .../PolicyChangedEventArgs.cs | 44 ++++ .../StoragePolicy.cs | 171 +++++++++++++ .../TelephonyPolicy.cs | 170 +++++++++++++ .../UsbPolicy.cs | 171 +++++++++++++ .../WifiPolicy.cs | 274 +++++++++++++++++++++ .../doc/api/Tizen.Security.DevicePolicyManager.md | 24 ++ 19 files changed, 2568 insertions(+) create mode 100644 src/Tizen.Security.DevicePolicyManager/Interop/Interop.DevicePolicyManager.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Interop/Interop.Libraries.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.csproj create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.sln create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BluetoothPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BrowserPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicyManager.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/EmailPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/LocationPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/MediaPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordQuality.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PolicyChangedEventArgs.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/StoragePolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/TelephonyPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/UsbPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/WifiPolicy.cs create mode 100644 src/Tizen.Security.DevicePolicyManager/doc/api/Tizen.Security.DevicePolicyManager.md diff --git a/src/Tizen.Security.DevicePolicyManager/Interop/Interop.DevicePolicyManager.cs b/src/Tizen.Security.DevicePolicyManager/Interop/Interop.DevicePolicyManager.cs new file mode 100644 index 0000000..a5e695a --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Interop/Interop.DevicePolicyManager.cs @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class DevicePolicyManager + { + internal enum ErrorCode + { + None = Tizen.Internals.Errors.ErrorCode.None, + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, + TimeOut = Tizen.Internals.Errors.ErrorCode.TimedOut, + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, + ConnectionRefused = Tizen.Internals.Errors.ErrorCode.ConnectionRefused, + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void PolicyChangedCallback(string name, string state, IntPtr userData); + // void (* dpm_policy_changed_cb)(const char* name, const char* state, void* user_data); + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_add_policy_changed_cb", CallingConvention = CallingConvention.Cdecl)] + internal static extern int AddPolicyChangedCallback(IntPtr handle, string name, PolicyChangedCallback callback, IntPtr userData, out int callbackId); + // int dpm_add_policy_changed_cb(device_policy_manager_h handle, const char* name, dpm_policy_changed_cb callback, void* user_data, int* id) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_remove_policy_changed_cb", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RemovePolicyChangedCallback(IntPtr handle, int callbackId); + // int dpm_remove_policy_changed_cb(device_policy_manager_h handle, int id) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_manager_create", CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr CreateHandle(); + // device_policy_manager_h dpm_manager_create(void) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_manager_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static extern int DestroyHandle(IntPtr handle); + // int dpm_manager_destroy(device_policy_manager_h handle) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_expires", CallingConvention = CallingConvention.Cdecl), ] + internal static extern int PasswordGetExpires(IntPtr handle, out int value); + // int dpm_password_get_expires(device_policy_manager_h handle, int* value) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_history", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PasswordGetHistory(IntPtr handle, out int value); + // int dpm_password_get_history(device_policy_manager_h handle, int* value) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_max_inactivity_time_device_lock", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PasswordGetMaxInactivityTimeDeviceLock(IntPtr handle, out int value); + // int dpm_password_get_max_inactivity_time_device_lock(device_policy_manager_h handle, int* value) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_maximum_failed_attempts_for_wipe", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PasswordGetMaximumFailedAttemptsForWipe(IntPtr handle, out int value); + // int dpm_password_get_maximum_failed_attempts_for_wipe(device_policy_manager_h handle, int* value) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_min_complex_chars", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PasswordGetMinComplexChars(IntPtr handle, out int value); + // int dpm_password_get_min_complex_chars(device_policy_manager_h handle, int* value) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_minimum_length", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PasswordGetMinimumLength(IntPtr handle, out int value); + // int dpm_password_get_minimum_length(device_policy_manager_h handle, int* value) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_password_get_quality", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PasswordGetQuality(IntPtr handle, out int quality); + // int dpm_password_get_quality(device_policy_manager_h handle, int* quality) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_messaging_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetMessagingState(IntPtr handle, string simId, out int allowed); + // int dpm_restriction_get_messaging_state(device_policy_manager_h handle, const char* sim_id, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_popimap_email_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetPopimapEmailState(IntPtr handle, out int allowed); + // int dpm_restriction_get_popimap_email_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_wifi_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetWifiState(IntPtr handle, out int allowed); + // int dpm_restriction_get_wifi_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_wifi_hotspot_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetWifiHotspotState(IntPtr handle, out int allowed); + // int dpm_restriction_get_wifi_hotspot_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_bluetooth_mode_change_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetBluetoothModeChangeState(IntPtr handle, out int allowed); + // int dpm_restriction_get_bluetooth_mode_change_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_bluetooth_tethering_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetBluetoothTetheringState(IntPtr handle, out int allowed); + // int dpm_restriction_get_bluetooth_tethering_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_browser_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetBrowserState(IntPtr handle, out int allowed); + // int dpm_restriction_get_browser_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_camera_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetCameraState(IntPtr handle, out int allowed); + // int dpm_restriction_get_camera_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_microphone_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetMicrophoneState(IntPtr handle, out int allowed); + // int dpm_restriction_get_microphone_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_location_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetLocationState(IntPtr handle, out int allowed); + // int dpm_restriction_get_location_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_external_storage_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetExternalStorageState(IntPtr handle, out int allowed); + // int dpm_restriction_get_external_storage_state(device_policy_manager_h handle, int* is_allowed) + + [DllImport(Libraries.DevicePolicyManager, EntryPoint = "dpm_restriction_get_usb_tethering_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RestrictionGetUsbTetheringState(IntPtr handle, out int allowed); + // int dpm_restriction_get_usb_tethering_state(device_policy_manager_h handle, int* is_allowed) + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Interop/Interop.Libraries.cs b/src/Tizen.Security.DevicePolicyManager/Interop/Interop.Libraries.cs new file mode 100644 index 0000000..df242b7 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Interop/Interop.Libraries.cs @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018 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 + */ + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string DevicePolicyManager = "libdpm.so.0"; + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.csproj b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.csproj new file mode 100644 index 0000000..3b49fbd --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.csproj @@ -0,0 +1,10 @@ + + + + netstandard2.0 + + + + + + diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.sln b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.sln new file mode 100644 index 0000000..cb5d5ce --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager.sln @@ -0,0 +1,65 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Security.DevicePolicyManager", "Tizen.Security.DevicePolicyManager.csproj", "{AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{13DD8158-41C1-4B9F-B398-9E82BB74210B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Debug|x64.ActiveCfg = Debug|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Debug|x64.Build.0 = Debug|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Debug|x86.ActiveCfg = Debug|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Debug|x86.Build.0 = Debug|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Release|Any CPU.Build.0 = Release|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Release|x64.ActiveCfg = Release|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Release|x64.Build.0 = Release|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Release|x86.ActiveCfg = Release|Any CPU + {AA4F6CF6-78E2-49D9-B73A-4FD63F7D90E3}.Release|x86.Build.0 = Release|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Debug|x64.ActiveCfg = Debug|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Debug|x64.Build.0 = Debug|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Debug|x86.ActiveCfg = Debug|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Debug|x86.Build.0 = Debug|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Release|Any CPU.Build.0 = Release|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Release|x64.ActiveCfg = Release|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Release|x64.Build.0 = Release|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Release|x86.ActiveCfg = Release|Any CPU + {13DD8158-41C1-4B9F-B398-9E82BB74210B}.Release|x86.Build.0 = Release|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Debug|x64.ActiveCfg = Debug|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Debug|x64.Build.0 = Debug|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Debug|x86.ActiveCfg = Debug|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Debug|x86.Build.0 = Debug|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Release|Any CPU.Build.0 = Release|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Release|x64.ActiveCfg = Release|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Release|x64.Build.0 = Release|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Release|x86.ActiveCfg = Release|Any CPU + {01B0E2DB-D4E8-4FB7-ACF1-A25C9920123F}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F8F12835-C9A3-4982-9D07-F3C882536CA6} + EndGlobalSection +EndGlobal diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BluetoothPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BluetoothPolicy.cs new file mode 100644 index 0000000..349052e --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BluetoothPolicy.cs @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The BluetoothPolicy provides methods to manage Bluetooth policies. + /// + /// 6 + /// The BluetoothPolicy is created by . and the DevicePolicyManager instance must exists when using the BluetoothPolicy. + public class BluetoothPolicy : DevicePolicy, IDisposable + { + /// + /// The Bluetooth policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string BluetoothPolicyName = "Bluetooth"; + + /// + /// The Bluetooth Tethering policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string BluetoothTetheringPolicyName = "BluetoothTethering"; + + private readonly string _bluetoothPolicyName = "bluetooth"; + private readonly string _bluetoothTetheringPolicyName = "bluetooth_tethering"; + private int _bluetoothCallbackId; + private int _bluetoothTetheringCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _bluetoothPolicyChangedCallback; + private Interop.DevicePolicyManager.PolicyChangedCallback _bluetoothTetheringPolicyChangedCallback; + private EventHandler _bluetoothPolicyChanged; + private EventHandler _bluetoothTetheringPolicyChanged; + + internal BluetoothPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of BluetoothPolicy. + /// + ~BluetoothPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the the bluetooth state change is allowed or not. + /// + /// true if the change is allowed, false otherwise. The default value is true. + /// 6 + public bool IsBluetoothAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetBluetoothModeChangeState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get bluetooth policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Gets whether the bluetooth tethering state change is allowed or not. + /// + /// true if the change is allowed, false otherwise. The default value is true. + /// 6 + public bool IsBluetoothTetheringAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetBluetoothTetheringState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get bluetooth tethering policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_bluetoothCallbackId != 0) + { + try + { + RemoveBluetoothPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + if (_bluetoothTetheringCallbackId != 0) + { + try + { + RemoveBluetoothTetheringPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The BluetoothPolicyChanged event is raised when the Bluetooth policy is changed. + /// + /// This event will be removed automatically when BluetoothPolicy is destroyed. + /// 6 + public event EventHandler BluetoothPolicyChanged + { + add + { + if (_bluetoothPolicyChanged == null) + { + AddBluetoothPolicyChangedCallback(); + } + + _bluetoothPolicyChanged += value; + } + + remove + { + _bluetoothPolicyChanged -= value; + if (_bluetoothPolicyChanged == null) + { + RemoveBluetoothPolicyChangedCallback(); + } + } + } + + private void AddBluetoothPolicyChangedCallback() + { + if (_bluetoothPolicyChangedCallback == null) + { + _bluetoothPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _bluetoothPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(BluetoothPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _bluetoothPolicyName, _bluetoothPolicyChangedCallback, IntPtr.Zero, out _bluetoothCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _bluetoothPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveBluetoothPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _bluetoothCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _bluetoothPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _bluetoothPolicyChangedCallback = null; + _bluetoothCallbackId = 0; + } + + /// + /// The BluetoothTetheringPolicyChanged event is raised when the Bluetooth tethering policy is changed. + /// + /// This event will be removed automatically when BluetoothPolicy is destroyed. + /// 6 + public event EventHandler BluetoothTetheringPolicyChanged + { + add + { + if (_bluetoothTetheringPolicyChanged == null) + { + AddBluetoothTetheringPolicyChangedCallback(); + } + + _bluetoothTetheringPolicyChanged += value; + } + + remove + { + _bluetoothTetheringPolicyChanged -= value; + if (_bluetoothTetheringPolicyChanged == null) + { + RemoveBluetoothTetheringPolicyChangedCallback(); + } + } + } + + private void AddBluetoothTetheringPolicyChangedCallback() + { + if (_bluetoothTetheringPolicyChangedCallback == null) + { + _bluetoothTetheringPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _bluetoothTetheringPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(BluetoothTetheringPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _bluetoothTetheringPolicyName, _bluetoothTetheringPolicyChangedCallback, IntPtr.Zero, out _bluetoothTetheringCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _bluetoothTetheringPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveBluetoothTetheringPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _bluetoothTetheringCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _bluetoothTetheringPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _bluetoothTetheringPolicyChangedCallback = null; + _bluetoothTetheringCallbackId = 0; + } + } +} \ No newline at end of file diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BrowserPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BrowserPolicy.cs new file mode 100644 index 0000000..ec6128b --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/BrowserPolicy.cs @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The BrowserPolicy provides methods to manage browser policies. + /// + /// 6 + /// The BrowserPolicy is created by . and the DevicePolicyManager instance must exists when using the BrowserPolicy. + public class BrowserPolicy : DevicePolicy, IDisposable + { + /// + /// The Browser policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string BrowserPolicyName = "Browser"; + + private readonly string _browserPolicyName = "browser"; + private int _browserCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _browserPolicyChangedCallback; + private EventHandler _browserPolicyChanged; + + internal BrowserPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of BrowserPolicy. + /// + ~BrowserPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the use of web browser is allowed or not. + /// + /// true if the use of web browser is allowed, false otherwise. The default value is true. + /// 6 + public bool IsBrowserAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetBrowserState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get browser policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_browserCallbackId != 0) + { + try + { + RemoveBrowserPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The BrowserPolicyChanged event is raised when the browser policy is changed. + /// + /// This event will be removed automatically when BrowserPolicy is destroyed. + /// 6 + public event EventHandler BrowserPolicyChanged + { + add + { + if (_browserPolicyChanged == null) + { + AddBrowserPolicyChangedCallback(); + } + + _browserPolicyChanged += value; + } + + remove + { + _browserPolicyChanged -= value; + if (_browserPolicyChanged == null) + { + RemoveBrowserPolicyChangedCallback(); + } + } + } + + private void AddBrowserPolicyChangedCallback() + { + if (_browserPolicyChangedCallback == null) + { + _browserPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _browserPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(BrowserPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _browserPolicyName, _browserPolicyChangedCallback, IntPtr.Zero, out _browserCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _browserPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveBrowserPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _browserCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _browserPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _browserPolicyChangedCallback = null; + _browserCallbackId = 0; + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicy.cs new file mode 100644 index 0000000..2908331 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicy.cs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2018 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 + */ + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The abstract class for Policy instances. + /// + /// 6 + public abstract class DevicePolicy + { + protected internal readonly DevicePolicyManager _dpm; + + internal DevicePolicy(DevicePolicyManager dpm) + { + _dpm = dpm; + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicyManager.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicyManager.cs new file mode 100644 index 0000000..390ebd3 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/DevicePolicyManager.cs @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; +using System.Collections.Generic; +using Tizen.Internals.Errors; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The DevicePolicyManager provides the methods to create handle for device policy. + /// + /// 6 + public class DevicePolicyManager : IDisposable + { + private IntPtr _handle = IntPtr.Zero; + private bool _disposed = false; + + /// + /// A constructor of DevicePolicyManager that creates handle. + /// + /// 6 + /// Thrown when connection refused or a memory error occurred. + public DevicePolicyManager() + { + _handle = Interop.DevicePolicyManager.CreateHandle(); + var lastError = ErrorFacts.GetLastResult(); + if (lastError != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + throw DevicePolicyManagerErrorFactory.CreateException(ErrorFacts.GetLastResult()); + } + } + + /// + /// Method to creates an instance of Device Policy. + /// + /// The generic type to create. + /// An instance of policy. + /// 6 + /// Thrown when failed to create instance of the policy. + public T GetPolicy() where T : DevicePolicy + { + try + { + T policy = Activator.CreateInstance(typeof(T), + System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, + null, new object[] { this }, null) as T; + return policy; + } + catch (Exception e) + { + Log.Error(Globals.LogTag, "Failed to create policy. " + e.Message); + throw new InvalidOperationException("Failed to create policy."); + } + } + + internal IntPtr GetHandle() + { + return _disposed ? IntPtr.Zero : _handle; + } + + /// + /// A Destructor of DevicePolicyManager. + /// + ~DevicePolicyManager() + { + this.Dispose(false); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_handle != IntPtr.Zero) + { + int ret = Interop.DevicePolicyManager.DestroyHandle(_handle); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to destroy handle " + ret); + } + + _handle = IntPtr.Zero; + } + + _disposed = true; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + } + + static internal class Globals + { + internal const string LogTag = "Tizen.Security.DPM"; + } + + internal static class DevicePolicyManagerErrorFactory + { + static internal Exception CreateException(int error) + { + Interop.DevicePolicyManager.ErrorCode errCode = (Interop.DevicePolicyManager.ErrorCode)error; + switch (errCode) + { + case Interop.DevicePolicyManager.ErrorCode.InvalidParameter: + return new ArgumentException("Invalid parameter"); + case Interop.DevicePolicyManager.ErrorCode.TimeOut: + return new TimeoutException("Timeout"); + case Interop.DevicePolicyManager.ErrorCode.PermissionDenied: + return new UnauthorizedAccessException("Permission Denied"); + case Interop.DevicePolicyManager.ErrorCode.OutOfMemory: + return new InvalidOperationException("Out of memory"); + case Interop.DevicePolicyManager.ErrorCode.ConnectionRefused: + return new InvalidOperationException("Connection refused"); + default: + return new InvalidOperationException("Unknown Error Code"); + } + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/EmailPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/EmailPolicy.cs new file mode 100644 index 0000000..ca06481 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/EmailPolicy.cs @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The EmailPolicy provides methods to manage email policies. + /// + /// 6 + /// The EmailPolicy is created by . and the DevicePolicyManager instance must exists when using the EmailPolicy. + public class EmailPolicy : DevicePolicy, IDisposable + { + /// + /// The PopImap email policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string PopImapEmailPolicyName = "PopImapEmail"; + + private readonly string _popImapPolicyName = "popimap_email"; + private int _popImapCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _popImapPolicyChangedCallback; + private EventHandler _popImapPolicyChanged; + + internal EmailPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of EmailPolicy. + /// + ~EmailPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the access to POP or IMAP email is allowed or not. + /// + /// true if the POP or IMAP email is allowed, false otherwise. The default value is true. + /// 6 + public bool IsPopImapAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetPopimapEmailState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get popimap email policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_popImapCallbackId != 0) + { + try + { + RemovePopImapPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The PopImapPolicyChanged event is raised when the popimap-email policy is changed. + /// + /// This event will be removed automatically when EmailPolicy is destroyed. + /// 6 + public event EventHandler PopImapPolicyChanged + { + add + { + if (_popImapPolicyChanged == null) + { + AddPopImapPolicyChangedCallback(); + } + + _popImapPolicyChanged += value; + } + + remove + { + _popImapPolicyChanged -= value; + if (_popImapPolicyChanged == null) + { + RemovePopImapPolicyChangedCallback(); + } + } + } + + private void AddPopImapPolicyChangedCallback() + { + if (_popImapPolicyChangedCallback == null) + { + _popImapPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _popImapPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(PopImapEmailPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _popImapPolicyName, _popImapPolicyChangedCallback, IntPtr.Zero, out _popImapCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _popImapPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemovePopImapPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _popImapCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _popImapPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _popImapPolicyChangedCallback = null; + _popImapCallbackId = 0; + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/LocationPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/LocationPolicy.cs new file mode 100644 index 0000000..819c750 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/LocationPolicy.cs @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The LocationPolicy provides methods to manage location policies. + /// + /// 6 + /// The LocationPolicy is created by . and the DevicePolicyManager instance must exists when using the LocationPolicy. + public class LocationPolicy : DevicePolicy, IDisposable + { + /// + /// The Location policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string LocationPolicyName = "Location"; + + private readonly string _locationPolicyName = "location"; + private int _locationCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _locationPolicyChangedCallback; + private EventHandler _locationPolicyChanged; + + internal LocationPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of LocationPolicy. + /// + ~LocationPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether user is allowed to change location state or not. + /// + /// true if the location state change is allowed, false otherwise. The default value is true. + /// 6 + public bool IsLocationAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetLocationState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get location policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_locationCallbackId != 0) + { + try + { + RemoveLocationPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The LocationPolicyChanged event is raised when the location policy is changed. + /// + /// This event will be removed automatically when LocationPolicy is destroyed. + /// 6 + public event EventHandler LocationPolicyChanged + { + add + { + if (_locationPolicyChanged == null) + { + AddLocationPolicyChangedCallback(); + } + + _locationPolicyChanged += value; + } + + remove + { + _locationPolicyChanged -= value; + if (_locationPolicyChanged == null) + { + RemoveLocationPolicyChangedCallback(); + } + } + } + + private void AddLocationPolicyChangedCallback() + { + if (_locationPolicyChangedCallback == null) + { + _locationPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _locationPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(LocationPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _locationPolicyName, _locationPolicyChangedCallback, IntPtr.Zero, out _locationCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _locationPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveLocationPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _locationCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _locationPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _locationPolicyChangedCallback = null; + _locationCallbackId = 0; + } + } +} \ No newline at end of file diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/MediaPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/MediaPolicy.cs new file mode 100644 index 0000000..dd87cc2 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/MediaPolicy.cs @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The MediaPolicy provides methods to manage media policies. + /// + /// 6 + /// The MediaPolicy is created by . and the DevicePolicyManager instance must exists when using the MediaPolicy. + public class MediaPolicy : DevicePolicy, IDisposable + { + /// + /// The Camera policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string CameraPolicyName = "Camera"; + + /// + /// The Microphone policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string MicrophonePolicyName = "Microphone"; + + private readonly string _cameraPolicyName = "camera"; + private readonly string _microphonePolicyName = "microphone"; + private int _cameraCallbackId; + private int _microphoneCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _cameraPolicyChangedCallback; + private Interop.DevicePolicyManager.PolicyChangedCallback _microphonePolicyChangedCallback; + private EventHandler _cameraPolicyChanged; + private EventHandler _microphonePolicyChanged; + + internal MediaPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of MediaPolicy. + /// + ~MediaPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the use of camera is allowed or not. + /// + /// true if the use of camera is allowed, false otherwise. The default value is true. + /// 6 + public bool IsCameraAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetCameraState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get camera policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Gets whether the use of microphone is allowed or not. + /// + /// true if the use of microphone is allowed, false otherwise. The default value is true. + /// 6 + public bool IsMicrophoneAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetMicrophoneState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get microphone policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_cameraCallbackId != 0) + { + try + { + RemoveCameraPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + if (_microphoneCallbackId != 0) + { + try + { + RemoveMicrophonePolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The CameraPolicyChanged event is raised when the camera policy is changed. + /// + /// This event will be removed automatically when MediaPolicy is destroyed. + /// 6 + public event EventHandler CameraPolicyChanged + { + add + { + if (_cameraPolicyChanged == null) + { + AddCameraPolicyChangedCallback(); + } + + _cameraPolicyChanged += value; + } + + remove + { + _cameraPolicyChanged -= value; + if (_cameraPolicyChanged == null) + { + RemoveCameraPolicyChangedCallback(); + } + } + } + + private void AddCameraPolicyChangedCallback() + { + if (_cameraPolicyChangedCallback == null) + { + _cameraPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _cameraPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(CameraPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _cameraPolicyName, _cameraPolicyChangedCallback, IntPtr.Zero, out _cameraCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _cameraPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveCameraPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _cameraCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _cameraPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _cameraPolicyChangedCallback = null; + _cameraCallbackId = 0; + } + + /// + /// The MicrophonePolicyChanged event is raised when the microphone policy is changed. + /// + /// This event will be removed automatically when MediaPolicy is destroyed. + /// 6 + public event EventHandler MicrophonePolicyChanged + { + add + { + if (_microphonePolicyChanged == null) + { + AddMicrophonePolicyChangedCallback(); + } + + _microphonePolicyChanged += value; + } + + remove + { + _microphonePolicyChanged -= value; + if (_microphonePolicyChanged == null) + { + RemoveMicrophonePolicyChangedCallback(); + } + } + } + + private void AddMicrophonePolicyChangedCallback() + { + if (_microphonePolicyChangedCallback == null) + { + _microphonePolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _microphonePolicyChanged?.Invoke(this, new PolicyChangedEventArgs(MicrophonePolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _microphonePolicyName, _microphonePolicyChangedCallback, IntPtr.Zero, out _microphoneCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _microphonePolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveMicrophonePolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _microphoneCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _microphonePolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _microphonePolicyChangedCallback = null; + _microphoneCallbackId = 0; + } + } +} \ No newline at end of file diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordPolicy.cs new file mode 100644 index 0000000..7151f92 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordPolicy.cs @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The PasswordPolicy provides methods to manage password policies. + /// + /// 6 + /// The PasswordPolicy is created by . and the DevicePolicyManager instance must exists when using the PasswordPolicy. + public class PasswordPolicy : DevicePolicy + { + internal PasswordPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// Gets the number of days password expires. + /// + /// Number of days after which the password expires. The default value is maximum of int. + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public int DaysToExpiration + { + get + { + int value = int.MaxValue; + int ret = Interop.DevicePolicyManager.PasswordGetExpires(_dpm.GetHandle(), out value); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password expires policy " + ret); + } + + return value; + } + } + + /// + /// Gets the number of min password history to avoid previous password. + /// + /// Number of previous passwords which cannot be used when settings a new password. The default value is 0. + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public int MinimumPreviousHistory + { + get + { + int value = 0; + int ret = Interop.DevicePolicyManager.PasswordGetHistory(_dpm.GetHandle(), out value); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password history policy " + ret); + } + + return value; + } + } + + /// + /// Gets the maximum number of seconds of inactivity time before the screen timeout occurs. + /// + /// Maximum inactivity time for device lock. The default value is maximum of int. + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public int MaxInactivityTimeDeviceLock + { + get + { + int value = int.MaxValue; + int ret = Interop.DevicePolicyManager.PasswordGetMaxInactivityTimeDeviceLock(_dpm.GetHandle(), out value); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password maximum inactivity time policy " + ret); + } + + return value; + } + } + + /// + /// Gets maximum number of failed attempts before device is wiped. + /// If user fails the last attempt, device will be wiped. + /// + /// Maximum count for failed passwords. The default value is maximum of int. + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public int MaximumFailedAttemptsForWipe + { + get + { + int value = int.MaxValue; + int ret = Interop.DevicePolicyManager.PasswordGetMaximumFailedAttemptsForWipe(_dpm.GetHandle(), out value); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password maximum failed attempts policy " + ret); + } + + return value; + } + } + + /// + /// Gets minimum complex char in password. + /// Complex characters are all non-alphabetic characters; that is, numbers and symbols. + /// + /// Number of minimum complex char in password. The default value is 0. + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public int MinimumRequiredComplexChars + { + get + { + int value = 0; + int ret = Interop.DevicePolicyManager.PasswordGetMinComplexChars(_dpm.GetHandle(), out value); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password min complext chars policy " + ret); + } + + return value; + } + } + + /// + /// Gets the minimum allowed password length. + /// + /// Allowed minimum password length. The default value is 0. + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public int MinimunLength + { + get + { + int value = 0; + int ret = Interop.DevicePolicyManager.PasswordGetMinimumLength(_dpm.GetHandle(), out value); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password min length policy " + ret); + } + + return value; + } + } + + /// + /// Gets password quality. + /// An administrator can get the password restrictions it is imposing. + /// + /// Password quality type, values of PasswordQuality. The default value is PasswordQuality UNSPECIFIED. + /// + /// 6 + /// http://tizen.org/privilege/dpm.password + /// partner + public PasswordQuality Quality + { + get + { + int quality; + int ret = Interop.DevicePolicyManager.PasswordGetQuality(_dpm.GetHandle(), out quality); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get password quality policy " + ret); + return PasswordQuality.Unspecified; + } + + return (PasswordQuality)quality; + } + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordQuality.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordQuality.cs new file mode 100644 index 0000000..bb77e87 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PasswordQuality.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018 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 + */ + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// Enumeration for dpm password quality type + /// + /// 6 + public enum PasswordQuality + { + /// + /// No requirements for password. + /// + /// 6 + Unspecified = 0x00, + /// + /// EAS(Exchange ActiveSync) requirement for simple password. + /// + /// 6 + Simple = 0x01, + /// + /// Some kind password required, but doesn't care what it is. + /// + /// 6 + Something = 0x10, + /// + /// Containing at least numeric character. + /// + /// 6 + Numeric = 0x20, + /// + /// Containing at least alphabetic (or other symbol) characters. + /// + /// 6 + Alphabetic = 0x40, + /// + /// Containing at least numeric and alphabetic characters. + /// + /// 6 + Alphanumeric = 0x80 + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PolicyChangedEventArgs.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PolicyChangedEventArgs.cs new file mode 100644 index 0000000..efc2269 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/PolicyChangedEventArgs.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// An extended EventArgs class contains the changed dpm policy state. + /// + /// 6 + public class PolicyChangedEventArgs : EventArgs + { + internal PolicyChangedEventArgs(string name, string state) + { + PolicyName = name; + IsAllowed = state.Equals("allowed"); + } + + /// + /// Gets the name of the changed policy. + /// + /// Each policy that can raise event has the name. The policy name value is in each policy class. + public string PolicyName { get; } + + /// + /// Gets the current state of the policy. + /// + public bool IsAllowed { get; } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/StoragePolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/StoragePolicy.cs new file mode 100644 index 0000000..0930d60 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/StoragePolicy.cs @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The StoragePolicy provides methods to manage storage policies. + /// + /// 6 + /// The StoragePolicy is created by . and the DevicePolicyManager instance must exists when using the StoragePolicy. + public class StoragePolicy : DevicePolicy, IDisposable + { + /// + /// The External storage policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string ExternalStoragePolicyName = "ExternalStorage"; + + private readonly string _externalStoragePolicyName = "external_storage"; + private int _externalStorageCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _externalStoragePolicyChangedCallback; + private EventHandler _externalStoragePolicyChanged; + + internal StoragePolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of StoragePolicy. + /// + ~StoragePolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the use of external storage is allowed or not. + /// + /// true if the use of external storage is allowed, false otherwise. The default value is true. + /// 6 + public bool IsExternalStorageAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetExternalStorageState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get external storage policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_externalStorageCallbackId != 0) + { + try + { + RemoveExternalStoragePolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The ExternalStoragePolicyChanged event is raised when the external storage policy is changed. + /// + /// This event will be removed automatically when StoragePolicy is destroyed. + /// 6 + public event EventHandler ExternalStoragePolicyChanged + { + add + { + if (_externalStoragePolicyChanged == null) + { + AddExternalStoragePolicyChangedCallback(); + } + + _externalStoragePolicyChanged += value; + } + + remove + { + _externalStoragePolicyChanged -= value; + if (_externalStoragePolicyChanged == null) + { + RemoveExternalStoragePolicyChangedCallback(); + } + } + } + + private void AddExternalStoragePolicyChangedCallback() + { + if (_externalStoragePolicyChangedCallback == null) + { + _externalStoragePolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _externalStoragePolicyChanged?.Invoke(this, new PolicyChangedEventArgs(ExternalStoragePolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _externalStoragePolicyName, _externalStoragePolicyChangedCallback, IntPtr.Zero, out _externalStorageCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _externalStoragePolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveExternalStoragePolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _externalStorageCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _externalStoragePolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _externalStoragePolicyChangedCallback = null; + _externalStorageCallbackId = 0; + } + } +} \ No newline at end of file diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/TelephonyPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/TelephonyPolicy.cs new file mode 100644 index 0000000..4b3dd2f --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/TelephonyPolicy.cs @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The TelephonyPolicy provides methods to manage telephony policies. + /// + /// 6 + /// The TelephonyPolicy is created by . and the DevicePolicyManager instance must exists when using the TelephonyPolicy. + public class TelephonyPolicy : DevicePolicy, IDisposable + { + /// + /// The Text messaging policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string MessagingPolicyName = "Messaging"; + + private readonly string _messagingPolicyName = "messaging"; + private int _messagingCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _messagingPolicyChangedCallback; + private EventHandler _messagingPolicyChanged; + + internal TelephonyPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of TelephonyPolicy. + /// + ~TelephonyPolicy() + { + this.Dispose(false); + } + + /// + /// Checks whether the text messaging is allowed or not. + /// + /// SIM identifier + /// true if the messaging is allowed, false otherwise. + /// 6 + /// Thrown when failed because of invalid parameter. + /// Thrown when failed because of timeout. + public bool IsMessagingAllowed(string simId) + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetMessagingState(_dpm.GetHandle(), simId, out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + return state == 1; + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_messagingCallbackId != 0) + { + try + { + RemoveMessagingPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The MessagingPolicyChanged event is raised when the messaging policy is changed. + /// + /// This event will be removed automatically when TelephonyPolicy is destroyed. + /// 6 + public event EventHandler MessagingPolicyChanged + { + add + { + if (_messagingPolicyChanged == null) + { + AddMessagingPolicyChangedCallback(); + } + + _messagingPolicyChanged += value; + } + + remove + { + _messagingPolicyChanged -= value; + if (_messagingPolicyChanged == null) + { + RemoveMessagingPolicyChangedCallback(); + } + } + } + + private void AddMessagingPolicyChangedCallback() + { + if (_messagingPolicyChangedCallback == null) + { + _messagingPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _messagingPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(MessagingPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _messagingPolicyName, _messagingPolicyChangedCallback, IntPtr.Zero, out _messagingCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _messagingPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveMessagingPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _messagingCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _messagingPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _messagingPolicyChangedCallback = null; + _messagingCallbackId = 0; + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/UsbPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/UsbPolicy.cs new file mode 100644 index 0000000..1fb8663 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/UsbPolicy.cs @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The UsbPolicy provides methods to manage usb policies. + /// + /// 6 + /// The UsbPolicy is created by . and the DevicePolicyManager instance must exists when using the UsbPolicy. + public class UsbPolicy : DevicePolicy, IDisposable + { + /// + /// The Usb tethering policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string UsbTetheringPolicyName = "UsbTethering"; + + private readonly string _usbTetheringPolicyName = "usb_tethering"; + private int _usbTetheringCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _usbTetheringPolicyChangedCallback; + private EventHandler _usbTetheringPolicyChanged; + + internal UsbPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of UsbPolicy. + /// + ~UsbPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the USB tethering state change is allowed. + /// + /// true if the change is allowed, false otherwise. The default value is true. + /// 6 + public bool IsUsbTetheringAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetUsbTetheringState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get usb tethering state change policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_usbTetheringCallbackId != 0) + { + try + { + RemoveUsbTetheringPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The UsbTetheringPolicyChanged event is raised when the usb tethering policy is changed. + /// + /// This event will be removed automatically when UsbPolicy is destroyed. + /// 6 + public event EventHandler UsbTetheringPolicyChanged + { + add + { + if (_usbTetheringPolicyChanged == null) + { + AddUsbTetheringPolicyChangedCallback(); + } + + _usbTetheringPolicyChanged += value; + } + + remove + { + _usbTetheringPolicyChanged -= value; + if (_usbTetheringPolicyChanged == null) + { + RemoveUsbTetheringPolicyChangedCallback(); + } + } + } + + private void AddUsbTetheringPolicyChangedCallback() + { + if (_usbTetheringPolicyChangedCallback == null) + { + _usbTetheringPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _usbTetheringPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(UsbTetheringPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _usbTetheringPolicyName, _usbTetheringPolicyChangedCallback, IntPtr.Zero, out _usbTetheringCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _usbTetheringPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveUsbTetheringPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _usbTetheringCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _usbTetheringPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _usbTetheringPolicyChangedCallback = null; + _usbTetheringCallbackId = 0; + } + } +} \ No newline at end of file diff --git a/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/WifiPolicy.cs b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/WifiPolicy.cs new file mode 100644 index 0000000..c08b7d0 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/Tizen.Security.DevicePolicyManager/WifiPolicy.cs @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2018 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 + */ + +using System; + +namespace Tizen.Security.DevicePolicyManager +{ + /// + /// The WifiPolicy provides methods to manage wifi policies. + /// + /// 6 + /// The WifiPolicy is created by . and the DevicePolicyManager instance must exists when using the WifiPolicy. + public class WifiPolicy : DevicePolicy, IDisposable + { + /// + /// The Wifi policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string WifiPolicyName = "Wifi"; + + /// + /// The Wifi hotspot policy name. This represents . + /// + /// This is used in . + /// 6 + public static readonly string WifiHotspotPolicyName = "WifiHotspot"; + + private readonly string _wifiPolicyName = "wifi"; + private readonly string _wifiHotspotPolicyName = "wifi_hotspot"; + + private int _wifiCallbackId; + private int _wifiHotspotCallbackId; + private bool _disposed = false; + + private Interop.DevicePolicyManager.PolicyChangedCallback _wifiPolicyChangedCallback; + private Interop.DevicePolicyManager.PolicyChangedCallback _wifiHotspotStatePolicyChangedCallback; + private EventHandler _wifiPolicyChanged; + private EventHandler _wifiHotspotPolicyChanged; + + internal WifiPolicy(DevicePolicyManager dpm) : base(dpm) + { + } + + /// + /// A Destructor of WifiPolicy. + /// + ~WifiPolicy() + { + this.Dispose(false); + } + + /// + /// Gets whether the Wi-Fi state change is allowed or not. + /// + /// true if the state change is allowed, false otherwise. The default value is true. + /// 6 + public bool IsWifiAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetWifiState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get wifi policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Gets whether the the Wi-Fi hotspot state change is allowed or not. + /// + /// true if the state change is allowed, false otherwise. The default value is true. + /// 6 + public bool IsWifiHotspotAllowed + { + get + { + int state; + int ret = Interop.DevicePolicyManager.RestrictionGetWifiHotspotState(_dpm.GetHandle(), out state); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to get wifi hotspot policy " + ret); + return true; + } + + return state == 1; + } + } + + /// + /// Releases any unmanaged resources used by this object. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects. + /// + /// If true, disposes any disposable objects. If false, does not dispose disposable objects. + protected virtual void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // to be used if there are any other disposable objects + } + + if (_wifiCallbackId != 0) + { + try + { + RemoveWifiStatePolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + if (_wifiHotspotCallbackId != 0) + { + try + { + RemoveWifiHotspotPolicyChangedCallback(); + } + catch (Exception e) + { + Log.Error(Globals.LogTag, e.ToString()); + } + } + + _disposed = true; + } + } + + /// + /// The WifiPolicyChanged event is raised when the wifi state policy is changed. + /// + /// This event will be removed automatically when WifiPolicy is destroyed. + /// 6 + public event EventHandler WifiPolicyChanged + { + add + { + if (_wifiPolicyChanged == null) + { + AddWifiStatePolicyChangedCallback(); + } + + _wifiPolicyChanged += value; + } + + remove + { + _wifiPolicyChanged -= value; + if (_wifiPolicyChanged == null) + { + RemoveWifiStatePolicyChangedCallback(); + } + } + } + + private void AddWifiStatePolicyChangedCallback() + { + if (_wifiPolicyChangedCallback == null) + { + _wifiPolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _wifiPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(WifiPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _wifiPolicyName, _wifiPolicyChangedCallback, IntPtr.Zero, out _wifiCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _wifiPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveWifiStatePolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _wifiCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _wifiPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _wifiPolicyChangedCallback = null; + _wifiCallbackId = 0; + } + + /// + /// The WifiHotspotPolicyChanged event is raised when the wifi hotspot policy is changed. + /// + /// This event will be removed automatically when WifiPolicy is destroyed. + /// 6 + public event EventHandler WifiHotspotPolicyChanged + { + add + { + if (_wifiHotspotPolicyChanged == null) + { + AddWifiHotspotPolicyChangedCallback(); + } + + _wifiHotspotPolicyChanged += value; + } + + remove + { + _wifiHotspotPolicyChanged -= value; + if (_wifiHotspotPolicyChanged == null) + { + RemoveWifiHotspotPolicyChangedCallback(); + } + } + } + + private void AddWifiHotspotPolicyChangedCallback() + { + if (_wifiHotspotStatePolicyChangedCallback == null) + { + _wifiHotspotStatePolicyChangedCallback = (string name, string state, IntPtr userData) => + { + _wifiHotspotPolicyChanged?.Invoke(this, new PolicyChangedEventArgs(WifiHotspotPolicyName, state)); + }; + } + + int ret = Interop.DevicePolicyManager.AddPolicyChangedCallback(_dpm.GetHandle(), _wifiHotspotPolicyName, _wifiHotspotStatePolicyChangedCallback, IntPtr.Zero, out _wifiHotspotCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to add policy changed callback, name " + _wifiHotspotPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + } + + private void RemoveWifiHotspotPolicyChangedCallback() + { + int ret = Interop.DevicePolicyManager.RemovePolicyChangedCallback(_dpm.GetHandle(), _wifiHotspotCallbackId); + if (ret != (int)Interop.DevicePolicyManager.ErrorCode.None) + { + Log.Error(Globals.LogTag, "Failed to remove policy changed callback, name " + _wifiHotspotPolicyName + ", ret : " + ret); + throw DevicePolicyManagerErrorFactory.CreateException(ret); + } + + _wifiHotspotStatePolicyChangedCallback = null; + _wifiHotspotCallbackId = 0; + } + } +} diff --git a/src/Tizen.Security.DevicePolicyManager/doc/api/Tizen.Security.DevicePolicyManager.md b/src/Tizen.Security.DevicePolicyManager/doc/api/Tizen.Security.DevicePolicyManager.md new file mode 100644 index 0000000..3577989 --- /dev/null +++ b/src/Tizen.Security.DevicePolicyManager/doc/api/Tizen.Security.DevicePolicyManager.md @@ -0,0 +1,24 @@ +--- +uid: Tizen.Security.DevicePolicyManager +summary: The Tizen.Security.DevicePolicyManager namespace provides classes to manage the device policy management framework. The device policy management framework provides APIs to create security-aware applications that are useful in enterprise settings. +remarks: *content +--- +## Overview +The primary purpose of the DPM(Device Policy Management) framework is to support enterprise applications. +The device policy API supports the policies listed in the below, and application can subscribe to those policies from events. + +### Policy List +|
Policy Name
|
Event
|
Description
| +|:--------|:--------|:--------| +|Wifi |WifiPolicyChanged |Specifies wether the use of Wi-Fi is allowed or not | +|WifiHotspot |WifiHotspotChanged |Specifies whether the use of Wi-Fi hotspot is allowed or not | +|Bluetooth |BluetoothPolicyChanged |Specifies whether the use of bluetooth is allowed or not | +|Camera |CameraPolicyChanged |Specifies whether the use of camera is allowed or not | +|Microphone |MicrophonePolicyChanged |Specifies whether the use of microphone is allowed or not | +|Location |LocationPolicyChanged |Specifies whether the use of GPS is allowed or not | +|ExternalStorage |ExternalStoragePolicyChanged |Specifies whether the use of external storage is allowed or not | +|Messaging |MessagingPolicyChanged |Specifies whether the use of text messaging is allowed or not | +|PopImapEmail |PopImapPolicyChanged |Specifies whether the use of POP/IMAP Email is allowed or not | +|Browser |BrowserPolicyChanged |Specifies whether the use of browser is allowed or not | +|BluetoothTethering |BluetoothTetheringPolicyChanged |Specifies whether the use of bluetooth tethering is allowed or not | +|UsbTethering |UsbTetheringPolicyChanged |Specifies whether the use of usb tethering is allowed or not | \ No newline at end of file -- 2.7.4