/// <summary> /// A constructor of DevicePolicyManager that creates handle. /// </summary> /// <since_tizen> 6 </since_tizen> /// <exception cref="InvalidOperationException">Thrown when connection refused or a memory error occurred.</exception> public DevicePolicyManager() { _handle = Interop.DevicePolicyManager.CreateHandle(); var lastError = ErrorFacts.GetLastResult(); if (lastError != (int)Interop.DevicePolicyManager.ErrorCode.None) { throw DevicePolicyManagerErrorFactory.CreateException(ErrorFacts.GetLastResult()); } }
/// <summary> /// Checks whether the text messaging is allowed or not. /// </summary> /// <param name="simId">SIM identifier</param> /// <returns>true if the messaging is allowed, false otherwise.</returns> /// <since_tizen> 6 </since_tizen> /// <exception cref="ArgumentException">Thrown when failed because of invalid parameter.</exception> /// <exception cref="TimeoutException">Thrown when failed because of timeout.</exception> 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); }
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; }
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); } }