michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsAndroidNetworkLinkService.h" michael@0: #include "nsServiceManagerUtils.h" michael@0: #include "mozilla/Services.h" michael@0: michael@0: #include "AndroidBridge.h" michael@0: michael@0: using namespace mozilla::widget::android; michael@0: michael@0: NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService, michael@0: nsINetworkLinkService) michael@0: michael@0: nsAndroidNetworkLinkService::nsAndroidNetworkLinkService() michael@0: { michael@0: } michael@0: michael@0: nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService() michael@0: { michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp) michael@0: { michael@0: if (!mozilla::AndroidBridge::Bridge()) { michael@0: // Fail soft here and assume a connection exists michael@0: NS_WARNING("GetIsLinkUp is not supported without a bridge connection"); michael@0: *aIsUp = true; michael@0: return NS_OK; michael@0: } michael@0: michael@0: *aIsUp = mozilla::widget::android::GeckoAppShell::IsNetworkLinkUp(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown) michael@0: { michael@0: NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED); michael@0: michael@0: *aIsKnown = mozilla::widget::android::GeckoAppShell::IsNetworkLinkKnown(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aLinkType); michael@0: michael@0: if (!mozilla::AndroidBridge::Bridge()) { michael@0: // Fail soft here and assume a connection exists michael@0: NS_WARNING("GetLinkType is not supported without a bridge connection"); michael@0: *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; michael@0: return NS_OK; michael@0: } michael@0: michael@0: *aLinkType = mozilla::widget::android::GeckoAppShell::NetworkLinkType(); michael@0: return NS_OK; michael@0: }