Skip to content

Commit

Permalink
Merge pull request #6 from mozilla/master
Browse files Browse the repository at this point in the history
Merging.
  • Loading branch information
sudheesh001 committed Sep 4, 2013
2 parents 16b96ea + 72f0331 commit f135be5
Show file tree
Hide file tree
Showing 36 changed files with 574 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Expand Up @@ -21,7 +21,7 @@
url = git://github.com/mykmelez/jetpack-subprocess.git
[submodule "addon/packages/gcli"]
path = addon/packages/gcli
url = git://github.com/erikvold/gcli-jplib.git
url = git://github.com/jryans/gcli-jplib.git
[submodule "addon/packages/jsonlint"]
path = addon/packages/jsonlint
url = git://github.com/rpl/jsonlint.git
22 changes: 11 additions & 11 deletions Makefile
Expand Up @@ -47,7 +47,7 @@ B2G_TYPE ?= specific

B2G_URL_BASE = https://ftp.mozilla.org/pub/mozilla.org/labs/r2d2b2g/

LIBADB_VERSION = 0.2
LIBADB_VERSION = 0.3

# The location of libadb for making ADB. Set this variable to "local" to build
# libadb.{so, dll} from source locally. Set to "remote" to grab prebuilt ADB
Expand All @@ -67,7 +67,7 @@ export ADB_AUTH
# Platform-specific Defines
ifeq (win32, $(B2G_PLATFORM))
# The URL of the specific B2G build.
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-07.en-US.win32.zip
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-30.en-US.win32.zip

ADB_PACKAGE = libadb-$(LIBADB_VERSION)-windows.zip
DEPS = AdbWinApi.dll
Expand All @@ -83,7 +83,7 @@ ifeq (win32, $(B2G_PLATFORM))
$(ADB_DRIVERS_DIR)/winusb/objfre_wxp_x86/i386/AdbWinUsbApi$(LIB_SUFFIX)
else
ifeq (mac64, $(B2G_PLATFORM))
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-07.en-US.mac64.dmg
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-30.en-US.mac64.dmg

ADB_PACKAGE = libadb-$(LIBADB_VERSION)-mac.zip
ADB_BINARIES = libadb.so
Expand All @@ -96,7 +96,7 @@ ifeq (mac64, $(B2G_PLATFORM))
DOWNLOAD_CMD = /usr/bin/curl -O
else
ifeq (linux64, $(B2G_PLATFORM))
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-07.en-US.linux-x86_64.tar.bz2
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-30.en-US.linux-x86_64.tar.bz2

ADB_PACKAGE = libadb-$(LIBADB_VERSION)-linux64.zip
ADB_BINARIES = libadb.so
Expand All @@ -107,7 +107,7 @@ ifeq (linux64, $(B2G_PLATFORM))
$(ADB_OUT_DIR)/libtest$(LIB_SUFFIX)
else
ifeq (linux, $(B2G_PLATFORM))
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-07.en-US.linux-i686.tar.bz2
B2G_URL ?= $(B2G_URL_BASE)b2g-18.0.2013-08-30.en-US.linux-i686.tar.bz2

ADB_PACKAGE = libadb-$(LIBADB_VERSION)-linux.zip
ADB_BINARIES = libadb.so
Expand Down Expand Up @@ -177,15 +177,15 @@ clean:
rm -f gaia/build/custom-prefs.js
rm -f gaia/build/custom-settings.json
rm -f $(ADB_PACKAGE)
make -C gaia clean
$(MAKE) -C gaia clean
python build/make-b2g.py $(B2G_TYPE_ARG) $(B2G_PLATFORM_ARG) $(B2G_ID_ARG) $(B2G_URL_ARG) --clean
make -C android-tools clean
$(MAKE) -C android-tools clean

profile:
cp build/override-prefs.js gaia/build/custom-prefs.js
cp build/override-settings.json gaia/build/custom-settings.json
NOFTU=1 GAIA_APP_SRCDIRS=apps make -C gaia
DESKTOP=1 NOFTU=1 GAIA_APP_SRCDIRS=apps make -C gaia preferences
NOFTU=1 GAIA_APP_SRCDIRS=apps $(MAKE) -C gaia
DESKTOP=1 NOFTU=1 GAIA_APP_SRCDIRS=apps $(MAKE) -C gaia preferences
python build/override-webapps.py
cd gaia/tools/extensions/desktop-helper/ && zip -r ../../../profile/extensions/desktop-helper\@gaiamobile.org.xpi *
cd gaia/tools/extensions/activities/ && zip -r ../../../profile/extensions/activities\@gaiamobile.org.xpi *
Expand Down Expand Up @@ -229,8 +229,8 @@ adb:
unzip $(ADB_PACKAGE) -d addon/data/$(B2G_PLATFORM)/adb; \
fi;
if [ "$(LIBADB_LOCATION)" = "local" ]; then \
make -C android-tools lib && \
make -C android-tools driver && \
$(MAKE) -C android-tools lib && \
$(MAKE) -C android-tools driver && \
cp $(ADB_LIBS) $(ADB_DATA_PATH); \
fi;

Expand Down
5 changes: 5 additions & 0 deletions addon/data/content/css/main.css
Expand Up @@ -81,6 +81,11 @@ h1 {
width: 140px;
text-indent: -9999px;
}
@media (min-resolution: 2dppx) {
.wordmark {
background-image: url('../fxos-wordmark@2x.png');
}
}
.badge, .badge:before, .badge:after {
text-align: center;
display: block;
Expand Down
Binary file modified addon/data/content/fxos-wordmark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/data/content/fxos-wordmark@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions addon/lib/adb/adb-device-poll-thread.js
Expand Up @@ -30,18 +30,25 @@ const console = new Console(worker);

const I = new Instantiator;
let libadb = null;
let winusbPath_ = null;
let getLastError = function() { return 0; };
let jsMsgFn = CommonMessageHandler(worker, console, function(channel, args) {
switch(channel) {
case "get-last-error":
return JsMessage.pack(getLastError(), Number);
case "winusbdll-path":
console.log("Got request for winusbdll-path");
return JsMessage.pack(winusbPath_, String);
default:
console.log("Unknown message: " + channel);
}

return JsMessage.pack(-1, Number);
});


worker.once("init", function({ libPath, driversPath, platform }) {
worker.once("init", function({ winusbPath, libPath, driversPath, platform }) {
libadb = ctypes.open(libPath);
winusbPath_ = winusbPath;

let install_js_msg =
I.declare({ name: "install_js_msg",
Expand Down Expand Up @@ -89,13 +96,16 @@ worker.once("init", function({ libPath, driversPath, platform }) {
{ "AdbNextInterface": AdbNextInterfaceType }
];

let [struct_dll_bridge, bridge, ref] = new BridgeBuilder(I, libadbdrivers).build("dll_bridge", bridge_funcs);
let bb = new BridgeBuilder(I, libadbdrivers);
let [struct_dll_bridge, bridge, ref] = bb.build("dll_bridge", bridge_funcs);

I.declare({ name: "usb_monitor",
returns: ctypes.int,
args: [ struct_dll_bridge.ptr ]
}, libadb);

getLastError = bb.getLastError.bind(bb);

I.use("usb_monitor")(bridge.address());
libadbdrivers.close();
} else {
Expand Down
3 changes: 2 additions & 1 deletion addon/lib/adb/adb-server-thread.js
Expand Up @@ -70,7 +70,8 @@ let jsMsgFn = CommonMessageHandler(worker, console, function(channel, args) {
let devicePollWorker = this.newWorker(workerURI, "device_poll_thread");
devicePollWorker.emitAndForget("init", { libPath: context.libPath,
driversPath: context.driversPath,
platform: context.platform });
platform: context.platform,
winusbPath: context.winusbPath });
}, WORKER_URL_DEVICE_POLL);
return JsMessage.pack(0, Number);
default:
Expand Down
2 changes: 1 addition & 1 deletion addon/lib/adb/adb-types.js
Expand Up @@ -56,7 +56,7 @@
const AdbEnumInterfacesType =
ctypes.FunctionType(ctypes.default_abi, ADBAPIHANDLE, [ GUID, bool, bool, bool ]);
const AdbCreateInterfaceByNameType =
ctypes.FunctionType(ctypes.default_abi, ADBAPIHANDLE, [ wchar_t.ptr ]);
ctypes.FunctionType(ctypes.default_abi, ADBAPIHANDLE, [ wchar_t.ptr, wchar_t.ptr ]);
const AdbCreateInterfaceType =
ctypes.FunctionType(ctypes.default_abi, ADBAPIHANDLE, [ GUID, ctypes.uint16_t, ctypes.uint16_t, ctypes.uint8_t ]);
const AdbGetInterfaceNameType =
Expand Down
8 changes: 5 additions & 3 deletions addon/lib/adb/adb.js
Expand Up @@ -61,14 +61,16 @@ if (platform === "winnt") {
throw "Unsupported platform";
}
let libPath = URL.toFilename(self.data.url(platformDir + "/adb/libadb" + extension));
let driversPath = (platform === "winnt") ?
URL.toFilename(self.data.url("win32/adb/AdbWinApi.dll")) : null;
let [driversPath, winusbPath] = (platform === "winnt") ?
[URL.toFilename(self.data.url("win32/adb/AdbWinApi.dll")),
URL.toFilename(self.data.url("win32/adb/AdbWinUsbApi.dll"))] : [null, null];

// the context is used as shared state between EventedChromeWorker runOnPeerThread calls and this module
let context = { __workers: [], // this array is populated automatically by EventedChromeWorker
platform: platform,
driversPath: driversPath,
libPath: libPath
libPath: libPath,
winusbPath: winusbPath
};

const DEVICE_NOT_CONNECTED = "Device not connected";
Expand Down
4 changes: 4 additions & 0 deletions addon/lib/adb/ctypes-bridge-builder.js
Expand Up @@ -7,6 +7,10 @@
*
* where a bridge is defined as simply intercepting function calls from native code
* and re-firing them from a different library
*
*
* TODO: This code could (and probably should) be replaced by calling
* LoadLibrary properly in Windows native code
*/

'use strict';
Expand Down
31 changes: 19 additions & 12 deletions addon/lib/remote-simulator-client.js
Expand Up @@ -30,8 +30,8 @@ const Geolocation = Cc["@mozilla.org/geolocation;1"].getService(Ci.nsISupports);
const DEBUGGER_CONNECT_TIMEOUT = 30000;

// add unsolicited notifications
dbgClient.UnsolicitedNotifications.geolocationStart = "geolocationStart";
dbgClient.UnsolicitedNotifications.geolocationStop = "geolocationStop";
dbgClient.UnsolicitedNotifications.enableRealGeolocation = "enableRealGeolocation";
dbgClient.UnsolicitedNotifications.disableRealGeolocation = "disableRealGeolocation";
dbgClient.UnsolicitedNotifications.appUpdateRequest = "appUpdateRequest";
dbgClient.UnsolicitedNotifications.appOpen = "appOpen";
dbgClient.UnsolicitedNotifications.appClose = "appClose";
Expand Down Expand Up @@ -95,7 +95,9 @@ const RemoteSimulatorClient = Class({
tabs: reply.tabs,
selected: reply.selected,
simulator: reply.simulatorActor,
webapps: reply.simulatorWebappsActor
webapps: reply.simulatorWebappsActor,
geolocation: reply.simulatorGeolocationActor,
geolocationUI: reply.simulatorGeolocationUIActor
});
}).bind(this));
});
Expand All @@ -104,8 +106,11 @@ const RemoteSimulatorClient = Class({
// listeners and emit an high level "ready" event
this.on("clientReady", function (remote) {
console.debug("rsc.onClientReady");
// Needed for Debugger Server to initialize SimulatorActor
// Actors are initialized lazily, so if they have any initialization work
// to perform (set up listeners / observers, etc.), then some message must
// be sent to trigger that process.
remote.client.request({to: remote.simulator, type: "ping"});
remote.client.request({to: remote.geolocationUI, type: "attach"});
this._remote = remote;
// Start watching app open/close
this.client.request({to: this._remote.webapps, type: "watchApps"},
Expand Down Expand Up @@ -252,8 +257,10 @@ const RemoteSimulatorClient = Class({
emit(this, "clientClosed", {client: client});
}).bind(this));

client.addListener("geolocationStart", this.onGeolocationStart.bind(this));
client.addListener("geolocationStop", this.onGeolocationStop.bind(this));
client.addListener("enableRealGeolocation",
this.onEnableRealGeolocation.bind(this));
client.addListener("disableRealGeolocation",
this.onDisableRealGeolocation.bind(this));
client.addListener("appOpen", this.onAppOpen.bind(this));
client.addListener("appClose", this.onAppClose.bind(this));

Expand All @@ -274,8 +281,8 @@ const RemoteSimulatorClient = Class({

_geolocationID: null,

onGeolocationStart: function onGeolocationStart() {
console.log("Firefox received geolocation start request");
onEnableRealGeolocation: function onEnableRealGeolocation() {
console.log("Firefox received enable real geolocation request");

let onSuccess = (function onSuccess(position) {
if (!this._remote) {
Expand All @@ -288,12 +295,12 @@ const RemoteSimulatorClient = Class({
console.log("Firefox sending geolocation response");

this._remote.client.request({
to: this._remote.simulator,
to: this._remote.geolocation,
message: {
lat: position.coords.latitude,
lon: position.coords.longitude,
},
type: "geolocationUpdate"
type: "update"
});
}).bind(this);

Expand All @@ -304,8 +311,8 @@ const RemoteSimulatorClient = Class({
this._geolocationID = Geolocation.watchPosition(onSuccess, onError);
},

onGeolocationStop: function onGeolocationStop() {
console.log("Firefox received geolocation stop request");
onDisableRealGeolocation: function onDisableRealGeolocation() {
console.log("Firefox received disable real geolocation request");
this._stopGeolocation();
},

Expand Down
3 changes: 2 additions & 1 deletion addon/lib/simulator.js
Expand Up @@ -111,7 +111,8 @@ let simulator = module.exports = {
worker.on("message", this.onMessage.bind(this));
worker.on("detach", function(message) {
worker = null;
});
this.unload();
}.bind(this));
worker.on("pageshow", function(message) {
worker = this;
});
Expand Down
4 changes: 3 additions & 1 deletion addon/package.json
@@ -1,7 +1,7 @@
{
"id": "r2d2b2g@mozilla.org",
"name": "r2d2b2g",
"version": "5.0pre4dev",
"version": "5.0pre5dev",
"fullName": "Firefox OS Simulator",
"description": "a Firefox OS simulator",
"author": "Myk Melez (https://github.com/mykmelez)",
Expand All @@ -13,8 +13,10 @@
"César Carruitero (https://github.com/ccarruitero)",
"David Gomes (https://github.com/davidgomes)",
"Fabrice Desré (https://github.com/fabricedesre)",
"Fraser Tweedale (https://github.com/frasertweedale)",
"Harald Kirschner (https://github.com/digitarald)",
"Jérémie Patonnier (https://github.com/JeremiePat)",
"J. Ryan Stinnett (https://github.com/jryans)",
"Kan-Ru Chen (陳侃如) (https://github.com/kanru)",
"Louis Stowasser (https://github.com/louisstow)",
"Luca Greco (https://github.com/rpl)",
Expand Down
24 changes: 14 additions & 10 deletions android-tools/Makefile
Expand Up @@ -4,15 +4,19 @@ else
LIB_TARGET = nixlib
endif

all:
make -C adb-bin
adb:
make -C adb-bin adb
clean:
make -C adb-bin clean
lib:
make -C adb-bin $(LIB_TARGET)
build: lib

driver:
if [ "$(LIB_TARGET)" = "winlib" ]; then \
make -C adb-win-api; \
fi
$(MAKE) -C adb-win-api; \
fi
lib: driver
$(MAKE) -C adb-bin $(LIB_TARGET)
adb: driver
$(MAKE) -C adb-bin adb

clean:
$(MAKE) -C adb-bin clean

package:
$(MAKE) -C adb-bin package

0 comments on commit f135be5

Please sign in to comment.