/// <summary> /// Load tethering manager if available. /// </summary> private bool MakeTetheringManagerAvailable() { if (tetheringManager == null) { // verify tethering capabilities var allAccounts = MobileBroadbandAccount.AvailableNetworkAccountIds; if (allAccounts.Count == 0) { rootPage.NotifyUser("There is no avaiable network account ID.", NotifyType.ErrorMessage); return(false); } string networkAccountId = allAccounts[0]; TetheringCapability capabilities = 0; try { capabilities = NetworkOperatorTetheringManager.GetTetheringCapability(networkAccountId); if (capabilities != TetheringCapability.Enabled) { OnCapabilityError(capabilities); } else { if (tetheringManager == null) { tetheringManager = NetworkOperatorTetheringManager.CreateFromNetworkAccountId(networkAccountId); if (tetheringManager == null) { rootPage.NotifyUser("Failed to create NetworkOperatorTetheringManager object using : " + networkAccountId, NotifyType.ErrorMessage); return(false); } } } } catch (Exception ex) { rootPage.NotifyUser("Unexpected exception occured: " + ex.ToString(), NotifyType.ErrorMessage); return(false); } } return(true); }
/// <summary> /// handle tethering disabled by capability /// </summary> /// <param name="capability"></param> private void OnCapabilityError(TetheringCapability capability) { var errorString = ""; switch (capability) { case TetheringCapability.DisabledByGroupPolicy: errorString = "Your network administrator has disabled tethering on your machine."; break; case TetheringCapability.DisabledByHardwareLimitation: errorString = "Your device hardware doesn't support tethering."; break; case TetheringCapability.DisabledByOperator: errorString = "Your Mobile Broadband Operator has disabled tethering on your device."; break; case TetheringCapability.DisabledBySku: errorString = "This version of Windows doesn't support tethering."; break; case TetheringCapability.DisabledByRequiredAppNotInstalled: errorString = "Required app is not installed."; break; case TetheringCapability.DisabledDueToUnknownCause: errorString = "Unknown issue."; break; } rootPage.NotifyUser("Unexpected exception occured: " + errorString, NotifyType.ErrorMessage); StartTetheringButton.IsEnabled = false; }
/// <summary> /// handle tethering disabled by capability /// </summary> /// <param name="capability"></param> private void OnCapabilityError(TetheringCapability capability) { var errorString = ""; switch (capability) { case TetheringCapability.DisabledByGroupPolicy: errorString = "Your network administrator has disabled tethering on your machine."; break; case TetheringCapability.DisabledByHardwareLimitation: errorString = "Your device hardware doesn't support tethering."; break; case TetheringCapability.DisabledByOperator: errorString = "Your Mobile Broadband Operator has disabled tethering on your device."; break; case TetheringCapability.DisabledBySku: errorString = "This version of Windows doesn't support tethering."; break; case TetheringCapability.DisabledByRequiredAppNotInstalled: errorString = "Required app is not installed."; break; case TetheringCapability.DisabledDueToUnknownCause: errorString = "Unknown issue."; break; } rootPage.NotifyUser("Unexpected exception occured: " + errorString, NotifyType.ErrorMessage); StartTetheringButton.IsEnabled = false; }