Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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]


JavaScript
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
Posted
Updated 16-Sep-14 4:00am
v3
Comments
George Jonsson 16-Sep-14 10:39am    
Android doesn't like iPhone ;)
Member 10819655 17-Sep-14 1:37am    
its just a ADB shell command which gives the IMEI of the Android device.
George Jonsson 17-Sep-14 2:45am    
Just kidding
George Jonsson 17-Sep-14 2:46am    
Have you tried other commands, such as cpuinfo?
Member 10819655 17-Sep-14 2:53am    
cpuinfo will give me the CPU detail of the device, wherein I'm looking for IMEI which I am getting by "adb shell dumpsys iphonesubinfo" from ADB Shell.

But I don't know how I can fire the same command from Node Module "ADBKit" client.shell API.

A sample source code using ADBKit Node module using the client.shell will be of great help.

Regards,
Arayn

1 solution

Got the solution...Thanks for help..

JavaScript
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)
})
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900