Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Convert to packed add-on #40

Merged
merged 3 commits into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
411 changes: 15 additions & 396 deletions .eslintrc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FILES=adb.js adb-*.js bootstrap.js device.js devtools-import.js devtools-require.js events.js fastboot.js main.js scanner.js unload.js
FILES=adb.js adb-*.js binary-manager.js bootstrap.js device.js devtools-import.js devtools-require.js events.js fastboot.js main.js scanner.js unload.js
ADDON_NAME=adbhelper
ADDON_VERSION=0.11.3pre
XPI_NAME=$(ADDON_NAME)-$(ADDON_VERSION)
Expand Down
24 changes: 11 additions & 13 deletions adb-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
* Mostly from original `adb.js`
*/

'use strict';
"use strict";

const { Cu, Cc, Ci } = require("chrome");
const { Cu } = require("chrome");
const { AdbSocket } = require("./adb-socket");

Cu.import("resource://gre/modules/Services.jsm");

// Starting with FF57, jsm share the same global and this require pulling it from it.
const { TextEncoder, TextDecoder } =
Cu.getGlobalForObject(Cu.import("resource://gre/modules/Services.jsm", {}));
Expand Down Expand Up @@ -42,14 +40,14 @@ function unpackPacket(aPacket, aIgnoreResponse) {
let decoder = new TextDecoder();
let length = parseInt(decoder.decode(lengthView), 16);
let text = new Uint8Array(buffer, aIgnoreResponse ? 4 : 8, length);
return { length: length, data: decoder.decode(text) };
return { length, data: decoder.decode(text) };
}

// Checks if the response is expected (defaults to OKAY).
// @return true if response equals expected.
function checkResponse(aPacket, aExpected = OKAY) {
let buffer = getBuffer(aPacket);
let view = new Uint32Array(buffer, 0 , 1);
let view = new Uint32Array(buffer, 0, 1);
if (view[0] == FAIL) {
console.debug("Response: FAIL");
}
Expand All @@ -63,7 +61,7 @@ function checkResponse(aPacket, aExpected = OKAY) {
// @return A 8 bit typed array.
function createRequest(aCommand) {
let length = aCommand.length.toString(16).toUpperCase();
while(length.length < 4) {
while (length.length < 4) {
length = "0" + length;
}

Expand All @@ -85,12 +83,12 @@ function connect() {
}

let client = {
getBuffer: getBuffer,
unpackPacket: unpackPacket,
checkResponse: checkResponse,
createRequest: createRequest,
connect: connect,
close: close
getBuffer,
unpackPacket,
checkResponse,
createRequest,
connect,
close
};

module.exports = client;
11 changes: 5 additions & 6 deletions adb-running-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
* Modified from adb-file-transfer from original ADB
*/

'use strict';

const { Cu, Cc, Ci } = require("chrome");
"use strict";

const { Cu } = require("chrome");
const { PromiseUtils } = Cu.import("resource://gre/modules/PromiseUtils.jsm", {});
const client = require("./adb-client");

Expand All @@ -24,12 +23,12 @@ exports.check = function check() {

let runFSM = function runFSM(aData) {
console.debug("runFSM " + state);
switch(state) {
switch (state) {
case "start":
let req = client.createRequest("host:version");
socket.send(req);
state = "wait-version";
break
break;
case "wait-version":
// TODO: Actually check the version number to make sure the daemon
// supports the commands we want to use
Expand Down Expand Up @@ -60,7 +59,7 @@ exports.check = function check() {
console.debug("running checker onopen");
state = "start";
runFSM();
}
};

socket.s.onclose = function(aEvent) {
console.debug("running checker onclose");
Expand Down
7 changes: 3 additions & 4 deletions adb-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
* 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';
"use strict";

const { Cc, Ci, Cr, Cu } = require("chrome");

Cu.import("resource://gre/modules/Services.jsm");
const { Cu } = require("chrome");
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});

// Starting with FF57, jsm share the same global and this require pulling it from it.
const { TextDecoder } =
Expand Down
Loading