Hello all,
I am developing application for Motorola iDEN phones. I have problem running the application implementing SDG Call (Selective Dynamic Group Call) (meant for Motorola iDEN device like i355). I am following the code given in iDEN
Java Developer Guide. My application is meant to make an SDG Call and receive it too. I have implemented Calling part and but when there is an incoming SDG Call (from another device with same application), my application does not receive such calls instead goes in background and SDGC alert comes in foreground. While, I want my application to handle the call the way I have coded. I have also added the jad attribute "iDEN-MIDlet-Phone" but still my application is not receiving the call. Do I need to get my MIDlet signed? How can I
test the SDGC Call Receiving feature on simulator and device?
Below is my source code for the device Motorola i605.
I have been looking for the solution for quite a long time and am clueless where I am missing. Please help!
Thanks!
/*
* Sdgc.java
*
* Created on July 20, 2009, 11:34 AM
*/
import com.motorola.iden.call.*;
import java.io.PrintStream;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.motorola.iden.lcdui.ExternalDisplay;
import com.motorola.iden.lcdui.ExternalDisplayCanvas;
import com.mot.iden.multimedia.Lighting;
/**
*
* @author swati
* @version
*/
public class Sdgc extends MIDlet implements CommandListener {
class extCanvas extends ExternalDisplayCanvas {
protected void paint(Graphics g) {
String displayStr;
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0);
Graphics _tmp = g;
Graphics _tmp1 = g;
if(callAlias != null) {
displayStr = callAlias + " active";
}else {
displayStr = "";
}
g.drawString(displayStr, 0, 0, 0x10 | 0x4);
}
protected void showNotify() {
System.out.println("external show notify");
try {
(new
Thread(new LightThread())).start();
repaint();
System.out.println("external show notify");
} catch(Exception exception) {
System.out.println("PROBLEM - 1 ");
exception.printStackTrace();
}
}
public extCanvas() {
}
}
class LightThread extends Thread {
public void run() {
System.out.println("inside run of lightening..!! ");
Lighting.javaOverRideLighting(true);
do
try {
Lighting.setLighting(4, 2);
Thread.currentThread();
Thread.sleep(250L);
Lighting.setLighting(4, 7);
Thread.currentThread();
Thread.sleep(250L);
Lighting.setLighting(4, 4);
Thread.currentThread();
Thread.sleep(250L);
} catch(Exception exception) {
System.out.println("PROBLEM - 2 ");
exception.printStackTrace();
}
while(true);
}
public LightThread() {
}
}
class CallThread extends Thread implements CallListener {
public void run() {
System.out.println("inside run of CallThread ");
try {
handle.startCallListener();
} catch(Exception exception) {
System.out.println("PROBLEM - 3 ");
exception.printStackTrace();
}
}
public void callActionListener(int i, int j) {
System.out.println("callActionListener method invoked.!! ");
System.out.println(" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ALIAS : " + sdgc.getSdgcCallAlias() );
if(j == CallHandler.SDGC_END_CALL_EVENT) {
siCallingNumber.setText("sdgc ended, the error is" +
sdgc.getSdgcSystemError());
//ed.requestDisplay();
//myDisplay.setCurrent(mainForm);
callAlias = null;
}
if(j == CallHandler.SDGC_CALL_START_EVENT ) {
siCallingNumber.setText("sdgc orginate from" +
sdgc.getSdgcOriginatorID() + " now wait");
System.out.println("============ ALIAS : " + sdgc.getSdgcCallAlias() );
myDisplay.setCurrent(fmAnswer);
callAlias = sdgc.getSdgcCallAlias();
}
if(j == CallHandler.SDGC_LISTEN_PERMIT_EVENT) {
siCallingNumber.setText("sdgc listen now");
callAlias = sdgc.getSdgcCallAlias();
}
if(j == CallHandler.SDGC_TALK_PERMIT_EVENT) {
siCallingNumber.setText("sdgc talk");
callAlias = sdgc.getSdgcCallAlias();
}
if(j == CallHandler.SDGC_TALK_INHIBIT_EVENT ) {
siCallingNumber.setText("talk over, come back to wait");
}
if(j == CallHandler.SDGC_LISTEN_INHIBIT_EVENT ) {
siCallingNumber.setText("talk over, come back to wait");
}
if(j == CallHandler.SDGC_SYSTEM_TERMINATED_EVENT ) {
siCallingNumber.setText("sdgc terminate");
callAlias = null;
myDisplay.setCurrent(mainForm);
isEnd = true;
}
}
public CallThread() {
System.out.println("inside constructor of CallThread ");
isThreadRun = true;
try {
//call = (InterconnectCall)CallHandler.getInstance(1, this);
sdgc = (SdgcCall)CallHandler.getInstance(3, this);
} catch(Exception exception) {
System.out.println("PROBLEM - 4 ");
exception.printStackTrace();
isThreadRun = false;
}
}
}
//private static boolean debug = true;
ExternalDisplay ed;
extCanvas exCan;
Form fmAnswer;
StringItem siCallingNumber;
CallHandler handle;
Command pttpressCommand;
Command pttreleaseCommand;
Command endCommand;
SdgcCall sdgc;
public boolean isThreadRun;
private Display myDisplay;
private Form mainForm;
TextField pid1;
TextField pid2;
TextField pid3;
TextField alias;
private TextBox exceptionTextBox;
private Command callCommand;
private Command exitCommand;
private String[] prvIDList;
private String callAlias;
private boolean isEnd;
public Sdgc() {
System.out.println("inside constructor of Sdgc ");
isEnd = true;
isThreadRun = false;
handle = new CallHandler();
exCan = new extCanvas();
myDisplay = Display.getDisplay(this);
pttpressCommand = new Command("PRESS", 1, 1);
pttreleaseCommand = new Command("RELEASE", 1, 2);
endCommand = new Command("End",1,2);
fmAnswer = new Form("Call Me");
siCallingNumber = new StringItem("SDGC", "");
fmAnswer.addCommand(pttpressCommand);
fmAnswer.addCommand(endCommand);
fmAnswer.append(siCallingNumber);
fmAnswer.setCommandListener(this);
mainForm = new Form("SDGC");
callCommand = null;
exitCommand = null;
callAlias = null;
pid1 = new TextField("privateID1", "50002", 15, TextField.ANY);
pid2 = new TextField("privateID2", "50003", 15, TextField.ANY);
pid3 = new TextField("privateID3", "50004", 15, TextField.ANY);
alias = new TextField("sdgc alias", "pnestec", 15, TextField.ANY);
exceptionTextBox = new TextBox("Exception Caught!", "", 100, 0);
mainForm.append(pid1);
mainForm.append(pid2);
mainForm.append(pid3);
mainForm.append(alias);
callCommand = new Command("CALL", 1, 2);
exitCommand = new Command("EXIT", 1, 2);
mainForm.addCommand(callCommand);
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
myDisplay.setCurrent(mainForm);
}
public void startApp() throws MIDletStateChangeException {
System.out.println("inside startApp.!! ");
ed = ExternalDisplay.getDisplay(this);
ed.setCurrent(exCan);
if(!isThreadRun)
(new Thread(new CallThread())).start();
}
public void pauseApp() {
if(ed.getFlipState()) {
ed.requestDisplay();
}
}
public void destroyApp(boolean flag) {
}
public void commandAction(Command command, Displayable displayable) {
System.out.println("commandAction method..!! ");
if(command == callCommand) {
System.out.println("call command..! ");
prvIDList = new String[2];
try {
prvIDList[0] = pid1.getString();
prvIDList[1] = pid2.getString();
//prvIDList[2] = pid3.getString();
callAlias = alias.getString();
System.out.println("before making the call ");
int i = GenericCall.makeCall(3, callAlias, prvIDList);
System.out.println("after making the call ");
if(i == 0) {
System.out.println("GenericCall.CALL_RESPONSE_OK");
myDisplay.setCurrent(fmAnswer);
}else {
if(i == 1)
System.out.println("GenericCall.CALL_RESPONSE_FAILURE");
else
if(i == 2)
System.out.println("GenericCall.CALL_RESPONSE_ERROR");
else
if(i == -1)
System.out.println("GenericCall.CALL_UNKNOWN_ERROR");
}
} catch(Exception ex) {
System.out.println("PROBLEM - 5 ");
ex.printStackTrace();
myDisplay.setCurrent(exceptionTextBox);
exceptionTextBox.setString(ex.toString());
}
} else {
if(command == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
if(command == pttpressCommand) {
System.out.println("pttpressCommand..>!! ");
try {
sdgc.sdgcAction(SdgcCall.PTT_PRESS);
}catch(Exception exception) {
System.out.println("PROBLEM - 6 ");
exception.printStackTrace();
notifyDestroyed();
}
System.out.println("after setting ptt action PTT_PRESS ");
fmAnswer.removeCommand(pttpressCommand);
if(isEnd) {
fmAnswer.removeCommand(endCommand);
}else {
fmAnswer.removeCommand(exitCommand);
}
fmAnswer.addCommand(pttreleaseCommand);
if(isEnd) {
fmAnswer.addCommand(endCommand);
}else {
fmAnswer.addCommand(exitCommand);
}
}
if(command == pttreleaseCommand) {
System.out.println("pttreleaseCommand...!! ");
try {
sdgc.sdgcAction(SdgcCall.PTT_RELEASE);
}catch(Exception exception) {
System.out.println("PROBLEM - 7 ");
exception.printStackTrace();
notifyDestroyed();
}
System.out.println("after setting sdgc action as PTT_RELEASE ");
fmAnswer.removeCommand(pttreleaseCommand);
if(isEnd) {
fmAnswer.addCommand(endCommand);
}else {
fmAnswer.removeCommand(exitCommand);
}
fmAnswer.addCommand(pttpressCommand);
if(isEnd) {
fmAnswer.addCommand(endCommand);
}else {
fmAnswer.addCommand(exitCommand);
}
}
if(command == endCommand) {
System.out.println("endCommand..>!! ");
try {
sdgc.sdgcAction(SdgcCall.END_CALL);
}catch(Exception exception) {
System.out.println("PROBLEM - 8 ");
exception.printStackTrace();
notifyDestroyed();
}
System.out.println("after setting sdgc END_CALL");
isEnd = false;
fmAnswer.removeCommand(endCommand);
fmAnswer.addCommand(exitCommand);
}
}
}