Class PrivacyPrivilegeManager
Definition
- Namespace:
- Tizen.Security
- Assembly:
- Tizen.Security.PrivacyPrivilegeManager.dll
- API Level:
- 4
The PrivacyPrivilegeManager provides the properties or methods to check and request a permission for privacy privilege.
C#Copypublic static class PrivacyPrivilegeManager
- Inheritance
-
System.ObjectPrivacyPrivilegeManager
Methods
Declaration
C#Copypublic static CheckResult CheckPermission(string privilege)
Parameters
Type | Name | Description |
---|---|---|
System.String | privilege | The privacy privilege to be checked. |
Returns
Type | Description |
---|---|
CheckResult | The permission setting for a respective privilege. |
Examples
CopyCheckResult result = PrivacyPrivilegeManager.CheckPermission("http://tizen.org/privilege/account.read"); switch (result) { case Allow: // Privilege can be used break; case Deny: // Privilege can't be used break; case Ask: // User permission request required PrivacyPrivilegeManager.RequestPermission("http://tizen.org/privilege/account.read"); break; }
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when an invalid parameter is passed. |
OutOfMemoryException | Thrown when a memory error occurred. |
IOException | Thrown when the method failed due to an internal I/O error. |
API Level: 4
CheckPermissions(IEnumerable<String>)
Gets the status of a privacy privileges permission.
Declaration
C#Copypublic static IEnumerable<CheckResult> CheckPermissions(IEnumerable<string> privileges)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | privileges | The privacy privileges to be checked. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<CheckResult> | The permission setting for a respective privileges. |
Examples
Copystring[] privileges = new [] {"http://tizen.org/privilege/account.read", "http://tizen.org/privilege/alarm"}; CheckResult[] results = PrivacyPrivilegeManager.CheckPermissions(privileges).ToArray(); List<string> privilegesWithAskStatus = new List<string>(); for (int iterator = 0; iterator < results.Length; ++iterator) { switch (results[iterator]) { case CheckResult.Allow: // Privilege can be used break; case CheckResult.Deny: // Privilege can't be used break; case CheckResult.Ask: // User permission request required privilegesWithAskStatus.Add(privileges[iterator]); break; } } PrivacyPrivilegeManager.RequestPermissions(privilegesWithAskStatus);
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when an invalid parameter is passed. |
OutOfMemoryException | Thrown when a memory error occurred. |
IOException | Thrown when the method failed due to an internal I/O error. |
API Level: 6
Declaration
C#Copypublic static WeakReference<PrivacyPrivilegeManager.ResponseContext> GetResponseContext(string privilege)
Parameters
Type | Name | Description |
---|---|---|
System.String | privilege | The privilege. |
Returns
Type | Description |
---|---|
WeakReference<PrivacyPrivilegeManager.ResponseContext> | The response context of a respective privilege. |
Examples
Copyprivate static void PPM_RequestResponse(object sender, RequestResponseEventArgs e) { if (e.cause == CallCause.Answer) { switch(e.result) { case RequestResult.AllowForever: Console.WriteLine("User allowed usage of privilege {0} definitely", e.privilege); break; case RequestResult.DenyForever: Console.WriteLine("User denied usage of privilege {0} definitely", e.privilege); break; case RequestResult.DenyOnce: Console.WriteLine("User denied usage of privilege {0} this time", e.privilege); break; }; } else { Console.WriteLine("Error occured during requesting permission for {0}", e.privilege); } } PrivacyPrivilegeManager.ResponseContext context = null; PrivacyPrivilegeManager.GetResponseContext("http://tizen.org/privilege/account.read").TryGetTarget(out context); if(context != null) { context.ResponseFetched += PPM_RequestResponse; } PrivacyPrivilegeManager.RequestPermission("http://tizen.org/privilege/account.read"); PrivacyPrivilegeManager.GetResponseContext("http://tizen.org/privilege/account.read").TryGetTarget(out context); if(context != null) { context.ResponseFetched -= PPM_RequestResponse; }
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if the key is an invalid parameter. |
API Level: 4
Declaration
C#Copypublic static void RequestPermission(string privilege)
Parameters
Type | Name | Description |
---|---|---|
System.String | privilege | The privacy privilege to be requested. |
Examples
CopyCheckResult result = PrivacyPrivilegeManager.CheckPermission("http://tizen.org/privilege/account.read"); switch (result) { case Allow: // Privilege can be used break; case Deny: // Privilege can't be used break; case Ask: // User permission request required PrivacyPrivilegeManager.RequestPermission("http://tizen.org/privilege/account.read"); break; }
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when an invalid parameter is passed. |
OutOfMemoryException | Thrown when a memory error occurred. |
IOException | Thrown when the method failed due to an internal I/O error. |
API Level: 4
Declaration
C#Copypublic static Task<RequestMultipleResponseEventArgs> RequestPermissions(IEnumerable<string> privileges)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | privileges | The privacy privileges to be requested. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<RequestMultipleResponseEventArgs> | Permission request Task |
Examples
Copystring[] privileges = new [] {"http://tizen.org/privilege/account.read", "http://tizen.org/privilege/alarm"}; CheckResult[] results = PrivacyPrivilegeManager.CheckPermissions(privileges).ToArray(); List<string> privilegesWithAskStatus = new List<string>(); for (int iterator = 0; iterator < results.Length; ++iterator) { switch (results[iterator]) { case CheckResult.Allow: // Privilege can be used break; case CheckResult.Deny: // Privilege can't be used break; case CheckResult.Ask: // User permission request required privilegesWithAskStatus.Add(privileges[iterator]); break; } } IEnumerable<PermissionRequestResponse> responses = PrivacyPrivilegeManager.RequestPermissions(privilegesWithAskStatus).Result; //handle responses
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when an invalid parameter is passed. |
OutOfMemoryException | Thrown when a memory error occurred. |
IOException | Thrown when the method failed due to an internal I/O error. |