mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 14:54:25 +00:00
Issue #1053 - Remove android support from netwerk
This commit is contained in:
@@ -27,10 +27,6 @@
|
||||
// The tickler only applies to wifi on mobile right now. Hopefully it
|
||||
// can also be restricted to particular handset models in the future.
|
||||
|
||||
#if defined(ANDROID)
|
||||
#define MOZ_USE_WIFI_TICKLER
|
||||
#endif
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsISupports.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1814,9 +1814,7 @@ NS_RelaxStrictFileOriginPolicy(nsIURI *aTargetURI,
|
||||
NS_FAILED(sourceFileURL->GetFile(getter_AddRefs(sourceFile))) ||
|
||||
!targetFile || !sourceFile ||
|
||||
NS_FAILED(targetFile->Normalize()) ||
|
||||
#ifndef MOZ_WIDGET_ANDROID
|
||||
NS_FAILED(sourceFile->Normalize()) ||
|
||||
#endif
|
||||
(!aAllowDirectoryTarget &&
|
||||
(NS_FAILED(targetFile->IsDirectory(&targetIsDir)) || targetIsDir))) {
|
||||
return false;
|
||||
|
||||
@@ -3064,9 +3064,8 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveVals(bool aEnabled,
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
// Not all *nix OSes support the following setsockopt() options
|
||||
// ... but we assume they are supported in the Android kernel;
|
||||
// build errors will tell us if they are not.
|
||||
#if defined(ANDROID) || defined(TCP_KEEPIDLE)
|
||||
#ifdef TCP_KEEPIDLE
|
||||
// Idle time until first keepalive probe; interval between ack'd probes; seconds.
|
||||
int err = setsockopt(sock, IPPROTO_TCP, TCP_KEEPIDLE,
|
||||
&aIdleTime, sizeof(aIdleTime));
|
||||
@@ -3077,7 +3076,7 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveVals(bool aEnabled,
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(ANDROID) || defined(TCP_KEEPINTVL)
|
||||
#ifdef TCP_KEEPINTVL
|
||||
// Interval between unack'd keepalive probes; seconds.
|
||||
err = setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL,
|
||||
&aRetryInterval, sizeof(aRetryInterval));
|
||||
@@ -3088,7 +3087,7 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveVals(bool aEnabled,
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(ANDROID) || defined(TCP_KEEPCNT)
|
||||
#ifdef TCP_KEEPCNT
|
||||
// Number of unack'd keepalive probes before connection times out.
|
||||
err = setsockopt(sock, IPPROTO_TCP, TCP_KEEPCNT,
|
||||
&aProbeCount, sizeof(aProbeCount));
|
||||
|
||||
@@ -42,11 +42,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
'/netwerk/system/mac',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
LOCAL_INCLUDES += [
|
||||
'/netwerk/system/android',
|
||||
]
|
||||
|
||||
elif CONFIG['OS_ARCH'] == 'Linux':
|
||||
LOCAL_INCLUDES += [
|
||||
'/netwerk/system/linux',
|
||||
|
||||
@@ -418,9 +418,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
#include "nsNetworkLinkService.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init)
|
||||
#elif defined(MOZ_WIDGET_ANDROID)
|
||||
#include "nsAndroidNetworkLinkService.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidNetworkLinkService)
|
||||
#elif defined(XP_LINUX)
|
||||
#include "nsNotifyAddrListener_Linux.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
|
||||
@@ -852,8 +849,6 @@ NS_DEFINE_NAMED_CID(NS_RTSPPROTOCOLHANDLER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
|
||||
#elif defined(MOZ_WIDGET_ANDROID)
|
||||
NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
|
||||
#elif defined(XP_LINUX)
|
||||
NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
|
||||
#endif
|
||||
@@ -1003,8 +998,6 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
|
||||
{ &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNotifyAddrListenerConstructor },
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
{ &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNetworkLinkServiceConstructor },
|
||||
#elif defined(MOZ_WIDGET_ANDROID)
|
||||
{ &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsAndroidNetworkLinkServiceConstructor },
|
||||
#elif defined(XP_LINUX)
|
||||
{ &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNotifyAddrListenerConstructor },
|
||||
#endif
|
||||
@@ -1158,8 +1151,6 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
|
||||
{ NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
|
||||
#elif defined(MOZ_WIDGET_COCOA)
|
||||
{ NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
|
||||
#elif defined(MOZ_WIDGET_ANDROID)
|
||||
{ NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
|
||||
#elif defined(XP_LINUX)
|
||||
{ NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
|
||||
#endif
|
||||
|
||||
Vendored
+1
-14
@@ -107,13 +107,9 @@ static const char * prefList[] = {
|
||||
|
||||
// Cache sizes, in KB
|
||||
const int32_t DEFAULT_CACHE_SIZE = 250 * 1024; // 250 MB
|
||||
#ifdef ANDROID
|
||||
const int32_t MAX_CACHE_SIZE = 200 * 1024; // 200 MB
|
||||
const int32_t OLD_MAX_CACHE_SIZE = 200 * 1024; // 200 MB
|
||||
#else
|
||||
const int32_t MAX_CACHE_SIZE = 350 * 1024; // 350 MB
|
||||
const int32_t OLD_MAX_CACHE_SIZE = 1024 * 1024; // 1 GB
|
||||
#endif
|
||||
|
||||
// Default cache size was 50 MB for many years until FF 4:
|
||||
const int32_t PRE_GECKO_2_0_DEFAULT_CACHE_SIZE = 50 * 1024;
|
||||
|
||||
@@ -593,17 +589,8 @@ SmartCacheSize(const uint32_t availKB, bool shouldUseOldMaxSmartSize)
|
||||
avail10MBs = 50;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// On Android, smaller/older devices may have very little storage and
|
||||
// device owners may be sensitive to storage footprint: Use a smaller
|
||||
// percentage of available space and a smaller minimum.
|
||||
|
||||
// 20% of space up to 500 MB (10 MB min)
|
||||
sz10MBs += std::max<uint32_t>(1, static_cast<uint32_t>(avail10MBs * .2));
|
||||
#else
|
||||
// 40% of space up to 500 MB (50 MB min)
|
||||
sz10MBs += std::max<uint32_t>(5, static_cast<uint32_t>(avail10MBs * .4));
|
||||
#endif
|
||||
|
||||
return std::min<uint32_t>(maxSize, sz10MBs * 10 * 1024);
|
||||
}
|
||||
|
||||
Vendored
+3
-27
@@ -235,18 +235,11 @@ nsDeleteDir::DeleteDir(nsIFile *dirIn, bool moveToTrash, uint32_t delay)
|
||||
if (!leaf.Length())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
rv = trash->GetParent(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = dir->MoveToNative(parent, leaf);
|
||||
#else
|
||||
// Important: must rename directory w/o changing parent directory: else on
|
||||
// NTFS we'll wait (with cache lock) while nsIFile's ACL reset walks file
|
||||
// tree: was hanging GUI for *minutes* on large cache dirs.
|
||||
rv = dir->MoveToNative(nullptr, leaf);
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
} else {
|
||||
@@ -269,21 +262,6 @@ nsresult
|
||||
nsDeleteDir::GetTrashDir(nsIFile *target, nsCOMPtr<nsIFile> *result)
|
||||
{
|
||||
nsresult rv;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// Try to use the app cache folder for cache trash on Android
|
||||
char* cachePath = getenv("CACHE_DIRECTORY");
|
||||
if (cachePath) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cachePath),
|
||||
true, getter_AddRefs(*result));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Add a sub folder with the cache folder name
|
||||
nsAutoCString leaf;
|
||||
rv = target->GetNativeLeafName(leaf);
|
||||
(*result)->AppendNative(leaf);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rv = target->Clone(getter_AddRefs(*result));
|
||||
}
|
||||
@@ -318,11 +296,9 @@ nsDeleteDir::RemoveOldTrashes(nsIFile *cacheDir)
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
rv = trash->GetParent(getter_AddRefs(parent));
|
||||
#else
|
||||
|
||||
rv = cacheDir->GetParent(getter_AddRefs(parent));
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
||||
@@ -49,11 +49,7 @@ namespace net {
|
||||
#define kRemoveTrashStartDelay 60000 // in milliseconds
|
||||
#define kSmartSizeUpdateInterval 60000 // in milliseconds
|
||||
|
||||
#ifdef ANDROID
|
||||
const uint32_t kMaxCacheSizeKB = 200*1024; // 200 MB
|
||||
#else
|
||||
const uint32_t kMaxCacheSizeKB = 350*1024; // 350 MB
|
||||
#endif
|
||||
|
||||
bool
|
||||
CacheFileHandle::DispatchRelease()
|
||||
@@ -1280,37 +1276,6 @@ CacheFileIOManager::OnProfile()
|
||||
|
||||
CacheObserver::ParentDirOverride(getter_AddRefs(directory));
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
nsCOMPtr<nsIFile> profilelessDirectory;
|
||||
char* cachePath = getenv("CACHE_DIRECTORY");
|
||||
if (!directory && cachePath && *cachePath) {
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(cachePath),
|
||||
true, getter_AddRefs(directory));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Save this directory as the profileless path.
|
||||
rv = directory->Clone(getter_AddRefs(profilelessDirectory));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Add profile leaf name to the directory name to distinguish
|
||||
// multiple profiles Fennec supports.
|
||||
nsCOMPtr<nsIFile> profD;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
|
||||
getter_AddRefs(profD));
|
||||
|
||||
nsAutoCString leafName;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = profD->GetNativeLeafName(leafName);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = directory->AppendNative(leafName);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
directory = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!directory) {
|
||||
rv = NS_GetSpecialDirectory(NS_APP_CACHE_PARENT_DIR,
|
||||
getter_AddRefs(directory));
|
||||
@@ -1329,15 +1294,6 @@ CacheFileIOManager::OnProfile()
|
||||
// All functions return a clone.
|
||||
ioMan->mCacheDirectory.swap(directory);
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
if (profilelessDirectory) {
|
||||
rv = profilelessDirectory->Append(NS_LITERAL_STRING("cache2"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
ioMan->mCacheProfilelessDirectory.swap(profilelessDirectory);
|
||||
#endif
|
||||
|
||||
if (ioMan->mCacheDirectory) {
|
||||
CacheIndex::Init(ioMan->mCacheDirectory);
|
||||
}
|
||||
@@ -2391,23 +2347,6 @@ void CacheFileIOManager::GetCacheDirectory(nsIFile** result)
|
||||
ioMan->mCacheDirectory->Clone(result);
|
||||
}
|
||||
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
|
||||
// static
|
||||
void CacheFileIOManager::GetProfilelessCacheDirectory(nsIFile** result)
|
||||
{
|
||||
*result = nullptr;
|
||||
|
||||
RefPtr<CacheFileIOManager> ioMan = gInstance;
|
||||
if (!ioMan || !ioMan->mCacheProfilelessDirectory) {
|
||||
return;
|
||||
}
|
||||
|
||||
ioMan->mCacheProfilelessDirectory->Clone(result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// static
|
||||
nsresult
|
||||
CacheFileIOManager::GetEntryInfo(const SHA1Sum::Hash *aHash,
|
||||
@@ -4019,17 +3958,8 @@ SmartCacheSize(const uint32_t availKB)
|
||||
avail10MBs = 50;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// On Android, smaller/older devices may have very little storage and
|
||||
// device owners may be sensitive to storage footprint: Use a smaller
|
||||
// percentage of available space and a smaller minimum.
|
||||
|
||||
// 20% of space up to 500 MB (10 MB min)
|
||||
sz10MBs += std::max<uint32_t>(1, static_cast<uint32_t>(avail10MBs * .2));
|
||||
#else
|
||||
// 40% of space up to 500 MB (50 MB min)
|
||||
sz10MBs += std::max<uint32_t>(5, static_cast<uint32_t>(avail10MBs * .4));
|
||||
#endif
|
||||
|
||||
return std::min<uint32_t>(maxSize, sz10MBs * 10 * 1024);
|
||||
}
|
||||
|
||||
@@ -346,9 +346,6 @@ public:
|
||||
};
|
||||
|
||||
static void GetCacheDirectory(nsIFile** result);
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
static void GetProfilelessCacheDirectory(nsIFile** result);
|
||||
#endif
|
||||
|
||||
// Calls synchronously OnEntryInfo for an entry with the given hash.
|
||||
// Tries to find an existing entry in the service hashtables first, if not
|
||||
@@ -459,13 +456,6 @@ private:
|
||||
bool mShuttingDown;
|
||||
RefPtr<CacheIOThread> mIOThread;
|
||||
nsCOMPtr<nsIFile> mCacheDirectory;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
// On Android we add the active profile directory name between the path
|
||||
// and the 'cache2' leaf name. However, to delete any leftover data from
|
||||
// times before we were doing it, we still need to access the directory
|
||||
// w/o the profile name in the path. Here it is stored.
|
||||
nsCOMPtr<nsIFile> mCacheProfilelessDirectory;
|
||||
#endif
|
||||
bool mTreeCreated;
|
||||
bool mTreeCreationFailed;
|
||||
CacheFileHandles mHandles;
|
||||
|
||||
@@ -569,17 +569,11 @@ private:
|
||||
{
|
||||
nsCacheService::GetDiskCacheDirectory(getter_AddRefs(mCache1Dir));
|
||||
CacheFileIOManager::GetCacheDirectory(getter_AddRefs(mCache2Dir));
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
CacheFileIOManager::GetProfilelessCacheDirectory(getter_AddRefs(mCache2Profileless));
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~CleaupCacheDirectoriesRunnable() {}
|
||||
uint32_t mVersion, mActive;
|
||||
nsCOMPtr<nsIFile> mCache1Dir, mCache2Dir;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
nsCOMPtr<nsIFile> mCache2Profileless;
|
||||
#endif
|
||||
};
|
||||
|
||||
// static
|
||||
@@ -613,13 +607,6 @@ NS_IMETHODIMP CleaupCacheDirectoriesRunnable::Run()
|
||||
if (mCache2Dir) {
|
||||
nsDeleteDir::RemoveOldTrashes(mCache2Dir);
|
||||
}
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
if (mCache2Profileless) {
|
||||
nsDeleteDir::RemoveOldTrashes(mCache2Profileless);
|
||||
// Always delete the profileless cache on Android
|
||||
nsDeleteDir::DeleteDir(mCache2Profileless, true, 30000);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Delete the non-active version cache data right now
|
||||
if (mVersion == mActive) {
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["MulticastDNS"];
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
var log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.d.bind(null, "MulticastDNS");
|
||||
|
||||
const FAILURE_INTERNAL_ERROR = -65537;
|
||||
|
||||
// Helper function for sending commands to Java.
|
||||
function send(type, data, callback) {
|
||||
let msg = {
|
||||
type: type
|
||||
};
|
||||
|
||||
for (let i in data) {
|
||||
try {
|
||||
msg[i] = data[i];
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
Messaging.sendRequestForResult(msg)
|
||||
.then(result => callback(result, null),
|
||||
err => callback(null, typeof err === "number" ? err : FAILURE_INTERNAL_ERROR));
|
||||
}
|
||||
|
||||
// Receives service found/lost event from NsdManager
|
||||
function ServiceManager() {
|
||||
}
|
||||
|
||||
ServiceManager.prototype = {
|
||||
listeners: {},
|
||||
numListeners: 0,
|
||||
|
||||
registerEvent: function() {
|
||||
log("registerEvent");
|
||||
Messaging.addListener(this.onServiceFound.bind(this), "NsdManager:ServiceFound");
|
||||
Messaging.addListener(this.onServiceLost.bind(this), "NsdManager:ServiceLost");
|
||||
},
|
||||
|
||||
unregisterEvent: function() {
|
||||
log("unregisterEvent");
|
||||
Messaging.removeListener("NsdManager:ServiceFound");
|
||||
Messaging.removeListener("NsdManager:ServiceLost");
|
||||
},
|
||||
|
||||
addListener: function(aServiceType, aListener) {
|
||||
log("addListener: " + aServiceType + ", " + aListener);
|
||||
|
||||
if (!this.listeners[aServiceType]) {
|
||||
this.listeners[aServiceType] = [];
|
||||
}
|
||||
if (this.listeners[aServiceType].includes(aListener)) {
|
||||
log("listener already exists");
|
||||
return;
|
||||
}
|
||||
|
||||
this.listeners[aServiceType].push(aListener);
|
||||
++this.numListeners;
|
||||
|
||||
if (this.numListeners === 1) {
|
||||
this.registerEvent();
|
||||
}
|
||||
|
||||
log("listener added: " + this);
|
||||
},
|
||||
|
||||
removeListener: function(aServiceType, aListener) {
|
||||
log("removeListener: " + aServiceType + ", " + aListener);
|
||||
|
||||
if (!this.listeners[aServiceType]) {
|
||||
log("listener doesn't exist");
|
||||
return;
|
||||
}
|
||||
let index = this.listeners[aServiceType].indexOf(aListener);
|
||||
if (index < 0) {
|
||||
log("listener doesn't exist");
|
||||
return;
|
||||
}
|
||||
|
||||
this.listeners[aServiceType].splice(index, 1);
|
||||
--this.numListeners;
|
||||
|
||||
if (this.numListeners === 0) {
|
||||
this.unregisterEvent();
|
||||
}
|
||||
|
||||
log("listener removed" + this);
|
||||
},
|
||||
|
||||
onServiceFound: function(aServiceInfo) {
|
||||
let listeners = this.listeners[aServiceInfo.serviceType];
|
||||
if (listeners) {
|
||||
for (let listener of listeners) {
|
||||
listener.onServiceFound(aServiceInfo);
|
||||
}
|
||||
} else {
|
||||
log("no listener");
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
onServiceLost: function(aServiceInfo) {
|
||||
let listeners = this.listeners[aServiceInfo.serviceType];
|
||||
if (listeners) {
|
||||
for (let listener of listeners) {
|
||||
listener.onServiceLost(aServiceInfo);
|
||||
}
|
||||
} else {
|
||||
log("no listener");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
// make an object from nsIPropertyBag2
|
||||
function parsePropertyBag2(bag) {
|
||||
if (!bag || !(bag instanceof Ci.nsIPropertyBag2)) {
|
||||
throw new TypeError("Not a property bag");
|
||||
}
|
||||
|
||||
let attributes = [];
|
||||
let enumerator = bag.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let name = enumerator.getNext().QueryInterface(Ci.nsIProperty).name;
|
||||
let value = bag.getPropertyAsACString(name);
|
||||
attributes.push({
|
||||
"name": name,
|
||||
"value": value
|
||||
});
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
function MulticastDNS() {
|
||||
this.serviceManager = new ServiceManager();
|
||||
}
|
||||
|
||||
MulticastDNS.prototype = {
|
||||
startDiscovery: function(aServiceType, aListener) {
|
||||
this.serviceManager.addListener(aServiceType, aListener);
|
||||
|
||||
let serviceInfo = {
|
||||
serviceType: aServiceType,
|
||||
uniqueId: aListener.uuid
|
||||
};
|
||||
|
||||
send("NsdManager:DiscoverServices", serviceInfo, (result, err) => {
|
||||
if (err) {
|
||||
log("onStartDiscoveryFailed: " + aServiceType + " (" + err + ")");
|
||||
this.serviceManager.removeListener(aServiceType, aListener);
|
||||
aListener.onStartDiscoveryFailed(aServiceType, err);
|
||||
} else {
|
||||
aListener.onDiscoveryStarted(result);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
stopDiscovery: function(aServiceType, aListener) {
|
||||
this.serviceManager.removeListener(aServiceType, aListener);
|
||||
|
||||
let serviceInfo = {
|
||||
uniqueId: aListener.uuid
|
||||
};
|
||||
|
||||
send("NsdManager:StopServiceDiscovery", serviceInfo, (result, err) => {
|
||||
if (err) {
|
||||
log("onStopDiscoveryFailed: " + aServiceType + " (" + err + ")");
|
||||
aListener.onStopDiscoveryFailed(aServiceType, err);
|
||||
} else {
|
||||
aListener.onDiscoveryStopped(aServiceType);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
registerService: function(aServiceInfo, aListener) {
|
||||
let serviceInfo = {
|
||||
port: aServiceInfo.port,
|
||||
serviceType: aServiceInfo.serviceType,
|
||||
uniqueId: aListener.uuid
|
||||
};
|
||||
|
||||
try {
|
||||
serviceInfo.host = aServiceInfo.host;
|
||||
} catch(e) {
|
||||
// host unspecified
|
||||
}
|
||||
try {
|
||||
serviceInfo.serviceName = aServiceInfo.serviceName;
|
||||
} catch(e) {
|
||||
// serviceName unspecified
|
||||
}
|
||||
try {
|
||||
serviceInfo.attributes = parsePropertyBag2(aServiceInfo.attributes);
|
||||
} catch(e) {
|
||||
// attributes unspecified
|
||||
}
|
||||
|
||||
send("NsdManager:RegisterService", serviceInfo, (result, err) => {
|
||||
if (err) {
|
||||
log("onRegistrationFailed: (" + err + ")");
|
||||
aListener.onRegistrationFailed(aServiceInfo, err);
|
||||
} else {
|
||||
aListener.onServiceRegistered(result);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
unregisterService: function(aServiceInfo, aListener) {
|
||||
let serviceInfo = {
|
||||
uniqueId: aListener.uuid
|
||||
};
|
||||
|
||||
send("NsdManager:UnregisterService", serviceInfo, (result, err) => {
|
||||
if (err) {
|
||||
log("onUnregistrationFailed: (" + err + ")");
|
||||
aListener.onUnregistrationFailed(aServiceInfo, err);
|
||||
} else {
|
||||
aListener.onServiceUnregistered(aServiceInfo);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
resolveService: function(aServiceInfo, aListener) {
|
||||
send("NsdManager:ResolveService", aServiceInfo, (result, err) => {
|
||||
if (err) {
|
||||
log("onResolveFailed: (" + err + ")");
|
||||
aListener.onResolveFailed(aServiceInfo, err);
|
||||
} else {
|
||||
aListener.onServiceResolved(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -31,11 +31,6 @@ else:
|
||||
'fallback/MulticastDNS.jsm',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
EXTRA_JS_MODULES += [
|
||||
'MulticastDNSAndroid.jsm',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsDNSServiceInfo.cpp',
|
||||
'nsMulticastDNSModule.cpp',
|
||||
|
||||
@@ -5,17 +5,9 @@
|
||||
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
let { PlatformInfo } = ExtensionUtils;
|
||||
|
||||
if (PlatformInfo.os == "android" && !Services.prefs.getBoolPref("network.mdns.use_js_fallback")) {
|
||||
Cu.import("resource://gre/modules/MulticastDNSAndroid.jsm");
|
||||
} else {
|
||||
Cu.import("resource://gre/modules/MulticastDNS.jsm");
|
||||
}
|
||||
Cu.import("resource://gre/modules/MulticastDNS.jsm");
|
||||
|
||||
const DNSSERVICEDISCOVERY_CID = Components.ID("{f9346d98-f27a-4e89-b744-493843416480}");
|
||||
const DNSSERVICEDISCOVERY_CONTRACT_ID = "@mozilla.org/toolkit/components/mdnsresponder/dns-sd;1";
|
||||
|
||||
@@ -1,301 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "AndroidCaptureProvider.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsMemory.h"
|
||||
#include "RawStructs.h"
|
||||
|
||||
// The maximum number of frames we keep in our queue. Don't live in the past.
|
||||
#define MAX_FRAMES_QUEUED 10
|
||||
|
||||
using namespace mozilla::net;
|
||||
|
||||
NS_IMPL_ISUPPORTS(AndroidCameraInputStream, nsIInputStream, nsIAsyncInputStream)
|
||||
|
||||
AndroidCameraInputStream::AndroidCameraInputStream() :
|
||||
mWidth(0), mHeight(0), mCamera(0), mHeaderSent(false), mClosed(true), mFrameSize(0),
|
||||
mMonitor("AndroidCamera.Monitor")
|
||||
{
|
||||
mAvailable = sizeof(RawVideoHeader);
|
||||
mFrameQueue = new nsDeque();
|
||||
}
|
||||
|
||||
AndroidCameraInputStream::~AndroidCameraInputStream() {
|
||||
// clear the frame queue
|
||||
while (mFrameQueue->GetSize() > 0) {
|
||||
free(mFrameQueue->PopFront());
|
||||
}
|
||||
delete mFrameQueue;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AndroidCameraInputStream::Init(nsACString& aContentType, nsCaptureParams* aParams)
|
||||
{
|
||||
if (!XRE_IsParentProcess())
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
mContentType = aContentType;
|
||||
mWidth = aParams->width;
|
||||
mHeight = aParams->height;
|
||||
mCamera = aParams->camera;
|
||||
|
||||
CameraStreamImpl *impl = CameraStreamImpl::GetInstance(0);
|
||||
if (!impl)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (impl->Init(mContentType, mCamera, mWidth, mHeight, this)) {
|
||||
mWidth = impl->GetWidth();
|
||||
mHeight = impl->GetHeight();
|
||||
mClosed = false;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void AndroidCameraInputStream::ReceiveFrame(char* frame, uint32_t length) {
|
||||
{
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor);
|
||||
if (mFrameQueue->GetSize() > MAX_FRAMES_QUEUED) {
|
||||
free(mFrameQueue->PopFront());
|
||||
mAvailable -= mFrameSize;
|
||||
}
|
||||
}
|
||||
|
||||
mFrameSize = sizeof(RawPacketHeader) + length;
|
||||
|
||||
char* fullFrame = (char*)moz_xmalloc(mFrameSize);
|
||||
|
||||
if (!fullFrame)
|
||||
return;
|
||||
|
||||
RawPacketHeader* header = (RawPacketHeader*) fullFrame;
|
||||
header->packetID = 0xFF;
|
||||
header->codecID = 0x595556; // "YUV"
|
||||
|
||||
// we copy the Y plane, and de-interlace the CrCb
|
||||
|
||||
uint32_t yFrameSize = mWidth * mHeight;
|
||||
uint32_t uvFrameSize = yFrameSize / 4;
|
||||
|
||||
memcpy(fullFrame + sizeof(RawPacketHeader), frame, yFrameSize);
|
||||
|
||||
char* uFrame = fullFrame + yFrameSize;
|
||||
char* vFrame = fullFrame + yFrameSize + uvFrameSize;
|
||||
char* yFrame = frame + yFrameSize;
|
||||
for (uint32_t i = 0; i < uvFrameSize; i++) {
|
||||
uFrame[i] = yFrame[2 * i + 1];
|
||||
vFrame[i] = yFrame[2 * i];
|
||||
}
|
||||
|
||||
{
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor);
|
||||
mAvailable += mFrameSize;
|
||||
mFrameQueue->Push((void*)fullFrame);
|
||||
}
|
||||
|
||||
NotifyListeners();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AndroidCameraInputStream::Available(uint64_t *aAvailable)
|
||||
{
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor);
|
||||
|
||||
*aAvailable = mAvailable;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::IsNonBlocking(bool *aNonBlock) {
|
||||
*aNonBlock = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::Read(char *aBuffer, uint32_t aCount, uint32_t *aRead) {
|
||||
return ReadSegments(NS_CopySegmentToBuffer, aBuffer, aCount, aRead);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::ReadSegments(nsWriteSegmentFun aWriter, void *aClosure, uint32_t aCount, uint32_t *aRead) {
|
||||
*aRead = 0;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (mAvailable == 0)
|
||||
return NS_BASE_STREAM_WOULD_BLOCK;
|
||||
|
||||
if (aCount > mAvailable)
|
||||
aCount = mAvailable;
|
||||
|
||||
if (!mHeaderSent) {
|
||||
CameraStreamImpl *impl = CameraStreamImpl::GetInstance(0);
|
||||
RawVideoHeader header;
|
||||
header.headerPacketID = 0;
|
||||
header.codecID = 0x595556; // "YUV"
|
||||
header.majorVersion = 0;
|
||||
header.minorVersion = 1;
|
||||
header.options = 1 | 1 << 1; // color, 4:2:2
|
||||
|
||||
header.alphaChannelBpp = 0;
|
||||
header.lumaChannelBpp = 8;
|
||||
header.chromaChannelBpp = 4;
|
||||
header.colorspace = 1;
|
||||
|
||||
header.frameWidth = mWidth;
|
||||
header.frameHeight = mHeight;
|
||||
header.aspectNumerator = 1;
|
||||
header.aspectDenominator = 1;
|
||||
|
||||
header.framerateNumerator = impl->GetFps();
|
||||
header.framerateDenominator = 1;
|
||||
|
||||
rv = aWriter(this, aClosure, (const char*)&header, 0, sizeof(RawVideoHeader), aRead);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
mHeaderSent = true;
|
||||
aCount -= sizeof(RawVideoHeader);
|
||||
mAvailable -= sizeof(RawVideoHeader);
|
||||
}
|
||||
|
||||
{
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor);
|
||||
while ((mAvailable > 0) && (aCount >= mFrameSize)) {
|
||||
uint32_t readThisTime = 0;
|
||||
|
||||
char* frame = (char*)mFrameQueue->PopFront();
|
||||
rv = aWriter(this, aClosure, (const char*)frame, *aRead, mFrameSize, &readThisTime);
|
||||
|
||||
if (readThisTime != mFrameSize) {
|
||||
mFrameQueue->PushFront((void*)frame);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// RawReader does a copy when calling VideoData::Create()
|
||||
free(frame);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
aCount -= readThisTime;
|
||||
mAvailable -= readThisTime;
|
||||
*aRead += readThisTime;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::Close() {
|
||||
return CloseWithStatus(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* must be called on the main (java) thread
|
||||
*/
|
||||
void AndroidCameraInputStream::doClose() {
|
||||
NS_ASSERTION(!mClosed, "Camera is already closed");
|
||||
|
||||
CameraStreamImpl *impl = CameraStreamImpl::GetInstance(0);
|
||||
impl->Close();
|
||||
mClosed = true;
|
||||
}
|
||||
|
||||
|
||||
void AndroidCameraInputStream::NotifyListeners() {
|
||||
mozilla::ReentrantMonitorAutoEnter autoMonitor(mMonitor);
|
||||
|
||||
if (mCallback && (mAvailable > sizeof(RawVideoHeader))) {
|
||||
nsCOMPtr<nsIInputStreamCallback> callback;
|
||||
if (mCallbackTarget) {
|
||||
callback = NS_NewInputStreamReadyEvent(mCallback, mCallbackTarget);
|
||||
} else {
|
||||
callback = mCallback;
|
||||
}
|
||||
|
||||
NS_ASSERTION(callback, "Shouldn't fail to make the callback!");
|
||||
|
||||
// Null the callback first because OnInputStreamReady may reenter AsyncWait
|
||||
mCallback = nullptr;
|
||||
mCallbackTarget = nullptr;
|
||||
|
||||
callback->OnInputStreamReady(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::AsyncWait(nsIInputStreamCallback *aCallback, uint32_t aFlags, uint32_t aRequestedCount, nsIEventTarget *aTarget)
|
||||
{
|
||||
if (aFlags != 0)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
if (mCallback || mCallbackTarget)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
mCallbackTarget = aTarget;
|
||||
mCallback = aCallback;
|
||||
|
||||
// What we are being asked for may be present already
|
||||
NotifyListeners();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP AndroidCameraInputStream::CloseWithStatus(nsresult status)
|
||||
{
|
||||
AndroidCameraInputStream::doClose();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* AndroidCaptureProvider implementation
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS0(AndroidCaptureProvider)
|
||||
|
||||
AndroidCaptureProvider* AndroidCaptureProvider::sInstance = nullptr;
|
||||
|
||||
AndroidCaptureProvider::AndroidCaptureProvider() {
|
||||
}
|
||||
|
||||
AndroidCaptureProvider::~AndroidCaptureProvider() {
|
||||
AndroidCaptureProvider::sInstance = nullptr;
|
||||
}
|
||||
|
||||
nsresult AndroidCaptureProvider::Init(nsACString& aContentType,
|
||||
nsCaptureParams* aParams,
|
||||
nsIInputStream** aStream) {
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aParams);
|
||||
|
||||
NS_ASSERTION(aParams->frameLimit == 0 || aParams->timeLimit == 0,
|
||||
"Cannot set both a frame limit and a time limit!");
|
||||
|
||||
RefPtr<AndroidCameraInputStream> stream;
|
||||
|
||||
if (aContentType.EqualsLiteral("video/x-raw-yuv")) {
|
||||
stream = new AndroidCameraInputStream();
|
||||
if (stream) {
|
||||
nsresult rv = stream->Init(aContentType, aParams);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
NS_NOTREACHED("Should not have asked Android for this type!");
|
||||
}
|
||||
stream.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<AndroidCaptureProvider> GetAndroidCaptureProvider() {
|
||||
if (!AndroidCaptureProvider::sInstance) {
|
||||
AndroidCaptureProvider::sInstance = new AndroidCaptureProvider();
|
||||
}
|
||||
RefPtr<AndroidCaptureProvider> ret = AndroidCaptureProvider::sInstance;
|
||||
return ret.forget();
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef AndroidDeviceCaptureProvide_h_
|
||||
#define AndroidDeviceCaptureProvide_h_
|
||||
|
||||
#include "nsDeviceCaptureProvider.h"
|
||||
#include "nsIAsyncInputStream.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/net/CameraStreamImpl.h"
|
||||
#include "nsIEventTarget.h"
|
||||
#include "nsDeque.h"
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
|
||||
class AndroidCaptureProvider final : public nsDeviceCaptureProvider {
|
||||
private:
|
||||
~AndroidCaptureProvider();
|
||||
|
||||
public:
|
||||
AndroidCaptureProvider();
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
MOZ_MUST_USE nsresult Init(nsACString& aContentType, nsCaptureParams* aParams, nsIInputStream** aStream) override;
|
||||
static AndroidCaptureProvider* sInstance;
|
||||
};
|
||||
|
||||
class AndroidCameraInputStream final : public nsIAsyncInputStream, mozilla::net::CameraStreamImpl::FrameCallback {
|
||||
private:
|
||||
~AndroidCameraInputStream();
|
||||
|
||||
public:
|
||||
AndroidCameraInputStream();
|
||||
|
||||
NS_IMETHODIMP Init(nsACString& aContentType, nsCaptureParams* aParams);
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
NS_DECL_NSIASYNCINPUTSTREAM
|
||||
|
||||
void ReceiveFrame(char* frame, uint32_t length) override;
|
||||
|
||||
protected:
|
||||
void NotifyListeners();
|
||||
void doClose();
|
||||
|
||||
uint32_t mAvailable;
|
||||
nsCString mContentType;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
uint32_t mCamera;
|
||||
bool mHeaderSent;
|
||||
bool mClosed;
|
||||
nsDeque *mFrameQueue;
|
||||
uint32_t mFrameSize;
|
||||
mozilla::ReentrantMonitor mMonitor;
|
||||
|
||||
nsCOMPtr<nsIInputStreamCallback> mCallback;
|
||||
nsCOMPtr<nsIEventTarget> mCallbackTarget;
|
||||
};
|
||||
|
||||
already_AddRefed<AndroidCaptureProvider> GetAndroidCaptureProvider();
|
||||
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "CameraStreamImpl.h"
|
||||
#include "GeneratedJNINatives.h"
|
||||
#include "nsCRTGlue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
static CameraStreamImpl* mCamera0 = nullptr;
|
||||
static CameraStreamImpl* mCamera1 = nullptr;
|
||||
|
||||
class CameraStreamImpl::Callback
|
||||
: public java::GeckoAppShell::CameraCallback::Natives<Callback>
|
||||
{
|
||||
public:
|
||||
static void OnFrameData(int32_t aCamera, jni::ByteArray::Param aData)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CameraStreamImpl* impl = GetInstance(uint32_t(aCamera));
|
||||
if (impl) {
|
||||
impl->TransmitFrame(aData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* CameraStreamImpl
|
||||
*/
|
||||
|
||||
void CameraStreamImpl::TransmitFrame(jni::ByteArray::Param aData) {
|
||||
if (!mCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
JNIEnv* const env = jni::GetGeckoThreadEnv();
|
||||
const size_t length = size_t(env->GetArrayLength(aData.Get()));
|
||||
|
||||
if (!length) {
|
||||
return;
|
||||
}
|
||||
|
||||
jbyte* const data = env->GetByteArrayElements(aData.Get(), nullptr);
|
||||
mCallback->ReceiveFrame(reinterpret_cast<char*>(data), length);
|
||||
env->ReleaseByteArrayElements(aData.Get(), data, JNI_ABORT);
|
||||
}
|
||||
|
||||
CameraStreamImpl* CameraStreamImpl::GetInstance(uint32_t aCamera) {
|
||||
CameraStreamImpl* res = nullptr;
|
||||
switch(aCamera) {
|
||||
case 0:
|
||||
if (mCamera0)
|
||||
res = mCamera0;
|
||||
else
|
||||
res = mCamera0 = new CameraStreamImpl(aCamera);
|
||||
break;
|
||||
case 1:
|
||||
if (mCamera1)
|
||||
res = mCamera1;
|
||||
else
|
||||
res = mCamera1 = new CameraStreamImpl(aCamera);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
CameraStreamImpl::CameraStreamImpl(uint32_t aCamera) :
|
||||
mInit(false), mCamera(aCamera)
|
||||
{
|
||||
NS_WARNING("CameraStreamImpl::CameraStreamImpl()");
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
mFps = 0;
|
||||
}
|
||||
|
||||
CameraStreamImpl::~CameraStreamImpl()
|
||||
{
|
||||
NS_WARNING("CameraStreamImpl::~CameraStreamImpl()");
|
||||
}
|
||||
|
||||
bool CameraStreamImpl::Init(const nsCString& contentType, const uint32_t& camera, const uint32_t& width, const uint32_t& height, FrameCallback* aCallback)
|
||||
{
|
||||
mCallback = aCallback;
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
Callback::Init();
|
||||
jni::IntArray::LocalRef retArray = java::GeckoAppShell::InitCamera(
|
||||
contentType, int32_t(camera), int32_t(width), int32_t(height));
|
||||
nsTArray<int32_t> ret = retArray->GetElements();
|
||||
|
||||
mWidth = uint32_t(ret[1]);
|
||||
mHeight = uint32_t(ret[2]);
|
||||
mFps = uint32_t(ret[3]);
|
||||
|
||||
return !!ret[0];
|
||||
}
|
||||
|
||||
void CameraStreamImpl::Close() {
|
||||
java::GeckoAppShell::CloseCamera();
|
||||
mCallback = nullptr;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
@@ -1,71 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __CAMERASTREAMIMPL_H__
|
||||
#define __CAMERASTREAMIMPL_H__
|
||||
|
||||
#include "mozilla/jni/Refs.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* This singleton class handles communication with the Android camera
|
||||
* through JNI. It is used by the IPDL parent or directly from the chrome process
|
||||
*/
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
class CameraStreamImpl {
|
||||
public:
|
||||
class FrameCallback {
|
||||
public:
|
||||
virtual void ReceiveFrame(char* frame, uint32_t length) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* instance bound to a given camera
|
||||
*/
|
||||
static CameraStreamImpl* GetInstance(uint32_t aCamera);
|
||||
|
||||
bool initNeeded() {
|
||||
return !mInit;
|
||||
}
|
||||
|
||||
FrameCallback* GetFrameCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool Init(const nsCString& contentType, const uint32_t& camera, const uint32_t& width, const uint32_t& height, FrameCallback* callback);
|
||||
void Close();
|
||||
|
||||
uint32_t GetWidth() { return mWidth; }
|
||||
uint32_t GetHeight() { return mHeight; }
|
||||
uint32_t GetFps() { return mFps; }
|
||||
|
||||
void takePicture(const nsAString& aFileName);
|
||||
|
||||
private:
|
||||
class Callback;
|
||||
|
||||
CameraStreamImpl(uint32_t aCamera);
|
||||
CameraStreamImpl(const CameraStreamImpl&);
|
||||
CameraStreamImpl& operator=(const CameraStreamImpl&);
|
||||
|
||||
~CameraStreamImpl();
|
||||
|
||||
void TransmitFrame(jni::ByteArray::Param aData);
|
||||
|
||||
bool mInit;
|
||||
uint32_t mCamera;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
uint32_t mFps;
|
||||
FrameCallback* mCallback;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
||||
@@ -4,15 +4,6 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
EXPORTS.mozilla.net += [
|
||||
'CameraStreamImpl.h',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'AndroidCaptureProvider.cpp',
|
||||
'CameraStreamImpl.cpp',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsDeviceChannel.cpp',
|
||||
'nsDeviceProtocolHandler.cpp',
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
#include "nsDeviceChannel.h"
|
||||
#include "nsDeviceCaptureProvider.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "AndroidCaptureProvider.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
// Copied from image/decoders/icon/nsIconURI.cpp
|
||||
@@ -112,9 +107,6 @@ nsDeviceChannel::OpenContentStream(bool aAsync,
|
||||
extractAttributeValue(spec.get(), "camera=", buffer);
|
||||
captureParams.camera = buffer.ToInteger(&err);
|
||||
captureParams.bpp = 32;
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
capture = GetAndroidCaptureProvider();
|
||||
#endif
|
||||
} else if (kNotFound != spec.Find(NS_LITERAL_CSTRING("type=video/x-raw-yuv"),
|
||||
true,
|
||||
0,
|
||||
@@ -138,11 +130,6 @@ nsDeviceChannel::OpenContentStream(bool aAsync,
|
||||
captureParams.bpp = 32;
|
||||
captureParams.timeLimit = 0;
|
||||
captureParams.frameLimit = 60000;
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// only enable if "device.camera.enabled" is true.
|
||||
if (Preferences::GetBool("device.camera.enabled", false) == true)
|
||||
capture = GetAndroidCaptureProvider();
|
||||
#endif
|
||||
} else {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@@ -143,14 +143,9 @@ this.UserAgentUpdates = {
|
||||
// try to load next one if the previous load failed
|
||||
return prevLoad ? prevLoad.then(null, tryNext) : tryNext();
|
||||
}, null).then(null, (ex) => {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Make one last attempt to read from the Fennec APK root.
|
||||
return readChannel("resource://android/" + FILE_UPDATES);
|
||||
#else
|
||||
// All previous (non-Android) load attempts have failed, so we bail.
|
||||
// All previous load attempts have failed, so we bail.
|
||||
throw new Error("UserAgentUpdates: Failed to load " + FILE_UPDATES +
|
||||
ex + "\n" + ex.stack);
|
||||
#endif
|
||||
}).then((update) => {
|
||||
// Apply update if loading was successful
|
||||
this._applyUpdate(update);
|
||||
|
||||
@@ -127,30 +127,6 @@ NewURI(const nsACString &aSpec,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
static nsCString
|
||||
GetDeviceModelId() {
|
||||
// Assumed to be running on the main thread
|
||||
// We need the device property in either case
|
||||
nsAutoCString deviceModelId;
|
||||
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService("@mozilla.org/system-info;1");
|
||||
MOZ_ASSERT(infoService, "Could not find a system info service");
|
||||
nsAutoString androidDevice;
|
||||
nsresult rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("device"), androidDevice);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
deviceModelId = NS_LossyConvertUTF16toASCII(androidDevice);
|
||||
}
|
||||
nsAutoCString deviceString;
|
||||
rv = Preferences::GetCString(UA_PREF("device_string"), &deviceString);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
deviceString.Trim(" ", true, true);
|
||||
deviceString.ReplaceSubstring(NS_LITERAL_CSTRING("%DEVICEID%"), deviceModelId);
|
||||
return deviceString;
|
||||
}
|
||||
return deviceModelId;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpHandler <public>
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -792,9 +768,7 @@ nsHttpHandler::InitUserAgentComponents()
|
||||
#ifndef MOZ_UA_OS_AGNOSTIC
|
||||
// Gather platform.
|
||||
mPlatform.AssignLiteral(
|
||||
#if defined(ANDROID)
|
||||
"Android"
|
||||
#elif defined(XP_WIN)
|
||||
#if defined(XP_WIN)
|
||||
"Windows"
|
||||
#elif defined(XP_MACOSX)
|
||||
"Macintosh"
|
||||
|
||||
@@ -25,9 +25,7 @@ LOCAL_INCLUDES += [
|
||||
|
||||
DEFINES['INET'] = 1
|
||||
DEFINES['SCTP_DEBUG'] = 1
|
||||
|
||||
if CONFIG['OS_TARGET'] != 'Android':
|
||||
DEFINES['INET6'] = 1
|
||||
DEFINES['INET6'] = 1
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'WINNT':
|
||||
DEFINES['__Userspace_os_Windows'] = 1
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef IFADDRS_ANDROID_EXT_H_included
|
||||
#define IFADDRS_ANDROID_EXT_H_included
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
|
||||
// Android (bionic) doesn't have getifaddrs(3)/freeifaddrs(3).
|
||||
// We fake it here, so java_net_NetworkInterface.cpp can use that API
|
||||
// with all the non-portable code being in this file.
|
||||
|
||||
// Source-compatible subset of the BSD struct.
|
||||
typedef struct ifaddrs {
|
||||
// Pointer to next struct in list, or NULL at end.
|
||||
struct ifaddrs* ifa_next;
|
||||
|
||||
// Interface name.
|
||||
char* ifa_name;
|
||||
|
||||
// Interface flags.
|
||||
unsigned int ifa_flags;
|
||||
|
||||
// Interface network address.
|
||||
struct sockaddr* ifa_addr;
|
||||
|
||||
// Interface netmask.
|
||||
struct sockaddr* ifa_netmask;
|
||||
} ifaddrs;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int getifaddrs(ifaddrs** result);
|
||||
void freeifaddrs(ifaddrs* addresses);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // IFADDRS_ANDROID_H_included
|
||||
@@ -1,189 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ifaddrs-android-ext.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ScopedFd.h"
|
||||
#include "LocalArray.h"
|
||||
|
||||
// Returns a pointer to the first byte in the address data (which is
|
||||
// stored in network byte order).
|
||||
uint8_t* sockaddrBytes(int family, sockaddr_storage* ss) {
|
||||
if (family == AF_INET) {
|
||||
sockaddr_in* ss4 = reinterpret_cast<sockaddr_in*>(ss);
|
||||
return reinterpret_cast<uint8_t*>(&ss4->sin_addr);
|
||||
} else if (family == AF_INET6) {
|
||||
sockaddr_in6* ss6 = reinterpret_cast<sockaddr_in6*>(ss);
|
||||
return reinterpret_cast<uint8_t*>(&ss6->sin6_addr);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Sadly, we can't keep the interface index for portability with BSD.
|
||||
// We'll have to keep the name instead, and re-query the index when
|
||||
// we need it later.
|
||||
bool ifa_setNameAndFlagsByIndex(ifaddrs *self, int interfaceIndex) {
|
||||
// Get the name.
|
||||
char buf[IFNAMSIZ];
|
||||
char* name = if_indextoname(interfaceIndex, buf);
|
||||
if (name == NULL) {
|
||||
return false;
|
||||
}
|
||||
self->ifa_name = new char[strlen(name) + 1];
|
||||
strcpy(self->ifa_name, name);
|
||||
|
||||
// Get the flags.
|
||||
ScopedFd fd(socket(AF_INET, SOCK_DGRAM, 0));
|
||||
if (fd.get() == -1) {
|
||||
return false;
|
||||
}
|
||||
ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strcpy(ifr.ifr_name, name);
|
||||
int rc = ioctl(fd.get(), SIOCGIFFLAGS, &ifr);
|
||||
if (rc == -1) {
|
||||
return false;
|
||||
}
|
||||
self->ifa_flags = ifr.ifr_flags;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Netlink gives us the address family in the header, and the
|
||||
// sockaddr_in or sockaddr_in6 bytes as the payload. We need to
|
||||
// stitch the two bits together into the sockaddr that's part of
|
||||
// our portable interface.
|
||||
void ifa_setAddress(ifaddrs *self, int family, void* data, size_t byteCount) {
|
||||
// Set the address proper...
|
||||
sockaddr_storage* ss = new sockaddr_storage;
|
||||
memset(ss, 0, sizeof(*ss));
|
||||
self->ifa_addr = reinterpret_cast<sockaddr*>(ss);
|
||||
ss->ss_family = family;
|
||||
uint8_t* dst = sockaddrBytes(family, ss);
|
||||
memcpy(dst, data, byteCount);
|
||||
}
|
||||
|
||||
// Netlink gives us the prefix length as a bit count. We need to turn
|
||||
// that into a BSD-compatible netmask represented by a sockaddr*.
|
||||
void ifa_setNetmask(ifaddrs *self, int family, size_t prefixLength) {
|
||||
// ...and work out the netmask from the prefix length.
|
||||
sockaddr_storage* ss = new sockaddr_storage;
|
||||
memset(ss, 0, sizeof(*ss));
|
||||
self->ifa_netmask = reinterpret_cast<sockaddr*>(ss);
|
||||
ss->ss_family = family;
|
||||
uint8_t* dst = sockaddrBytes(family, ss);
|
||||
memset(dst, 0xff, prefixLength / 8);
|
||||
if ((prefixLength % 8) != 0) {
|
||||
dst[prefixLength/8] = (0xff << (8 - (prefixLength % 8)));
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: use iovec instead.
|
||||
struct addrReq_struct {
|
||||
nlmsghdr netlinkHeader;
|
||||
ifaddrmsg msg;
|
||||
};
|
||||
|
||||
inline bool sendNetlinkMessage(int fd, const void* data, size_t byteCount) {
|
||||
ssize_t sentByteCount = TEMP_FAILURE_RETRY(send(fd, data, byteCount, 0));
|
||||
return (sentByteCount == static_cast<ssize_t>(byteCount));
|
||||
}
|
||||
|
||||
inline ssize_t recvNetlinkMessage(int fd, char* buf, size_t byteCount) {
|
||||
return TEMP_FAILURE_RETRY(recv(fd, buf, byteCount, 0));
|
||||
}
|
||||
|
||||
// Source-compatible with the BSD function.
|
||||
int getifaddrs(ifaddrs** result)
|
||||
{
|
||||
// Simplify cleanup for callers.
|
||||
*result = NULL;
|
||||
|
||||
// Create a netlink socket.
|
||||
ScopedFd fd(socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE));
|
||||
if (fd.get() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Ask for the address information.
|
||||
addrReq_struct addrRequest;
|
||||
memset(&addrRequest, 0, sizeof(addrRequest));
|
||||
addrRequest.netlinkHeader.nlmsg_flags = NLM_F_REQUEST | NLM_F_MATCH;
|
||||
addrRequest.netlinkHeader.nlmsg_type = RTM_GETADDR;
|
||||
addrRequest.netlinkHeader.nlmsg_len = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(addrRequest)));
|
||||
addrRequest.msg.ifa_family = AF_UNSPEC; // All families.
|
||||
addrRequest.msg.ifa_index = 0; // All interfaces.
|
||||
if (!sendNetlinkMessage(fd.get(), &addrRequest, addrRequest.netlinkHeader.nlmsg_len)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Read the responses.
|
||||
LocalArray<0> buf(65536); // We don't necessarily have std::vector.
|
||||
ssize_t bytesRead;
|
||||
while ((bytesRead = recvNetlinkMessage(fd.get(), &buf[0], buf.size())) > 0) {
|
||||
nlmsghdr* hdr = reinterpret_cast<nlmsghdr*>(&buf[0]);
|
||||
for (; NLMSG_OK(hdr, (size_t)bytesRead); hdr = NLMSG_NEXT(hdr, bytesRead)) {
|
||||
switch (hdr->nlmsg_type) {
|
||||
case NLMSG_DONE:
|
||||
return 0;
|
||||
case NLMSG_ERROR:
|
||||
return -1;
|
||||
case RTM_NEWADDR:
|
||||
{
|
||||
ifaddrmsg* address = reinterpret_cast<ifaddrmsg*>(NLMSG_DATA(hdr));
|
||||
rtattr* rta = IFA_RTA(address);
|
||||
size_t ifaPayloadLength = IFA_PAYLOAD(hdr);
|
||||
while (RTA_OK(rta, ifaPayloadLength)) {
|
||||
if (rta->rta_type == IFA_LOCAL) {
|
||||
int family = address->ifa_family;
|
||||
if (family == AF_INET || family == AF_INET6) {
|
||||
ifaddrs *next = *result;
|
||||
*result = new ifaddrs;
|
||||
memset(*result, 0, sizeof(ifaddrs));
|
||||
(*result)->ifa_next = next;
|
||||
if (!ifa_setNameAndFlagsByIndex(*result, address->ifa_index)) {
|
||||
return -1;
|
||||
}
|
||||
ifa_setAddress(*result, family, RTA_DATA(rta), RTA_PAYLOAD(rta));
|
||||
ifa_setNetmask(*result, family, address->ifa_prefixlen);
|
||||
}
|
||||
}
|
||||
rta = RTA_NEXT(rta, ifaPayloadLength);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We only get here if recv fails before we see a NLMSG_DONE.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Source-compatible with the BSD function.
|
||||
void freeifaddrs(ifaddrs* addresses) {
|
||||
ifaddrs* self = addresses;
|
||||
while (self != NULL) {
|
||||
delete[] self->ifa_name;
|
||||
delete self->ifa_addr;
|
||||
delete self->ifa_netmask;
|
||||
ifaddrs* next = self->ifa_next;
|
||||
delete self;
|
||||
self = next;
|
||||
}
|
||||
}
|
||||
@@ -34,11 +34,6 @@ SOURCES += [
|
||||
'user_socket.c',
|
||||
]
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'Android':
|
||||
SOURCES += [
|
||||
'ifaddrs_android.cpp',
|
||||
]
|
||||
|
||||
Library('nksctp_s')
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
@@ -58,16 +53,11 @@ for var in ('SCTP_SIMPLE_ALLOCATOR',
|
||||
'CALLBACK_API', 'SCTP_DEBUG'):
|
||||
DEFINES[var] = 1
|
||||
|
||||
# Android NDK r5c, used on the builders at the time of this writing, doesn't
|
||||
# have the headers we need for IPv6
|
||||
if CONFIG['OS_TARGET'] != 'Android':
|
||||
DEFINES['INET6'] = 1
|
||||
DEFINES['INET6'] = 1
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'WINNT':
|
||||
DEFINES['__Userspace_os_Windows'] = 1
|
||||
DEFINES['_LIB'] = 1
|
||||
elif CONFIG['OS_TARGET'] == 'Android':
|
||||
DEFINES['__Userspace_os_Linux'] = 1
|
||||
else:
|
||||
DEFINES['__Userspace_os_%s' % CONFIG['OS_TARGET']] = 1
|
||||
|
||||
@@ -75,7 +65,7 @@ if CONFIG['OS_TARGET'] == 'Darwin':
|
||||
DEFINES['__APPLE_USE_RFC_2292'] = 1
|
||||
DEFINES['__APPLE__'] = False
|
||||
|
||||
if CONFIG['OS_TARGET'] in ('Linux', 'Android'):
|
||||
if CONFIG['OS_TARGET'] == 'Linux':
|
||||
# to make sure that in6_pktinfo gets defined on all distros
|
||||
DEFINES['_GNU_SOURCE'] = True
|
||||
|
||||
|
||||
@@ -48,14 +48,10 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 276914 2015-01-10 20:49:57Z
|
||||
#include <netinet/sctp_asconf.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
#include <netinet/sctp_indata.h>
|
||||
#if defined(ANDROID)
|
||||
#include <unistd.h>
|
||||
#include <ifaddrs-android-ext.h>
|
||||
#else
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/unistd.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Declare all of our malloc named types */
|
||||
#ifndef __Panda__
|
||||
|
||||
@@ -495,7 +495,7 @@ struct sx {int dummy;};
|
||||
/* for getifaddrs */
|
||||
#include <sys/types.h>
|
||||
#if !defined(__Userspace_os_Windows)
|
||||
#if !defined(ANDROID) && (defined(INET) || defined(INET6))
|
||||
#if defined(INET) || defined(INET6)
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
SOURCES += [
|
||||
'nsAndroidNetworkLinkService.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
LOCAL_INCLUDES += [
|
||||
'/netwerk/base',
|
||||
]
|
||||
@@ -1,63 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsAndroidNetworkLinkService.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
namespace java = mozilla::java;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsAndroidNetworkLinkService,
|
||||
nsINetworkLinkService)
|
||||
|
||||
nsAndroidNetworkLinkService::nsAndroidNetworkLinkService()
|
||||
{
|
||||
}
|
||||
|
||||
nsAndroidNetworkLinkService::~nsAndroidNetworkLinkService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp)
|
||||
{
|
||||
if (!mozilla::AndroidBridge::Bridge()) {
|
||||
// Fail soft here and assume a connection exists
|
||||
NS_WARNING("GetIsLinkUp is not supported without a bridge connection");
|
||||
*aIsUp = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aIsUp = java::GeckoAppShell::IsNetworkLinkUp();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown)
|
||||
{
|
||||
NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
|
||||
|
||||
*aIsKnown = java::GeckoAppShell::IsNetworkLinkKnown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLinkType);
|
||||
|
||||
if (!mozilla::AndroidBridge::Bridge()) {
|
||||
// Fail soft here and assume a connection exists
|
||||
NS_WARNING("GetLinkType is not supported without a bridge connection");
|
||||
*aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aLinkType = java::GeckoAppShell::GetNetworkLinkType();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef NSANDROIDNETWORKLINKSERVICE_H_
|
||||
#define NSANDROIDNETWORKLINKSERVICE_H_
|
||||
|
||||
#include "nsINetworkLinkService.h"
|
||||
|
||||
class nsAndroidNetworkLinkService: public nsINetworkLinkService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSINETWORKLINKSERVICE
|
||||
|
||||
nsAndroidNetworkLinkService();
|
||||
|
||||
private:
|
||||
virtual ~nsAndroidNetworkLinkService();
|
||||
};
|
||||
|
||||
#endif /* NSANDROIDNETWORKLINKSERVICE_H_ */
|
||||
@@ -6,12 +6,7 @@
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
DIRS += ['win32']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
DIRS += ['mac']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
DIRS += ['android']
|
||||
|
||||
elif CONFIG['OS_ARCH'] == 'Linux':
|
||||
DIRS += ['linux']
|
||||
|
||||
Reference in New Issue
Block a user