javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/InstallationNotifier.java
--- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/InstallationNotifier.java Thu Jul 15 18:31:06 2010 +0300
+++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/InstallationNotifier.java Thu Aug 19 09:48:13 2010 +0300
@@ -46,6 +46,8 @@
// Maximum number of progress updates to SysUtil.setProperty().
private static final int MAX_PROPERTY_PROGRESS_UPDATES = 5;
+ // Maximum number of progress updates to SIF.
+ private static final int MAX_SIF_PROGRESS_UPDATES = 5;
// Maximum number of progress updates to UI.
private static final int MAX_UI_PROGRESS_UPDATES = 20;
@@ -61,11 +63,16 @@
private int iMaxValue = 1;
// Tells how often property progress should be updated.
private int iPropertyProgressStep = 1;
+ // Tells how often SIF progress should be updated.
+ private int iSifProgressStep = 1;
// Tells how often UI progress should be updated.
private int iUiProgressStep = 1;
// Point between 0 and iMaxValue where the last property
// update has been made.
private int iLastPropertyUpdate = 0;
+ // Point between 0 and iMaxValue where the last SIF update
+ // has been made.
+ private int iLastSifUpdate = 0;
// Point between 0 and iMaxValue where the last UI update
// has been made.
private int iLastUiUpdate = 0;
@@ -203,6 +210,11 @@
{
iPropertyProgressStep = 1;
}
+ iSifProgressStep = iMaxValue / MAX_SIF_PROGRESS_UPDATES;
+ if (iSifProgressStep == 0)
+ {
+ iSifProgressStep = 1;
+ }
iUiProgressStep = iMaxValue / MAX_UI_PROGRESS_UPDATES;
if (iUiProgressStep == 0)
{
@@ -241,29 +253,44 @@
Log.log("InstallationNotifier.set: progress " + currentPercentage);
defineProperties();
- if (aCurrentValue == 0 ||
- aCurrentValue == iMaxValue ||
- aCurrentValue >= iLastPropertyUpdate + iPropertyProgressStep ||
- aCurrentValue <= iLastPropertyUpdate - iPropertyProgressStep)
+ if (isUpdateNeeded(aCurrentValue, iMaxValue,
+ iLastPropertyUpdate, iPropertyProgressStep))
{
iLastPropertyUpdate = aCurrentValue;
Log.log("InstallationNotifier.set: update property to " +
currentPercentage);
// Update property values: progress.
- SysUtil.setPropertyValue
- (SysUtil.PROP_CATEGORY_SYSTEM,
- SysUtil.PROP_KEY_JAVA_LATEST_INSTALLATION_PROGRESS,
- currentPercentage);
+ SysUtil.setPropertyValue(
+ SysUtil.PROP_CATEGORY_SYSTEM,
+ SysUtil.PROP_KEY_JAVA_LATEST_INSTALLATION_PROGRESS,
+ currentPercentage);
}
- if (aCurrentValue == 0 ||
- aCurrentValue == iMaxValue ||
- aCurrentValue >= iLastUiUpdate + iUiProgressStep ||
- aCurrentValue <= iLastUiUpdate - iUiProgressStep)
+ if (isUpdateNeeded(aCurrentValue, iMaxValue,
+ iLastSifUpdate, iSifProgressStep))
{
- iLastUiUpdate = aCurrentValue;
+ if (iSifNotifier != null)
+ {
+ iLastSifUpdate = aCurrentValue;
+ try
+ {
+ iSifNotifier.notifyProgress(
+ iSifNotifier.SUB_OP_NO, currentPercentage, 100);
+ }
+ catch (Throwable t)
+ {
+ Log.logError(
+ "InstallationNotifier: SifNotifier.notifyProgress threw exception", t);
+ }
+ }
+ }
+
+ if (isUpdateNeeded(aCurrentValue, iMaxValue,
+ iLastUiUpdate, iUiProgressStep))
+ {
if (iInstallerUi != null)
{
+ iLastUiUpdate = aCurrentValue;
Log.log("InstallationNotifier.set: update ui to " +
currentPercentage);
try
@@ -276,21 +303,6 @@
"InstallationNotifier: InstallerUi.updateProgress threw exception", t);
}
}
- if (iSifNotifier != null)
- {
- Log.log("InstallationNotifier.set: update SifNotifier to " +
- currentPercentage);
- try
- {
- iSifNotifier.notifyProgress(
- iSifNotifier.SUB_OP_NO, currentPercentage, 100);
- }
- catch (Throwable t)
- {
- Log.logError(
- "InstallationNotifier: SifNotifier.notifyProgress threw exception", t);
- }
- }
}
}
@@ -382,4 +394,24 @@
"InstallationNotifier: Deleting property failed", ex);
}
}
+
+ /**
+ * Returns true if progress update is needed, false otherwise.
+ *
+ * @param aCurrent current progress value
+ * @param aMax maximum progress value
+ * @param aPrevious previously updated progress value
+ * @param aStep step between progress updates
+ */
+ private static boolean isUpdateNeeded(
+ int aCurrent, int aMax, int aPrevious, int aStep)
+ {
+ if (aCurrent == 0 || aCurrent == aMax ||
+ aCurrent >= aPrevious + aStep ||
+ aCurrent <= aPrevious - aStep)
+ {
+ return true;
+ }
+ return false;
+ }
}