Class PrivacyPrivilegeManager
Definition
- Assembly:
- Tizen.Security.PrivacyPrivilegeManager.dll
The PrivacyPrivilegeManager provides the properties or methods to check and request a permission for privacy privilege.
public static class PrivacyPrivilegeManager
- Inheritance
-
objectPrivacyPrivilegeManager
Methods
View SourceCheckPermission(string)
Gets the status of a privacy privilege permission.
Declaration
public static CheckResult CheckPermission(string privilege)
Parameters
Type | Name | Description |
---|---|---|
string | privilege | The privacy privilege to be checked. |
Returns
Type | Description |
---|---|
CheckResult | The permission setting for a respective privilege. |
Examples
CheckResult 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. |
System.OutOfMemoryException | Thrown when a memory error occurred. |
System.IO.IOException | Thrown when the method failed due to an internal I/O error. |
GetResponseContext(string)
Gets the response context for a given privilege.
Declaration
public static WeakReference<PrivacyPrivilegeManager.ResponseContext> GetResponseContext(string privilege)
Parameters
Type | Name | Description |
---|---|---|
string | privilege | The privilege. |
Returns
Type | Description |
---|---|
System.WeakReference<T><PrivacyPrivilegeManager.ResponseContext> | The response context of a respective privilege. |
Examples
private 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. |
See Also
View SourceRequestPermission(string)
Triggers the permission request for a user.
Declaration
public static void RequestPermission(string privilege)
Parameters
Type | Name | Description |
---|---|---|
string | privilege | The privacy privilege to be requested. |
Examples
CheckResult 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. |
System.OutOfMemoryException | Thrown when a memory error occurred. |
System.IO.IOException | Thrown when the method failed due to an internal I/O error. |