usbengines/usbwatcher/src/cusbactivepersonalityhandler.cpp
changeset 50 cc2090c68156
parent 48 625e74332ce2
child 52 831068540b07
child 63 ef2686f7597e
child 77 5b2a402e96ac
equal deleted inserted replaced
49:141c98a07b37 50:cc2090c68156
    27 #include "cusbactivepersonalityhandler.h"
    27 #include "cusbactivepersonalityhandler.h"
    28 #include "cusbglobalsystemstateobserver.h"
    28 #include "cusbglobalsystemstateobserver.h"
    29 #include <usbuinotif.h>
    29 #include <usbuinotif.h>
    30 
    30 
    31 // CONSTANTS
    31 // CONSTANTS
    32 // const TInt KSerialNumberLength = 12;
    32 const TInt KSerialNumberLength = 12;
    33 const TInt KContainerIdLength = 16;
       
    34 
    33 
    35 const TUid KUsbmanSvrUid = {0x101fe1db};
    34 const TUid KUsbmanSvrUid = {0x101fe1db};
    36 
    35 
    37 // ============================ MEMBER FUNCTIONS ==============================
    36 // ============================ MEMBER FUNCTIONS ==============================
    38 
    37 
   122     // make sure that the serial number fulfills USB requirements and then
   121     // make sure that the serial number fulfills USB requirements and then
   123     // convert the serial number so that it can be printed to log
   122     // convert the serial number so that it can be printed to log
   124     TLex lex( iPhoneInfo.iSerialNumber );
   123     TLex lex( iPhoneInfo.iSerialNumber );
   125     TInt length = iPhoneInfo.iSerialNumber.Length();
   124     TInt length = iPhoneInfo.iSerialNumber.Length();
   126 
   125 
   127     // currently the serial number is used for the USB container ID
   126     if( length < KSerialNumberLength )
   128     // the container ID length must be at least 16 bytes
   127         {
   129     // also, even when serial number is not used for the container id
   128         // In GSM, the complete IMEI can be used as USB serial
   130     // it must be at least 12, see below
   129         // number. But in CDMA, the ESN is too short for a valid Mass
   131     if( length < KContainerIdLength )
   130         // Storage serial number (Mass-Storage and Bulk Only Transport
   132         {
   131         // specs both require minimum 12 byte number), so it is
   133         // In GSM, the complete IMEI can used as USB serial number. But in
   132         // extended with trailing zeroes. When doing this, make sure
   134         // CDMA, the ESN is too short for a valid Mass Storage serial number
   133         // not to write anything over descriptor's max length
   135         // (Mass-Storage and Bulk Only Transport specs both require minimum
   134         if( iPhoneInfo.iSerialNumber.MaxLength() < KSerialNumberLength )
   136         // 12 byte number), so it is extended with leading zeroes. When
   135             {
   137         // doing this, make sure not to write anything over descriptor's
   136             iPhoneInfo.iSerialNumber.SetLength( KSerialNumberLength );
   138         // max length
   137             }
   139         if( iPhoneInfo.iSerialNumber.MaxLength() < KContainerIdLength )
   138         while( length < KSerialNumberLength )
   140             {
       
   141             iPhoneInfo.iSerialNumber.SetLength( KContainerIdLength );
       
   142             }
       
   143         while( length < KContainerIdLength )
       
   144             {
   139             {
   145             iPhoneInfo.iSerialNumber.Append( '0' );
   140             iPhoneInfo.iSerialNumber.Append( '0' );
   146             ++length;
   141             ++length;
   147             }
   142             }
   148         }
   143         }