# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1274956963 -10800 # Node ID 48a2e0d8a4ce93d40d5f52561460f791c5d68b58 # Parent a5c0bb5018eb385b0d38bf3195185987e5d1d5a7 Revision: 201021 Kit: 2010121 diff -r a5c0bb5018eb -r 48a2e0d8a4ce backupandrestore/backupengine/group/connectivity_securebackupengine.iby --- a/backupandrestore/backupengine/group/connectivity_securebackupengine.iby Fri May 14 16:42:01 2010 +0300 +++ b/backupandrestore/backupengine/group/connectivity_securebackupengine.iby Thu May 27 13:42:43 2010 +0300 @@ -21,7 +21,7 @@ file=ABI_DIR\BUILD_DIR\abclient.dll System\libs\abclient.dll #ifndef SBEHEAPMAX -#define SBEHEAPMAX 0x400000 +#define SBEHEAPMAX 0x2000000 #endif file=ABI_DIR\BUILD_DIR\sbengine.exe System\programs\sbengine.exe heapmax=SBEHEAPMAX diff -r a5c0bb5018eb -r 48a2e0d8a4ce backupandrestore/backuptest/ABTester/group/abtester.iby --- a/backupandrestore/backuptest/ABTester/group/abtester.iby Fri May 14 16:42:01 2010 +0300 +++ b/backupandrestore/backuptest/ABTester/group/abtester.iby Thu May 27 13:42:43 2010 +0300 @@ -21,13 +21,13 @@ file=ABI_DIR\BUILD_DIR\abtestclient3.EXE System\programs\abtestclient3.EXE file=ABI_DIR\BUILD_DIR\abtestclient4.EXE System\programs\abtestclient4.EXE -data=DATAZ_\private\0AB7E57C\backup_registration.xml private\0AB7E57C\backup_registration.xml -data=DATAZ_\private\0AB7E57D\backup_registration.xml private\0AB7E57D\backup_registration.xml -data=DATAZ_\private\0AB7E57E\backup_registration.xml private\0AB7E57E\backup_registration.xml -data=DATAZ_\private\0AB7E58A\backup_registration.xml private\0AB7E58A\backup_registration.xml -data=DATAZ_\private\0AB7E58B\backup_registration.xml private\0AB7E58B\backup_registration.xml -data=DATAZ_\private\0AB7E58C\backup_registration.xml private\0AB7E58C\backup_registration.xml +data=DATAZ_\private\0ab7e57c\backup_registration.xml private\0ab7e57c\backup_registration.xml +data=DATAZ_\private\0ab7e57d\backup_registration.xml private\0ab7e57d\backup_registration.xml +data=DATAZ_\private\0ab7e57e\backup_registration.xml private\0ab7e57e\backup_registration.xml +data=DATAZ_\private\0ab7e58a\backup_registration.xml private\0ab7e58a\backup_registration.xml +data=DATAZ_\private\0ab7e58b\backup_registration.xml private\0ab7e58b\backup_registration.xml +data=DATAZ_\private\0ab7e58c\backup_registration.xml private\0ab7e58c\backup_registration.xml -data=DATAZ_\private\0FA00001\backup_registration.xml private\0FA00001\backup_registration.xml +data=DATAZ_\private\0fa00001\backup_registration.xml private\0fa00001\backup_registration.xml #endif diff -r a5c0bb5018eb -r 48a2e0d8a4ce backupandrestore/backuptest/ABTester/group/bld.inf --- a/backupandrestore/backuptest/ABTester/group/bld.inf Fri May 14 16:42:01 2010 +0300 +++ b/backupandrestore/backuptest/ABTester/group/bld.inf Thu May 27 13:42:43 2010 +0300 @@ -33,10 +33,10 @@ ./abtester.oby /epoc32/rom/include/abtester.oby ./abtester.iby /epoc32/rom/include/abtester.iby - ../data/incremental_active_backup_registration.xml z:/private/0AB7E57C/backup_registration.xml - ../data/proxy_active_backup_registration.xml z:/private/0AB7E57D/backup_registration.xml - ../data/base_active_backup_registration.xml z:/private/0AB7E57E/backup_registration.xml - ../data/base_active_backup_registration2.xml z:/private/0AB7E58A/backup_registration.xml - ../data/base_active_backup_registration3.xml z:/private/0AB7E58B/backup_registration.xml - ../data/passive_backup_registration.xml z:/private/0AB7E58C/backup_registration.xml - ../data/backup_public_files_registration.xml z:/private/0FA00001/backup_registration.xml + ../data/incremental_active_backup_registration.xml z:/private/0ab7e57c/backup_registration.xml + ../data/proxy_active_backup_registration.xml z:/private/0ab7e57d/backup_registration.xml + ../data/base_active_backup_registration.xml z:/private/0ab7e57e/backup_registration.xml + ../data/base_active_backup_registration2.xml z:/private/0ab7e58a/backup_registration.xml + ../data/base_active_backup_registration3.xml z:/private/0ab7e58b/backup_registration.xml + ../data/passive_backup_registration.xml z:/private/0ab7e58c/backup_registration.xml + ../data/backup_public_files_registration.xml z:/private/0fa00001/backup_registration.xml diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpdataproviders/mtpimagedp/group/bld.inf --- a/mtpdataproviders/mtpimagedp/group/bld.inf Fri May 14 16:42:01 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/group/bld.inf Thu May 27 13:42:43 2010 +0300 @@ -30,9 +30,9 @@ PRJ_EXPORTS // Note: these files are exported for testing and techview only. Not used in a device -2001FCA2.txt /epoc32/data/z/private/10202be9/2001FCA2.txt -2001FCA2.txt /epoc32/release/winscw/udeb/z/private/10202be9/2001FCA2.txt -2001FCA2.txt /epoc32/release/winscw/urel/z/private/10202be9/2001FCA2.txt +2001fca2.txt /epoc32/data/z/private/10202be9/2001fca2.txt +2001fca2.txt /epoc32/release/winscw/udeb/z/private/10202be9/2001fca2.txt +2001fca2.txt /epoc32/release/winscw/urel/z/private/10202be9/2001fca2.txt ../group/mtp_imagedp.iby /epoc32/rom/include/mtp_imagedp.iby diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp Thu May 27 13:42:43 2010 +0300 @@ -238,7 +238,10 @@ //add Suid to deleteobjectlist iDataProvider.AppendDeleteObjectsArrayL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid)); //coverity[unterminated_case] - case KErrNone: + case KErrPathNotFound: + //if the file does not exist on device, remove it from objectstore + //coverity[fallthrough] + case KErrNone: //add for test __FLOG(_L8("KErrNone")); //if the image object is new, we should update new picture count diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Thu May 27 13:42:43 2010 +0300 @@ -403,16 +403,18 @@ aValue = KThumbFormatCode; break; case EMTPObjectPropCodeProtectionStatus: - iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry); - if (entry.IsReadOnly()) + { + TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry); + if ( err == KErrNone && entry.IsReadOnly()) { aValue = EMTPProtectionReadOnly; } else { aValue = EMTPProtectionNoProtection; - } - break; + } + } + break; default: aValue = 0;//initialization //ingore the failure if we can't get properties form MdS diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/daemon/server/group/mtpserver.mmp --- a/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp Thu May 27 13:42:43 2010 +0300 @@ -29,6 +29,8 @@ EPOCHEAPSIZE 0x80000 0x800000 // 8MB #endif +EPOCSTACKSIZE 0x14000 + MW_LAYER_SYSTEMINCLUDE_SYMBIAN USERINCLUDE ../inc/ diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h --- a/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpgetstorageinfo.h Thu May 27 13:42:43 2010 +0300 @@ -30,6 +30,15 @@ //forward declaration class CMTPTypeStorageInfo; +//Default drive name used when failed to read drive name from +//System +_LIT(KPhoneMemory,"Phone memory"); +_LIT(KMassMemory,"Mass memory"); +_LIT(KMemoryCard,"Memory card"); +_LIT(KNoName,"No name"); +//The last resort for drive name:DriveChar + drive, eg 'A drive' +_LIT(KDefaultName," drive"); + /** Defines device data provider GetStorageInfo request processor diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp Thu May 27 13:42:43 2010 +0300 @@ -197,10 +197,22 @@ case EMediaFloppy: if (iDriveInfo.iDriveAtt & KDriveAttRemovable) { - storageType = EMTPStorageRemovableRAM; + //E: is set as logically removable after eMMC image updated + //So here we need to deal with this case to set it as FixedRam + if(iDriveInfo.iDriveAtt & KDriveAttInternal) + { + __FLOG(_L8("removable but internal drive, set as Fixed RAM")); + storageType = EMTPStorageFixedRAM; + } + else + { + __FLOG(_L8("non internal,set as removable RAM")); + storageType = EMTPStorageRemovableRAM; + } } else { + __FLOG(_L8("Non removable, set as Fixed RAM")); storageType = EMTPStorageFixedRAM; } break; @@ -309,30 +321,68 @@ __FLOG(_L8("SetStorageDescriptionL - Entry")); TUint32 storage(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); TInt driveNumber = iFramework.StorageMgr().DriveNumber(storage); - RBuf volumeName; - volumeName.CreateL(KMaxFileName); - volumeName.CleanupClosePushL(); - RMTPDeviceDpSingletons devSingletons; - devSingletons.OpenL(iFramework); - CleanupClosePushL(devSingletons); - TRAPD(resError, devSingletons.ConfigMgr().GetFriendlyVolumeNameL(driveNumber, volumeName)); - if ((KErrNone == resError) && (0 < volumeName.Length())) - { - __FLOG(_L8("Using volume name from resource file")); - CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(volumeName); - iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription); - CleanupStack::PopAndDestroy(mtpDescription); - } - else if (0 < iVolumeInfo.iName.Length()) - { - __FLOG(_L8("Using standard volume name")); - CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(iVolumeInfo.iName); - iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription); - CleanupStack::PopAndDestroy(mtpDescription); - } - - CleanupStack::PopAndDestroy(&devSingletons); - CleanupStack::PopAndDestroy(&volumeName); + __FLOG_1(_L8("driveNumber:%d"),driveNumber); + + CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(); + + //Firstly, read name from VolumeInfo + if (0 < iVolumeInfo.iName.Length()) + { + __FLOG_1(_L8("Using standard volume name:%S"),&iVolumeInfo.iName); + mtpDescription->SetL(iVolumeInfo.iName); + } + else //If name not set, set name according to type + { + TMTPTypeUint16 storageType(EMTPStorageUndefined); + iStorageInfo->GetL(CMTPTypeStorageInfo::EStorageType,storageType); + __FLOG_1(_L8("Set name according to storage type: %d"),storageType.Value()); + + switch (storageType.Value()) + { + case EMTPStorageFixedROM: + if (driveNumber == EDriveC)//Phone Memory + { + __FLOG(_L8("drive c")); + mtpDescription->SetL(KPhoneMemory); + } + break; + case EMTPStorageRemovableROM: + break; + case EMTPStorageFixedRAM: // Mass Memory + mtpDescription->SetL(KMassMemory); + break; + case EMTPStorageRemovableRAM: // Memory Card + mtpDescription->SetL(KMemoryCard); + break; + case EMTPStorageUndefined: + default: + break; + } + + //Finally, it the name still not set, use default value: + //eg, 'A drive' + if(mtpDescription->NumChars() == 0) + { + TChar driveChar; + TInt err = iFramework.Fs().DriveToChar(driveNumber,driveChar); + __FLOG_2(_L8("Use default name,driveNumber:%d err:%d"),driveNumber,err); + if (err == KErrNone) + { + TBuf driveName; + driveName.Append(driveChar); + driveName.Append(KDefaultName); + mtpDescription->SetL(driveName); + } + else + { + mtpDescription->SetL(KNoName); + } + } + } + + iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription,*mtpDescription); + CleanupStack::PopAndDestroy(mtpDescription); + __FLOG(_L8("SetStorageDescriptionL - Exit")); } diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/inc/cmtpobjectstore.h --- a/mtpfws/mtpfw/inc/cmtpobjectstore.h Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/inc/cmtpobjectstore.h Thu May 27 13:42:43 2010 +0300 @@ -27,7 +27,7 @@ #include "mtpframeworkconst.h" #include "rmtpframework.h" #include "mtpdebug.h" - +#include "cmtpreferencemgr.h" class CFileStore; class CMTPHandleAllocator; class CMTPObjectMetaData; @@ -155,6 +155,8 @@ } void DoL(RDbTable& aTable) { + //no need to call GetL already all it in TraverseL + iStore.ReferenceMgr().RemoveReferencesL(aTable.ColUint32(EObjectStoreHandleId)); aTable.DeleteL(); iStore.IncTranOpsNumL(); } @@ -200,6 +202,7 @@ void MarkNonPersistentObjectsL(TUint aDataProviderId, TUint32 aStorageId); void EstablishDBSnapshotL(TUint32 aStorageId); void CleanDBSnapshotL(TBool aOnlyRoot = EFalse); + void RemoveUndefinedObjectsL(); void ObjectsEnumComplete(); void MarkDPLoadedL(TUint aDataProviderId, TBool aFlag); @@ -364,6 +367,7 @@ TInt iSnapshotCleanPos; CSnapshotWorker* iSnapshotWorker; mutable TFileName iSuidBuf; + TBool iCleanUndefined; /** FLOGGER debug trace member variable. */ diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/src/cmtpconnectionmgr.cpp --- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Thu May 27 13:42:43 2010 +0300 @@ -40,8 +40,7 @@ CMTPConnectionMgr::~CMTPConnectionMgr() { StopTransport( iTransportUid, ETrue ); - iConnections.ResetAndDestroy(); - iSuspendedTransports.Reset(); + iConnections.ResetAndDestroy(); iSuspendedTransports.Close(); delete iTransportTrigger; __FLOG_CLOSE; diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp --- a/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp Thu May 27 13:42:43 2010 +0300 @@ -372,7 +372,17 @@ */ EXPORT_C TInt CMTPDataProviderController::DpId(TUint aUid) { - return iDataProviders.FindInOrder(TUid::Uid(aUid), CMTPDataProvider::LinearOrderUid); + TInt dpId = KErrNotFound; + for (TUint index=0; index < iDataProviders.Count(); index++) + { + if (iDataProviders[index]->ImplementationUid().iUid == aUid) + { + dpId = iDataProviders[index]->DataProviderId(); + break; + } + } + + return dpId; } /** diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtpfws/mtpfw/src/cmtpobjectstore.cpp --- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp Thu May 27 13:42:43 2010 +0300 @@ -25,7 +25,6 @@ #include #include "cmtphandleallocator.h" #include "cmtpobjectstore.h" -#include "cmtpreferencemgr.h" #include "dbutility.h" #include "cmtpdataprovidercontroller.h" #include "cmtpdataprovider.h" @@ -54,6 +53,8 @@ const TInt KMaxLimitCompactInEnumeration = 2048; const TInt KMaxLimitCompactAfterEnumeration = 1024; const TInt KSnapshotGranularity = 128; +const TInt KMaxLimitSnapshotSize = 50000; + @@ -768,7 +769,7 @@ } iCachedSuidHash = 0; iCachedHandle = 0; - + iReferenceMgr->RemoveReferencesL(aHandle.Value()); iBatched.DeleteL(); __FLOG(_L8("RemoveObjectL From iBacthed")); IncTranOpsNumL(); @@ -787,6 +788,8 @@ } iCachedSuidHash = 0; iCachedHandle = 0; + //no need to call GetL already all it in LocateBySuidL + iReferenceMgr->RemoveReferencesL(iBatched_SuidHashID.ColUint32(EObjectStoreHandleId)); iBatched_SuidHashID.DeleteL(); IncTranOpsNumL(); } @@ -837,6 +840,8 @@ void CMTPObjectStore::CleanL() { __FLOG(_L8("CleanL - Entry")); + + RemoveUndefinedObjectsL(); Swi::RSisRegistrySession sisSession; User::LeaveIfError(sisSession.Connect()); CleanupClosePushL(sisSession); @@ -1375,6 +1380,39 @@ __FLOG(_L8("CleanDBSnapshotL Exit")); } +void CMTPObjectStore::RemoveUndefinedObjectsL() + { + __FLOG(_L8("CompactDBSnapshotL Entry")); + + if (iCleanUndefined) + { + return; + } + + TInt32 count = 0; + RDbTable temp; + CleanupClosePushL(temp); + User::LeaveIfError(temp.Open(iDatabase, KSQLHandleTableName, RDbRowSet::EUpdatable)); + count = temp.CountL(RDbRowSet::EQuick); + + __FLOG_VA((_L8("Count before deletion %d "), count)); + CleanupStack::PopAndDestroy(&temp); + + if (count > KMaxLimitSnapshotSize) + { + // Delete all object with undefined format + _LIT(KSQLDeleteObjectText, "DELETE FROM HandleStore WHERE FormatCode = %u"); + iSqlStatement.Format(KSQLDeleteObjectText, EMTPFormatCodeUndefined); + User::LeaveIfError(iDatabase.Execute(iSqlStatement)); + } + + iCleanUndefined = ETrue; + + + __FLOG(_L8("CompactDBSnapshotL Exit")); + } + + CMTPObjectStore::CEnumertingCacheItem::CEnumertingCacheItem(TUint32 aSuidHash, TUint32 aHandle, TUint32 aParent, TUint32 aFormat, TUint64 aId, TUint8 aDpID) { iObjSuiIdHash = aSuidHash; diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h --- a/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h Fri May 14 16:42:01 2010 +0300 +++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h Thu May 27 13:42:43 2010 +0300 @@ -53,6 +53,8 @@ void CancelReceiveL(TInt aReason); void CancelSendL(TInt aReason); + void FlushRxDataL(); + protected: CMTPUsbEpBase(TUint aId, TPriority aPriority, CMTPUsbConnection& aConnection); @@ -92,7 +94,6 @@ TBool ValidateUSBHeaderL(); void InitiateFirstChunkReceiveL(); void ProcessFirstReceivedChunkL(); - void FlushRxDataL(); protected: // Owned @@ -204,7 +205,6 @@ */ TUint64 iDataLength; - private: // Not owned /** diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp --- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp Thu May 27 13:42:43 2010 +0300 @@ -131,21 +131,30 @@ __FLOG(_L8("CloseConnection - Exit")); } -void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/) +void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest) { __FLOG(_L8("ReceiveDataL - Entry")); // Update the transaction state. SetBulkTransactionState(EDataIToRPhase); - // Setup the bulk container and initiate the bulk data receive sequence. - iUsbBulkContainer->SetPayloadL(&aData); - - //Expected containerType pre-setup here in case we don't receive IToR dataphase at all so - //Cancel operation can trigger right call inside ReceiveBulkDataCompleteL(). - iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeDataBlock); - - static_cast(iEndpoints[EMTPUsbEpBulkOut])->ReceiveBulkDataL(*iUsbBulkContainer); + if (iIsCancelReceived) //cancel received + { + __FLOG(_L8("Transaction has been cancelled, just flush trash data and complete")); + static_cast(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL(); + BoundProtocolLayer().ReceiveDataCompleteL(KErrCancel, aData, iMTPRequest); + } + else + { + // Setup the bulk container and initiate the bulk data receive sequence. + iUsbBulkContainer->SetPayloadL(&aData); + + //Expected containerType pre-setup here in case we don't receive IToR dataphase at all so + //Cancel operation can trigger right call inside ReceiveBulkDataCompleteL(). + iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeDataBlock); + + static_cast(iEndpoints[EMTPUsbEpBulkOut])->ReceiveBulkDataL(*iUsbBulkContainer); + } __FLOG(_L8("ReceiveDataL - Exit")); } @@ -472,11 +481,9 @@ #endif isResponseTransactionCancelledNeeded = true; - if( BoundProtocolLayer().TransactionPhaseL(iMTPSessionId) > EIdlePhase ) + TMTPTransactionPhase transPhase = BoundProtocolLayer().TransactionPhaseL(iMTPSessionId); + if( transPhase > EIdlePhase && transPhase < ECompletingPhase ) { - - - iMTPEvent.Reset(); iMTPEvent.SetUint16(TMTPTypeEvent::EEventCode, iUsbControlRequestCancelData.Uint16(TMTPUsbControlRequestCancelData::ECancellationCode)); iMTPEvent.SetUint32(TMTPTypeEvent::EEventSessionID, iMTPSessionId); @@ -496,45 +503,25 @@ BoundProtocolLayer().ReceivedEventL(iMTPEvent); } } + else if (transPhase == ECompletingPhase) + { + __FLOG(_L8("cancel event received at completing phase, flush rx data")); + + //flush rx data. + static_cast(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL(); + } else { - - #ifdef _DEBUG - RDebug::Print(_L("cancel evnet received at idle state, stop data EPs, flush rx data, restart data eps,statusOK\n")); - #endif - + __FLOG(_L8("cancel event received at idle phase, stop data EPs, flush rx data, restart data eps")); + // stop data endpoint DataEndpointsStop(); - //flush rx data - TInt nbytes = 0; - TInt err = iLdd.QueryReceiveBuffer(EndpointNumber(EMTPUsbEpBulkOut), nbytes); - #ifdef _DEBUG - RDebug::Print(_L("QueryReceiveBuffer()-----err is %d , nbytes is %d"), err, nbytes); - #endif - - // has data, read it - if( (err == KErrNone) && (nbytes > 0) ) - { - // create the read buff - RBuf8 readBuf; - readBuf.CreateL(nbytes); - // synchronously read the data - TRequestStatus status; - iLdd.ReadOneOrMore(status, EndpointNumber(EMTPUsbEpBulkOut), readBuf); - User::WaitForRequest(status); - if (KErrNone == status.Int()) - { - #ifdef _DEBUG - RDebug::Print(_L("%d bytes is flushed"), nbytes); - #endif - } - readBuf.Close(); - } + //flush rx data. + static_cast(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL(); + // initiate bulk request sequence. - InitiateBulkRequestSequenceL(); - - SetDeviceStatus(EMTPUsbDeviceStatusOK); + InitiateBulkRequestSequenceL(); } } @@ -1052,6 +1039,10 @@ CMTPUsbEpControl& ctrl(*static_cast(iEndpoints[EMTPUsbEpControl])); if (!ctrl.Stalled()) { + // wait 100 miliseconds before issue control request. + // This line is to fix winlogo transport cancel test issue due to that ReadUntilShort never complete sometimes + // If USB team fixed the issue, this line could be removed. +// User::After(1000*100); // 100 Miliseconds ctrl.ReceiveControlRequestSetupL(iUsbControlRequestSetup); } __FLOG(_L8("InitiateControlRequestSequenceL - Exit")); @@ -1400,6 +1391,7 @@ case KErrUsbDeviceClosing: case KErrUsbCableDetached: case KErrUsbDeviceBusReset: + case KErrUsbEpNotReady: // Interface state is changing (@see RunL). break; diff -r a5c0bb5018eb -r 48a2e0d8a4ce mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp --- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp Fri May 14 16:42:01 2010 +0300 +++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp Thu May 27 13:42:43 2010 +0300 @@ -73,7 +73,7 @@ iReceiveData(NULL, 0), iSendChunkData(NULL, 0), iSendData(NULL, 0), - iIsFirstChunk(EFalse), + iIsFirstChunk(EFalse), iConnection(aConnection) { CActiveScheduler::Add(this); @@ -254,7 +254,6 @@ Cancel(); } - __ASSERT_DEBUG(iState == EIdle, Panic(EMTPUsbBadState)); iReceiveDataSink = &aSink; @@ -528,6 +527,12 @@ TUint16 containerType(Connection().BulkContainer().Uint16L(CMTPUsbContainer::EContainerType)); iDataLength = Connection().BulkContainer().Uint32L(CMTPUsbContainer::EContainerLength); +#ifdef __FLOG_ACTIVE + TUint32 transactionId(Connection().BulkContainer().Uint32L(CMTPUsbContainer::ETransactionID)); + TUint16 code(Connection().BulkContainer().Uint16L(CMTPUsbContainer::ECode)); + __FLOG_VA((_L8("ContainerLength = %lu, containerType = 0x%x, code = 0x%x, transactionID = 0x%x"), iDataLength, containerType, code, transactionId)); +#endif + //Due to an issue of Windows OS, the value of CMTPUsbContainer::EContainerLength is incorrect if the //object >= 4G-12. The value should be KMaxTUint32 in this kind of cases, but in current Windows //implementation it will be a value between 0 and 11. @@ -540,23 +545,14 @@ __FLOG_VA((_L8("containerType = %u , dataLength = %lu bytes"), containerType, iDataLength)); - if (iDataLength >= KUSBHeaderSize && - (containerType == EMTPUsbContainerTypeCommandBlock || containerType == EMTPUsbContainerTypeDataBlock)) - { - result = ETrue; - iDataCounter = 0; -#ifdef _DEBUG - RDebug::Print(_L("Find the valid usb header------------------------------------------------------\n")); - TUint16 code(Connection().BulkContainer().Uint16L(CMTPUsbContainer::ECode)); - TUint32 transactionID(Connection().BulkContainer().Uint32L(CMTPUsbContainer::ETransactionID)); - RDebug::Print(_L("ContainerLength = 0x%x, containerType = 0x%x , code = 0x%x , transactionID = 0x%x "), iDataLength, containerType, code, transactionID); - } - else - { - RDebug::Print(_L("inValid usb Header read...........................................................")); -#endif - } - __FLOG(_L8("CMTPUsbEpBase::ValidateUSBHeader - Exit")); + if (iDataLength >= KUSBHeaderSize && + (containerType == EMTPUsbContainerTypeCommandBlock || containerType == EMTPUsbContainerTypeDataBlock)) + { + result = ETrue; + iDataCounter = 0; + } + + __FLOG_VA((_L8("CMTPUsbEpBase::ValidateUSBHeader - Exit with the result of %d"), result)); return result; } @@ -606,15 +602,23 @@ TRequestStatus status; do { - // Keep looking for headers. - // The case we are trying to catch is when we have 12 garbage bytes followed by 12 good bytes. - // In this case the ReadOneOrMore is acting on the next packet rather than the current packet. - // If the garbage data is a multiple of 12 bytes, we should still be able to catch the next good - // header. Otherwise the ReadOneOrMore will return will <12 bytes and we will fall through - // to the retry code below. + //trash data, continue to flush. + iReceiveData.Zero(); + Connection().Ldd().ReadPacket(status, EndpointNumber(), iReceiveData, KUSBHeaderSize); + User::WaitForRequest(status); + + //check the first 12 bytes of next packet to see whether it's an expected USB header iReceiveData.Zero(); Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), iReceiveData, KUSBHeaderSize); User::WaitForRequest(status); + +#ifdef __FLOG_ACTIVE + __FLOG_VA((_L8("Keep looking for headers, length = %d"), iReceiveData.Length())); + for (int i=0; i<3&&(i*4+4)<=iReceiveData.Length(); i++) + { + __FLOG_VA((_L8("0x%x 0x%x 0x%x 0x%x"), iReceiveData[i*4], iReceiveData[i*4+1], iReceiveData[i*4+2], iReceiveData[i*4+3])); + } +#endif } while (iReceiveData.Length()==KUSBHeaderSize && !ValidateUSBHeaderL()); if(!ValidateUSBHeaderL()) @@ -1034,7 +1038,7 @@ void CMTPUsbEpBase::FlushRxDataL() { - + __FLOG(_L8("FlushRxDataL - Entry")); // create the read buff RBuf8 readBuf; readBuf.CreateL(KFlushBufferMaxLen); @@ -1046,27 +1050,42 @@ // get the data size in the receive buffer ready to read TInt nbytes = 0; TInt err = Connection().Ldd().QueryReceiveBuffer(EndpointNumber(), nbytes); -#ifdef _DEBUG - RDebug::Print(_L("FlushRxDataL()--1---err is %d , nbytes is %d"), err, nbytes); -#endif + + __FLOG_VA((_L8("FlushRxDataL()--1---err is %d , nbytes is %d"), err, nbytes)); // has data, read it if( (err == KErrNone) && (nbytes > 0) ) - { - + { // synchronously read the data TRequestStatus status; Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), readBuf); User::WaitForRequest(status); if(status.Int() != KErrNone) break; - - // whenever some data read, reset the rest wait time . + +#ifdef __FLOG_ACTIVE + TInt length = readBuf.Length(); + __FLOG_VA((_L8("The length of trash data is %d"), length)); + + __FLOG(_L8("Begining of trash data")); + for (int i=0; i<4&&(i*4+4)<=length; i++) + { + __FLOG_VA((_L8("0x%x 0x%x 0x%x 0x%x"), readBuf[i*4], readBuf[i*4+1], readBuf[i*4+2], readBuf[i*4+3])); + } + + __FLOG(_L8("Residual of trash data if any")); + TInt residualLength = length%512; + for (int i=0; i<4&&(i*4+4)<=residualLength; i++) + { + TInt beginIndex = length - residualLength; + __FLOG_VA((_L8("0x%x 0x%x 0x%x 0x%x"), readBuf[beginIndex + i*4], readBuf[beginIndex + i*4+1], readBuf[beginIndex + i*4+2], readBuf[beginIndex + i*4+3])); + } +#endif + + // whenever some data read, reset the rest wait time. uRestTimeToWait = INTERVAL_FOR_FLUSH_TRASH_DATA; - -#ifdef _DEBUG - RDebug::Print(_L("FlushRxDataL()---Reset the rest wait time")); -#endif + + __FLOG(_L8("FlushRxDataL()---Reset the rest wait time")); } else { @@ -1075,13 +1094,11 @@ // reduce the rest time to wait uRestTimeToWait -= INTERVAL_FOR_READ_TRASH_DATA ; } - -#ifdef _DEBUG - RDebug::Print(_L("FlushRxDataL()---uRestTimeToWait is %d"), uRestTimeToWait); -#endif + + __FLOG_VA((_L8("FlushRxDataL()---uRestTimeToWait is %d"), uRestTimeToWait)); }while( uRestTimeToWait > 0); readBuf.Close(); - + __FLOG(_L8("FlushRxDataL - Exit")); }