如何在node.js中使用ADBKIT获取IMEI [英] How to Fetch IMEI using ADBKIT in node.js

查看:826
本文介绍了如何在node.js中使用ADBKIT获取IMEI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想使用Node.js和ADBKIT来检索Android设备的IMEI。



我可以使用client.getProperties()获取其他详细信息,但不能使用IMEI。



有人可以帮助我使用ADBKIT找到IMEI,



我尝试了adb shell dumpsys iphonesubinfo来获取IMEI但它总是返回我[对象对象]





 client.shell(device.id,   adb shell dumpsys iphonesubinfo function (错误,输出){
if (错误){
console .log(err);
}
console .log(输出);
});





如果有任何其他方法/ api可以获取详细信息,我建议如何获取详细信息。



问候,

Arayn

解决方案

得到了解决方案...感谢您的帮助..



  var  adb = require('  adbkit'); 
var client = adb.createClient();
var 承诺 = require(' bluebird');
var readline = require(' readline' );

client.listDevices()
.then( function (devices){
返回 承诺 .map(设备,功能(设备){
console .log(' Device%s',device.id)
client.shell(device.id, dumpsys iphonesubinfo function (错误,输出){
if (错误){
console .log(err);
}
var readStream = output;

readStream
.on(' data' function (data){
console .l og(' Data!',data.toString());
var lines = data.toString()。split(' n')。length - 1 ;
console .log(行);


})
.on(' error' function (错误){ console .error( ' 错误',错误);})
.on(' < span class =code-string> end'
function (){ console 。 log(' 全部完成!');});


})
})
catch function (错误){
console .log(' 未检测到设备!'
console .error(' 出错了:',错误.stack)
})


Hi,

I would like to use Node.js and ADBKIT for retrieving IMEI of the android device.

I am able to get other details using client.getProperties(), but not the IMEI.

Can someone help me out in finding IMEI using ADBKIT,

I tried the "adb shell dumpsys iphonesubinfo" to get the IMEI but it always returns me [Object object]


client.shell(device.id, "adb shell dumpsys iphonesubinfo", function(err, output) {
if (err) {
			    console.log(err);
			  }
			  console.log(output);
});



Please suggest if there are any other method / api which can fetch me the details, how can I get the details.

Regards,
Arayn

解决方案

Got the solution...Thanks for help..

var adb = require('adbkit');
var client = adb.createClient();
var Promise = require('bluebird');
var readline = require('readline');
 
client.listDevices()
	.then(function(devices) {
		return Promise.map(devices, function(device) {
			console.log('Device %s ', device.id)
			client.shell(device.id, "dumpsys iphonesubinfo", function(err, output) {
			if (err) {
			    console.log(err);
			  }
				var readStream = output;

readStream
  .on('data',  function (data) { 
	console.log('Data!', data.toString());  
		var lines = data.toString().split('n').length - 1;
  		console.log(lines);

		
	})
  .on('error', function (err)  { console.error('Error', err); })
  .on('end',   function ()     { console.log('All done!');    });

			
		})
	})
.catch(function(err) {
	console.log('No device detected!')
	console.error('Something went wrong:', err.stack)
})


这篇关于如何在node.js中使用ADBKIT获取IMEI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆