All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ocap.system.package.html Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version








package









This API is used to access system modules.

 

Example of application access of Specific Application Resource

This is sample code for accessing the Specific Application Resource. See also Section 20.2.2.4.1.

 

import org.ocap.system.*;

public class PrivateHostApp implements SystemModuleHandler {

??? SystemModule sm; // A SystemModule returns by ready() method.

??? SystemModuleRegistrar registrar;

??? // Note that this is not an actual byte data.

??? byte[] privateHostAppID = {0x01, 0x23, 0x45, 0x67};

???

??? /**

???? * Constructor of this class.

?? ??* Register this class as a Private Host Application.

???? */

??? public PrivateHostApp() {

??????? registrar = SystemModuleRegistrar.getInstance();

??????? // Note that a current resident Private Host Application

??????? // (ID=0x01234567) will terminate by this method call.

??????? registrar.registerSASHandler(this, privateHostAppID);

??? }

 

??? /**

???? * Unregister this class, i.e., terminate assuming.

???? */

??? public void unregister() {

??????? // Unregister itself.

??????? registrar.unregisterSASHandler(privateHostAppID);

??? }

 

??? /**

???? * Define the receiveAPDU() method in the SystemModuleHandler.

???? */

??? public void receiveAPDU(int apduTag, int lengthField, byte[] dataByte) {

??????? // Define a process for each receiving APDU here.

??? }

???

??? /**

???? * Define the sendAPDUFailed() method in the SystemModuleHandler.

???? */

??? public void sendAPDUFailed(int apduTag, byte[] dataByte) {

??????? // Define an error recovery for each receiving APDU here.

??????? // For example, re-send it.

??????? sm.sendAPDU(apduTag, dataByte);

??? }

 

??? /**

???? * Define the notifyUnregister() method in the SystemModuleHandler.

???? */

??? public void notifyUnregister() {

??????? // Terminate activity and communication with the POD.

??????? // Return immediately!

??????? // Write a termination procedure here.

??? }

 

??? /**

???? * Define the ready() method in the SystemModuleHandler.

???? */

??? public void ready(SystemModule systemModule) {

??????? // Note that this is not an actual byte data.

??????? int??? sasDataRqstApduTag = 0x9F9A02;

??????? byte[] sas_data_rqst_byte = {0x01, 0x23, 0x45, 0x67};

 

??????? //Start communication with the POD.

??????? sm = systemModule;

??????? sm.sendAPDU(sasDataRqstApduTag, sas_data_rqst_byte);

??? }

}

 

 

 

Example of accessing MMI Resource

This is sample code for accessing MMI Resource. See also Section 20.2.2.4.2.

 

import org.ocap.system.*;

import org.ocap.hardware.pod.*;

public class MMI implements SystemModuleHandler{

??? SystemModule??????????? sm; // A SystemModule returns by ready() method.

??? SystemModuleRegistrar?? registrar;

 

??? /**

???? * Constructor of this class.

???? * Register this class to access MMI.

???? */

??? public MMI() {

??????? registrar = SystemModuleRegistrar.getInstance();

??????? // Note that a resident MMI doesn't terminate by this method call.

??????? registrar.registerMMIHandler(this);

??????? POD pod = POD.getInstance();

??????? PODApplication[] apps = pod.getApplications();

??????? String url = apps[0].getURL();

??? }

 

??? /**

???? * Unregister this class, i.e., terminate registration.

???? */

??? public void unregister() {

??????? //Unregister itself.

??????? registrar.unregisterMMIHandler();

??? }

 

??? /**

???? * Define the receiveAPDU() method in the SystemModuleHandler.

? ???*/

??? public void receiveAPDU(int apduTag, int lengthField, byte[] dataByte) {

??????? // Define a process for each receiving APDU here.

??????? // For example, draw a new MMI dialogue.

??? }

 

??? /**

???? * Define the sendAPDUFailed() method in the SystemModuleHandler.

???? */

??? public void sendAPDUFailed(int apduTag, byte[] byteData) {

??????? // Define a error recovery for each receiving APDU here.

??????? // For example, re-send it.

??????? sm.sendAPDU(apduTag, byteData);

??? }

 

??? /**

???? * Define the notifyUnregister() method in the SystemModuleHandler.

???? */

??? public void notifyUnregister() {

??????? // Terminate activity and communication with the POD.

??????? // Return immediately!

??????? // Write a termination procedure here.

??? }

 

??? /**

???? * Define the ready() method in the SystemModuleHandler.

???? */

??? public void ready(SystemModule systemModule) {

??????? // Note that this is not an actual byte data.

??????? int??? serverQueryApduTag = 0x9F8022;

??????? byte[] server_query_byte = {0x12, 0x34, 0x56};

??????? // Start communication with the POD.

??????? sm = systemModule;

??????? sm.sendAPDU(serverQueryApduTag, server_query_byte);

??? }

}

 

 

Example of setting EAS Audio and Display Attributes

This is sample code for OCAP-J application management of audio presentation and setting of EASdisplay attributes. See also Section 20.2.3.10.

 

import org.ocap.system.*;

/**

?* This is a sample implementation of EAS manager.

?*/

public class EASModule implements EASHandler {

 

??? /**

??? ?* Constructor of this class.

???? * The EASmodule class is a part of the Monitor Application. It SHALL

???? * have a MonitorAppPermission("handler.eas") permission.

???? */

??? public EASModule() {

??????? try {

??????????? EASModuleRegistrar easmr = EASModuleRegistrar.getInstance();

??????????? easmr.registerEASHandler(this);

 

??????????? //Investigate possible font colors.

??????????? java.awt.Color fontColor[] =

??????????????? (java.awt.Color[])easmr.getEASCapability(

??????????????????????? EASModuleRegistrar.EAS_ATTRIBUTE_FONT_COLOR);

 

??????????? //Investigate possible font styles.

??????????? String fontStyle[] =

??????????????? (String[])easmr.getEASCapability(

??????????????????????? EASModuleRegistrar.EAS_ATTRIBUTE_FONT_STYLE);

 

????????? ??//Investigate possible font face.

??????????? String fontFace[] =

??????????????? (String[])easmr.getEASCapability(

??????????????????????? EASModuleRegistrar.EAS_ATTRIBUTE_FONT_FACE);

 

??????????? //Set a preferred font color/style/face.

??????????? //(Set the first item for every attribute as a sample.

??????????? //An actual Monitor Application may provide a GUI to select

??????????? //user preferences.)

??????????? int attributes[] = {EASModuleRegistrar.EAS_ATTRIBUTE_FONT_COLOR,

??????????????? ????????????????EASModuleRegistrar.EAS_ATTRIBUTE_FONT_STYLE,

??????????????????????????????? EASModuleRegistrar.EAS_ATTRIBUTE_FONT_FACE};

??????????? Object values[] = {fontColor[0], fontStyle[0], fontFace[0]};

??????????? easmr.setEASAttribute(attributes, values);

 

??????? }

??????? catch (Exception e) {

??????? }

??? }

 

??? /**

???? * Defined in EASHandler.

???? */

??? public boolean notifyPrivateDescriptor(byte[] descriptor) {

??????? // Play audio according to the descriptor.

??????? return(true);

??? }

 

??? /**

???? * Defined in EASHandler.

???? */

??? public void stopAudio() {

??????? //Stop audio that was informed by notifyPrivateDescriptor() method.

??? }

}

 





© 2015 - 2024 Weber Informatics LLC | Privacy Policy