Sunday, June 01, 2008

My Thesis - Literature Study - JSR 135

According to Nokia’s developer guide [1], JSR-135 is Mobile Media API that allows MIDlets to do various multimedia operations, including: playing several kinds of audio and video, capturing images using the local device’s camera, and adjusting these operations using special kind of controls. In this thesis project, JSR-135 will be used to play audio and video files which are transferred from the news server. Thus, client will be able to preview the audio or video files before he/ she decides to keep the file permanently inside his/ her device’s storage.

The API will allow application developer to create an instance of Player, which can be connected to an audio or video file using Manager.createPlayer() method. After the connection has been established, the Player can get all of the resources needed to play the audio or video file by using the realize() method. To get media player controls, such as volume control or video control, getControls() method can be used. Moreover, prefetch() method can be used to take some part of the file, so that the player can start immediately when the start() method is invoked. In addition, stop() method can be used to stop the media player and deallocate() method can be used to release all resources being hold by the media player.

According to Nokia’s “MIDP Mobile Media API Developers Guide” [1] and embedded Java Documentation inside NetBeans IDE, JSR-135 supports the following media file extensions:
  • Audio : .WAV, .AU, .AMR, .MID, and .MP3
  • Video : .3gp, .mp4, and .rm

Reference:
[1] MIDP Mobile Media API Developers Guide version 1.0, Forum Nokia. MIDP_Mobile_Media_API_Developers_Guide_v1_0_en.pdf.

My Thesis - Literature Study - kXML

Both database backup and recovery will use XML technology. The resulting backup-files and the recovery files will be stored in XML format. In order to implement this scheme, a XML parser will be needed. There are three kinds of XML Parser:
  • Model parser
    • It reads an entire document and creates a representation of the document in memory. Model parsers use significantly more memory than other types of parsers.
  • Push parser
    • It reads through an entire document. As it encounters various parts of the document, it notifies a listener object.
  • Pull parser
    • It reads a little bit of a document at once. The application drives the parser through the document by repeatedly request the next piece.

Among these three parser types, pull parser is considered to be the best choice since it could support the ability to parse huge size of XML file (i.e. typical size of database backup result). kXML [1] is an example of XML pull parser. It is an open source and free XML parser. It is also small in term of size (i.e. 50 kB, but if the application is obfuscated, the size can reduce to only 10 kB), so it will not really affect the size of the resulting application. Overall, the main advantages of using kXML are because kXML provides:
  • Simple to use API that concentrates on how to generate XML file quickly
  • Interface that is designed to allow implementation of very fast XML serializer
  • Minimal memory requirement
In order to parse a XML file, one must connect to the XML file (i.e. by employing JSR-75) and assign a file reader using InputStreamReader classes. Then, the file reader could be used to read and parse the XML file by using the KXmlParser.setInput() method. Moving through every tags using KXmlParser.nextTag() method, reading intended tag using KXmlParser.require() method, and reading tag’s content using KXmlParser.nextText() method.
When it comes to XML file-creation, KXmlSerializer class can be used to write through the content. KXmlSerializer provide method for:
  • Assigning output using the setOutput() method.
  • Identifying start of XML document using startDocument() method.
  • Writing tags using startTag() and endTag() method.
  • Inserting content into tags using text() method.
  • Finalizing the newly-created XML document using endDocument() method.
Another reason of using XML file is because one can create this file easily in PC. So, if the user hates the struggle of typing news content on his/ her mobile phone, the user can use notepad or other text editor application in his/ her PC to create the XML file with the news in it. After creating the XML file, the user can transfer it to his/ her mobile phone, and then use the database recovery feature to add the news inside the XML file into the news database.


Reference:
[1] KXML. http://kxml.sourceforge.net/kxml2/.

My Thesis - Literature Study - JSR 75

In order to add database backup and recovery ability into this thesis project, there must be a way to store files into phone’s file system. It is why JSR-75 is needed in this application development. According to Sun’s developer website [1], JSR-75 can handle local file connection and local file creation functions. File creation is needed during database backup, while file connection will be needed during the database recovery. Besides for database backup and recovery system, JSR-75 will also be utilized for storing files which are transferred from the server into the client’s local file storage.

FileConnection is the class that will handle connections to the device’s file system. Once a connection to a file system is established, several kinds of queries can be performed using the FileConnection object's methods, including:
  • Get a filtered list of files and directories using the method list(String filter, boolean includeHidden). In the filter parameter * can be used as a wildcard to specify zero or more occurences of any character. The includeHidden parameter specifies whether to list only visible files, or hidden files as well.
  • Discover whether a file or directory exists using exists().
  • Discover whether a file or directory is hidden using isHidden().
  • Create or delete a file or directory using create(), mkdir(), or delete().

Moreover, in order to list directory roots in a device, listRoots() method of FileSystemRegistry can be used.

However, there is one important issue that should be concerned, that is about directory access permission in Nokia mobile phones. According to Nokia’s “MIDP 2.0 Signed MIDlet Developers Guide” [2], there are two kinds of application, Trusted application and Untrusted application. Untrusted application will not have access to the file system unless it has been confirmed by the user. Thus, it will keep asking for confirmation every time the application tries to establish a file connection. On the other hand, Trusted application is able to access the file system without having user confirmation. To become a Trusted application, an application has to be legally signed. This application signature is available for purchase at Verisign [3] at the price of $499(the price is valid by April 2008). Regarding the lengthy period for the application testing and the funds needed in acquiring the signature, the resulting application of this project will not be a signed one.


Reference:
[1] Sun Developer Network Site: J2ME technology reference. http://developers.sun.com/mobility/reference/techart/index.jsp.
[2]
MIDP 2.0 Signed MIDlet Developers Guide version 2.0, Forum Nokia. MIDP_2_0_Signed_MIDlet_Developers_Guide_v2_0_en.pdf.
[3]
Verisign: Digital Code Signing. http://www.verisign.com/products-services/security-services/code-signing/digital-ids-code-signing/index.html.

My Thesis - Literature Study - JSR 82

JSR stands for Java Specification Request. It is the actual descriptions of proposed and final specifications for the Java platform. According to Motorola’s JSR-82 specification document [1], JSR-82 is a J2ME Application Programming Interface (API) for Bluetooth environment. It enables Java applications to interact using Bluetooth technology. Having this, application developers will not need to bother about the hardware stack of the Bluetooth Protocol Stacks. Instead, they only need to deal with the software stack.

Moreover, JSR-82 provides following capabilities:
  • Register and publish services
  • Discover devices and services
  • Establish connection between devices
  • Send and retrieve data
  • Manage and control the communication connections
  • Provide security for the activities mentioned above

Particularly, JSR-82 provides device-management capabilities by providing two classes, LocalDevice and RemoteDevice. Both classes can help application to get information about devices. Methods of getLocalDevice() and getRemoteDevice() can respectively get local device and remote device as objects. Both classes also provides getBluetoothAddress() and getFriendlyName() to get the Bluetooth address of the device and retrieve the name of the Bluetooth device respectively.

In order to make a connection, one device should initiate the connection. On the client side, JSR-82 provides DiscoveryAgent class in order to find nearby active Bluetooth devices by using startInquiry() method. After active devices are found, it can begin to search for available services using the searchServices() method.

On the server side, it has the responsibility to publish its services, allowing clients to see and consume available services. To provide server with this capability, JSR-82 allows Bluetooth server device:
  • To create and publish services using Connector.open() method.
  • To add services to the Service Discovery Database (SDDB) using LocalDevice.getRecord() method.
  • To update any changes on SDDB using LocalDevice.updateRecord() method.
  • To wait and accept any incoming client connections using StreamConnectionNotifier.acceptAndOpen() method.
  • To remove services from SDDB using StreamConnectionNotifier.close() method when it is no longer needed.
Reference:
[1] Java APIs for Bluetooth Wireless Technology (JSR 82), Motorola. JABWT-Spec.pdf.

My Thesis - Literature Study - RMS

Record Management System (RMS) has been used as persistent storage for keeping mobile phones’ users records. It works similarly like desktop file-based database (e.g. dBase or dbf-formatted database). In order to store records, there are no exact SQL-command-like commands that can be used. Instead, an application has to convert records into byte arrays and then store them one-by-one or in sequence. Each record will occupy a row which could have data that are grouped into several columns. Unlike in desktop databases where each data could be stored into its column by just mentioning the name of the destined column (e.g. INSERT INTO table1 (column1, column2) VALUES (value1, value2)), RMS has to know the correct column order or sequence in order to have byte arrays of data stored in the correct column. This is very contrast to desktop databases (e.g. MySQL, Ms SQL Server, Oracle, etc) where data can be stored easily by just invoking SQL commands. However, compared to desktop database, RMS are lighter, more compact in term of size, and can be faster accessed. That’s why it is suitable for small mobile devices which have limited computing and storage resources to use it as persistent storage.

RMS of an application may contain several Record Stores. Record Store can be illustrated as Table in term of common desktop database management system. To create or open a Record Store, RecordStore.openRecordStore() method can be used. In order to create or store a record, one must convert or pack the data into byte arrays using DataOutputStream and ByteArrayOutputStream classes then add the record using the RecordStore.addRecord() method. Conversely, reading records will be done by unpacking the byte arrays using DataInputStream and ByteArrayInputStream classes. In addition, when a Record Store stores a record, it assigns unique record ID to it. Later on, this record ID will be used when the application wants to access that particular record. Ability of accessing particular record might come into handy when one wants to update or delete records. To delete a record, RecordStore.deleteRecord() can be used. For updating a particular record, method of RecordStore.setRecord() can be used. Of course, both of these methods require the record ID as its parameter. Finally, when all Record Store operations are done and it is no longer needed, one can use RecordStore.close to close the Record Store.

My Thesis - Literature Study - MIDP

Mobile Information Device Profile (MIDP) includes specification regarding use of java on embedded devices. Each java-enabled mobile phone belongs to certain MIDP version. There are 2 MIDP versions that have been introduced to date; those are MIDP 1.0 and MIDP 2.0. In short, MIDP 2.0 has more capability or richer features than MIDP 1.0, especially in Multimedia, API’s and User Interfaces. Most MIDP applications (called as MIDlet) that work in MIDP 1.0 devices will also work in MIDP 2.0, but not the other way around. In this thesis project, MIDP 2.0 will be used.

My Thesis - Literature Study - J2ME

Java 2 Micro Edition (J2ME) is part of the Java 2 platform that focuses on consumer and embedded devices, such as mobile phones and PDAs. It contains a collection of APIs which can be used to create J2ME application which is called as MIDlet. Before heading to the analysis, let’s take a look on collection of APIs that will be used in the development of this thesis project. The thesis project will involve several J2ME APIs, such as: MIDP, RMS, JSR-82, JSR-75, kXML, JSR-135, JSR-118, and JSR-120.

My Thesis - Literature Study - Bluetooth

1.1.1 Definition

According to Bluetooth.com [1], Bluetooth is a wireless protocol utilizing short-range (typically up to 10 meters of range between devices) communications technology. It can facilitate both voice and data transmission over short distances from fixed and/ or mobile devices. When two or more Bluetooth devices are connected together, they form a dynamically created network that comprises a master device and up to seven slaves; hence, creating personal area networks (PAN) called as Piconet.

Bluetooth radio technology uses 2.4 GHz Industrial, Scientific, and Medical (ISM) frequency band. This frequency band is unlicensed and anyone may use the frequency for free.

1.1.2 Characteristics

Bluetooth characteristics are as follows:

  • Provide wireless connection
  • Inexpensive
  • Uses ISM band which has been standardized throughout the world
  • Handles transmission of data
  • Uses omni-directional signals that can pass through walls
  • Uses frequency hoping to avoid communication interception
  • Low power consumption

Reference:
[1] Bluetooth.com: The Official Bluetooth® Technology Info Site. http://www.bluetooth.com. Tuesday, 28 May 2008.