说说product ID, platform ID 以及 machine ID Tuesday, August 4, 2009

product ID 和platform ID实际上非常类似,可以认为是同样的东西,只是有不同的语义;platform ID 出现在同一个平台上的所有设备中,以及将来兼容这个平台的所有设备中,本质上是S60 UI platform 的识别ID。product ID 一般只用于当前平台,用来标示当前平台上的产品系列。比如如果某个应用只能运行在某个平台上的某个系列的设备上,就应该在PKG包中用Product ID来限制,而不是platform ID。
machine ID 一个独立机制的部分,这个机制支持component在不同设备上的条件安装(例如,为了避免设备不兼容等)。这个id可以用于PKG文件中条件选择。machine ID 保证是唯一的,在不同的设备上这个值肯定是不同的。而product ID 在不同的设备上可能有相同的值,甚至可以不设置这个值。 注意在同一个设备上,machine ID 和product ID 有可能取同一个值。
每个设备上针对自己兼容的platform ID 和 product ID 包含一些相应的sis文件存根(sis file stub)(存储在z:\system\install,模拟器路径为\epoc32\data\z\system\install),文件名的格式是series60v*.sis。当一个sis安装包被安装的时候,installer 把PKG文件中所有的product/platform ID 和每个sis文件存根一一做比较。如果匹配,则sis包安装的应用程序和当前设备是兼容的,否则不兼容,设备给出提示信息。
Machine ID 用api HAL::Get 获得。
这里提供一个链接,列举了目前最全的ID
http://developer.symbian.com/wiki/display/pub/Device+vs+Product%2C+Platform%2C+HAL+information#DevicevsProduct%2CPlatform%2CHALinformation-platformIds
如果有兴趣的话,在上面的连接中关注一下Nokia N70 和N72, 为什么他们的id都是一样一样的呢? 说明个什么问题?

How to retrieve the phone IMEI code

Here I’ll present an approach to retrieve IMEI code by calling functions of class RMobilePhone. I have debugged these source codes on W950 (Symbian 9.1, UIQ3.0).
You can get some description of the format of IMEI code in [1]. In this paper, the PlpVariant::GetMachineIdL function is called to retrieve the phone IMEI code, but this function has been deprecated on UIQ3.0. So if you call it, you maybe will retrieve a incorrect IMEI code. I have debugged it on W950, the return is ‘14750005-630771776’. My phone IMEI code is actually ‘00440107-000879-8’.
And the link [2] provides another approach, but it’s so hard to get the mentioned .h files and librarys. I can not find them, so I did not debug it.
On UIQ 3.0, class RMobilePhone provides client access to mobile phone functionality provided by TSY. You can get the detailed description of class RMobilePhone in the help document of UIQ SDK.
My steps are as following:
1. Connect to the ETel server
2. Get the name of registered phones
3. Open mobile phone sub session
4. Check if the phone provided the capabilities to retrieve IMEI code or not
5. Retrieve the phone IMEI code

The defined parameters:


RTelServer iTelServer; // Root telephony server session
RMobilePhone iMmPhone;
TBuf<> iPhoneName
RMobilePhone::TMobilePhoneIdentityV1 iPhoneId;


1. Connect to the ETel server


User::LeaveIfError(iTelServer.Connect());


2. Get the name of registered phones


// Get the number of registered phones
TInt numberOfPhones;
User::LeaveIfError(aTelServer.EnumeratePhones(numberOfPhones));
LOG("%i",numberOfPhones);
for( TInt i = 0; i<numberOfPhones; i++ )
{
RTelServer::TPhoneInfo info;
iTelServer.GetPhoneInfo(i,info);
LOG("NetworkTyp:[%i],Name:[%S],NumberofLines:[%i],Extensions:[%i]", (TInt)info.iNetworkType,&info.iName,info.iNumberOfLines,info.iExtensions);
iPhoneName.Copy(info.iName);
}


In your smart phone, there can be several registered phones i.e. the returned value of ‘number ofPhones’ can be more than 1. hence you need to choice one directly or adopt other policy.But fortunately most of the smart phones have just one
3. Open mobile phone sub session


// open mobile phone sub session
User::LeaveIfError(iMmPhone.Open(iTelServer, iPhoneName));


4. Check if the phone provided the capabilities to retrieve IMEI code or not
And call the RMobilePhone::GetPhoneId function to retrieve IMEI.


TUint32 lCaps = 0;
TInt err = iMmPhone.GetIdentityCaps(lCaps);
if(err != KErrNone && err != KErrNotSupported)
{
LOG(_L("an unexpected error occoured"));
}
else if(err == KErrNotSupported)
{
LOG(_L("RMobilePhone::GetIdentityCaps() returned KErrNotSupported "));
}
else if (lCaps & RMobilePhone::KCapsGetSerialNumber)
{
iMmPhone.GetPhoneId(iStatus, iPhoneId); // asynchronous call
iActiveStatus = ST_GET_PHONE_ID;
SetActive();
return;
}


The function,RMobilePhone:: GetPhoneId, is the key function. In fact, here I introduce how to use it.
5. After returning, the value of the parameter, iPhoneId.iSerialNumber, is the phone IMEI code
6. Don't forget to close the opened handles as like:


iMmPhone.Close();
iTelServer.Close();



Reference:
1. “Retrieving the device IMEI code”
http://www.newlc.com/Retrieving-the-device-IMEI-code.html
2. “FAQ & Tech Tips”
http://www2.symbian.com/faq.nsf/7b5405edb1250e7c802569ee005d054e/ba491eaeb25c5c7d80256bf3003e75fc?OpenDocument