Does anyone know how to programmatically read the IMEI using embedded visual C. I have tried the TAPI lineGetGeneralInfo function but this always seems to return an error, as it requires TAPI extensions which don't seem to work. Is there any other function or API which returns this info?
Any help would be appreciated.
You need to use the SimGetRecordInfo() function. The IMEI is stored at address 0x6F07.
Steve
Thanks,
However this is the Sim's IMSI (International Mobile Subs Identifier) which identifies the country and home network. I am trying to get the phone's IMEI which is the electronic serial no of the phone (to use as part of a secure https validation procedure).
IMEI Code
#include <TAPI.h>
#include <ExTAPI.h>
#define TAPI_VERSION_1_0 0x00010003
#define TAPI_VERSION_1_4 0x00010004
#define TAPI_VERSION_2_0 0x00020000
void CALLBACK lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
void GetError(DWORD dwReturn);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HLINEAPP hLineAp = NULL;
DWORD dwNumDevs, dwDeviceID = 2;
HLINE hLine = NULL;
int i;
WCHAR szIMSI[180];
WCHAR szIMEI[180];
WCHAR szOutput[50];
LINEGENERALINFO lpLineInfo;
DWORD dwReturn, dwAPIVersion = TAPI_CURRENT_VERSION;
lineInitialize(&hLineAp, hInstance, lineCallbackFunc, NULL, &dwNumDevs);
lineNegotiateExtVersion(hLineAp, dwDeviceID, TAPI_VERSION_1_0, TAPI_CURRENT_VERSION, dwAPIVersion, NULL);
lineOpen(hLineAp, dwDeviceID, &hLine, dwAPIVersion, 0, 0, LINECALLPRIVILEGE_NONE, 0, 0);
lpLineInfo.dwTotalSize = 180;
dwReturn = lineGetGeneralInfo(hLine, &lpLineInfo);
if (!dwReturn)
{
if (lpLineInfo.dwSubscriberNumberSize > 2)
{
for (i = 0; i < (signed) lpLineInfo.dwSubscriberNumberSize/2; i++)
szIMSI = *((unsigned short *)(&lpLineInfo) + i + lpLineInfo.dwSubscriberNumberOffset/2);
szIMSI=NULL;
MessageBox(NULL,szIMSI,_T(" IMSI"),MB_OK);
}
else
if (lpLineInfo.dwSubscriberNumberSize)
MessageBox(NULL,_T("Please Enter PIN"),_T(" IMSI"),MB_OK);
else
MessageBox(NULL,_T("No SIM Card Present"),_T(" IMSI"),MB_OK);
for (i = 0; i < (signed) (lpLineInfo.dwSerialNumberSize/2); i++)
szIMEI = *((unsigned short *)(&lpLineInfo) + i + lpLineInfo.dwSerialNumberOffset/2);
szIMEI=NULL;
wsprintf(szOutput,_T("NULL"));
MessageBox(NULL,szIMEI,_T(" IMEI"),MB_OK);
}
else
GetError(dwReturn);
lineClose(hLine);
lineShutdown(hLineAp);
return 0;
}
void CALLBACK lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
}
void GetError(DWORD dwReturn)
{
switch (dwReturn)
{
case LINEERR_RESOURCEUNAVAIL:
MessageBox(NULL,_T("No SIM Card"),_T("Error"),MB_OK);
break;
case LINEERR_INVALLINEHANDLE:
MessageBox(NULL,_T("Line Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_STRUCTURETOOSMALL:
MessageBox(NULL,_T("Oops"),_T(" Error"),MB_OK);
break;
case LINEERR_INVALPOINTER:
MessageBox(NULL,_T("Line Pointer Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_UNINITIALIZED:
MessageBox(NULL,_T("Radio Not Turned On"),_T(" Error"),MB_OK);
break;
case LINEERR_NOMEM:
MessageBox(NULL,_T("Out of Memory"),_T(" Error"),MB_OK);
break;
case LINEERR_OPERATIONUNAVAIL:
MessageBox(NULL,_T("Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_OPERATIONFAILED:
MessageBox(NULL,_T("Please Turn Radio On"),_T(" Error"),MB_OK);
break;
default:
MessageBox(NULL,_T("Error"),_T(" Error"),MB_OK);
}
}
Works great
Thanks
hi all, i tried to above code but it gave me thos following error !
any one can help me plz ?
unresolved external symbol lineGetGeneralInfo referenced in function WinMain
thankx alot
hi alla again
these is nothing wrong else that i forgot to like the cellcore.lib lbrary to my project
the code compiled but it gave me the result of " Unavailable " !
so how do i can get the IMEI ?
i'm using ROM 3.16.13 ENG
best regards
Essa
Two possible answers:
A: Turn the phone on
B: HTC have changed the memory map allocation
I have some debug code behind the stuff I posted earlier to dump the entire contents of the lpLineInfo struct. i'l try and see what teh problem is.
On previous versions they omitted the IMEI or extended the HW id sections.
vpreHoose thanx alot for ur replay..
ur code is working fine the problem is that i didnt load the cellcore.lib for the evc compiler and the other problem is the DeviceID
in ur code u r using DeviceID = 2 while me i must use DeviceID = 0,
so i changed dwDeviceID = 2 to dwDeviceID = 0; and every thing is working fine
can u tell me how do i can get the caller number while mobile ringing ?
i would like to develope a software that assigne a ringing tone to each contact number.
thanx alot
Yea, I was a little bit lazy not to write it to loop through all deviceid's...
:roll:
Thanks very much to the person who provided the code. I'd been battling with lineGetGeneralStatus for days, no joy. Microsoft giving away nothing here. I found the missing line in my code from yours:
lpLineInfo.dwTotalSize = 180;
And now it works. If only MS had stated this, would have solved me a whole load of hastle.
There must be more and useful information on the ExTapi. Like how to use the functions so that they work. Does anybody have a reference??
Ben
I tried this code on my qtek 2020 but my application return the following error:
unavailable
why???
a favor to ask
can anyone convert the code to c#? would be much appreciated
Re: IMEI Code
will this code work in an emulator?
test
lollone said:
I tried this code on my qtek 2020 but my application return the following error:
unavailable
why???
Click to expand...
Click to collapse
I got the same problem, and then changed the value of dwDeviceID to 0
DWORD dwDeviceID = 0;
and now i get an another error:
Please Turn Radio On
Click to expand...
Click to collapse
while I am a Newbie with XDA, so i want to ask, what is the Radio and how to turn it on?
thanks a lot
Pai
pai said:
lollone said:
I tried this code on my qtek 2020 but my application return the following error:
unavailable
why???
Click to expand...
Click to collapse
I got the same problem, and then changed the value of dwDeviceID to 0
DWORD dwDeviceID = 0;
and now i get an another error:
Please Turn Radio On
Click to expand...
Click to collapse
while I am a Newbie with XDA, so i want to ask, what is the Radio and how to turn it on?
thanks a lot
Pai
Click to expand...
Click to collapse
I have solved this problem by only restart, i think the radio means Handy-Net
Smart phones ?
This method doesn't work on smart phones?!
On WM 2003 Smart phone it always gives unsupported operation
Hello!
I'm developing a big application and a part of it is about contacts. I want to, first, get all the groups of contacts. And when the users selects one, show all the contacts of the group.
I've seen other applications and widgets (like LauncherPro widget or HTC Sense Widget) than can do it, but when I try, I don't get same results.
My code is:
1.- To get an example group (this is just for testing, in real application user selects):
Code:
long idGroup = 0;
String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
Cursor c = mcp.getContext().getContentResolver().query(ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null, null, ContactsContract.Groups.TITLE + " ASC");
while(c.moveToNext())
{
if (c.getString(1).contains("Family")){
idGroup = c.getLong(0);
}
}
c.close();
2.- To filter Users by group??
Thank you!
2.- To filter Users by group??
Same question... Cannot find the answer... Anybody knows ?
well maybe i should not revive this thread, but i had a lot of issues finding this,, my code working and you can filter and avoid repeated groups and only with phone numbers
Code:
String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE,ContactsContract.Groups.SUMMARY_COUNT ,ContactsContract.Groups.SUMMARY_WITH_PHONES };
Cursor c = context.getApplicationContext().getContentResolver().query(
ContactsContract.Groups.CONTENT_SUMMARY_URI,
GROUP_PROJECTION,
ContactsContract.Groups.SUMMARY_WITH_PHONES +"> 0"
, null, ContactsContract.Groups.TITLE + " ASC");
Hi, this is my code, i cant get upload a simple file:
Signgin in to DropBox:
.....private AccessTokenPair tokensDB;
.....private DropboxAPI<AndroidAuthSession> mDBApi;
.....final static private AccessType ACCESS_TYPE = AccessType.DROPBOX;
.....AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
.....AndroidAuthSession sesDropBox = new AndroidAuthSession(appKeys, ACCESS_TYPE);
.....mDBApi = new DropboxAPI<AndroidAuthSession>(sesDropBox);
.....mDBApi.getSession().startAuthentication(this);
When activity resums this code is executed:
.....mDBApi.getSession().finishAuthentication();
.....tokensDB = mDBApi.getSession().getAccessTokenPair();
when the user clicks over a button in same activity next code is executed:
protected void subeArchivos() {
.....// Uploading content.
.....String fileContents = "Hello World, this is only an example!!";
.....ByteArrayInputStream inputStream = new ByteArrayInputStream(fileContents.getBytes());
.....try {
..........mDBApi.putFile("/testing.txt", inputStream, fileContents.length(), null, null);
..........//Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
.....} catch (DropboxUnlinkedException e) {
..........// User has unlinked, ask them to link again here.
..........Log.e("DbExampleLog", "User has unlinked.");
.....} catch (DropboxException e) {
..........toast = Toast.makeText(getApplicationContext(), "C U A: " + e.getMessage(), Toast.LENGTH_SHORT);
..........toast.show();
..........//Log.e("DbExampleLog", "Something went wrong while uploading.");
.....}
}
The code in red throws error. and after the conde in yellow is executed.
My mnifiest permissions are:
.....<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
.....<uses-permission android:name="android.permission.INTERNET"></uses-permission>
.....<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
P.D. All works, exept code in red!!
I hope you can help me!! thx!!
anyone??
I didn't understand anything exc. that you can't upload any file with Dropbox, but I had similar problem. Seems you shouldn't delete the Downloads app, else it bugs DB uploads.
Hope it helps.
thx man, every folder in his place, but maybe something in my code is wrong!!
Firstly of all apologises if this is not the best place to ask a DEV question, but I have no access to the developer forum pages for Android.
My App is reading the images from Nikon camera plugged into the USB OTG port on a Samsung S4 phone running Android 4.2.2 (JDQ39.i9505xxubmea).
I am getting an Fatal signal 11 (SIGSEGV) at 0x74564000 (code=1), when trying to call getStorageIds in approx 1 in 10 attempts.
The biggest problem being I can't stop the app from crashing in the most undignified mannner.
In the LogCat I can see messages from the Android MtpDevice class, saying "readResponse failed" and "got response packet instead of data packet", however the mtpDevice open() still gives back a non-null value.
The whole block of code is wrapped up in a try/catch, but it as it appears to be an error in the native library rather than a Java exception, so unsurprisingly it's never thrown.
If can somehow detect that the device wasn't being read properly, then I could abort before calling the getstorageIds method. It has clearly found the device, as it reported the make/model and serial number of the camera.
Any ideas very much appreciated.
Thankyou
Code:
if (!mtpDevice.open(usbDeviceConnection)) {
tvStatus.setText("Open MTP device failed!");
return;
}
Log.d(TAG, "mtpDevice is open! " + mtpDevice.getDeviceName() );
MtpDeviceInfo info = mtpDevice.getDeviceInfo();
if (info == null) {
Log.d(TAG, "info is null!");
usbDeviceConnection.close();
mtpDevice.close();
return;
}
int[] storageIds = mtpDevice.getStorageIds(); // this where it stops![/QUOTE][/QUOTE]
Hi,
I try to implement a server side verification of an application with LVL library.
I use this php code : http://code.google.com/p/android-market-license-verification/
In the file sample/verify.php, I have two lines to complete :
Code:
$responseData = '';
$signature = '';
I see in the google LVL that there is a function called verify which has these parameters :
public void verify(PublicKey publicKey, int responseCode, String signedData, String signature);
But I don't undestand where this function is called and by what function.
Also I want to get this datas.
How can I do that ?
Thank you,
Yeah!! Same here!
Can someone tell us?
Most apps use client side license verification, don't know why... This would be very useful!