136 } |
161 } |
137 CleanupStack::PopAndDestroy(&fileName); |
162 CleanupStack::PopAndDestroy(&fileName); |
138 return firstInvocation; |
163 return firstInvocation; |
139 } |
164 } |
140 |
165 |
|
166 void CSisRegistrySession::ProcessRomStubsL() |
|
167 { |
|
168 DEBUG_PRINTF(_L8("SIS Registry Server - Starting processing of ROM Stub sis files")); |
|
169 iScrSession.CreateTransactionL(); |
|
170 ProcessRomDriveL(); |
|
171 iScrSession.CommitTransactionL(); |
|
172 |
|
173 // Create a file in <systemdrive>:\sys to mark a successful initialization |
|
174 // so that we don't come here again (unless firmware is upgraded in which case <systemdrive>:\sys |
|
175 // should be cleaned |
|
176 RBuf fileName; |
|
177 CleanupClosePushL(fileName); |
|
178 fileName.CreateL(KMaxPath); |
|
179 TDriveUnit drive(iSystemDrive); |
|
180 fileName = drive.Name(); |
|
181 fileName.Append(KSWIRegFirstInitFile); |
|
182 RFile file; |
|
183 CleanupClosePushL(file); |
|
184 file.Replace(iFs, fileName, EFileWrite | EFileShareAny); |
|
185 CleanupStack::PopAndDestroy(2, &fileName); // file |
|
186 |
|
187 DEBUG_PRINTF(_L8("SIS Registry Server - Completed processing of ROM Stub sis files")); |
|
188 } |
|
189 |
|
190 void CSisRegistrySession::ProcessApplicationsL() |
|
191 { |
|
192 TComponentId compId = 0; |
|
193 DEBUG_PRINTF(_L8("SIS Registry Server - Deleteing all existing ROM applications.")); |
|
194 ScrHelperUtil::DeleteApplicationEntriesL(iScrSession, compId); |
|
195 |
|
196 //Register all apps found in \private\10003a3f\apps |
|
197 TDriveUnit romDrive(SisRegistryUtil::SystemRomDrive()); |
|
198 RBuf apparcRegFilePath; |
|
199 apparcRegFilePath.CreateL(romDrive.Name(), KMaxPath); |
|
200 CleanupClosePushL(apparcRegFilePath); |
|
201 apparcRegFilePath.Append(KApparcRegFilePath); |
|
202 |
|
203 //Create a single transaction to register all in rom apps |
|
204 iScrSession.CreateTransactionL(); |
|
205 RegisterAllAppL(apparcRegFilePath); |
|
206 |
|
207 //Register all apps found in \private\10003a3f\import\apps |
|
208 apparcRegFilePath = romDrive.Name(); |
|
209 apparcRegFilePath.Append(KApparcRegFileImportPath); |
|
210 RegisterAllAppL(apparcRegFilePath); |
|
211 |
|
212 //Register all apps found in UDA |
|
213 TDriveUnit systemDrive(iSystemDrive); |
|
214 |
|
215 //Register all apps found in <systemdrive>\private\10003a3f\apps |
|
216 apparcRegFilePath = systemDrive.Name(); |
|
217 apparcRegFilePath.Append(KApparcRegFilePath); |
|
218 RegisterAllAppL(apparcRegFilePath); |
|
219 |
|
220 //Register all apps found in <systemdrive>\private\10003a3f\import\apps |
|
221 apparcRegFilePath = systemDrive.Name(); |
|
222 apparcRegFilePath.Append(KApparcRegFileImportPath); |
|
223 RegisterAllAppL(apparcRegFilePath); |
|
224 |
|
225 iScrSession.CommitTransactionL(); |
|
226 |
|
227 CleanupStack::PopAndDestroy(&apparcRegFilePath); |
|
228 |
|
229 DEBUG_PRINTF(_L8("SIS Registry Server - Completed processing of all existing ROM applications.")); |
|
230 } |
|
231 |
141 // Does initialization required when run after very first boot of phone (or after firmware upgrade) |
232 // Does initialization required when run after very first boot of phone (or after firmware upgrade) |
142 // Method is only invoked when such a state is detected |
233 // Method is only invoked when such a state is detected (only in device, NOT in emulator) |
143 // Leaves behind a file in <systemdrive>:\sys to mark a successful initialization |
234 // Leaves behind a file in <systemdrive>:\sys to mark a successful initialization |
144 void CSisRegistrySession::FirstInvocationInitL() |
235 void CSisRegistrySession::FirstInvocationInitL() |
145 { |
236 { |
146 // Add the ROM installed stub details to SCR |
237 // Add the ROM installed stub details to SCR |
147 // Create an SCR transaction, so that entries won't be added to the SCR if the function leaves |
238 // Create an SCR transaction, so that entries won't be added to the SCR if the function leaves |
148 iScrSession.CreateTransactionL(); |
239 TInt value(EIdlePhase1NOK); |
149 ProcessRomDriveL(); |
240 TInt ret = RProperty::Get(KPSUidStartup, KPSIdlePhase1Ok, value); |
150 iScrSession.CommitTransactionL(); |
241 |
151 // Create a file in <systemdrive>:\sys to mark a successful initialization |
242 TBool isFromSWIDaemon = EFalse; |
152 // so that we don't come here again (unless firmware is upgraded in which case <systemdrive>:\sys |
243 _LIT_SECURE_ID(KSWIDaemonSID, 0x10202DCE); |
153 // should be cleaned |
244 if (KSWIDaemonSID.iId == iClientSid.iId) |
154 RBuf fileName; |
245 { |
155 CleanupClosePushL(fileName); |
246 isFromSWIDaemon = ETrue; |
156 fileName.CreateL(KMaxPath); |
247 } |
157 TDriveUnit drive(iSystemDrive); |
248 |
158 fileName = drive.Name(); |
249 //If the image is NCP 'KPSUidStartup' property is not set, hence settig it explicitly for processing stubs |
159 fileName.Append(KSWIRegFirstInitFile); |
250 if(ret == KErrNotFound) |
160 RFile file; |
251 { |
161 CleanupClosePushL(file); |
252 DEBUG_PRINTF(_L8("SIS Registry Server - 'KPSUidStartup' property is not set")); |
162 file.Replace(iFs, fileName, EFileWrite | EFileShareAny); |
253 value = EIdlePhase1Ok; |
163 CleanupStack::PopAndDestroy(2, &fileName); // file |
254 } |
|
255 else |
|
256 { |
|
257 DEBUG_PRINTF(_L8("SIS Registry Server - 'KPSUidStartup' property is set")); |
|
258 } |
|
259 if ((value == EIdlePhase1Ok || isFromSWIDaemon) && iIsFirstInit) |
|
260 { |
|
261 ProcessRomStubsL(); |
|
262 } |
|
263 |
|
264 if (iIsFwUpdated) |
|
265 { |
|
266 // Delete the SisRegistry marker file |
|
267 RBuf fileName; |
|
268 CleanupClosePushL(fileName); |
|
269 fileName.CreateL(KMaxPath); |
|
270 TDriveUnit drive(iSystemDrive); |
|
271 fileName = drive.Name(); |
|
272 fileName.Append(KSWIRegFirstInitFile); |
|
273 iFs.Delete(fileName); |
|
274 CleanupStack::PopAndDestroy(&fileName); |
|
275 |
|
276 ProcessApplicationsL(); |
|
277 } |
164 } |
278 } |
165 |
279 |
166 // |
280 // |
167 // Handle a client request. |
281 // Handle a client request. |
168 // Leaving is handled by CSisRegistry::ServiceError() which reports |
282 // Leaving is handled by CSisRegistry::ServiceError() which reports |
930 |
1058 |
931 // Gets the total number of files in a stub file and all the entries as well. |
1059 // Gets the total number of files in a stub file and all the entries as well. |
932 // The output will be based on the request parameters (operational mode) sent as input. |
1060 // The output will be based on the request parameters (operational mode) sent as input. |
933 void CSisRegistrySession::RequestStubFileEntriesL(const RMessage2& aMessage) |
1061 void CSisRegistrySession::RequestStubFileEntriesL(const RMessage2& aMessage) |
934 { |
1062 { |
935 TBool stubNotFound(ETrue); |
|
936 |
|
937 TUid tUid; |
1063 TUid tUid; |
938 TPckg<TUid> packageUid(tUid); |
1064 TPckg<TUid> packageUid(tUid); |
939 aMessage.ReadL(EIpcArgument0, packageUid, 0); |
1065 aMessage.ReadL(EIpcArgument0, packageUid, 0); |
940 |
1066 |
941 TStubExtractionMode tMode; |
1067 TStubExtractionMode tMode; |
942 TPckg<TStubExtractionMode> packageMode(tMode); |
1068 TPckg<TStubExtractionMode> packageMode(tMode); |
943 aMessage.ReadL(EIpcArgument1, packageMode, 0); |
1069 aMessage.ReadL(EIpcArgument1, packageMode, 0); |
944 |
1070 |
945 // Prepare the stub file path. |
1071 TInt startingFileNo = 0; |
946 TDriveUnit romDrive(EDriveZ); |
1072 if (tMode == EGetFiles) |
947 RBuf romRegistryPath; |
1073 { |
948 romRegistryPath.CreateL(romDrive.Name(), KMaxPath); |
1074 TPckg<TInt> start(startingFileNo); |
949 CleanupClosePushL(romRegistryPath); |
1075 aMessage.ReadL(EIpcArgument2, start, 0); |
950 romRegistryPath.Append(KPreInstalledPath); |
1076 } |
951 |
1077 |
952 RFs tFs; |
1078 TInt fileCount = 0; |
953 CDir* dir; |
1079 RPointerArray<HBufC> fileNames; |
954 |
1080 CleanupResetAndDestroy<RPointerArray<HBufC> >::PushL(fileNames); |
955 // Get stub files under the ROM stub directory (Z:\system\install\). |
1081 |
956 User::LeaveIfError(tFs.Connect()); |
1082 TRAPD(errCode, GetStubFileInfoL(tUid, tMode, startingFileNo, fileCount, fileNames)); |
957 CleanupClosePushL(tFs); |
1083 if (KErrNone == errCode) |
958 |
1084 { |
959 TInt err = tFs.GetDir(romRegistryPath, KEntryAttMatchExclude | KEntryAttDir, ESortNone, dir); |
1085 if (tMode == EGetFiles) |
960 |
1086 { |
961 if (err == KErrNone) |
1087 // Stream via multiple IPC writes instead of |
962 { |
1088 // copying to a buffer and streaming from there. |
963 CleanupStack::PushL(dir); |
1089 RIpcWriteStream ipcstream; |
964 TInt count(dir->Count()); |
1090 ipcstream.Open(aMessage, EIpcArgument3); |
965 RBuf controllerFileName; |
1091 CleanupClosePushL(ipcstream); |
966 controllerFileName.CreateL(KMaxFileName); |
1092 ExternalizePointerArrayL(fileNames,ipcstream); |
967 CleanupClosePushL(controllerFileName); |
1093 ipcstream.CommitL(); |
968 for (TInt index = 0; index < count; ++index) |
1094 aMessage.Complete(KErrNone); |
969 { |
1095 CleanupStack::PopAndDestroy(&ipcstream); |
970 controllerFileName = romRegistryPath; |
1096 } |
971 controllerFileName.Append((*dir)[index].iName); |
1097 else if (tMode == EGetCount) |
972 |
1098 { |
973 // Read the ROM stub controller |
1099 TPckgBuf<TInt> fileCnt(fileCount); |
974 CFileSisDataProvider* fileProvider = CFileSisDataProvider::NewLC(tFs, controllerFileName); |
1100 aMessage.WriteL(EIpcArgument2, fileCnt); |
975 Swi::Sis::CController* stubController = NULL; |
1101 aMessage.Complete(KErrNone); |
976 TRAPD(errCode, stubController = Swi::Sis::CController::NewL(*fileProvider)); |
1102 } |
977 if (errCode != KErrNone) |
1103 } |
978 { |
1104 else |
979 // Ignore the broken stub file under the ROM stub directory. |
1105 { |
980 DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to read the stub controller. Error code %d."), errCode); |
1106 aMessage.Complete(errCode); |
981 CleanupStack::PopAndDestroy(fileProvider); |
1107 } |
982 continue; |
1108 CleanupStack::PopAndDestroy(); |
983 } |
1109 } |
984 CleanupStack::PushL(stubController); |
1110 |
985 |
1111 void CSisRegistrySession::GetStubFilesL(const TDesC& aFileName, RPointerArray<HBufC>& aFileNames) |
986 // If the UID in a stub file matches the current package's UID, |
1112 { |
987 // populate the list of eclipsable files from the same stub file. |
1113 // Read the ROM stub controller |
988 if ( stubController->Info().Uid().Uid() == tUid ) |
1114 CFileSisDataProvider* fileProvider = CFileSisDataProvider::NewLC(iFs, aFileName); |
989 { |
1115 Swi::Sis::CController* stubController = NULL; |
990 stubNotFound = EFalse; |
1116 TRAPD(errCode, stubController = Swi::Sis::CController::NewL(*fileProvider)); |
991 const RPointerArray<Sis::CFileDescription>& depArray = stubController->InstallBlock().FileDescriptions(); |
1117 if (errCode != KErrNone) |
992 // Get as many number of files as possible that can be accomodate in client allocated buffer. |
1118 { |
993 if (tMode == EGetFiles) |
1119 // Ignore the broken stub file under the ROM stub directory. |
994 { |
1120 DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to read the stub controller. Error code %d."), errCode); |
995 TInt sizeRed = 0; |
1121 CleanupStack::PopAndDestroy(fileProvider); |
996 TInt startingFileNo; |
1122 User::Leave(errCode); |
997 TPckg<TInt> start(startingFileNo); |
1123 } |
998 aMessage.ReadL(EIpcArgument2, start, 0); |
1124 CleanupStack::PushL(stubController); |
999 |
1125 const RPointerArray<Sis::CFileDescription>& filesArray = stubController->InstallBlock().FileDescriptions(); |
1000 RPointerArray<TPtrC> fileNames; |
1126 TInt totalFileCount = filesArray.Count(); |
1001 CleanupResetAndDestroy<RPointerArray<TPtrC> >::PushL(fileNames); |
1127 // Populate the files in to a temporary array. |
1002 |
1128 for(TInt fileCount = 0; fileCount < totalFileCount; ++fileCount ) |
1003 TInt totalDepArrayCount = depArray.Count(); |
1129 { |
1004 // Populate the files in to a temporary array. |
1130 HBufC* fileName = filesArray[fileCount]->Target().Data().AllocLC(); |
1005 for(TInt fileCount = startingFileNo; fileCount < totalDepArrayCount; ++fileCount ) |
1131 // Adding drive letter of rom if not mentioned in stub sis file |
1006 { |
1132 TPtr a=fileName->Des(); |
1007 sizeRed += depArray[fileCount]->Target().Data().Size(); |
1133 if (a[0] == '!') |
1008 // If amount of data red exceeds the client buffer size, break reading. |
1134 { |
1009 if (sizeRed > KDefaultBufferSize) |
1135 TChar driveChar; |
1010 { |
1136 User::LeaveIfError(iFs.DriveToChar(EDriveZ, driveChar)); |
1011 break; |
1137 a[0] = driveChar; |
1012 } |
1138 } |
1013 |
1139 |
1014 // Only create a TPtrC when we know we have space available |
1140 aFileNames.AppendL(fileName); |
1015 TPtrC* fileName = new(ELeave) TPtrC(depArray[fileCount]->Target().Data()); |
1141 CleanupStack::Pop(fileName); |
1016 CleanupStack::PushL(fileName); |
1142 } |
1017 fileNames.AppendL(fileName); |
1143 CleanupStack::PopAndDestroy(2, fileProvider); |
1018 CleanupStack::Pop(fileName); |
1144 } |
1019 } |
1145 |
1020 // Stream via multiple IPC writes instead of |
1146 void CSisRegistrySession::GetStubFileInfoL(TUid aUid, TStubExtractionMode aMode, TInt aStartingFileNo, TInt& aFileCount, RPointerArray<HBufC>& aFileNames) |
1021 // copying to a buffer and streaming from there. |
1147 { |
1022 RIpcWriteStream ipcstream; |
1148 TBool stubNotFound(ETrue); |
1023 ipcstream.Open(aMessage, EIpcArgument3); |
1149 |
1024 CleanupClosePushL(ipcstream); |
1150 // Prepare the stub file path. |
1025 ExternalizePointerArrayL(fileNames,ipcstream); |
1151 TDriveUnit romDrive(EDriveZ); |
1026 ipcstream.CommitL(); |
1152 RBuf romRegistryPath; |
1027 aMessage.Complete(KErrNone); |
1153 romRegistryPath.CreateL(romDrive.Name(), KMaxPath); |
1028 CleanupStack::PopAndDestroy(&ipcstream); |
1154 CleanupClosePushL(romRegistryPath); |
1029 CleanupStack::PopAndDestroy(&fileNames); |
1155 romRegistryPath.Append(KPreInstalledPath); |
1030 } |
1156 |
1031 // If only the count needed, send the stub file's total entrie's count. |
1157 RFs tFs; |
1032 else if (tMode == EGetCount) |
1158 CDir* dir; |
1033 { |
1159 |
1034 TPckgBuf<TInt> fileCount(depArray.Count()); |
1160 // Get stub files under the ROM stub directory (Z:\system\install\). |
1035 aMessage.WriteL(EIpcArgument2, fileCount); |
1161 User::LeaveIfError(tFs.Connect()); |
1036 aMessage.Complete(KErrNone); |
1162 CleanupClosePushL(tFs); |
1037 } |
1163 |
1038 CleanupStack::PopAndDestroy(2, fileProvider); |
1164 TInt err = tFs.GetDir(romRegistryPath, KEntryAttMatchExclude | KEntryAttDir, ESortNone, dir); |
1039 break; |
1165 |
1040 } |
1166 if (err == KErrNone) |
1041 CleanupStack::PopAndDestroy(2, fileProvider); |
1167 { |
1042 } |
1168 CleanupStack::PushL(dir); |
1043 CleanupStack::PopAndDestroy(2, dir); // controllerFileName |
1169 TInt count(dir->Count()); |
1044 // If the stub file itself not found, leave with the same error info' |
1170 RBuf controllerFileName; |
1045 if (stubNotFound) |
1171 controllerFileName.CreateL(KMaxFileName); |
1046 { |
1172 CleanupClosePushL(controllerFileName); |
1047 aMessage.Complete(KErrNotFound); |
1173 for (TInt index = 0; index < count; ++index) |
1048 } |
1174 { |
1049 } |
1175 controllerFileName = romRegistryPath; |
1050 else if(err != KErrPathNotFound) |
1176 controllerFileName.Append((*dir)[index].iName); |
1051 { |
1177 |
1052 aMessage.Complete(err); |
1178 // Read the ROM stub controller |
1053 } |
1179 CFileSisDataProvider* fileProvider = CFileSisDataProvider::NewLC(tFs, controllerFileName); |
1054 CleanupStack::PopAndDestroy(2, &romRegistryPath); // tFs |
1180 Swi::Sis::CController* stubController = NULL; |
1055 } |
1181 TRAPD(errCode, stubController = Swi::Sis::CController::NewL(*fileProvider)); |
|
1182 if (errCode != KErrNone) |
|
1183 { |
|
1184 // Ignore the broken stub file under the ROM stub directory. |
|
1185 DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to read the stub controller. Error code %d."), errCode); |
|
1186 CleanupStack::PopAndDestroy(fileProvider); |
|
1187 continue; |
|
1188 } |
|
1189 CleanupStack::PushL(stubController); |
|
1190 |
|
1191 // If the UID in a stub file matches the current package's UID, |
|
1192 // populate the list of eclipsable files from the same stub file. |
|
1193 if ( stubController->Info().Uid().Uid() == aUid ) |
|
1194 { |
|
1195 stubNotFound = EFalse; |
|
1196 const RPointerArray<Sis::CFileDescription>& filesArray = stubController->InstallBlock().FileDescriptions(); |
|
1197 // Get as many number of files as possible that can be accomodate in client allocated buffer. |
|
1198 if (aMode == EGetFiles) |
|
1199 { |
|
1200 TInt sizeRed = 0; |
|
1201 TInt totalFileCount = filesArray.Count(); |
|
1202 // Populate the files in to a temporary array. |
|
1203 for(TInt fileCount = aStartingFileNo; fileCount < totalFileCount; ++fileCount ) |
|
1204 { |
|
1205 sizeRed += filesArray[fileCount]->Target().Data().Size(); |
|
1206 // If amount of data red exceeds the client buffer size, break reading. |
|
1207 if (sizeRed > KDefaultBufferSize) |
|
1208 { |
|
1209 break; |
|
1210 } |
|
1211 |
|
1212 // Only create a TPtrC when we know we have space available |
|
1213 HBufC* fileName = filesArray[fileCount]->Target().Data().AllocLC(); |
|
1214 // Adding drive letter of rom if not mentioned in stub sis file |
|
1215 TPtr a=fileName->Des(); |
|
1216 if (a[0] == '!') |
|
1217 { |
|
1218 TChar driveChar; |
|
1219 User::LeaveIfError(iFs.DriveToChar(EDriveZ, driveChar)); |
|
1220 a[0] = driveChar; |
|
1221 } |
|
1222 |
|
1223 aFileNames.AppendL(fileName); |
|
1224 CleanupStack::Pop(fileName); |
|
1225 } |
|
1226 } |
|
1227 // If only the count needed, send the stub file's total entrie's count. |
|
1228 else if (aMode == EGetCount) |
|
1229 { |
|
1230 aFileCount = filesArray.Count(); |
|
1231 } |
|
1232 CleanupStack::PopAndDestroy(2, fileProvider); |
|
1233 break; |
|
1234 } |
|
1235 CleanupStack::PopAndDestroy(2, fileProvider); |
|
1236 } |
|
1237 CleanupStack::PopAndDestroy(2, dir); // controllerFileName |
|
1238 // If the stub file itself not found, leave with the same error info' |
|
1239 |
|
1240 if (stubNotFound) |
|
1241 { |
|
1242 CleanupStack::PopAndDestroy(2, &romRegistryPath); // tFs |
|
1243 User::Leave(KErrNotFound); |
|
1244 } |
|
1245 } |
|
1246 else if(err != KErrPathNotFound) |
|
1247 { |
|
1248 CleanupStack::PopAndDestroy(2, &romRegistryPath); // tFs |
|
1249 User::Leave(err); |
|
1250 } |
|
1251 CleanupStack::PopAndDestroy(2, &romRegistryPath); // tFs |
|
1252 } |
1056 |
1253 |
1057 void CSisRegistrySession::RequestRegistryEntryL(const RMessage2& aMessage) |
1254 void CSisRegistrySession::RequestRegistryEntryL(const RMessage2& aMessage) |
1058 { |
1255 { |
1059 TUid uid; |
1256 TUid uid; |
1060 TPckg<TUid> packageUid(uid); |
1257 TPckg<TUid> packageUid(uid); |
2095 } |
2441 } |
2096 |
2442 |
2097 CleanupStack::PopAndDestroy(&entryList); |
2443 CleanupStack::PopAndDestroy(&entryList); |
2098 } |
2444 } |
2099 |
2445 |
2100 void CSisRegistrySession::GetCompIdAndCompSidIndexL(const TUid& aSid, TComponentId& aComponentId, TInt& aIndex, TInt aExpectedDrive) |
2446 void CSisRegistrySession::GetComponentIdsForSidL(TUid aSid, RArray<TComponentId>& aComponentIds) |
2101 { |
2447 { |
|
2448 _LIT(KComponentSidPropertyRegex, "CompSid%"); |
2102 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
2449 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
2103 componentFilter->SetSoftwareTypeL(KSoftwareTypeNative); |
2450 componentFilter->SetSoftwareTypeL(KSoftwareTypeNative); |
2104 componentFilter->AddPropertyL(KCompSidsPresent, 1); |
2451 componentFilter->AddPropertyL(KComponentSidPropertyRegex, static_cast<TUint>(aSid.iUid), CComponentFilter::ELike, CComponentFilter::EEqual); |
2105 |
2452 |
2106 // Retrieve the componentId of all the components with SIDs from the SCR. |
2453 // Retrieve all component Id's |
2107 RArray<TComponentId> componentIdList; |
2454 iScrSession.GetComponentIdsL(aComponentIds, componentFilter); |
2108 CleanupClosePushL(componentIdList); |
2455 |
2109 iScrSession.GetComponentIdsL(componentIdList, componentFilter); |
2456 CleanupStack::PopAndDestroy(componentFilter); |
2110 |
2457 } |
2111 TInt componentCount = componentIdList.Count(); |
2458 |
2112 RArray<TUid> sidArray; |
2459 |
2113 CleanupClosePushL(sidArray); |
2460 HBufC* CSisRegistrySession::SidToFileNameL(TUid aSid, TComponentId& aComponentId, TInt aExpectedDrive) |
2114 TBool sidMatchFound = EFalse; |
2461 { |
2115 |
2462 aComponentId = KErrNotFound; |
2116 for(TInt i = 0; i < componentCount && !sidMatchFound; ++i) |
2463 RArray<TComponentId> componentIdList; |
2117 { |
2464 CleanupClosePushL(componentIdList); |
2118 TComponentId componentId = componentIdList[i]; |
2465 |
2119 sidArray.Reset(); |
2466 // Retrieve the component Id's. |
2120 ScrHelperUtil::InternalizeSidArrayL(iScrSession, componentId, sidArray); |
2467 GetComponentIdsForSidL(aSid, componentIdList); |
2121 |
2468 |
2122 // index of the first matching SID in the array. |
2469 if(componentIdList.Count() == 0) |
2123 aIndex = sidArray.Find(aSid); |
2470 { |
2124 if(aIndex == KErrNotFound) |
2471 CleanupStack::PopAndDestroy(&componentIdList); |
2125 continue; |
2472 return NULL; |
2126 |
2473 } |
2127 // If the search is narrowed to a particular drive, get the file name and check whether it matches the drive |
2474 |
2128 if (aExpectedDrive != -1) |
2475 RArray<TUid> sidArray; |
2129 { |
2476 CleanupClosePushL(sidArray); |
2130 TBuf<KSmlBufferSize> compSidFileName(KEmptyString); |
2477 TInt index(0); |
2131 compSidFileName.Format(KCompSidFileNameFormat, aIndex); |
2478 TBuf<KSmlBufferSize> compSidFileName(KEmptyString); |
|
2479 HBufC* fileName = NULL; |
|
2480 |
|
2481 |
|
2482 if(aExpectedDrive == -1) |
|
2483 { |
|
2484 // No drive specified, just return the first component Id and the corresponding Sid index. |
|
2485 aComponentId = componentIdList[0]; |
|
2486 sidArray.Reset(); |
|
2487 ScrHelperUtil::InternalizeSidArrayL(iScrSession, aComponentId, sidArray); |
|
2488 index = sidArray.Find(aSid); |
|
2489 compSidFileName.Format(KCompSidFileNameFormat, index); |
|
2490 fileName = GetStrPropertyValueL(iScrSession, aComponentId, compSidFileName); |
|
2491 } |
|
2492 else |
|
2493 { |
|
2494 // If the search is narrowed to a particular drive, get the file name and check whether it matches the drive |
|
2495 |
|
2496 for(TInt i=0; i<componentIdList.Count(); ++i) |
|
2497 { |
|
2498 sidArray.Reset(); |
|
2499 ScrHelperUtil::InternalizeSidArrayL(iScrSession, componentIdList[i], sidArray); |
|
2500 index = sidArray.Find(aSid); |
|
2501 |
|
2502 compSidFileName.Format(KCompSidFileNameFormat, index); |
|
2503 fileName = GetStrPropertyValueL(iScrSession, componentIdList[i], compSidFileName); |
|
2504 CleanupStack::PushL(fileName); |
|
2505 |
|
2506 if (fileName->Length() == 0) |
|
2507 { |
|
2508 CleanupStack::PopAndDestroy(fileName); |
|
2509 fileName = NULL; |
|
2510 continue; |
|
2511 } |
|
2512 |
|
2513 TInt drive; |
|
2514 User::LeaveIfError(RFs::CharToDrive((*fileName)[0], drive)); |
|
2515 if(drive != aExpectedDrive) |
|
2516 { |
|
2517 CleanupStack::PopAndDestroy(fileName); |
|
2518 fileName = NULL; |
|
2519 continue; |
|
2520 } |
|
2521 |
|
2522 //Expected drive found ! |
|
2523 aComponentId = componentIdList[i]; |
|
2524 CleanupStack::Pop(fileName); |
|
2525 break; |
|
2526 } |
|
2527 } |
|
2528 CleanupStack::PopAndDestroy(2, &componentIdList); |
|
2529 return fileName; // Ownership with caller. |
2132 |
2530 |
2133 HBufC* fileName = GetStrPropertyValueL(iScrSession, componentId, compSidFileName); |
|
2134 CleanupStack::PushL(fileName); |
|
2135 if (fileName->Length() == 0) |
|
2136 { |
|
2137 CleanupStack::PopAndDestroy(fileName); |
|
2138 continue; |
|
2139 } |
|
2140 TInt drive; |
|
2141 User::LeaveIfError(RFs::CharToDrive((*fileName)[0], drive)); |
|
2142 if(drive != aExpectedDrive) |
|
2143 { |
|
2144 CleanupStack::PopAndDestroy(fileName); |
|
2145 continue; |
|
2146 } |
|
2147 CleanupStack::PopAndDestroy(fileName); |
|
2148 } |
|
2149 |
|
2150 aComponentId = componentId; |
|
2151 sidMatchFound = ETrue; |
|
2152 } |
|
2153 |
|
2154 CleanupStack::PopAndDestroy(3, componentFilter); // componentIdList and sidArray. |
|
2155 if(!sidMatchFound) |
|
2156 { |
|
2157 // No component contains aSid. |
|
2158 aComponentId = KErrNotFound; |
|
2159 } |
|
2160 } |
2531 } |
2161 |
2532 |
2162 TBool CSisRegistrySession::ModifiableL(const TDesC& aFileName) |
2533 TBool CSisRegistrySession::ModifiableL(const TDesC& aFileName) |
2163 { |
2534 { |
2164 // Retrieve the list of components which contain aFileName. |
2535 // Retrieve the list of components which contain aFileName. |
2632 return EFalse; |
2996 return EFalse; |
2633 } |
2997 } |
2634 |
2998 |
2635 void CSisRegistrySession::UpdateRecentFWVersionL() |
2999 void CSisRegistrySession::UpdateRecentFWVersionL() |
2636 { |
3000 { |
2637 //Write a cache of the ROM version to a separate stream |
3001 //Write a cache of the ROM version to a separate stream |
2638 //Build the filename for the cache file |
3002 //Build the filename for the cache file |
2639 TChar sysDrive = RFs::GetSystemDriveChar(); |
3003 TChar sysDrive = RFs::GetSystemDriveChar(); |
2640 TInt maxSizeofFileName = KROMVersionStringCacheDir().Length() + KROMVersionStringCacheFileName().Length() + 1; |
3004 TInt maxSizeofFileName = KROMVersionStringCacheDir().Length() + KROMVersionStringCacheFileName().Length() + 1; |
2641 RBuf romVersionCacheFileName; |
3005 RBuf romVersionCacheFileName; |
2642 romVersionCacheFileName.CreateL(maxSizeofFileName); |
3006 romVersionCacheFileName.CreateL(maxSizeofFileName); |
2643 romVersionCacheFileName.CleanupClosePushL(); |
3007 romVersionCacheFileName.CleanupClosePushL(); |
2644 romVersionCacheFileName.Append(sysDrive); |
3008 romVersionCacheFileName.Append(sysDrive); |
2645 romVersionCacheFileName.Append(KROMVersionStringCacheDir()); |
3009 romVersionCacheFileName.Append(KROMVersionStringCacheDir()); |
2646 romVersionCacheFileName.Append(KROMVersionStringCacheFileName()); |
3010 romVersionCacheFileName.Append(KROMVersionStringCacheFileName()); |
|
3011 |
|
3012 iFs.MkDirAll(romVersionCacheFileName); |
|
3013 //Read the length & value from it, if any. |
|
3014 RFileWriteStream romVerStream; |
|
3015 User::LeaveIfError(romVerStream.Replace(iFs,romVersionCacheFileName,EFileWrite)); |
|
3016 CleanupClosePushL(romVerStream); |
|
3017 TBuf<KInfoBufLength> version; |
|
3018 GetSWVersion(version); |
|
3019 |
|
3020 // Write even if SysUtil returns err since all conditions are taken care during restore. |
|
3021 romVerStream.WriteUint32L(version.Length()); |
|
3022 romVerStream.WriteL(version); |
|
3023 CleanupStack::PopAndDestroy(2); //romVerStream, romVersionCacheFileName |
|
3024 } |
|
3025 |
|
3026 void CSisRegistrySession::AppRegInfoEntryL(const RMessage2& aMessage) |
|
3027 { |
|
3028 Usif::TComponentId componentId = aMessage.Int0(); |
|
3029 |
|
3030 RIpcReadStream stream; |
|
3031 CleanupClosePushL(stream); |
|
3032 stream.Open(aMessage, 1); |
|
3033 CApplicationRegistrationData *applicationData = CApplicationRegistrationData::NewL(stream); |
|
3034 CleanupStack::PopAndDestroy(&stream); |
|
3035 CleanupStack::PushL(applicationData); |
|
3036 |
|
3037 TRAPD(err, ScrHelperUtil::AddApplicationEntryL(iScrSession, componentId, *applicationData)); |
|
3038 if (err == KErrAlreadyExists) |
|
3039 { |
|
3040 //Delete the existing application |
|
3041 ScrHelperUtil::DeleteApplicationEntryL(iScrSession, applicationData->AppUid()); |
|
3042 err = KErrNone; |
|
3043 TRAP(err, ScrHelperUtil::AddApplicationEntryL(iScrSession, componentId, *applicationData)); |
|
3044 } |
|
3045 aMessage.Complete(err); |
|
3046 CleanupStack::PopAndDestroy(applicationData); |
|
3047 } |
|
3048 |
|
3049 void CSisRegistrySession::GetComponentIdForPackageL(const RMessage2& aMessage) |
|
3050 { |
|
3051 Usif::TComponentId componentId(0); |
|
3052 TInt strLen = aMessage.GetDesLengthL(EIpcArgument0); |
|
3053 HBufC* packageName = HBufC::NewLC(strLen); |
|
3054 TPtr pkgname = packageName->Des(); |
|
3055 aMessage.ReadL(EIpcArgument0, pkgname, 0); |
|
3056 |
|
3057 strLen = aMessage.GetDesLengthL(EIpcArgument1); |
|
3058 HBufC* vendorName = HBufC::NewLC(strLen); |
|
3059 TPtr vndrname = vendorName->Des(); |
|
3060 aMessage.ReadL(EIpcArgument1, vndrname, 0); |
|
3061 componentId = ScrHelperUtil::GetComponentIdL(iScrSession, *packageName, *vendorName); |
|
3062 if (!componentId) |
|
3063 { |
|
3064 DEBUG_PRINTF2(_L8("Sis Registry Server - Component id for package Name %S was not found."), packageName); |
|
3065 User::Leave(KErrNotFound); |
|
3066 } |
|
3067 CleanupStack::PopAndDestroy(2, packageName); //vendorName |
|
3068 TPckgC<Usif::TComponentId> componentIdPckg(componentId); |
|
3069 aMessage.WriteL(EIpcArgument2, componentIdPckg); |
|
3070 aMessage.Complete(KErrNone); |
|
3071 } |
|
3072 |
|
3073 void CSisRegistrySession::GetAppUidsForComponentL(const RMessage2& aMessage) |
|
3074 { |
|
3075 Usif::TComponentId compId; |
|
3076 TPckg<Usif::TComponentId> componentId(compId); |
|
3077 RArray<TUid> appUids; |
|
3078 CleanupClosePushL(appUids); |
|
3079 aMessage.ReadL(EIpcArgument0, componentId); |
|
3080 iScrSession.GetAppUidsForComponentL(compId, appUids); |
|
3081 SisRegistryUtil::SendDataArrayL(aMessage, appUids, EIpcArgument1); |
|
3082 CleanupStack::PopAndDestroy(&appUids); |
|
3083 } |
|
3084 |
|
3085 void CSisRegistrySession::GetComponentIdsForUidL(const RMessage2& aMessage) |
|
3086 { |
|
3087 TUid Uid; |
|
3088 TPckg<TUid> pkgUid(Uid); |
|
3089 aMessage.ReadL(EIpcArgument0, pkgUid); |
|
3090 |
|
3091 // Setup a filter based on the input parameters |
|
3092 Usif::CComponentFilter* compFilter = Usif::CComponentFilter::NewLC(); |
|
3093 compFilter->AddPropertyL(KCompUid, Uid.iUid); |
|
3094 compFilter->SetSoftwareTypeL(Usif::KSoftwareTypeNative); |
|
3095 RArray<Usif::TComponentId> componentIdList; |
|
3096 CleanupClosePushL(componentIdList); |
|
3097 iScrSession.GetComponentIdsL(componentIdList, compFilter); |
|
3098 if(componentIdList.Count() == 0) |
|
3099 { |
|
3100 // No components are found in the SCR. So, return false |
|
3101 CleanupStack::PopAndDestroy(2, compFilter); // componentIdList |
|
3102 DEBUG_PRINTF2(_L8("Sis Registry Server - Unable to find component for UID: %x"), Uid.iUid); |
|
3103 SisRegistryUtil::SendDataArrayL(aMessage, componentIdList, EIpcArgument1); |
|
3104 return; |
|
3105 } |
|
3106 SisRegistryUtil::SendDataArrayL(aMessage, componentIdList, EIpcArgument1); |
|
3107 CleanupStack::PopAndDestroy(2, compFilter); |
|
3108 } |
|
3109 |
|
3110 void CSisRegistrySession::RegisterAllAppL(RBuf& aApparcRegFilePath) |
|
3111 { |
|
3112 CDir* dir; |
|
3113 TInt err = iFs.GetDir(aApparcRegFilePath, KEntryAttMatchExclude | KEntryAttDir, ESortNone, dir); |
|
3114 DEBUG_PRINTF3(_L("Sis Registry Server - Reading apparc registration file directory(%S) returned %d."), &aApparcRegFilePath, err); |
|
3115 |
|
3116 if (err == KErrNone) |
|
3117 { |
|
3118 CleanupStack::PushL(dir); |
|
3119 |
|
3120 TInt count(dir->Count()); |
|
3121 RBuf appRegFileName; |
|
3122 appRegFileName.CreateL(KMaxFileName); |
|
3123 CleanupClosePushL(appRegFileName); |
|
3124 RSisLauncherSession launcher; |
|
3125 CleanupClosePushL(launcher); |
|
3126 User::LeaveIfError(launcher.Connect()); |
|
3127 RFs fs; |
|
3128 CleanupClosePushL(fs); |
|
3129 User::LeaveIfError(fs.Connect()); |
|
3130 User::LeaveIfError(fs.ShareProtected()); |
|
3131 RArray<TLanguage> appLanguages; |
|
3132 CleanupClosePushL(appLanguages); |
|
3133 appLanguages.AppendL(User::Language()); |
|
3134 for (TInt index = 0; index < count; ++index) |
|
3135 { |
|
3136 appRegFileName = TParsePtrC(aApparcRegFilePath).DriveAndPath(); |
|
3137 appRegFileName.Append((*dir)[index].iName); |
|
3138 RFile file; |
|
3139 CleanupClosePushL(file); |
|
3140 User::LeaveIfError(file.Open(fs, appRegFileName, EFileRead)); |
|
3141 |
|
3142 Usif::CApplicationRegistrationData* appRegData = NULL; |
|
3143 TRAPD(result, appRegData = launcher.SyncParseResourceFileL(file, appLanguages)); |
|
3144 if (result == KErrNone) |
|
3145 { |
|
3146 CleanupStack::PushL(appRegData); |
|
3147 TComponentId compId = 0; // ROM application |
|
3148 TRAPD(res, ScrHelperUtil::AddApplicationEntryL(iScrSession, compId, *appRegData);); |
|
3149 if (res != KErrNone) |
|
3150 { |
|
3151 // log it only, we cannot stop as the next might be ok |
|
3152 DEBUG_PRINTF3(_L("Sis Registry Server - Failed to register in ROM application %S. Error code %d."), &appRegFileName, res); |
|
3153 } |
|
3154 CleanupStack::PopAndDestroy(appRegData); |
|
3155 } |
|
3156 else |
|
3157 DEBUG_PRINTF2(_L8("Sis Registry Server - Parsing in ROM application . Error code %d."), result); |
|
3158 |
|
3159 CleanupStack::PopAndDestroy(&file); |
|
3160 } |
|
3161 |
|
3162 CleanupStack::PopAndDestroy(5, dir); // appRegFileName, launcher, fs, appLanguages |
|
3163 } |
|
3164 else if(err != KErrPathNotFound) |
|
3165 { |
|
3166 User::Leave(err); |
|
3167 } |
|
3168 } |
|
3169 |
|
3170 void CSisRegistrySession::DriveFormatDetectedL(TDriveUnit aDrive) |
|
3171 { |
|
3172 DEBUG_PRINTF2(_L("Sis Registry Server - Drive format detected for drive %d"), static_cast<TInt>(aDrive)); |
|
3173 |
|
3174 Usif::RStsSession stsSession; |
|
3175 TInt64 transactionId = stsSession.CreateTransactionL(); |
|
3176 CleanupClosePushL(stsSession); |
|
3177 |
|
3178 //Create SCR Transaction |
|
3179 iScrSession.CreateTransactionL(); |
|
3180 |
|
3181 RArray<TComponentId> foundComponentIds; |
|
3182 CleanupClosePushL(foundComponentIds); |
2647 |
3183 |
2648 //Read the length & value from it, if any. |
3184 TDriveList filterFormatDrive; |
2649 RFileWriteStream romVerStream; |
3185 filterFormatDrive.FillZ(KMaxDrives); |
2650 User::LeaveIfError(romVerStream.Replace(iFs,romVersionCacheFileName,EFileWrite)); |
3186 filterFormatDrive[static_cast<TInt>(aDrive)] = 1; |
2651 CleanupClosePushL(romVerStream); |
3187 |
2652 TBuf<KInfoBufLength> version; |
3188 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
2653 GetSWVersion(version); |
3189 componentFilter->SetInstalledDrivesL(filterFormatDrive); |
2654 |
3190 |
2655 // Write even if SysUtil returns err since all conditions are taken care during restore. |
3191 iScrSession.GetComponentIdsL(foundComponentIds, componentFilter); |
2656 romVerStream.WriteUint32L(version.Length()); |
3192 |
2657 romVerStream.WriteL(version); |
3193 TBool processRomDrive = EFalse; |
2658 CleanupStack::PopAndDestroy(2); //romVerStream, romVersionCacheFileName |
3194 for(TInt i=0; i < foundComponentIds.Count(); ++i) |
|
3195 { |
|
3196 CSisRegistryObject* object = CSisRegistryObject::NewLC(); |
|
3197 ScrHelperUtil::GetComponentL(iScrSession, foundComponentIds[i], *object); |
|
3198 TUint installedDrives = object->Drives(); |
|
3199 |
|
3200 if(installedDrives & (1 << aDrive)) |
|
3201 { |
|
3202 if (!processRomDrive && |
|
3203 (object->InstallType() == Sis::EInstInstallation || object->InstallType() == Sis::EInstPartialUpgrade) && |
|
3204 SisRegistryUtil::RomBasedPackageL(object->Uid())) |
|
3205 { |
|
3206 processRomDrive = ETrue; |
|
3207 } |
|
3208 |
|
3209 // Retrieve all the associated files. |
|
3210 RPointerArray<CSisRegistryFileDescription>& fileDescriptions = object->FileDescriptions(); |
|
3211 _LIT(KHashPathFormat, "%c:\\sys\\hash\\%S"); |
|
3212 for(TInt j=0; j<fileDescriptions.Count(); ++j) |
|
3213 { |
|
3214 const TDesC& targetPath = fileDescriptions[j]->Target(); |
|
3215 |
|
3216 // Get the drive on which the file is present. |
|
3217 TInt drive; |
|
3218 User::LeaveIfError(RFs::CharToDrive(targetPath[0], drive)); |
|
3219 |
|
3220 // If the file is a binary ( present in \sys\bin), delete the corresponding hash present in |
|
3221 // C:\sys\hash |
|
3222 |
|
3223 if(KErrNotFound != targetPath.FindF(KBinPath)) |
|
3224 { |
|
3225 // Retrieve the filename from the target path. |
|
3226 TParsePtrC parser(targetPath); |
|
3227 HBufC* fileName = parser.NameAndExt().AllocLC(); |
|
3228 |
|
3229 TChar systemDrive = RFs::GetSystemDriveChar(); |
|
3230 |
|
3231 // Create the hash file path. |
|
3232 RBuf hashFilePath; |
|
3233 hashFilePath.CreateL(KMaxPath); |
|
3234 CleanupClosePushL(hashFilePath); |
|
3235 hashFilePath.Format(KHashPathFormat, static_cast<TUint>(systemDrive), fileName); |
|
3236 |
|
3237 // Delete hash file. |
|
3238 SisRegistryUtil::DeleteFile(iFs, hashFilePath); //Ignore return code. |
|
3239 |
|
3240 CleanupStack::PopAndDestroy(2, fileName); |
|
3241 } |
|
3242 |
|
3243 if(aDrive == TDriveUnit(drive)) |
|
3244 { |
|
3245 // File does not exist on disk as the drive is assumed to have been formatted. |
|
3246 continue; |
|
3247 } |
|
3248 SisRegistryUtil::DeleteFile(iFs, targetPath); //Ignore return code. |
|
3249 } |
|
3250 |
|
3251 DeleteEntryL(*object, transactionId, EFalse); |
|
3252 CleanupStack::PopAndDestroy(object); |
|
3253 } |
|
3254 } |
|
3255 |
|
3256 if(processRomDrive) |
|
3257 { |
|
3258 // Re-add the ROM installed stub details to SCR (only those missing will be added) |
|
3259 ProcessRomDriveL(); |
|
3260 } |
|
3261 |
|
3262 //Commit the changes. |
|
3263 stsSession.CommitL(); |
|
3264 iScrSession.CommitTransactionL(); |
|
3265 |
|
3266 CleanupStack::PopAndDestroy(3, &stsSession); |
2659 } |
3267 } |
2660 |
3268 |
|
3269 void CSisRegistrySession::AddAppRegInfoL(const RMessage2& aMessage) |
|
3270 { |
|
3271 //This API is for use during development/debug use only; not used in production software |
|
3272 |
|
3273 TUint regFileNameLen = aMessage.GetDesLengthL(EIpcArgument0); |
|
3274 HBufC* regFileName = HBufC::NewLC(regFileNameLen); |
|
3275 TPtr namePtr = regFileName->Des(); |
|
3276 aMessage.ReadL(EIpcArgument0, namePtr); |
|
3277 |
|
3278 Usif::CApplicationRegistrationData* appRegData = NULL; |
|
3279 //Check if the file name passed is valid reg file or not , if valid then parse |
|
3280 TRAPD(result, ValidateAndParseAppRegFileL(*regFileName, appRegData, EFalse)); |
|
3281 |
|
3282 if (result == KErrNone) |
|
3283 { |
|
3284 CleanupStack::PushL(appRegData); |
|
3285 TComponentId compId = 0; |
|
3286 TUid appUid = appRegData->AppUid(); |
|
3287 //Check if component exists for the appUid, if then append the app reg info to the same compId(base) |
|
3288 TRAP_IGNORE(compId = iScrSession.GetComponentIdForAppL(appUid)); |
|
3289 TRAPD(res, ScrHelperUtil::AddApplicationEntryL(iScrSession, compId, *appRegData)); |
|
3290 if (res != KErrNone && res != KErrAlreadyExists ) |
|
3291 { |
|
3292 DEBUG_PRINTF2(_L("Sis Registry Server - Failed to add app registration data of in the SCR . Error code %d."), res); |
|
3293 CleanupStack::PopAndDestroy(2, regFileName); //appRegData |
|
3294 aMessage.Complete(res); |
|
3295 return; |
|
3296 } |
|
3297 else if (res == KErrAlreadyExists) |
|
3298 { |
|
3299 // Delete the existing application entry, which is not associated with any package |
|
3300 ScrHelperUtil::DeleteApplicationEntryL(iScrSession, appUid); |
|
3301 ScrHelperUtil::AddApplicationEntryL(iScrSession, compId, *appRegData); |
|
3302 } |
|
3303 |
|
3304 //Notify Apparc of the new app |
|
3305 RSisLauncherSession launcher; |
|
3306 CleanupClosePushL(launcher); |
|
3307 User::LeaveIfError(launcher.Connect()); |
|
3308 TAppUpdateInfo newAppInfo; |
|
3309 RArray<TAppUpdateInfo> affectedApps; |
|
3310 CleanupClosePushL(affectedApps); |
|
3311 newAppInfo = TAppUpdateInfo(appUid, EAppInstalled); |
|
3312 affectedApps.AppendL(newAppInfo); |
|
3313 launcher.NotifyNewAppsL(affectedApps); |
|
3314 CleanupStack::PopAndDestroy(3, appRegData); // affectedApps, launcher |
|
3315 } |
|
3316 else |
|
3317 { |
|
3318 DEBUG_PRINTF2(_L8("Sis Registry Server - Parsing application registration info. Error code %d."), result); |
|
3319 } |
|
3320 |
|
3321 CleanupStack::PopAndDestroy(regFileName); |
|
3322 aMessage.Complete(result); |
|
3323 } |
|
3324 |
|
3325 void CSisRegistrySession::RemoveAppRegInfoL(const RMessage2& aMessage) |
|
3326 { |
|
3327 //This API is for use during development/debug use only; not used in production software |
|
3328 |
|
3329 TUint regFileNameLen = aMessage.GetDesLengthL(EIpcArgument0); |
|
3330 HBufC* regFileName = HBufC::NewLC(regFileNameLen); |
|
3331 TPtr namePtr = regFileName->Des(); |
|
3332 aMessage.ReadL(EIpcArgument0, namePtr); |
|
3333 |
|
3334 Usif::CApplicationRegistrationData* appRegData = NULL; |
|
3335 // Check if the file name passed is valid reg file or not , if valid then parse it |
|
3336 TRAPD(result, ValidateAndParseAppRegFileL(*regFileName, appRegData, EFalse)); |
|
3337 |
|
3338 if(result == KErrNone) |
|
3339 { |
|
3340 TUid appUid = appRegData->AppUid(); |
|
3341 delete appRegData; |
|
3342 appRegData = NULL; |
|
3343 |
|
3344 // Check if component exists for the appUid |
|
3345 TComponentId compId(0); |
|
3346 TRAPD(err,compId = iScrSession.GetComponentIdForAppL(appUid)); |
|
3347 |
|
3348 // Check if appUid(reg file data to be removed) is registered with scr |
|
3349 if(err != KErrNone) |
|
3350 { |
|
3351 DEBUG_PRINTF2(_L8("Sis Registry Server -Reg file (%S) not registered with scr"), ®FileName); |
|
3352 User::Leave(KErrNotFound); |
|
3353 } |
|
3354 |
|
3355 TBool isAppReRegistered(ETrue); |
|
3356 if(compId == 0) // If component Id is 0 i.e. for in-rom *_reg.rsc files(without stub association) or inserted using AddAppRegInfoL(). |
|
3357 { |
|
3358 TDriveUnit romDrive(SisRegistryUtil::SystemRomDrive()); |
|
3359 RBuf romRegFilesPath; |
|
3360 CleanupClosePushL(romRegFilesPath); |
|
3361 romRegFilesPath.CreateL(romDrive.Name(), KMaxPath); |
|
3362 romRegFilesPath.Append(KApparcRegFilePath); |
|
3363 |
|
3364 /* Scan the reg files in apparc's pvt folder's in rom, and compare their app uid with the uid of the reg file to be removed, |
|
3365 * if found register the reg file present in rom replacing the existing app |
|
3366 */ |
|
3367 TRAPD(err, ReRegisterAppRegFileL(romRegFilesPath, appUid)); |
|
3368 CleanupStack::PopAndDestroy(&romRegFilesPath); |
|
3369 |
|
3370 if(err == KErrNotFound) //If reg file is not found, search it in under "\\private\\10003a3f\\import\\apps\\*.rsc" path |
|
3371 { |
|
3372 RBuf romRegImportFilesPath; |
|
3373 CleanupClosePushL(romRegImportFilesPath); |
|
3374 romRegImportFilesPath.CreateL(romDrive.Name(), KMaxPath); |
|
3375 romRegImportFilesPath.Append(KApparcRegFileImportPath); |
|
3376 err = 0; |
|
3377 TRAP(err, ReRegisterAppRegFileL(romRegImportFilesPath,appUid)); |
|
3378 CleanupStack::PopAndDestroy(&romRegImportFilesPath); |
|
3379 } |
|
3380 |
|
3381 if(err == KErrNotFound) // Since _reg.rsc file doesn't exists in rom and it is registered in scr, remove it |
|
3382 { |
|
3383 // Delete the existing application entry, which is not associated with any package |
|
3384 ScrHelperUtil::DeleteApplicationEntryL(iScrSession, appUid); |
|
3385 isAppReRegistered = EFalse; |
|
3386 } |
|
3387 |
|
3388 else if(err != KErrNone && err != KErrNotFound) |
|
3389 { |
|
3390 DEBUG_PRINTF2(_L8("Sis Registry Server - Error in removing reg file (%S)"), ®FileName); |
|
3391 User::Leave(err); |
|
3392 } |
|
3393 } |
|
3394 else // else if compId is not 0 i.e. either appUid is associated with stub in rom or any other package in other drive |
|
3395 { |
|
3396 CSisRegistryObject* object = CSisRegistryObject::NewLC(); |
|
3397 ScrHelperUtil::GetComponentL(iScrSession, compId, *object); |
|
3398 if (object->InRom()) // If its a rom based pkg which has not been eclipsed then we can go back to the stubs |
|
3399 { |
|
3400 RemoveEntryL(compId); |
|
3401 // Re-add the ROM installed stub details to SCR (only those missing will be added) |
|
3402 ProcessRomDriveL(); |
|
3403 } |
|
3404 else |
|
3405 { |
|
3406 // Delete the existing application entry, which is not associated with any package |
|
3407 ScrHelperUtil::DeleteApplicationEntryL(iScrSession, appUid); |
|
3408 // Register the reg files of the applications, only the unregistered reg file data will be added(the association of reg file with stub will be lost) |
|
3409 ProcessApplicationsL(); |
|
3410 } |
|
3411 CleanupStack::PopAndDestroy(object); |
|
3412 } |
|
3413 |
|
3414 //Notify Apparc of the app being removed |
|
3415 RSisLauncherSession launcher; |
|
3416 CleanupClosePushL(launcher); |
|
3417 User::LeaveIfError(launcher.Connect()); |
|
3418 RArray<TAppUpdateInfo> affectedApps; |
|
3419 CleanupClosePushL(affectedApps); |
|
3420 TAppUpdateInfo newAppInfo; |
|
3421 if(isAppReRegistered) // If App reg data in rom is registerted again(i.e overwrites the existing one) we notify apparc of Installed app else Uninstalled app |
|
3422 { |
|
3423 newAppInfo = TAppUpdateInfo(appUid, EAppInstalled); |
|
3424 } |
|
3425 else |
|
3426 { |
|
3427 newAppInfo = TAppUpdateInfo(appUid, EAppUninstalled); |
|
3428 } |
|
3429 affectedApps.AppendL(newAppInfo); |
|
3430 launcher.NotifyNewAppsL(affectedApps); |
|
3431 CleanupStack::PopAndDestroy(2, &launcher); // affectedApps |
|
3432 } |
|
3433 else |
|
3434 { |
|
3435 DEBUG_PRINTF2(_L8("Sis Registry Server - Parsing application registration info. Error code %d."), result); |
|
3436 } |
|
3437 CleanupStack::PopAndDestroy(regFileName); |
|
3438 aMessage.Complete(result); |
|
3439 } |
|
3440 |
|
3441 void CSisRegistrySession::ValidateAndParseAppRegFileL(const TDesC& aRegFileName, Usif::CApplicationRegistrationData*& aAppRegData,TBool aInternal) |
|
3442 { |
|
3443 |
|
3444 TParsePtrC filename(aRegFileName); |
|
3445 if(!aInternal) //check if called for API and regFile path is "\\private\\10003a3f\\import\\apps\\" |
|
3446 { |
|
3447 if (filename.Path().Left(KApparcRegImportDir().Length()).CompareF(KApparcRegImportDir) != 0) |
|
3448 { |
|
3449 User::Leave(KErrNotSupported); |
|
3450 } |
|
3451 } |
|
3452 |
|
3453 RFs fs; |
|
3454 CleanupClosePushL(fs); |
|
3455 User::LeaveIfError(fs.Connect()); |
|
3456 User::LeaveIfError(fs.ShareProtected()); |
|
3457 RFile file; |
|
3458 CleanupClosePushL(file); |
|
3459 User::LeaveIfError(file.Open(fs, aRegFileName, EFileRead)); |
|
3460 |
|
3461 // Reading the TUidType information fron the reg rsc file header |
|
3462 TBuf8<sizeof(TCheckedUid)> uidBuf; |
|
3463 TInt err = file.Read(0, uidBuf, sizeof(TCheckedUid)); |
|
3464 if (err != KErrNone) |
|
3465 { |
|
3466 CleanupStack::PopAndDestroy(2, &fs); //file |
|
3467 User::Leave(KErrNotSupported); |
|
3468 } |
|
3469 |
|
3470 if(uidBuf.Size() != sizeof(TCheckedUid)) |
|
3471 { |
|
3472 DEBUG_PRINTF(_L("The file is not a valid registration resource file")); |
|
3473 CleanupStack::PopAndDestroy(2, &fs); // file |
|
3474 User::Leave(KErrNotSupported); |
|
3475 } |
|
3476 TCheckedUid uid(uidBuf); |
|
3477 |
|
3478 //check the uid of the reg file to be parsed |
|
3479 if(!(uid.UidType()[1] == KUidAppRegistrationFile)) |
|
3480 { |
|
3481 CleanupStack::PopAndDestroy(2, &fs); //file |
|
3482 User::Leave(KErrNotSupported); |
|
3483 } |
|
3484 |
|
3485 RSisLauncherSession launcher; |
|
3486 CleanupClosePushL(launcher); |
|
3487 User::LeaveIfError(launcher.Connect()); |
|
3488 RArray<TLanguage> appLanguages; |
|
3489 CleanupClosePushL(appLanguages); |
|
3490 appLanguages.AppendL(User::Language()); |
|
3491 aAppRegData = launcher.SyncParseResourceFileL(file, appLanguages); |
|
3492 CleanupStack::PopAndDestroy(4, &fs); //appLanguages, launcher, file |
|
3493 } |
|
3494 |
|
3495 void CSisRegistrySession::ReRegisterAppRegFileL(const TDesC& aRegFileDrivePath, const TUid& aAppUid) |
|
3496 { |
|
3497 /* |
|
3498 * Reads and parses the *_reg.rsc files in the aRegFileDrivePath path and compare uid of each with the aAppUid, if matched remove the existing i.e. aAppUid |
|
3499 * and register the one found in the path. |
|
3500 */ |
|
3501 |
|
3502 // open the directory |
|
3503 CDir* dir; |
|
3504 TInt err = iFs.GetDir(aRegFileDrivePath, KEntryAttMatchExclude | KEntryAttDir, ESortNone, dir); |
|
3505 |
|
3506 if (err == KErrNone) |
|
3507 { |
|
3508 CleanupStack::PushL(dir); |
|
3509 TInt count(dir->Count()); |
|
3510 TBool foundAndReplaced(EFalse); |
|
3511 // scan through all the *_reg.rsc files |
|
3512 for (TInt index = 0; index < count; ++index) |
|
3513 { |
|
3514 RBuf regResourceFileName; |
|
3515 CleanupClosePushL(regResourceFileName); |
|
3516 regResourceFileName.CreateL(KMaxFileName); |
|
3517 //construct the app reg file present in rom |
|
3518 regResourceFileName = TParsePtrC(aRegFileDrivePath).DriveAndPath(); |
|
3519 regResourceFileName.Append((*dir)[index].iName); |
|
3520 //validate and parse the app reg file |
|
3521 Usif::CApplicationRegistrationData* appRegData = NULL; |
|
3522 TRAPD(res,ValidateAndParseAppRegFileL(regResourceFileName, appRegData, ETrue)); |
|
3523 CleanupStack::PopAndDestroy(®ResourceFileName); |
|
3524 CleanupStack::PushL(appRegData); |
|
3525 |
|
3526 if(res != KErrNone) |
|
3527 { |
|
3528 // log it only, we cannot stop as the next might be ok |
|
3529 DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to register in ROM controller. Error code %d."), res); |
|
3530 CleanupStack::Pop(appRegData); |
|
3531 continue; |
|
3532 } |
|
3533 |
|
3534 /* If appuid of the current processing reg file is same as of the reg file to be removed, delete existing app reg data and |
|
3535 * add the reg entry of _reg.rsc file currently processed. |
|
3536 */ |
|
3537 if(aAppUid == appRegData->AppUid()) |
|
3538 { |
|
3539 TComponentId compId(0); |
|
3540 // Delete the existing application entry, which is not associated with any package |
|
3541 ScrHelperUtil::DeleteApplicationEntryL(iScrSession, aAppUid); |
|
3542 ScrHelperUtil::AddApplicationEntryL(iScrSession, compId, *appRegData); |
|
3543 CleanupStack::PopAndDestroy(appRegData); |
|
3544 foundAndReplaced = ETrue; |
|
3545 break; |
|
3546 } |
|
3547 CleanupStack::PopAndDestroy(appRegData); |
|
3548 } |
|
3549 if(!foundAndReplaced) |
|
3550 { |
|
3551 User::Leave(KErrNotFound); |
|
3552 } |
|
3553 CleanupStack::PopAndDestroy(dir); |
|
3554 } |
|
3555 else |
|
3556 { |
|
3557 User::Leave(KErrNotFound); |
|
3558 } |
|
3559 } |