Bug 991589 - Use ro.product.model to identify USB devices. r=jryans

This commit is contained in:
Paul Rouget 2014-07-22 09:08:41 +02:00
parent 8868f0fec4
commit d079299eaa
2 changed files with 22 additions and 2 deletions

View File

@ -533,7 +533,10 @@ exports.AppManager = AppManager = {
_updateUSBRuntimes: function() {
this.runtimeList.usb = [];
for (let id of Devices.available()) {
this.runtimeList.usb.push(new USBRuntime(id));
let r = new USBRuntime(id);
this.runtimeList.usb.push(r);
r.updateNameFromADB().then(
() => this.update("runtimelist"), () => {});
}
this.update("runtimelist");
},

View File

@ -33,7 +33,24 @@ USBRuntime.prototype = {
return this.id;
},
getName: function() {
return this.id;
return this._productModel || this.id;
},
updateNameFromADB: function() {
if (this._productModel) {
return promise.resolve();
}
let device = Devices.getByName(this.id);
let deferred = promise.defer();
if (device && device.shell) {
device.shell("getprop ro.product.model").then(stdout => {
this._productModel = stdout;
deferred.resolve();
}, () => {});
} else {
this._productModel = null;
deferred.reject();
}
return deferred.promise;
},
}