mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-21 05:15:17 +02:00
Update to new device DB.
This commit is contained in:
@@ -5,52 +5,28 @@ var logger = require('./logger')
|
||||
|
||||
var log = logger.createLogger('util:datautil')
|
||||
|
||||
var aliases = {
|
||||
'KYY22': 'L02'
|
||||
, 'SH-06DNERV': 'SH-06D_NERV'
|
||||
}
|
||||
|
||||
var datautil = module.exports = Object.create(null)
|
||||
|
||||
datautil.applyData = function(device) {
|
||||
var model = device.model
|
||||
var name = device.name
|
||||
var match = deviceData.find({
|
||||
model: device.model
|
||||
, name: device.product
|
||||
})
|
||||
|
||||
if (model) {
|
||||
var match = deviceData.find({model: model, name: name})
|
||||
|
||||
if (!match) {
|
||||
if (aliases[model]) {
|
||||
match = deviceData.find({model: aliases[model], name: name})
|
||||
}
|
||||
else {
|
||||
if (!match) {
|
||||
model = model.replace(/ /g, '_')
|
||||
match = deviceData.find({model: model, name: name})
|
||||
|
||||
if (!match) {
|
||||
model = model.replace(/_/g, '')
|
||||
match = deviceData.find({model: model, name: name})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
device.name = match.name.id
|
||||
device.model = match.name.long
|
||||
device.releasedAt = match.date
|
||||
device.image = model + '.jpg' // TODO: check for icon/photo file existence
|
||||
device.cpu = match.cpu
|
||||
device.memory = match.memory
|
||||
}
|
||||
else {
|
||||
log.warn(
|
||||
'Device database does not have a match for device "%s" (model "%s")'
|
||||
, device.serial
|
||||
, device.model
|
||||
)
|
||||
}
|
||||
if (match) {
|
||||
device.name = match.name.id
|
||||
device.releasedAt = match.date
|
||||
device.image = match.image
|
||||
device.cpu = match.cpu
|
||||
device.memory = match.memory
|
||||
}
|
||||
else {
|
||||
log.warn(
|
||||
'Device database does not have a match for device "%s" (model "%s"/"%s")'
|
||||
, device.serial
|
||||
, device.model
|
||||
, device.product
|
||||
)
|
||||
}
|
||||
|
||||
return device
|
||||
|
||||
@@ -133,7 +133,7 @@ devutil.makeIdentity = function(serial, properties) {
|
||||
, version = properties['ro.build.version.release']
|
||||
, sdk = properties['ro.build.version.sdk']
|
||||
, abi = properties['ro.product.cpu.abi']
|
||||
, name = properties['ro.product.name']
|
||||
, product = properties['ro.product.name']
|
||||
|
||||
// Remove brand prefix for consistency
|
||||
if (model.substr(0, brand.length) === brand) {
|
||||
@@ -156,6 +156,6 @@ devutil.makeIdentity = function(serial, properties) {
|
||||
, version: version
|
||||
, abi: abi
|
||||
, sdk: sdk
|
||||
, name: name
|
||||
, product: product
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ var uuid = require('node-uuid')
|
||||
var _ = require('lodash')
|
||||
|
||||
var dbapi = require('../db/api')
|
||||
var devices = require('stf-device-db')
|
||||
var devices = require('stf-device-db/dist/devices-latest')
|
||||
|
||||
module.exports.generate = function() {
|
||||
module.exports.generate = function(wantedModel) {
|
||||
var serial = util.format(
|
||||
'fake-%s'
|
||||
, uuid.v4(null, new Buffer(16)).toString('base64')
|
||||
@@ -20,11 +20,12 @@ module.exports.generate = function() {
|
||||
, status: 'OFFLINE'
|
||||
})
|
||||
.then(function() {
|
||||
var model = wantedModel || _.sample(Object.keys(devices))
|
||||
return dbapi.saveDeviceIdentity(serial, {
|
||||
platform: 'Android'
|
||||
, manufacturer: 'Foo Electronics'
|
||||
, operator: 'Loss Networks'
|
||||
, model: _.sample(Object.keys(devices))
|
||||
, model: model
|
||||
, version: '4.1.2'
|
||||
, abi: 'armeabi-v7a'
|
||||
, sdk: 8 + Math.floor(Math.random() * 12)
|
||||
@@ -46,6 +47,7 @@ module.exports.generate = function() {
|
||||
, network: 'LTE'
|
||||
, phoneNumber: '0000000000'
|
||||
}
|
||||
, product: model
|
||||
})
|
||||
})
|
||||
.then(function() {
|
||||
|
||||
Reference in New Issue
Block a user