--- a/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifRegistrator.java Wed Sep 15 12:05:25 2010 +0300
+++ b/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifRegistrator.java Wed Oct 13 14:23:59 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -25,6 +25,7 @@
import com.nokia.mj.impl.installer.utils.FileUtils;
import com.nokia.mj.impl.installer.utils.Log;
import com.nokia.mj.impl.installer.utils.PlatformUid;
+import com.nokia.mj.impl.rt.installer.ApplicationInfoImpl;
import com.nokia.mj.impl.utils.Attribute;
import com.nokia.mj.impl.utils.Uid;
@@ -60,14 +61,6 @@
}
/**
- * Returns SIF specific error category from given error id.
- */
- public static int getErrorCategory(int aErrorId)
- {
- return _getErrorCategory(aErrorId);
- }
-
- /**
* Launches the application view. If launching application view
* fails this method does not throw exception but produces an
* error log entry.
@@ -136,6 +129,27 @@
}
/**
+ * Registers or unregisters Java software type to software
+ * installation framework.
+ *
+ * @param aRegister true for registration, false for unregistration
+ */
+ public static void registerJavaSoftwareType(boolean aRegister)
+ {
+ String op = (aRegister? "Register": "Unregister");
+ int err = _registerJavaSoftwareType(aRegister);
+ if (err < 0)
+ {
+ InstallerException.internalError(
+ op + " Java software type failed with code " + err);
+ }
+ else
+ {
+ Log.log("SifRegistrator " + op + "ed Java software type");
+ }
+ }
+
+ /**
* Starts application registration session.
* The registrations and unregistrations are done only
* when commitSession is called.
@@ -165,7 +179,7 @@
if (ret < 0)
{
InstallerException.internalError(
- "Creating SIF session failed with code " + ret);
+ "Creating session failed with code " + ret);
}
//Log.log("SifRegistrator session started");
iSessionHandle = ret;
@@ -184,18 +198,36 @@
*/
public void registerSuite(SuiteInfo aSuiteInfo, boolean aIsUpdate)
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
Log.log("SifRegistrator registering application suite " +
aSuiteInfo.getGlobalId());
- // Register suite as a component.
- registerComponent(aSuiteInfo, aIsUpdate);
- registerLocalizedComponentName(aSuiteInfo, -1);
- // Register applications within the component.
- Vector apps = aSuiteInfo.getApplications();
- for (int i = 0; i < apps.size(); i++)
+ if (_getUsifMode() > 0)
{
- registerApplication(aSuiteInfo, i);
+ // USIF Phase 2 registration.
+ // Register suite as a component.
+ registerComponent(aSuiteInfo, aIsUpdate);
+ registerLocalizedComponentName(aSuiteInfo, -1);
+ // Register applications within the component.
+ Vector apps = aSuiteInfo.getApplications();
+ for (int i = 0; i < apps.size(); i++)
+ {
+ registerApplication(aSuiteInfo, i);
+ }
+ }
+ else
+ {
+ // USIF Phase 1 registration.
+ // Register each application in the suite.
+ Vector apps = aSuiteInfo.getApplications();
+ for (int i = 0; i < apps.size(); i++)
+ {
+ registerComponent(aSuiteInfo, i, aIsUpdate);
+ registerLocalizedComponentName(aSuiteInfo, i);
+ }
}
registerLocalizedProperties(aSuiteInfo);
}
@@ -211,12 +243,29 @@
*/
public void unregisterSuite(SuiteInfo aSuiteInfo)
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
Log.log("SifRegistrator unregistering application suite " +
aSuiteInfo.getGlobalId());
- // Unregister suite as a component.
- unregisterComponent(aSuiteInfo);
+ if (_getUsifMode() > 0)
+ {
+ // USIF Phase 2 unregistration.
+ // Unregister suite as a component.
+ unregisterComponent(aSuiteInfo);
+ }
+ else
+ {
+ // USIF Phase 1 unregistration.
+ // Unregister each application in the suite.
+ Vector apps = aSuiteInfo.getApplications();
+ for (int i = 0; i < apps.size(); i++)
+ {
+ unregisterComponent(aSuiteInfo, i);
+ }
+ }
}
/**
@@ -229,11 +278,15 @@
*/
public void commitSession()
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
+
int err = _commitSession(iSessionHandle);
if (err < 0)
{
- InstallerException.internalError("Commiting SIF session failed with code " + err);
+ InstallerException.internalError("Commiting session failed with code " + err);
}
// Current session has been closed
iSessionHandle = 0;
@@ -248,13 +301,17 @@
*/
public void rollbackSession()
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
+
int err = _rollbackSession(iSessionHandle);
// Session is closed always when rollback is called
iSessionHandle = 0;
if (err < 0)
{
- InstallerException.internalError("Rolling back SIF session failed with code " + err);
+ InstallerException.internalError("Rolling back the session failed with code " + err);
}
//Log.log("SifRegistrator session rolled back");
}
@@ -270,6 +327,7 @@
{
return;
}
+
_closeSession(iSessionHandle);
// Current session has been closed
iSessionHandle = 0;
@@ -286,7 +344,11 @@
*/
public ComponentId getComponentId(String aGlobalId)
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
+
ComponentId result = new ComponentId();
int ret = _getComponentId(iSessionHandle, aGlobalId, result);
if (-1 == ret)
@@ -314,7 +376,11 @@
*/
public ComponentId getComponentId(Uid aAppUid)
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
+
ComponentId result = new ComponentId();
int ret = _getComponentIdForApp(
iSessionHandle, ((PlatformUid)aAppUid).getIntValue(), result);
@@ -340,12 +406,15 @@
*/
public void logComponent(String aGlobalId)
{
- checkSession();
+ if (0 == iSessionHandle)
+ {
+ InstallerException.internalError("No valid SIF session.");
+ }
+
int ret = _logComponent(iSessionHandle, aGlobalId);
if (ret < -1)
{
- Log.logError("SifRegistrator logComponent for " + aGlobalId +
- " failed with code " + ret);
+ Log.logError("SifRegistrator logComponent failed with code " + ret);
}
}
@@ -353,19 +422,120 @@
/*** ----------------------------- PRIVATE ---------------------------- */
/**
- * Checks if SifRegistrator session has been started.
- * @throws InstallerException if SifRegistrator session has not been started
+ * Registers one Java application to S60 USIF as a component.
+ * Used with USIF Phase 1.
+ *
+ * @param aSuiteInfo Information needed to register the application
+ * @param aIndex index of the application in the suite
+ * @param aIsUpdate true in case of an update, false in case of a new
+ * installation
+ * @throws InstallerException if registration cannot done or
+ * startSession has not been called successfully
+ * @see startSession
+ * @see SuiteInfo
*/
- private void checkSession()
+ private void registerComponent(
+ SuiteInfo aSuiteInfo, int aIndex, boolean aIsUpdate)
{
- if (iSessionHandle == 0)
+ String globalId = aSuiteInfo.getGlobalId(aIndex);
+ if (globalId == null)
+ {
+ Log.logWarning("SifRegistrator: Application with index " + aIndex +
+ " not found from " + aSuiteInfo.getGlobalId());
+ return;
+ }
+ ApplicationInfo appInfo =
+ (ApplicationInfo)aSuiteInfo.getApplications().elementAt(aIndex);
+ String suiteName = aSuiteInfo.getName();
+ String vendor = aSuiteInfo.getVendor();
+ String version = aSuiteInfo.getVersion().toString();
+ String name = appInfo.getName();
+ int uid = ((PlatformUid)appInfo.getUid()).getIntValue();
+ String[] componentFiles = getComponentFiles(aSuiteInfo);
+ long componentSize = aSuiteInfo.getInitialSize();
+ String attrValue = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Block-Uninstall");
+ boolean isRemovable = !(attrValue != null && attrValue.equalsIgnoreCase("true"));
+ boolean isDrmProtected = (aSuiteInfo.getContentInfo() == aSuiteInfo.CONTENT_INFO_DRM);
+ boolean isOriginVerified = aSuiteInfo.isTrusted();
+ String midletInfoUrl = aSuiteInfo.getAttributeValue("MIDlet-Info-URL");
+ String midletDescription = aSuiteInfo.getAttributeValue("MIDlet-Description");
+ String downloadUrl = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Download-URL");
+ ComponentId componentId = new ComponentId();
+ int err = _registerComponent(
+ iSessionHandle, uid,
+ getScrString(suiteName), getScrString(vendor),
+ getScrString(version), getScrString(name),
+ getScrString(globalId), componentFiles,
+ componentSize, isRemovable, isDrmProtected,
+ isOriginVerified, aIsUpdate, aSuiteInfo.getMediaId(),
+ getScrString(midletInfoUrl),
+ getScrString(midletDescription),
+ getScrString(downloadUrl),
+ componentId);
+ if (err < 0)
+ {
+ InstallerException.internalError(
+ "Registering component " + globalId +
+ " failed with code " + err);
+ }
+ else
{
- InstallerException.internalError("No valid SIF session.");
+ appInfo.setComponentId(componentId);
+ Log.log("SifRegistrator registered component " + globalId +
+ " with id " + componentId.getId());
+ }
+ }
+
+ /**
+ * Unregisters one Java application from being S60 USIF component.
+ * Used with USIF Phase 1.
+ *
+ * @param aSuiteInfo Information needed to unregister the application,
+ * @param aIndex index of the application in the suite
+ * @throws InstallerException if unregistration cannot done or
+ * startSession has not been called successfully
+ * @see startSession
+ * @see SuiteInfo
+ */
+ private void unregisterComponent(SuiteInfo aSuiteInfo, int aIndex)
+ {
+ String globalId = aSuiteInfo.getGlobalId(aIndex);
+ if (globalId == null)
+ {
+ Log.logWarning("SifRegistrator: Application with index " + aIndex +
+ " not found from " + aSuiteInfo.getGlobalId());
+ return;
+ }
+ ComponentId componentId = getComponentId(globalId);
+ if (componentId == null)
+ {
+ Log.logWarning(
+ "SifRegistrator unregistration failed, application " +
+ globalId + " does not exist");
+ return;
+ }
+ // Save component id to ApplicationInfo.
+ ApplicationInfo appInfo =
+ (ApplicationInfo)aSuiteInfo.getApplications().elementAt(aIndex);
+ appInfo.setComponentId(componentId);
+ // Unregister application.
+ int err = _unregisterComponent(iSessionHandle, componentId.getId());
+ if (err < 0)
+ {
+ InstallerException.internalError(
+ "Unregistering component " + globalId +
+ " failed with code " + err);
+ }
+ else
+ {
+ Log.log("SifRegistrator unregistered component " + globalId +
+ " with id " + componentId.getId());
}
}
/**
* Registers Java application suite to S60 USIF as a component.
+ * Used with USIF Phase 2.
*
* @param aSuiteInfo Suite information
* @param aIsUpdate true in case of an update, false in case of a new
@@ -381,6 +551,7 @@
String suiteName = aSuiteInfo.getName();
String vendor = aSuiteInfo.getVendor();
String version = aSuiteInfo.getVersion().toString();
+ String name = null; // Set name to null so that suite name will be used.
int uid = ((PlatformUid)aSuiteInfo.getUid()).getIntValue();
String[] componentFiles = getComponentFiles(aSuiteInfo);
long componentSize = aSuiteInfo.getInitialSize();
@@ -391,20 +562,17 @@
String midletInfoUrl = aSuiteInfo.getAttributeValue("MIDlet-Info-URL");
String midletDescription = aSuiteInfo.getAttributeValue("MIDlet-Description");
String downloadUrl = aSuiteInfo.getAttributeValue("Nokia-MIDlet-Download-URL");
- String updateUrl = aSuiteInfo.getAttributeValue("Nokia-Update");
ComponentId componentId = new ComponentId();
int err = _registerComponent(
iSessionHandle, uid,
getScrString(suiteName), getScrString(vendor),
- getScrString(version), getScrString(globalId),
- componentFiles, componentSize,
- isRemovable, isDrmProtected,
- isOriginVerified, aIsUpdate,
- aSuiteInfo.getMediaId(),
+ getScrString(version), getScrString(name),
+ getScrString(globalId), componentFiles,
+ componentSize, isRemovable, isDrmProtected,
+ isOriginVerified, aIsUpdate, aSuiteInfo.getMediaId(),
getScrString(midletInfoUrl),
getScrString(midletDescription),
getScrString(downloadUrl),
- getScrString(updateUrl),
componentId);
if (err < 0)
{
@@ -422,6 +590,7 @@
/**
* Unregisters Java application suite from being S60 USIF component.
+ * Used with USIF Phase 2.
*
* @param aSuiteInfo suite information
* @throws InstallerException if unregistration cannot done or
@@ -463,6 +632,7 @@
* from given SuiteInfo object. The SuiteInfo must already have
* been registered to USIF as a component with registerComponent()
* method before this method is called.
+ * Used with USIF Phase 2.
*
* @param aSuiteInfo information needed to register the application
* @param aIndex index of the application in the suite
@@ -520,20 +690,15 @@
private static String[] getComponentFiles(SuiteInfo aSuite)
{
Vector componentFiles = new Vector();
- if (!aSuite.isPreinstalled())
+ String path = aSuite.getJadPath();
+ if (path != null)
{
- // Add component jad and jar files only when the
- // application is not preinstalled.
- String path = aSuite.getJadPath();
- if (path != null)
- {
- componentFiles.addElement(getScrString(path));
- }
- path = aSuite.getJarPath();
- if (path != null)
- {
- componentFiles.addElement(getScrString(path));
- }
+ componentFiles.addElement(getScrString(path));
+ }
+ path = aSuite.getJarPath();
+ if (path != null)
+ {
+ componentFiles.addElement(getScrString(path));
}
boolean addRootPath = true;
int rootDrive = FileUtils.getDrive(aSuite.getRootDir());
@@ -551,15 +716,10 @@
}
if (addRootPath)
{
- componentFiles.addElement(
- getScrString(aSuite.getRootDir() + "nofile.txt"));
+ componentFiles.addElement(getScrString(aSuite.getRootDir()));
}
String[] result = new String[componentFiles.size()];
componentFiles.copyInto(result);
- for (int i = 0; i < result.length; i++)
- {
- Log.log("SifRegistrator componentFiles[" + i + "]: " + result[i]);
- }
return result;
}
@@ -666,48 +826,21 @@
}
// Register Domain-Category property.
- String protectionDomainProperty = "Domain-Category";
- String protectionDomainName = aSuite.getProtectionDomainName();
+ ApplicationInfoImpl appInfoImpl = (ApplicationInfoImpl)
+ com.nokia.mj.impl.rt.support.ApplicationInfo.getInstance();
+ String domainCategory = appInfoImpl.getProtectionDomain();
err = _setLocalizedComponentProperty(
- iSessionHandle, cid, protectionDomainProperty,
- getProtectionDomainPropertyValue(protectionDomainName),
- UNSPECIFIED_LOCALE);
+ iSessionHandle, cid, "Domain-Category",
+ domainCategory, UNSPECIFIED_LOCALE);
if (err < 0)
{
InstallerException.internalError(
- "Adding property " + protectionDomainProperty +
- " value " + protectionDomainName + " for component " +
- cid + " failed with code " + err);
+ "Adding property Domain-Category value " + domainCategory +
+ " for component " + cid + " failed with code " + err);
}
}
/**
- * Returns the "Domain-Category" property value which contains
- * the text id and text file name for the localized domain category
- * text. This method must never return null.
- */
- private String getProtectionDomainPropertyValue(String aProtectionDomain)
- {
- String textId = "txt_java_inst_setlabel_cert_domain_val_untrusted_third_party";
- if (aProtectionDomain != null)
- {
- if (aProtectionDomain.equals("Manufacturer"))
- {
- textId = "txt_java_inst_setlabel_cert_domain_val_manufacturer";
- }
- else if (aProtectionDomain.equals("Operator"))
- {
- textId = "txt_java_inst_setlabel_cert_domain_val_operator";
- }
- else if (aProtectionDomain.equals("IdentifiedThirdParty"))
- {
- textId = "txt_java_inst_setlabel_cert_domain_val_trusted_third_party";
- }
- }
- return textId + ",javaapplicationinstaller";
- }
-
- /**
* Returns array of localized names from the specified
* attributes of given suite. Assumes that aAttrPrefix
* is an attribute name prefix that is followed by locale.
@@ -736,13 +869,6 @@
"SifRegistrator ignored unknown locale: " +
name + ": " + localizedName);
}
- else if (localizedName.getName() == null ||
- localizedName.getName().length() == 0)
- {
- Log.logWarning(
- "SifRegistrator ignored empty localized text: " +
- name + ": " + localizedName);
- }
else
{
Log.log("SifRegistrator found localized text " +
@@ -823,6 +949,14 @@
private static native int _launchAppView();
/**
+ * Registers Java software type to software installation framework.
+ *
+ * @param aRegister true for registration, false for unregistration
+ * @return 0 or Symbian error code (negative number)
+ */
+ private static native int _registerJavaSoftwareType(boolean aRegister);
+
+ /**
* Starts native application registration session.
*
* @param aTransaction true if also transaction for this session should
@@ -864,6 +998,7 @@
* @param aSuiteName
* @param aVendor
* @param aVersion
+ * @param aName
* @param aGlobalId
* @param aComponentFiles
* @param aComponentSize
@@ -875,19 +1010,17 @@
* @param aMidletInfoUrl
* @param aMidletDescription
* @param aDownloadUrl
- * @param aUpdateUrl
* @param aComponentId upon successful execution contains the
* component id for the registered component
* @return 0 if registration succeeded or Symbian error code
*/
private static native int _registerComponent(
int aSessionHandle, int aUid, String aSuiteName, String aVendor,
- String aVersion, String aGlobalId,
+ String aVersion, String aName, String aGlobalId,
String[] aComponentFiles, long aComponentSize,
boolean aIsRemovable, boolean aIsDrmProtected,
boolean aIsOriginVerified, boolean aIsUpdate, int aMediaId,
- String aMidletInfoUrl, String aMidletDescription,
- String aDownloadUrl, String aUpdateUrl,
+ String aMidletInfoUrl, String aMidletDescription, String aDownloadUrl,
ComponentId aComponentId);
/**
@@ -995,9 +1128,4 @@
* @return 1 if application data should be registered to USIF, 0 otherwise
*/
private static native int _getUsifMode();
-
- /**
- * Returns SIF specific error category from given error id.
- */
- private static native int _getErrorCategory(int aErrorId);
}