26
|
1 |
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Implements a utility class which read information from Central Repository
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
#include <centralrepository.h>
|
|
19 |
#include <usb/usblogger.h>
|
|
20 |
#ifdef SYMBIAN_FEATURE_MANAGER
|
|
21 |
#include <featureuids.h>
|
48
|
22 |
#ifndef __DUMMY_LDD__
|
|
23 |
#include <featdiscovery.h>
|
|
24 |
#else
|
|
25 |
#include "featurediscovery.h"
|
|
26 |
#endif
|
26
|
27 |
#endif
|
|
28 |
#include "usbmanprivatecrkeys.h"
|
|
29 |
#include "UsbSettings.h"
|
|
30 |
#include "CPersonality.h"
|
|
31 |
#include "usbmancenrepmanager.h"
|
|
32 |
#include "CUsbDevice.h"
|
29
|
33 |
#include "OstTraceDefinitions.h"
|
|
34 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
35 |
#include "usbmancenrepmanagerTraces.h"
|
|
36 |
#endif
|
26
|
37 |
|
|
38 |
|
|
39 |
_LIT(KUsbCenRepPanic, "UsbCenRep");
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Panic codes for the USB Central Repository Manager
|
|
43 |
*/
|
|
44 |
enum TUsbCenRepPanic
|
|
45 |
{
|
|
46 |
ECenRepObserverNotStopped = 0,
|
|
47 |
ECenRepObserverAlreadySet,
|
|
48 |
ECenRepConfigError,
|
|
49 |
ECenRepFeatureManagerError,
|
|
50 |
};
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// Private consctruction
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CUsbManCenRepManager::CUsbManCenRepManager(CUsbDevice& aUsbDevice)
|
|
57 |
: iUsbDevice( aUsbDevice )
|
|
58 |
{
|
29
|
59 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_CONS_ENTRY );
|
|
60 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_CONS_EXIT );
|
26
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// The first phase construction
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CUsbManCenRepManager* CUsbManCenRepManager::NewL(CUsbDevice& aUsbDevice)
|
|
68 |
{
|
29
|
69 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_NEWL_ENTRY );
|
26
|
70 |
CUsbManCenRepManager* self = new (ELeave) CUsbManCenRepManager(aUsbDevice);
|
|
71 |
CleanupStack::PushL( self );
|
|
72 |
self->ConstructL();
|
|
73 |
CleanupStack::Pop( self );
|
29
|
74 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_NEWL_EXIT );
|
26
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// The second phase construction
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CUsbManCenRepManager::ConstructL()
|
|
83 |
{
|
29
|
84 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CONSTRUCTL_ENTRY );
|
26
|
85 |
// Open the Central Repository
|
|
86 |
iRepository = CRepository::NewL( KCRUidUSBManagerConfiguration );
|
|
87 |
CheckSignatureL();
|
29
|
88 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CONSTRUCTL_EXIT );
|
26
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
// Deconstruction
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
CUsbManCenRepManager::~CUsbManCenRepManager()
|
|
96 |
{
|
29
|
97 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_DES_ENTRY );
|
26
|
98 |
delete iRepository;
|
29
|
99 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CUSBMANCENREPMANAGER_DES_EXIT );
|
26
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// Read specific Key whose value type is String
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
HBufC* CUsbManCenRepManager::ReadStringKeyLC( TUint32 aKeyId )
|
|
107 |
{
|
29
|
108 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READSTRINGKEYLC_ENTRY );
|
26
|
109 |
HBufC* keyBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
|
|
110 |
TPtr key = keyBuf->Des();
|
|
111 |
|
29
|
112 |
TInt err = iRepository->Get( aKeyId, key );
|
|
113 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READSTRINGKEYLC, "CUsbManCenRepManager::ReadStringKeyLC;Leave err=%d", err ););
|
|
114 |
OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_READSTRINGKEYLC_DUP1, "CUsbManCenRepManager::ReadStringKeyLC;aKeyId=%x;key=%S", aKeyId, key );
|
26
|
115 |
|
29
|
116 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READSTRINGKEYLC_EXIT );
|
26
|
117 |
return keyBuf;
|
|
118 |
}
|
|
119 |
|
|
120 |
// ---------------------------------------------------------------------------
|
|
121 |
// Read specific Key whose value type is TInt
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
//
|
|
124 |
TInt CUsbManCenRepManager::ReadKeyL( TUint32 aKeyId )
|
|
125 |
{
|
29
|
126 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READKEYL_ENTRY );
|
26
|
127 |
TInt key;
|
|
128 |
|
29
|
129 |
TInt err = iRepository->Get( aKeyId, key );
|
|
130 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READKEYL, "CUsbManCenRepManager::ReadKeyL;Leave err=%d", err ); );
|
|
131 |
OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_READKEYL_DUP1, "CUsbManCenRepManager::ReadKeyL;LocSets: ReadKeyL id: 0x%x, val: 0x%x", aKeyId, (TInt32)key );
|
26
|
132 |
|
29
|
133 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READKEYL_EXIT );
|
26
|
134 |
return key;
|
|
135 |
}
|
|
136 |
|
|
137 |
// ---------------------------------------------------------------------------
|
|
138 |
// Check wheather cenrep's version is supported by cenrep manager
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
//
|
|
141 |
void CUsbManCenRepManager::CheckSignatureL()
|
|
142 |
{
|
29
|
143 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_CHECKSIGNATUREL_ENTRY );
|
26
|
144 |
iSignature = ReadKeyL( KUsbManConfigSign );
|
|
145 |
|
|
146 |
if ( iSignature < TUsbManagerSupportedVersionMin ||
|
|
147 |
iSignature > TUsbManagerSupportedVersionMax )
|
|
148 |
{
|
29
|
149 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_CHECKSIGNATUREL, "CUsbManCenRepManager::CheckSignatureL;Leave reason=%d", KErrNotSupported );
|
26
|
150 |
}
|
29
|
151 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_CHECKSIGNATUREL_EXIT );
|
26
|
152 |
}
|
|
153 |
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
// Read Device configuration table
|
|
156 |
// ---------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
void CUsbManCenRepManager::ReadDeviceConfigurationL(CUsbDevice::TUsbDeviceConfiguration& aDeviceConfig)
|
|
159 |
{
|
29
|
160 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_ENTRY );
|
26
|
161 |
//Only support version four right now.
|
29
|
162 |
if(TUsbManagerSupportedVersionFour != iSignature)
|
|
163 |
{
|
|
164 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL, "CUsbManCenRepManager::ReadDeviceConfigurationL;Panic error=%d", ECenRepConfigError );
|
|
165 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
166 |
}
|
|
167 |
|
26
|
168 |
|
|
169 |
//Shall only have on device configuration setting.
|
|
170 |
TUint32 devConfigCount = ReadKeyL( KUsbManDeviceCountIndexKey );
|
29
|
171 |
if(devConfigCount != 1)
|
|
172 |
{
|
|
173 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP1, "CUsbManCenRepManager::ReadDeviceConfigurationL;Panic error=%d", ECenRepConfigError );
|
|
174 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
175 |
}
|
|
176 |
|
26
|
177 |
|
|
178 |
RArray<TUint32> keyArray;
|
|
179 |
CleanupClosePushL( keyArray );
|
29
|
180 |
TInt err = iRepository->FindL( KUsbManDevicePartialKey, KUsbManConfigKeyMask, keyArray );
|
|
181 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP2, "CUsbManCenRepManager::ReadDeviceConfigurationL;Leave err=%d", err ); );
|
26
|
182 |
|
|
183 |
TInt keyCount = keyArray.Count();
|
29
|
184 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP3, "CUsbManCenRepManager::ReadDeviceConfigurationL;keyCount of device config = %d", keyCount );
|
26
|
185 |
|
|
186 |
//Get each extension type key value and store in iExtList array
|
|
187 |
for( TInt index = 0; index < keyCount; index++ )
|
|
188 |
{
|
|
189 |
TUint32 key = keyArray[index];
|
|
190 |
TUint32 fieldId = ( key & KUsbManConfigFieldMask );
|
29
|
191 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP4, "CUsbManCenRepManager::ReadDeviceConfigurationL;fieldId=%d", fieldId );
|
26
|
192 |
if( fieldId == KUsbManDeviceVendorIdKey )
|
|
193 |
{
|
|
194 |
aDeviceConfig.iVendorId = ReadKeyL( key );
|
|
195 |
}
|
|
196 |
else if( fieldId == KUsbManDeviceManufacturerNameKey )
|
|
197 |
{
|
|
198 |
HBufC* manufacturer = ReadStringKeyLC( key );
|
|
199 |
TPtr manufacturerPtr = manufacturer->Des();
|
|
200 |
aDeviceConfig.iManufacturerName->Des().Copy( manufacturerPtr );
|
|
201 |
CleanupStack::PopAndDestroy( manufacturer );
|
|
202 |
}
|
|
203 |
else if( fieldId == KUsbManDeviceProductNameKey )
|
|
204 |
{
|
|
205 |
HBufC* product = ReadStringKeyLC( key );
|
|
206 |
TPtr productName = product->Des();
|
|
207 |
aDeviceConfig.iProductName->Des().Copy( productName );
|
|
208 |
CleanupStack::PopAndDestroy( product );
|
|
209 |
}
|
|
210 |
else
|
|
211 |
{
|
29
|
212 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_DUP5, "CUsbManCenRepManager::ReadDeviceConfigurationL;panic error=%d", ECenRepConfigError );
|
|
213 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
26
|
214 |
}
|
|
215 |
}
|
|
216 |
CleanupStack::PopAndDestroy( &keyArray );
|
29
|
217 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READDEVICECONFIGURATIONL_EXIT );
|
26
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
// Read personality table
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CUsbManCenRepManager::ReadPersonalitiesL(RPointerArray<CPersonality>& aPersonalities)
|
|
226 |
{
|
29
|
227 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READPERSONALITIESL_ENTRY );
|
26
|
228 |
|
|
229 |
//Only support version four right now.
|
29
|
230 |
if(TUsbManagerSupportedVersionFour != iSignature)
|
|
231 |
{
|
|
232 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READPERSONALITIESL, "CUsbManCenRepManager::ReadPersonalitiesL;ECenRepConfigError=%d", ECenRepConfigError );
|
|
233 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
234 |
}
|
|
235 |
|
26
|
236 |
// Get the personality count.
|
|
237 |
TUint32 personalityCount = ReadKeyL( KUsbManDevicePersonalitiesCountIndexKey );
|
29
|
238 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP3, "CUsbManCenRepManager::ReadPersonalitiesL;personalityCount=%d", personalityCount );
|
26
|
239 |
|
|
240 |
RArray<TUint32> keyArray;
|
|
241 |
CleanupClosePushL( keyArray );
|
|
242 |
|
|
243 |
|
|
244 |
// Go through all personalities and store them.
|
|
245 |
for( TInt personalityIdx = 0; personalityIdx < personalityCount; personalityIdx++ )
|
|
246 |
{
|
|
247 |
CPersonality* personality = CPersonality::NewL();
|
|
248 |
CleanupStack::PushL( personality );
|
|
249 |
|
|
250 |
// Find the keys belonging to the personality
|
|
251 |
TUint32 devicePersonalitiesKey = KUsbManDevicePersonalitiesPartialKey | ( personalityIdx << KUsbManPersonalitiesOffset );
|
29
|
252 |
TInt err = iRepository->FindL( devicePersonalitiesKey, KUsbManConfigKeyMask, keyArray );
|
|
253 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP1, "CUsbManCenRepManager::ReadPersonalitiesL;Leave err=%d", err ); );
|
26
|
254 |
|
|
255 |
TInt keyCount = keyArray.Count();
|
29
|
256 |
OstTrace1( TRACE_NORMAL, DUP2_CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP2, "CUsbManCenRepManager::ReadPersonalitiesL; keyCount of personality = %d", keyCount );
|
26
|
257 |
|
|
258 |
// Get each key value of the personality and store it.
|
|
259 |
for( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
|
|
260 |
{
|
|
261 |
TUint32 key = keyArray[keyIdx];
|
|
262 |
TUint32 fieldId = (key & KUsbManConfigFieldMask);
|
29
|
263 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP4, "CUsbManCenRepManager::ReadPersonalitiesL;key id of personality=%d", fieldId );
|
26
|
264 |
switch( fieldId )
|
|
265 |
{
|
|
266 |
case KUsbManDevicePersonalitiesDeviceClassKey:
|
|
267 |
personality->SetDeviceClass(ReadKeyL( key ));
|
|
268 |
break;
|
|
269 |
case KUsbManDevicePersonalitiesDeviceSubClassKey:
|
|
270 |
personality->SetDeviceSubClass(ReadKeyL( key ));
|
|
271 |
break;
|
|
272 |
case KUsbManDevicePersonalitiesProtocolKey:
|
|
273 |
personality->SetDeviceProtocol(ReadKeyL( key ));
|
|
274 |
break;
|
|
275 |
case KUsbManDevicePersonalitiesNumConfigKey:
|
|
276 |
personality->SetNumConfigurations(ReadKeyL( key ));
|
|
277 |
break;
|
|
278 |
case KUsbManDevicePersonalitiesProductIdKey:
|
|
279 |
personality->SetProductId(ReadKeyL( key ));
|
|
280 |
break;
|
|
281 |
case KUsbManDevicePersonalitiesBcdDeviceKey:
|
|
282 |
personality->SetBcdDevice(ReadKeyL( key ));
|
|
283 |
break;
|
|
284 |
case KUsbManDevicePersonalitiesFeatureIdKey:
|
|
285 |
personality->SetFeatureId(ReadKeyL( key ));
|
|
286 |
break;
|
|
287 |
case KUsbManDevicePersonalitiesPersonalityIdKey:
|
|
288 |
personality->SetPersonalityId(ReadKeyL( key ));
|
|
289 |
ReadConfigurationsForPersonalityL( personality->PersonalityId(), *personality );
|
|
290 |
break;
|
|
291 |
case KUsbManDevicePersonalitiesPropertyKey:
|
|
292 |
personality->SetProperty(ReadKeyL( key ));
|
|
293 |
break;
|
|
294 |
case KUsbManDevicePersonalitiesDescriptionKey:
|
|
295 |
{
|
|
296 |
HBufC* description;
|
|
297 |
description = ReadStringKeyLC( key );
|
|
298 |
personality->SetDescription( description );
|
|
299 |
CleanupStack::PopAndDestroy( description );
|
|
300 |
break;
|
|
301 |
}
|
|
302 |
default:
|
29
|
303 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP5, "CUsbManCenRepManager::ReadPersonalitiesL;Panic error=%d", ECenRepConfigError );
|
|
304 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
26
|
305 |
break;
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
personality->SetVersion(iSignature);
|
|
310 |
|
|
311 |
//The following code is to check whether we support this personality.
|
|
312 |
if(personality->FeatureId() != KUsbManFeatureNotConfigurable)
|
|
313 |
{
|
|
314 |
if(!IsFeatureSupportedL(personality->FeatureId()))
|
|
315 |
{
|
|
316 |
CleanupStack::PopAndDestroy(personality);
|
|
317 |
continue;
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
//The following code is to check whether we support this personality. It will not include:
|
|
322 |
//1)the personality which contains single class which is not supported
|
|
323 |
//2)the personality which contains multiple classes which are all not supported
|
|
324 |
TBool isPersonalitySupport = EFalse;
|
|
325 |
TInt configurationCount = personality->PersonalityConfigs().Count();
|
|
326 |
for(TInt configurationIdx = 0; configurationIdx < configurationCount; ++configurationIdx)
|
|
327 |
{
|
|
328 |
const RPointerArray<CPersonalityConfigurations>& personalityConfigs = personality->PersonalityConfigs();
|
|
329 |
CPersonalityConfigurations *personalityConfigurations = personalityConfigs[configurationIdx];
|
|
330 |
TInt classesCount = personalityConfigurations->Classes().Count();
|
|
331 |
if(0 != classesCount)
|
|
332 |
{
|
|
333 |
isPersonalitySupport = ETrue;
|
|
334 |
break;
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
if(isPersonalitySupport)
|
|
339 |
{
|
29
|
340 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP6, "CUsbManCenRepManager::ReadPersonalitiesL; Personality ID: %d is supported", personality->PersonalityId() );
|
26
|
341 |
aPersonalities.Append( personality );
|
|
342 |
CleanupStack::Pop( personality );
|
|
343 |
}
|
|
344 |
else
|
|
345 |
{
|
29
|
346 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READPERSONALITIESL_DUP7, "CUsbManCenRepManager::ReadPersonalitiesL;Personality ID: %d is not supported", personality->PersonalityId() );
|
26
|
347 |
CleanupStack::PopAndDestroy(personality);
|
|
348 |
}
|
|
349 |
}
|
|
350 |
CleanupStack::PopAndDestroy( &keyArray );
|
29
|
351 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READPERSONALITIESL_EXIT );
|
26
|
352 |
}
|
|
353 |
|
|
354 |
// ---------------------------------------------------------------------------
|
|
355 |
// Read configuration table for specific personality
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
void CUsbManCenRepManager::ReadConfigurationsForPersonalityL(TInt aPersonalityId, CPersonality& aPersonality)
|
|
359 |
{
|
29
|
360 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_ENTRY );
|
26
|
361 |
RArray<TUint32> configArray;
|
|
362 |
CleanupClosePushL(configArray);
|
|
363 |
|
|
364 |
//Only support version four right now.
|
29
|
365 |
if(TUsbManagerSupportedVersionFour != iSignature)
|
|
366 |
{
|
|
367 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
|
|
368 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
369 |
}
|
|
370 |
|
|
371 |
TInt err = iRepository->FindEqL( KUsbManDeviceConfigurationsPartialKey, KUsbManConfigFirstEntryMask, aPersonalityId, configArray );
|
|
372 |
LEAVEIFERRORL( err, OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP1, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Leave err=%d", err ); );
|
26
|
373 |
|
|
374 |
// Get the configuration count.
|
|
375 |
TUint32 configCount = configArray.Count();
|
|
376 |
TUint32 totalConfigCount = ReadKeyL( KUsbManDeviceConfigurationsCountIndexKey );
|
|
377 |
|
29
|
378 |
OstTraceExt3( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP2,
|
|
379 |
"CUsbManCenRepManager::ReadConfigurationsForPersonalityL;aPersonalityId = %d total configCount = %d configArray.Count() = %d", aPersonalityId, totalConfigCount, configArray.Count() );
|
26
|
380 |
|
|
381 |
//This is intend to handle one special case that key 0x2ff00's value
|
|
382 |
// equal our target personality id.
|
|
383 |
if(totalConfigCount == aPersonalityId)
|
|
384 |
{
|
|
385 |
--configCount;
|
|
386 |
}
|
|
387 |
|
|
388 |
TInt keyCount = 0;
|
|
389 |
if(TUsbManagerSupportedVersionFour == iSignature)
|
|
390 |
{
|
|
391 |
keyCount = KUsbManDeviceConfigurationsKeyCountVersionFour;
|
|
392 |
}
|
|
393 |
|
|
394 |
// Go through all configurations belonging to this personality 'aPersonalityId'
|
|
395 |
for ( TInt configIdx = 0; configIdx < configCount; configIdx++ )
|
|
396 |
{
|
|
397 |
CPersonalityConfigurations* config = new ( ELeave ) CPersonalityConfigurations;
|
|
398 |
CleanupStack::PushL( config );
|
|
399 |
TUint32 key = configArray[configIdx];
|
|
400 |
|
|
401 |
// Get each key value in the configuration and store it
|
|
402 |
for ( TInt keyIdx = 0; keyIdx < keyCount; keyIdx++ )
|
|
403 |
{
|
|
404 |
TUint32 fieldId = ( (key + keyIdx ) & KUsbManConfigFieldMask );
|
|
405 |
TInt keyValue = -1;
|
29
|
406 |
OstTraceExt3( TRACE_NORMAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP3, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;fieldId=%d;configIdx=%d;keyIdx=%d", fieldId, configIdx, keyIdx );
|
26
|
407 |
|
|
408 |
if(KUsbManDeviceConfigurationsPersonalityIdKey == fieldId)
|
|
409 |
{
|
|
410 |
TRAPD( err, keyValue = ReadKeyL( key + keyIdx ) );
|
|
411 |
if( err == KErrNone )
|
|
412 |
{
|
29
|
413 |
if(keyValue != aPersonalityId)
|
|
414 |
{
|
|
415 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP4, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
|
|
416 |
__ASSERT_DEBUG( EFalse, User::Panic( KUsbCenRepPanic, ECenRepConfigError ) );
|
|
417 |
}
|
26
|
418 |
config->SetPersonalityId( keyValue );
|
|
419 |
}
|
|
420 |
}
|
|
421 |
else if(KUsbManDeviceConfigurationsIdKey == fieldId)
|
|
422 |
{
|
|
423 |
TRAPD( err, keyValue = ReadKeyL( key + keyIdx ) );
|
|
424 |
if( err == KErrNone )
|
|
425 |
{
|
|
426 |
config->SetConfigId(keyValue);
|
|
427 |
}
|
|
428 |
}
|
|
429 |
else if(KUsbManDeviceConfigurationsClassUidsKey == fieldId)
|
|
430 |
{
|
|
431 |
HBufC* keyValueBuf = ReadStringKeyLC( key + keyIdx );
|
|
432 |
TPtr keyPtr = keyValueBuf->Des();
|
|
433 |
|
|
434 |
RArray<TUint> classUids;
|
|
435 |
CleanupClosePushL( classUids );
|
|
436 |
|
|
437 |
iUsbDevice.ConvertUidsL( keyPtr, classUids );
|
|
438 |
TInt uidsCnt = classUids.Count();
|
|
439 |
|
|
440 |
// Get featureId of each class and store each class.
|
|
441 |
TInt featureId = KUsbManFeatureNotConfigurable;
|
|
442 |
CPersonalityConfigurations::TUsbClasses usbClass;
|
|
443 |
for ( TInt uidIdx = 0; uidIdx < uidsCnt; uidIdx++ )
|
|
444 |
{
|
|
445 |
usbClass.iClassUid = TUid::Uid( classUids[uidIdx] );
|
|
446 |
usbClass.iFeatureId = featureId; // By default
|
|
447 |
if ( IsClassConfigurableL( classUids[uidIdx], featureId ) )
|
|
448 |
{
|
|
449 |
usbClass.iFeatureId = featureId;
|
|
450 |
if(IsFeatureSupportedL(featureId))
|
|
451 |
{
|
|
452 |
config->AppendClassesL( usbClass );
|
|
453 |
}
|
|
454 |
}
|
|
455 |
else
|
|
456 |
{
|
|
457 |
config->AppendClassesL( usbClass );
|
|
458 |
}
|
|
459 |
}
|
|
460 |
|
|
461 |
CleanupStack::PopAndDestroy( &classUids ); // close uid array
|
|
462 |
CleanupStack::PopAndDestroy( keyValueBuf );
|
|
463 |
}
|
|
464 |
else
|
|
465 |
{
|
29
|
466 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_DUP5, "CUsbManCenRepManager::ReadConfigurationsForPersonalityL;Panic error=%d", ECenRepConfigError );
|
|
467 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
26
|
468 |
}
|
|
469 |
}
|
|
470 |
aPersonality.AppendPersonalityConfigsL( config );
|
|
471 |
|
|
472 |
CleanupStack::Pop( config );
|
|
473 |
}
|
|
474 |
|
|
475 |
CleanupStack::PopAndDestroy( &configArray );
|
29
|
476 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_READCONFIGURATIONSFORPERSONALITYL_EXIT );
|
26
|
477 |
}
|
|
478 |
|
|
479 |
// ---------------------------------------------------------------------------
|
|
480 |
// Check the class belonging to a personality configurable or not.
|
|
481 |
// ---------------------------------------------------------------------------
|
|
482 |
//
|
|
483 |
TBool CUsbManCenRepManager::IsClassConfigurableL(TUint aClassId, TInt& aFeatureId)
|
|
484 |
{
|
29
|
485 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_ENTRY );
|
26
|
486 |
TBool classConfigurable = EFalse;
|
|
487 |
RArray<TUint32> keyArray;
|
|
488 |
CleanupClosePushL(keyArray);
|
|
489 |
|
|
490 |
TInt err = iRepository->FindEqL( KUsbManDeviceConfigurableClassesPartialKey, KUsbManConfigFirstEntryMask, (TInt)aClassId, keyArray );
|
29
|
491 |
OstTraceExt2( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL, "CUsbManCenRepManager::IsClassConfigurableL;aClassId=0x%x;err=%d", aClassId, err );
|
26
|
492 |
switch ( err )
|
|
493 |
{
|
|
494 |
case KErrNotFound:
|
|
495 |
break;
|
|
496 |
case KErrNone:
|
|
497 |
{
|
29
|
498 |
#ifdef _DEBUG
|
|
499 |
if(keyArray.Count() != 1)
|
|
500 |
{
|
|
501 |
OstTrace1( TRACE_FATAL, DUP1_CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_DUP1, "CUsbManCenRepManager::IsClassConfigurableL;panic error=%d", ECenRepConfigError );
|
|
502 |
User::Panic( KUsbCenRepPanic, ECenRepConfigError );
|
|
503 |
}
|
|
504 |
#endif
|
26
|
505 |
// The array size always is 1, so here using 0 as index.
|
|
506 |
aFeatureId = ReadKeyL( keyArray[0] | KUsbManDeviceConfigurableClassesFeatureIdKey );
|
|
507 |
classConfigurable = ETrue;
|
|
508 |
break;
|
|
509 |
}
|
|
510 |
default:
|
29
|
511 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_DUP2, "CUsbManCenRepManager::IsClassConfigurableL;Leave err=%d", err );
|
|
512 |
User::Leave( err );
|
26
|
513 |
break;
|
|
514 |
}
|
|
515 |
|
|
516 |
CleanupStack::PopAndDestroy( &keyArray );
|
29
|
517 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISCLASSCONFIGURABLEL_EXIT );
|
26
|
518 |
return classConfigurable;
|
|
519 |
}
|
|
520 |
|
|
521 |
// ---------------------------------------------------------------------------
|
|
522 |
// Check the class belonging to a personality support or not.
|
|
523 |
// ---------------------------------------------------------------------------
|
|
524 |
//
|
|
525 |
TBool CUsbManCenRepManager::IsFeatureSupportedL(TInt aFeatureId)
|
|
526 |
{
|
29
|
527 |
OstTraceFunctionEntry0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_ENTRY );
|
26
|
528 |
#ifdef SYMBIAN_FEATURE_MANAGER
|
|
529 |
if(CFeatureDiscovery::IsFeatureSupportedL(TUid::Uid(aFeatureId)))
|
|
530 |
{
|
29
|
531 |
OstTrace1( TRACE_NORMAL, DUP1_CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_DUP1, "CUsbManCenRepManager::IsFeatureSupportedL;featureId = 0x%x supported", aFeatureId );
|
|
532 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_EXIT );
|
26
|
533 |
return ETrue;
|
|
534 |
}
|
|
535 |
else
|
|
536 |
{
|
29
|
537 |
OstTrace1( TRACE_NORMAL, CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_DUP2, "CUsbManCenRepManager::IsFeatureSupportedL;featureId = 0x%x not supported", aFeatureId );
|
|
538 |
OstTraceFunctionExit0( CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL_EXIT_DUP1 );
|
26
|
539 |
return EFalse;
|
|
540 |
}
|
|
541 |
#else
|
29
|
542 |
OstTrace1( TRACE_FATAL, CUSBMANCENREPMANAGER_ISFEATURESUPPORTEDL, "CUsbManCenRepManager::IsFeatureSupportedL;panic error code=%d", ECenRepFeatureManagerError );
|
|
543 |
User::Panic( KUsbCenRepPanic, ECenRepFeatureManagerError )
|
26
|
544 |
#endif
|
|
545 |
}
|