|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Native SISX runtime type for AppMngr2 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appmngr2sisxruntime.h" // CAppMngr2SisxRuntime |
|
20 #include "appmngr2sisxappinfo.h" // CAppMngr2SisxAppInfo |
|
21 #include "appmngr2sisxpackageinfo.h" // CAppMngr2SisxPackageInfo |
|
22 #include "appmngr2sisxunknownlist.h" // CAppMngr2SisxUnknownList |
|
23 #include "appmngr2sisxswimonitor.h" // CAppMngr2SisxSwiMonitor |
|
24 #include <appmngr2runtimeobserver.h> // MAppMngr2RuntimeObserver |
|
25 #include <appmngr2recognizedfile.h> // CAppMngr2RecognizedFile |
|
26 #include <appmngr2cleanuputils.h> // CleanupResetAndDestroyPushL |
|
27 #include <appmngr2debugutils.h> // FLOG macros |
|
28 #include <swi/sisregistryentry.h> // RSisRegistryEntry |
|
29 #include <swi/sisregistrypackage.h> // CSisRegistryPackage |
|
30 #include <data_caging_path_literals.hrh> // KDC_APP_BITMAP_DIR |
|
31 #include <AknIconArray.h> // CAknIconArray |
|
32 #include <AknsUtils.h> // AknsUtils |
|
33 #include <gulicon.h> // CGulIcon |
|
34 #include <eikenv.h> // CEikonEnv |
|
35 #include <driveinfo.h> // DriveInfo |
|
36 #include <f32file.h> // RFs |
|
37 #include <SWInstDefs.h> // MIME types |
|
38 #include <appmngr2sisx.mbg> // icon IDs |
|
39 |
|
40 _LIT( KAppMngr2SisxIconFileNameMif, "AppMngr2Sisx.mif" ); |
|
41 _LIT( KDriveSpec, "%c:" ); |
|
42 _LIT8( KSisInstallerUidType, "x-epoc/x-app268436505" ); |
|
43 |
|
44 const TInt KUidLength = 8; |
|
45 |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CAppMngr2SisxRuntime::NewL() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CAppMngr2SisxRuntime* CAppMngr2SisxRuntime::NewL( MAppMngr2RuntimeObserver &aObserver ) |
|
54 { |
|
55 CAppMngr2SisxRuntime* self = new (ELeave) CAppMngr2SisxRuntime( aObserver ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL( aObserver ); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CAppMngr2SisxRuntime::~CAppMngr2SisxRuntime() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CAppMngr2SisxRuntime::~CAppMngr2SisxRuntime() |
|
67 { |
|
68 delete iSwiMonitor; |
|
69 iSisRegistrySession.Close(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CAppMngr2SisxRuntime::LoadIconsL() |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void CAppMngr2SisxRuntime::LoadIconsL( CAknIconArray& aIconArray ) |
|
77 { |
|
78 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
79 HBufC* iconFilePath = NULL; |
|
80 |
|
81 iconFilePath = FullBitmapFileNameLC( KAppMngr2SisxIconFileNameMif ); |
|
82 |
|
83 // Icon loading order in must be the same in which SISX icons |
|
84 // are defined in TAppMngr2SisxIcons enum in appmngr2sisx.hrh. |
|
85 |
|
86 // Icon 0: SIS application icon, EQgnMenuAmSis |
|
87 CGulIcon* icon = AknsUtils::CreateGulIconL( skinInstance, |
|
88 KAknsIIDQgnMenuAmSis, *iconFilePath, |
|
89 EMbmAppmngr2sisxQgn_menu_am_sis, |
|
90 EMbmAppmngr2sisxQgn_menu_am_sis_mask ); |
|
91 CleanupStack::PushL( icon ); |
|
92 aIconArray.AppendL( icon ); |
|
93 CleanupStack::Pop( icon ); |
|
94 |
|
95 // Icon 1: DRM expired rights icon, EQgnPropDrmExpLarge |
|
96 icon = AknsUtils::CreateGulIconL( skinInstance, |
|
97 KAknsIIDQgnPropDrmRightsExpLarge, *iconFilePath, |
|
98 EMbmAppmngr2sisxQgn_prop_drm_exp_large, |
|
99 EMbmAppmngr2sisxQgn_prop_drm_exp_large_mask ); |
|
100 CleanupStack::PushL( icon ); |
|
101 aIconArray.AppendL( icon ); |
|
102 CleanupStack::Pop( icon ); |
|
103 |
|
104 // Icon 2: untrusted SIS application, EQgnIndiAmInstNoAdd |
|
105 // Indicator icons are color-skinned as normal icons are |
|
106 // graphically-skinned. CreateColorIconL() must be used to |
|
107 // create color-skinned icon. |
|
108 CFbsBitmap* bitmap = NULL; |
|
109 CFbsBitmap* mask = NULL; |
|
110 AknsUtils::CreateColorIconLC( skinInstance, |
|
111 KAknsIIDQgnIndiAmInstNoAdd, |
|
112 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13, |
|
113 bitmap, mask, *iconFilePath, |
|
114 EMbmAppmngr2sisxQgn_indi_am_inst_no_add, |
|
115 EMbmAppmngr2sisxQgn_indi_am_inst_no_add_mask, |
|
116 KRgbBlack ); |
|
117 icon = CGulIcon::NewL( bitmap, mask ); |
|
118 icon->SetBitmapsOwnedExternally( EFalse ); |
|
119 CleanupStack::Pop( 2 ); // bitmap and mask, order may vary |
|
120 CleanupStack::PushL( icon ); |
|
121 aIconArray.AppendL( icon ); |
|
122 CleanupStack::Pop( icon ); |
|
123 |
|
124 CleanupStack::PopAndDestroy( iconFilePath ); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CAppMngr2SisxRuntime::GetSupportedDataTypesL() |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CAppMngr2SisxRuntime::GetSupportedDataTypesL( |
|
132 CDataTypeArray& aDataTypeArray ) |
|
133 { |
|
134 TDataType sisxType( SwiUI::KSisxMimeType ); |
|
135 aDataTypeArray.AppendL( sisxType ); |
|
136 TDataType sisType( SwiUI::KSisMimeType ); |
|
137 aDataTypeArray.AppendL( sisType ); |
|
138 TDataType pipType( SwiUI::KPipMimeType ); |
|
139 aDataTypeArray.AppendL( pipType ); |
|
140 TDataType installedUidType( KSisInstallerUidType ); |
|
141 aDataTypeArray.AppendL( installedUidType ); |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CAppMngr2SisxRuntime::GetAdditionalDirsToScanL() |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CAppMngr2SisxRuntime::GetAdditionalDirsToScanL( RFs& aFsSession, |
|
149 RPointerArray<HBufC>& aDirs ) |
|
150 { |
|
151 // Return KAppMngr2DaemonPrivateFolder directories that may contain |
|
152 // untrusted applications. Untrusted application is partially installed |
|
153 // and user needs to install it's SISX from KAppMngr2DaemonPrivateFolder |
|
154 // to complete it's installation. For example, when memory card is inserted |
|
155 // in mobile phone, installer processes applications installed in the memory |
|
156 // card. If some memory card application requires user-granted capabilities, |
|
157 // installer creates SISX in KAppMngr2DaemonPrivateFolder. The SISX must be |
|
158 // installed to grant the capabilities to the application. |
|
159 TDriveList driveList; |
|
160 TInt driveCount = 0; |
|
161 User::LeaveIfError( DriveInfo::GetUserVisibleDrives( aFsSession, driveList, driveCount ) ); |
|
162 |
|
163 TInt driveListLength = driveList.Length(); |
|
164 for( TInt driveNumber = 0; driveNumber < driveListLength; driveNumber++ ) |
|
165 { |
|
166 if( driveList[ driveNumber ] ) |
|
167 { |
|
168 // Internal and remote drives are not listed. Internal drives cannot |
|
169 // be removed/replaced, so there are no untrusted applications either. |
|
170 // Remote drives cannot be used to install applications at all. |
|
171 TUint driveStatus = 0; |
|
172 TInt err = DriveInfo::GetDriveStatus( aFsSession, driveNumber, driveStatus ); |
|
173 if( err == KErrNone && !( driveStatus & DriveInfo::EDriveRemote ) && |
|
174 !( driveStatus & DriveInfo::EDriveInternal ) ) |
|
175 { |
|
176 TChar driveLetter; |
|
177 if( RFs::DriveToChar( driveNumber, driveLetter ) == KErrNone ) |
|
178 { |
|
179 const TInt dirLength = KDriveSpec().Length() + |
|
180 KAppMngr2DaemonPrivateFolder().Length(); |
|
181 HBufC* dir = HBufC::NewLC( dirLength ); |
|
182 TPtr dirPtr = dir->Des(); |
|
183 dirPtr.Format( KDriveSpec, static_cast<TUint>( driveLetter ) ); |
|
184 dirPtr.Append( KAppMngr2DaemonPrivateFolder ); |
|
185 aDirs.AppendL( dir ); |
|
186 FLOG( "CAppMngr2SisxRuntime::GetAdditionalDirsToScanL: adding %S", dir ); |
|
187 CleanupStack::Pop( dir ); |
|
188 } |
|
189 } |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // CAppMngr2SisxRuntime::GetInstallationFilesL() |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 void CAppMngr2SisxRuntime::GetInstallationFilesL( |
|
199 RPointerArray<CAppMngr2PackageInfo>& aPackageInfos, |
|
200 const RPointerArray<CAppMngr2RecognizedFile>& aFileList, |
|
201 RFs& aFsSession, TRequestStatus& aStatus ) |
|
202 { |
|
203 TInt fileCount = aFileList.Count(); |
|
204 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: fileCount = %d", fileCount ); |
|
205 if( fileCount ) |
|
206 { |
|
207 // Check if this is the memory card installer daemon private folder. |
|
208 // All files are from the same directory, |
|
209 CAppMngr2RecognizedFile* firstFile = aFileList[ 0 ]; |
|
210 if( firstFile->FileName().Find( KAppMngr2DaemonPrivateFolder ) == KErrNotFound ) |
|
211 { |
|
212 // No, it isn't. Process all files in aFileList and create package info objects. |
|
213 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: normal folder" ); |
|
214 for( TInt index = 0; index < fileCount; index++ ) |
|
215 { |
|
216 CAppMngr2RecognizedFile* file = aFileList[ index ]; |
|
217 |
|
218 TPtrC fileName = file->FileName(); |
|
219 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: file %S", &fileName ); |
|
220 CreateNewPackageL( fileName, aPackageInfos, aFsSession ); |
|
221 } |
|
222 } |
|
223 else |
|
224 { |
|
225 // It is. Process only those files that are not installed. |
|
226 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: swidaemon private folder" ); |
|
227 RArray<TUid> uids; |
|
228 CleanupClosePushL( uids ); |
|
229 iSisRegistrySession.InstalledUidsL( uids ); |
|
230 |
|
231 for( TInt index = 0; index < fileCount; index++ ) |
|
232 { |
|
233 CAppMngr2RecognizedFile* recFile = aFileList[ index ]; |
|
234 |
|
235 TPtrC fileName = recFile->FileName(); |
|
236 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: file %S", &fileName ); |
|
237 |
|
238 // extract UID name from full path name |
|
239 TParsePtrC parse( fileName ); |
|
240 TPtrC uidName = parse.Name().Left( KUidLength ); |
|
241 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: uidName %S", &uidName ); |
|
242 |
|
243 // convert UID name to numerical form |
|
244 TLex lex( uidName ); |
|
245 TUint32 uidValue; |
|
246 TInt lexError = lex.Val( uidValue, EHex ); |
|
247 if( lexError == KErrNone ) |
|
248 { |
|
249 // It's an UID name, try to display package name instead |
|
250 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: value %08x", uidValue ); |
|
251 |
|
252 // check if this UID is already installed |
|
253 TUid fileUid; |
|
254 fileUid.iUid = uidValue; |
|
255 if( uids.Find( fileUid ) == KErrNotFound ) |
|
256 { |
|
257 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: not installed" ); |
|
258 // Not installed, must be displayed. |
|
259 CreateNewPackageL( fileName, aPackageInfos, aFsSession ); |
|
260 } |
|
261 else |
|
262 { |
|
263 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: is installed" ); |
|
264 // Installed, two possible cases here. The package is in the |
|
265 // SWI daemon private folder in memory card because: |
|
266 // 1) memory card application is installed in use normally, or |
|
267 // 2) the same application is already in ROM/internal drive. |
|
268 // In case 1) this item MAY NOT be displayed here as it is already |
|
269 // displayed in "Installed apps" side. In case of 2) it MUST be |
|
270 // displayed, so that user can remove it from memory card. Cases |
|
271 // 1) and 2) can be identified by checking the memory card's |
|
272 // "unknown" list. If the sis package is unknown, it is case 2), |
|
273 // as applications that are installed in use, are always known. |
|
274 TChar driveLetter = parse.Drive()[ 0 ]; |
|
275 TInt driveNumber = 0; |
|
276 User::LeaveIfError( RFs::CharToDrive( driveLetter, driveNumber ) ); |
|
277 CAppMngr2SisxUnknownList* unknownSisx = CAppMngr2SisxUnknownList::NewLC( |
|
278 driveNumber ); |
|
279 TInt unknownIndex = unknownSisx->FindPkgWithUID( fileUid ); |
|
280 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: unknownIndex %d", |
|
281 unknownIndex ); |
|
282 if( unknownIndex >= 0 && unknownIndex < unknownSisx->PkgCount() ) |
|
283 { |
|
284 // It is unknown package after all, add it to the list. |
|
285 CreateNewPackageL( fileName, aPackageInfos, aFsSession ); |
|
286 } |
|
287 CleanupStack::PopAndDestroy( unknownSisx ); |
|
288 } |
|
289 } |
|
290 else |
|
291 { |
|
292 // Not an UID name, must be displayed. |
|
293 FLOG( "CAppMngr2SisxRuntime::GetInstallationFilesL: not UID name (lexErr %d)", |
|
294 lexError ); |
|
295 CreateNewPackageL( fileName, aPackageInfos, aFsSession ); |
|
296 } |
|
297 } |
|
298 |
|
299 CleanupStack::PopAndDestroy( &uids ); |
|
300 } |
|
301 } |
|
302 TRequestStatus* status = &aStatus; |
|
303 User::RequestComplete( status, KErrNone ); |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // CAppMngr2SisxRuntime::CancelGetInstallationFiles() |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void CAppMngr2SisxRuntime::CancelGetInstallationFiles() |
|
311 { |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CAppMngr2SisxRuntime::GetInstalledAppsL() |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CAppMngr2SisxRuntime::GetInstalledAppsL( |
|
319 RPointerArray<CAppMngr2AppInfo>& aApps, |
|
320 RFs& aFsSession, TRequestStatus& aStatus ) |
|
321 { |
|
322 FLOG( "CAppMngr2SisxRuntime::GetInstalledAppsL" ); |
|
323 |
|
324 RPointerArray<Swi::CSisRegistryPackage> removablePackages; |
|
325 CleanupResetAndDestroyPushL( removablePackages ); |
|
326 iSisRegistrySession.RemovablePackagesL( removablePackages ); |
|
327 |
|
328 TInt appCount = removablePackages.Count(); |
|
329 FLOG( "CAppMngr2SisxRuntime::GetInstalledAppsL, appCount %d", appCount ); |
|
330 for( TInt index = 0; index < appCount; index++ ) |
|
331 { |
|
332 Swi::RSisRegistryEntry entry; |
|
333 CleanupClosePushL( entry ); |
|
334 FLOG( "CAppMngr2SisxRuntime::GetInstalledAppsL, uid 0x%08x, name %S", |
|
335 removablePackages[ index ]->Uid().Uid, |
|
336 &( removablePackages[ index ]->Name() ) ); |
|
337 entry.OpenL( iSisRegistrySession, *( removablePackages[ index ] ) ); |
|
338 |
|
339 FLOG( "CAppMngr2SisxRuntime::GetInstalledAppsL, IsPresentL = %d", |
|
340 entry.IsPresentL() ); |
|
341 // Check that sis entry is present. We should not show applications |
|
342 // installed to memory card if card is not found. |
|
343 if ( entry.IsPresentL() ) |
|
344 { |
|
345 FLOG( "CAppMngr2SisxRuntime::GetInstalledAppsL, Sis is present." ); |
|
346 |
|
347 CAppMngr2SisxAppInfo* appObj = NULL; |
|
348 TRAPD( err, appObj = CAppMngr2SisxAppInfo::NewL( *this, entry, aFsSession ) ); |
|
349 FLOG( "CAppMngr2SisxRuntime::GetInstalledAppsL, err %d", err ); |
|
350 if( err == KErrNone ) |
|
351 { |
|
352 CleanupStack::PushL( appObj ); |
|
353 aApps.AppendL( appObj ); |
|
354 CleanupStack::Pop( appObj ); |
|
355 } |
|
356 } |
|
357 |
|
358 CleanupStack::PopAndDestroy( &entry ); |
|
359 } |
|
360 |
|
361 CleanupStack::PopAndDestroy( &removablePackages ); |
|
362 |
|
363 TRequestStatus* status = &aStatus; |
|
364 User::RequestComplete( status, KErrNone ); |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CAppMngr2SisxRuntime::CancelGetInstalledApps() |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CAppMngr2SisxRuntime::CancelGetInstalledApps() |
|
372 { |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------------------------- |
|
376 // CAppMngr2SisxRuntime::CAppMngr2SisxRuntime() |
|
377 // --------------------------------------------------------------------------- |
|
378 // |
|
379 CAppMngr2SisxRuntime::CAppMngr2SisxRuntime( MAppMngr2RuntimeObserver &aObserver ) |
|
380 : CAppMngr2Runtime( aObserver ) |
|
381 { |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // CAppMngr2SisxRuntime::ConstructL() |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 void CAppMngr2SisxRuntime::ConstructL( MAppMngr2RuntimeObserver& aObserver ) |
|
389 { |
|
390 User::LeaveIfError( iSisRegistrySession.Connect() ); |
|
391 iSwiMonitor = CAppMngr2SisxSwiMonitor::NewL( aObserver ); |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // CAppMngr2SisxRuntime::ConstructL() |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 void CAppMngr2SisxRuntime::CreateNewPackageL( const TDesC& aFileName, |
|
399 RPointerArray<CAppMngr2PackageInfo>& aPackageInfos, RFs& aFs ) |
|
400 { |
|
401 CAppMngr2SisxPackageInfo* packageInfo = NULL; |
|
402 TRAPD( err, packageInfo = CAppMngr2SisxPackageInfo::NewL( *this, aFileName, aFs ) ); |
|
403 FLOG( "CAppMngr2SisxRuntime::CreateNewPackageL: file %S, err %d", &aFileName, err ); |
|
404 if( err == KErrNone ) |
|
405 { |
|
406 CleanupStack::PushL( packageInfo ); |
|
407 aPackageInfos.AppendL( packageInfo ); |
|
408 CleanupStack::Pop( packageInfo ); |
|
409 } |
|
410 } |
|
411 |