Skip to content

Commit

Permalink
QA-15737 Научиться доставать market name прямо из устройства
Browse files Browse the repository at this point in the history
-get marketname from settings
  • Loading branch information
a.chistov committed Jan 9, 2025
1 parent 33f41eb commit f8e3b63
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
10 changes: 7 additions & 3 deletions lib/units/device/plugins/util/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import logger from '../../../../util/logger.js'
import properties from '../../support/properties.js'
import display from './display.js'
import phone from './phone.js'
import adb from '../../support/adb.js'
export default syrup.serial()
.dependency(properties)
.dependency(display)
.dependency(phone)
.define(function(options, properties, display, phone) {
.dependency(adb)
.define(function(options, properties, display, phone, adb) {
var log = logger.createLogger('device:plugins:identity')
function solve() {

async function solve() {
log.info('Solving identity')
let identity = devutil.makeIdentity(options.serial, properties)
let identity = await devutil.makeIdentity(options.serial, properties, adb)
identity.display = display.properties
identity.phone = phone
if (options.deviceName) {
identity.module = options.deviceName
}
return identity
}

return solve()
})
32 changes: 18 additions & 14 deletions lib/util/devutil.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import util from 'util'
import split from 'split'
import Promise from 'bluebird'
import androidDeviceList from 'android-device-list'
var devutil = Object.create(null)
function closedError(err) {
return err.message.indexOf('closed') !== -1
Expand Down Expand Up @@ -116,7 +115,7 @@ devutil.killProcsByComm = function(adb, serial, comm, bin, mode) {
})
})
}
devutil.makeIdentity = function(serial, properties) {
devutil.makeIdentity = async function(serial, properties, adb) {
let model = properties['ro.product.model']
let brand = properties['ro.product.brand']
let manufacturer = properties['ro.product.manufacturer']
Expand All @@ -128,7 +127,7 @@ devutil.makeIdentity = function(serial, properties) {
let product = properties['ro.product.name']
let cpuPlatform = properties['ro.board.platform']
let openGLESVersion = properties['ro.opengles.version']
let marketName = properties['ro.product.device']
let marketName = await devutil.getDeviceMarketName(adb, serial)
let customMarketName = properties['debug.stf.product.device']
let macAddress = properties.mac_address
let ram = properties.ram
Expand Down Expand Up @@ -160,17 +159,8 @@ devutil.makeIdentity = function(serial, properties) {
if (customMarketName) {
marketName = customMarketName
}
else if (marketName) {
var devices = androidDeviceList.getDevicesByDeviceId(marketName)
if (devices.length > 0) {
const deviceFilter = devices.filter(device => device.model === model)
if (deviceFilter.length > 0) {
marketName = deviceFilter[0].name
}
else {
marketName = devices[0].name
}
}
else if (!marketName) {
marketName = properties['ro.product.device']
}
// Clean up remaining model name
// model = model.replace(/[_ ]/g, '')
Expand All @@ -191,4 +181,18 @@ devutil.makeIdentity = function(serial, properties) {
, ram: ram
}
}

devutil.getDeviceMarketName = function(adb, serial) {
return adb.getDevice(serial).execOut('settings get global device_name', 'utf-8').then(function(deviceName) {
if (!deviceName || deviceName === 'null\n') {
return adb.getDevice(serial).execOut('settings get secure bluetooth_name', 'utf-8').then(function(bluetoothName) {
if (!bluetoothName || bluetoothName === 'null\n') {
return null
}
return bluetoothName
})
}
return deviceName
})
}
export default devutil
14 changes: 0 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@devicefarmer/stf-wiki": "1.0.0",
"@julusian/jpeg-turbo": "2.1.0",
"@sentry/node": "^8.34.0",
"android-device-list": "1.2.10",
"angular": "1.8.3",
"angular-animate": "1.8.3",
"angular-borderlayout": "https://github.com/filearts/angular-borderlayout#7c9716aebd9260763f798561ca49d6fbfd4a5c67",
Expand Down

0 comments on commit f8e3b63

Please sign in to comment.