javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/CheckDiskSpace.java
equal
deleted
inserted
replaced
130 } |
130 } |
131 |
131 |
132 /** |
132 /** |
133 * Chooses the default installation drive from given DriveInfo vector. |
133 * Chooses the default installation drive from given DriveInfo vector. |
134 * Default installation drive is the first INTERNAL_MASS_STORAGE, |
134 * Default installation drive is the first INTERNAL_MASS_STORAGE, |
135 * PHONE_MEMORY or MEMORY_CARD drive that has enough free space for |
135 * MEMORY_CARD or PHONE_MEMORY drive that has enough free space for |
136 * the application. |
136 * the application. |
137 * @param aDrives DriveInfo objects. |
137 * @param aDrives DriveInfo objects. |
138 * @param aSizeInBytes application size. |
138 * @param aSizeInBytes application size. |
139 * @return Default installation drive id. |
139 * @return Default installation drive id. |
140 * @throws InstallerException if none of the drives has enough free |
140 * @throws InstallerException if none of the drives has enough free |
168 aSizeInBytes, null); |
168 aSizeInBytes, null); |
169 } |
169 } |
170 |
170 |
171 /** |
171 /** |
172 * Sorts DriveInfos in given vector to drive priority order. |
172 * Sorts DriveInfos in given vector to drive priority order. |
173 * Priority order for the drives is USER_CHOSEN, INTERNAL_MASS_STORAGE, |
173 * Priority order for the drives is CONFIGURED_DEFAULT, |
174 * PHONE_MEMORY, MEMORY_CARD. If there is more than one drive |
174 * INTERNAL_MASS_STORAGE, MEMORY_CARD, PHONE_MEMORY. |
175 * of the same type, the ones which have more free space have |
175 * If there is more than one drive of the same type, |
176 * higher priority. |
176 * the ones which have more free space have higher priority. |
177 */ |
177 */ |
178 private static void sortDrives(Vector aDrives) |
178 private static void sortDrives(Vector aDrives) |
179 { |
179 { |
180 for (int i = 0; i < aDrives.size(); i++) |
180 for (int i = 0; i < aDrives.size(); i++) |
181 { |
181 { |
190 aDrives.removeElementAt(j); |
190 aDrives.removeElementAt(j); |
191 aDrives.insertElementAt(d2, i); |
191 aDrives.insertElementAt(d2, i); |
192 } |
192 } |
193 } |
193 } |
194 } |
194 } |
195 // Move user chosen drive to be the first. |
195 // Move the configured default installation drive to be the first. |
196 int userChosen = getUserChosenDrive(); |
196 int configuredDefault = getConfiguredDefaultDrive(); |
197 if (userChosen != -1) |
197 if (configuredDefault != -1) |
198 { |
198 { |
199 for (int i = 0; i < aDrives.size(); i++) |
199 for (int i = 0; i < aDrives.size(); i++) |
200 { |
200 { |
201 DriveInfo d = (DriveInfo)aDrives.elementAt(i); |
201 DriveInfo d = (DriveInfo)aDrives.elementAt(i); |
202 if (d.getNumber() == userChosen) |
202 if (d.getNumber() == configuredDefault) |
203 { |
203 { |
204 aDrives.removeElementAt(i); |
204 aDrives.removeElementAt(i); |
205 aDrives.insertElementAt(d, 0); |
205 aDrives.insertElementAt(d, 0); |
206 } |
206 } |
207 } |
207 } |
224 } |
224 } |
225 Log.log(aMsg + sortedDrives); |
225 Log.log(aMsg + sortedDrives); |
226 } |
226 } |
227 |
227 |
228 /** |
228 /** |
229 * Returns the installation drive the user has chosen last. |
229 * Returns the configured default installation drive. |
230 * If user selection is not available, returns -1. |
230 * If it is not available, returns -1. |
231 */ |
231 */ |
232 private static int getUserChosenDrive() |
232 private static int getConfiguredDefaultDrive() |
233 { |
233 { |
234 int result = -1; |
234 int result = -1; |
235 try |
235 try |
236 { |
236 { |
237 String driveName = SysUtil.getRepositoryStringValue( |
237 String driveName = SysUtil.getRepositoryStringValue( |
242 result = driveName.toLowerCase().charAt(0) - 'a'; |
242 result = driveName.toLowerCase().charAt(0) - 'a'; |
243 } |
243 } |
244 } |
244 } |
245 catch (Throwable t) |
245 catch (Throwable t) |
246 { |
246 { |
247 Log.log("Getting user chosen drive from repository failed", t); |
247 Log.log("Getting default installation drive from repository failed", t); |
248 } |
248 } |
249 Log.log("Last user chosen drive from repository: " + result); |
249 Log.log("Default installation drive from repository: " + result); |
250 return result; |
250 return result; |
251 } |
251 } |
252 |
252 |
253 /** |
253 /** |
254 * Returns true if aD2 has higher priority than aD1. |
254 * Returns true if aD2 has higher priority than aD1. |
274 { |
274 { |
275 result = true; |
275 result = true; |
276 } |
276 } |
277 if (!result && |
277 if (!result && |
278 type1 != DriveInfo.INTERNAL_MASS_STORAGE && |
278 type1 != DriveInfo.INTERNAL_MASS_STORAGE && |
|
279 type1 != DriveInfo.MEMORY_CARD && |
|
280 type2 == DriveInfo.MEMORY_CARD) |
|
281 { |
|
282 result = true; |
|
283 } |
|
284 if (!result && |
|
285 type1 != DriveInfo.INTERNAL_MASS_STORAGE && |
|
286 type1 != DriveInfo.MEMORY_CARD && |
279 type1 != DriveInfo.PHONE_MEMORY && |
287 type1 != DriveInfo.PHONE_MEMORY && |
280 type2 == DriveInfo.PHONE_MEMORY) |
288 type2 == DriveInfo.PHONE_MEMORY) |
281 { |
|
282 result = true; |
|
283 } |
|
284 if (!result && |
|
285 type1 != DriveInfo.INTERNAL_MASS_STORAGE && |
|
286 type1 != DriveInfo.PHONE_MEMORY && |
|
287 type1 != DriveInfo.MEMORY_CARD && |
|
288 type2 == DriveInfo.MEMORY_CARD) |
|
289 { |
289 { |
290 result = true; |
290 result = true; |
291 } |
291 } |
292 return result; |
292 return result; |
293 } |
293 } |