/// <summary> /// Determines whether this instance has permission the specified permission. /// </summary> /// <returns><c>true</c> if this instance has permission the specified permission; otherwise, <c>false</c>.</returns> /// <param name="permission">Permission to check.</param> public Task <PermissionStatus> CheckPermissionStatusAsync(Permission permission) { switch (permission) { case Permission.Calendar: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeCalendarRead) && Privilege.GetPrivacyPrivilegeStatus(privilegeCalendarWrite)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Camera: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeCamera)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Contacts: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeContactRead) && Privilege.GetPrivacyPrivilegeStatus(privilegeContactWrite)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Location: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeLocation)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Microphone: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeRecorder)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Phone: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeCall)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Photos: return(Task.FromResult(PermissionStatus.Unknown)); case Permission.Reminders: return(Task.FromResult(PermissionStatus.Unknown)); case Permission.Sensors: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeHealthInfo)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Sms: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeMessageRead) && Privilege.GetPrivacyPrivilegeStatus(privilegeMessageWrite)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Storage: try { if (Privilege.GetPrivacyPrivilegeStatus(privilegeExternalStorage)) { return(Task.FromResult(PermissionStatus.Granted)); } else { return(Task.FromResult(PermissionStatus.Denied)); } } catch { return(Task.FromResult(PermissionStatus.Unknown)); } case Permission.Speech: return(Task.FromResult(PermissionStatus.Unknown)); default: return(Task.FromResult(PermissionStatus.Unknown)); } }