зеркало из https://github.com/mozilla/gecko-dev.git
Bug 784226 - Support libhardware_legacy and libnetutils on JB, r=vchang
This commit is contained in:
Родитель
c1469f803e
Коммит
f804d996c8
|
@ -202,28 +202,60 @@ this.libnetutils = (function () {
|
|||
let dns2buf = ctypes.char.array(4096)();
|
||||
let serverbuf = ctypes.char.array(4096)();
|
||||
let lease = ctypes.int();
|
||||
let c_dhcp_do_request =
|
||||
library.declare("dhcp_do_request", ctypes.default_abi,
|
||||
ctypes.int, // return value
|
||||
ctypes.char.ptr, // ifname
|
||||
ctypes.char.ptr, // ipaddr
|
||||
ctypes.char.ptr, // gateway
|
||||
ctypes.int.ptr, // prefixlen
|
||||
ctypes.char.ptr, // dns1
|
||||
ctypes.char.ptr, // dns2
|
||||
ctypes.char.ptr, // server
|
||||
ctypes.int.ptr); // lease
|
||||
let vendorbuf = ctypes.char.array(4096)();
|
||||
let c_dhcp_do_request;
|
||||
|
||||
// also changed for 16
|
||||
if (sdkVersion >= 16) {
|
||||
c_dhcp_do_request =
|
||||
library.declare("dhcp_do_request", ctypes.default_abi,
|
||||
ctypes.int, // return value
|
||||
ctypes.char.ptr, // ifname
|
||||
ctypes.char.ptr, // ipaddr
|
||||
ctypes.char.ptr, // gateway
|
||||
ctypes.int.ptr, // prefixlen
|
||||
ctypes.char.ptr, // dns1
|
||||
ctypes.char.ptr, // dns2
|
||||
ctypes.char.ptr, // server
|
||||
ctypes.int.ptr, // lease
|
||||
ctypes.char.ptr); // vendorinfo
|
||||
} else {
|
||||
c_dhcp_do_request =
|
||||
library.declare("dhcp_do_request", ctypes.default_abi,
|
||||
ctypes.int, // return value
|
||||
ctypes.char.ptr, // ifname
|
||||
ctypes.char.ptr, // ipaddr
|
||||
ctypes.char.ptr, // gateway
|
||||
ctypes.int.ptr, // prefixlen
|
||||
ctypes.char.ptr, // dns1
|
||||
ctypes.char.ptr, // dns2
|
||||
ctypes.char.ptr, // server
|
||||
ctypes.int.ptr); // lease
|
||||
}
|
||||
|
||||
|
||||
iface.dhcp_do_request = function dhcp_do_request(ifname) {
|
||||
let ret = c_dhcp_do_request(ifname,
|
||||
ipaddrbuf,
|
||||
gatewaybuf,
|
||||
prefixLen.address(),
|
||||
dns1buf,
|
||||
dns2buf,
|
||||
serverbuf,
|
||||
lease.address());
|
||||
let ret;
|
||||
if (sdkVersion >= 16) {
|
||||
ret = c_dhcp_do_request(ifname,
|
||||
ipaddrbuf,
|
||||
gatewaybuf,
|
||||
prefixLen.address(),
|
||||
dns1buf,
|
||||
dns2buf,
|
||||
serverbuf,
|
||||
lease.address(),
|
||||
vendorbuf);
|
||||
} else {
|
||||
ret = c_dhcp_do_request(ifname,
|
||||
ipaddrbuf,
|
||||
gatewaybuf,
|
||||
prefixLen.address(),
|
||||
dns1buf,
|
||||
dns2buf,
|
||||
serverbuf,
|
||||
lease.address());
|
||||
}
|
||||
|
||||
if (ret && DEBUG) {
|
||||
let error = iface.dhcp_get_errmsg();
|
||||
|
@ -237,7 +269,8 @@ this.libnetutils = (function () {
|
|||
dns1_str: dns1buf.readString(),
|
||||
dns2_str: dns2buf.readString(),
|
||||
server_str: serverbuf.readString(),
|
||||
lease: lease.value | 0
|
||||
lease: lease.value | 0,
|
||||
vendor_str: vendorbuf.readString()
|
||||
};
|
||||
obj.ipaddr = netHelpers.stringToIP(obj.ipaddr_str);
|
||||
obj.mask_str = netHelpers.ipToString(obj.mask);
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
|
||||
let libhardware_legacy = (function () {
|
||||
let library = ctypes.open("libhardware_legacy.so");
|
||||
let sdkVersion = libcutils.property_get("ro.build.version.sdk", "0");
|
||||
sdkVersion = parseInt(sdkVersion, 10);
|
||||
|
||||
return {
|
||||
let iface = {
|
||||
// Load wifi driver, 0 on success, < 0 on failure.
|
||||
load_driver: library.declare("wifi_load_driver", ctypes.default_abi, ctypes.int),
|
||||
|
||||
|
@ -37,4 +39,58 @@ let libhardware_legacy = (function () {
|
|||
// the maximum reply length initially and is updated with the actual length. 0 is returned on success, < 0 on failure.
|
||||
command: library.declare("wifi_command", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.char.ptr, ctypes.size_t.ptr),
|
||||
};
|
||||
|
||||
if (sdkVersion >= 16) {
|
||||
let c_start_supplicant =
|
||||
library.declare("wifi_start_supplicant",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
ctypes.int);
|
||||
iface.start_supplicant = function () {
|
||||
return c_start_supplicant(0);
|
||||
};
|
||||
|
||||
let c_connect_to_supplicant =
|
||||
library.declare("wifi_connect_to_supplicant",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
ctypes.char.ptr);
|
||||
iface.connect_to_supplicant = function () {
|
||||
return c_connect_to_supplicant("wlan0");
|
||||
};
|
||||
|
||||
let c_close_supplicant_connection =
|
||||
library.declare("wifi_close_supplicant_connection",
|
||||
ctypes.default_abi,
|
||||
ctypes.void_t,
|
||||
ctypes.char.ptr);
|
||||
iface.close_supplicant_connection = function () {
|
||||
c_close_supplicant_connection("wlan0");
|
||||
};
|
||||
|
||||
let c_wait_for_event =
|
||||
library.declare("wifi_wait_for_event",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
ctypes.char.ptr,
|
||||
ctypes.char.ptr,
|
||||
ctypes.size_t);
|
||||
iface.wait_for_event = function (cbuf, len) {
|
||||
return c_wait_for_event("wlan0", cbuf, len);
|
||||
};
|
||||
|
||||
let c_command =
|
||||
library.declare("wifi_command",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
ctypes.char.ptr,
|
||||
ctypes.char.ptr,
|
||||
ctypes.char.ptr,
|
||||
ctypes.size_t.ptr);
|
||||
iface.command = function (message, cbuf, len) {
|
||||
return c_command("wlan0", message, cbuf, len);
|
||||
};
|
||||
}
|
||||
|
||||
return iface;
|
||||
})();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
importScripts("libhardware_legacy.js", "systemlibs.js");
|
||||
importScripts("systemlibs.js", "libhardware_legacy.js");
|
||||
|
||||
var cbuf = ctypes.char.array(4096)();
|
||||
var hwaddr = ctypes.uint8_t.array(6)();
|
||||
|
|
Загрузка…
Ссылка в новой задаче