| C H A P T E R 2 |
|
Porting the Personal Information Management and File Connection Optional Package |
This chapter discusses the design and porting of the PDA Optional Packages for the J2ME Platform (JSR 75). The JSR 75 specification defines the Personal Information Management (PIM) and File Connection (FC) optional packages. The customized version included with Java Wireless Client software is based on the Java Wireless Toolkit implementation. See http://www.jcp.org/en/jsr/detail?id=75 for more information about JSR 75.
The file midpFileConnection.c contains a native implementation of the DefaultFileHandler class. It uses PCSL (see the Sun Java Wireless Client Porting Guide) to abstract from most system-dependent features. It calls the functions defined in midpNativeMounts.h to get native mount points. Use this API to initiate the native file system monitor, request currently mounted roots, and resolve human-friendly file root names into native file path nomenclature.
The following performance optimizations are done in midpFileConnection.c:
The list of supported devices is defined by the validDisks array in midpMountedRoots.cpp. For this release, the CFCard, SDCard, and MMCCard devices are supported for the Texas Instruments OMAP730 development board, and the Floppy device is supported for the PC. The following special file roots are available for all targets: PIMdb, Storage, and Private. These roots are stored in dedicated subdirectories of the appdb directory. These directories are automatically created by the build system. The first one is used to store the PIM database, the second one can be useful if no removable devices (such as flash cards) are connected, and the third is a container for MIDlet private working directories.
The jsr75_suite_remove_cleanup() function is called when MIDlet suites are removed. It deletes the suites's private working directory and all its content.
The ROMizer is used to improve performance and security.
To build the JSR 75 module, the following variables must be defined:
The makefiles contain default settings that assume that USE_JSR_75 is set to false. The typical mechanism to override the default settings is to use command line settings when invoking the make command as shown in the following file fragment.
Use the following steps to configure Java Device Test Suite software version 1.4 to test the JSR 75 module:
1. Run the run_admin configuration script.
2. Open an existing profile or create a new profile that includes PDA OP (JSR 75) TestSuite (File->Open Profile or File->New Profile).
3. Select Configure Test Suites->PDA OP (JSR 75) TestSuite.
4. On the FileConnection tab specify the root directory name (for example, Storage/).
5. Select Security Permissions:
a. On the read_user_data_access tab, enable the javax.microedition.io.Connector.file.read checkbox.
b. On the write_user_data_access tab, enable the javax.microedition.io.Connector.file.write checkbox.
See the Sun Java Device Test Suite Administration Guide for more information.
FileConnection JavaCall API functions play the same role as PCSL functions do for non-JavaCall API platforms.
Personal Information Management JavaCall API functions are much like jsr75_pim_xxx() native porting layer functions.
FileConnection JavaCall API functions are defined in javacall_fileconnection.h header file.
All API functions listed below are mandatory. In addition to these, JSR 75 FC requires some of core MIDP JavaCall API functions (defined in javacall_file.h and javacall_dir.h) to be implemented.
Personal Information Management JavaCall API functions are defined in javacall_pim.h.
Implementations can provide access to PIM databases that are not resident on the device but at well known locations, located on SIM cards attached to the device, or to PIM databases created and managed by the Java platform VM itself.
All API functions listed below are mandatory, unless the Java platform implementation of PIM (based on high-level File Connection interface) is used.
This section describes general principles of the FC and PIM JavaCall API.
Buffers for all output parameters are allocated by the caller, unless specified otherwise.
In case of strings and arrays, there is a parameter for the size of the buffer. If output data does not fit into the buffer of the given size, the JavaCall API function must return JAVACALL_FAIL value.
All javacall_fileconnection_get_xxx_dir() functions return paths to the directories where files of certain types are located. Each directory corresponds to one system property accessible on Java level:
If any of the directories are absent (not supported) on the platform, the respective JavaCall API function should return JAVACALL_FAIL value. This will mean null value of the corresponding system property in the Java platform.
For any of the special storage locations that is supported, a localized name must also be provided. In other words, if a javacall_fileconnection_get_xxx_dir() function returns JAVACALL_OK, then the corresponding javacall_fileconnection_get_localized_xxx_dir() must also return JAVACALL_OK and provide a meaningful localized string describing the storage directory. These functions provide values for the following system properties:
JSR 75 FC uses several platform-dependent constants that should be properly defined when implementing JavaCall API. These constants are used by the JSR code for buffers pre-allocation when calling JavaCall API functions, so their values must be sufficient as buffer sizes to hold file names, root lists, and other native file system data:
This function must be called by the platform every time a file system root gets mounted or unmounted. The function body is platform-independent (implemented by Sun) and does not require any porting.
JavaCall API implementation must notify Java of mount/unmount events as soon as possible - ideally, platform may have an efficient mechanism to invoke the callback function immediately upon root change.
This section explains how the JSR 75 code can be ported to a new platform using the JavaCall API. The new platform is represented here as <new_platform>.
1. Create <new_platform>/jsr75_pim_fc directory in the javacall-com/implementation directory.
2. Copy fileconnection.c from javacall-com/implementation/stubs/jsr75_pim_fc to the <new_platform>/jsr75_pim_fc directory.
3. Rewrite functions in your new fileconnection.c according to the platform specifics.
4. Adjust platform-specific file system constants in javacall_file.h, javacall_dir.h, and javacall_fileconnection.h as necessary.
1. Create <new_platform>/jsr75_pim_fc directory in the javacall-com/implementation directory.
2. Copy pim.c from javacall-com/implementation/stubs/jsr75_pim_fc to the <new_platform>/jsr75_pim_fc directory.
3. Rewrite functions in your new pim.c according to the platform specifics.
4. Set the appropriate values for PIMRootDir and file.linebreak in jsr75/src/config/javacall/properties_jsr75.xml.
5. Set value for JSR_75_PIM_HANDLER_IMPL to platform in jsr75/src/config/common/config.gmk file.
Copyright © 2007, Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL.