|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "nsAndroidNetworkLinkService.h" |
|
8 #include "nsServiceManagerUtils.h" |
|
9 #include "mozilla/Services.h" |
|
10 |
|
11 #include "AndroidBridge.h" |
|
12 |
|
13 using namespace mozilla::widget::android; |
|
14 |
|
15 NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService, |
|
16 nsINetworkLinkService) |
|
17 |
|
18 nsAndroidNetworkLinkService::nsAndroidNetworkLinkService() |
|
19 { |
|
20 } |
|
21 |
|
22 nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService() |
|
23 { |
|
24 } |
|
25 |
|
26 NS_IMETHODIMP |
|
27 nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp) |
|
28 { |
|
29 if (!mozilla::AndroidBridge::Bridge()) { |
|
30 // Fail soft here and assume a connection exists |
|
31 NS_WARNING("GetIsLinkUp is not supported without a bridge connection"); |
|
32 *aIsUp = true; |
|
33 return NS_OK; |
|
34 } |
|
35 |
|
36 *aIsUp = mozilla::widget::android::GeckoAppShell::IsNetworkLinkUp(); |
|
37 return NS_OK; |
|
38 } |
|
39 |
|
40 NS_IMETHODIMP |
|
41 nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown) |
|
42 { |
|
43 NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED); |
|
44 |
|
45 *aIsKnown = mozilla::widget::android::GeckoAppShell::IsNetworkLinkKnown(); |
|
46 return NS_OK; |
|
47 } |
|
48 |
|
49 NS_IMETHODIMP |
|
50 nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType) |
|
51 { |
|
52 NS_ENSURE_ARG_POINTER(aLinkType); |
|
53 |
|
54 if (!mozilla::AndroidBridge::Bridge()) { |
|
55 // Fail soft here and assume a connection exists |
|
56 NS_WARNING("GetLinkType is not supported without a bridge connection"); |
|
57 *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; |
|
58 return NS_OK; |
|
59 } |
|
60 |
|
61 *aLinkType = mozilla::widget::android::GeckoAppShell::NetworkLinkType(); |
|
62 return NS_OK; |
|
63 } |