« Back to Cius Developer Questions

Cisco Telephony API - device.getDeviceInfo() throwing RT exception?

Combination View Flat View Tree View
Threads [ Previous | Next ]
Cisco Telephony API - device.getDeviceInfo() throwing RT exception?
ciscotelephonymanager getdeviceinfo exception samplephoneapplication
Answer
1/14/12 12:45 AM
Hi all,
 
I'm using the SamplePhoneApplication project in order to test out getting CiscoTelephonyManagerDeviceInfo from the CiscoTelephonyManager.
 
To test it out, I added the following code into the "SamplePhoneApplication" project, in "SamplePhoneApplication.java" file; first in onCreate(), then in handleMessage(), then lastly in onCallEvent():
 
----------
CiscoTelephonyManager.CiscoTelephonyManagerDevice      myDevice = ctm.getCiscoTelephonyManagerDevice();
if (myDevice != null)
{
   Log.d(LOG_TAG, "Got the device");
   try
   {
       CiscoTelephonyManager.CiscoTelephonyManagerDeviceInfo  myDeviceInfo = myDevice.getDeviceInfo();
       Log.d(LOG_TAG, "Got the device info");
   }
   catch (CiscoTelephonyManager.CiscoTelephonyManagerDevice.CiscoTelephonyManagerDeviceInvalidObject e)
   {
       Log.d(LOG_TAG, "ERROR : CiscoTelephonyManagerDeviceInvalidObject");
   }
}
else
{
   Log.d(LOG_TAG, "ERROR : getCiscoTelephonyManagerDevice() returned null");
}
----------
 
 
In all cases, the program gets a RuntimeException in the Android Binder.class, in a private function called "boolean execTransact(int code, int dataObj, int replyObj)".
 
The sample app runs fine when my new code isn't included.  What am I doing wrong here?  Are there certain times/contexts when it is not safe to call getDeviceInfo()?


Thanks for any help!


  - Greg Marquez

We are looking into this issue.Can you perhaps give me the entire file with this code in it.

Greg,

I'm pretty sure that you have already found a solution to your problem but for those that are waiting for an answer here is the modified service from the sample. With this you can do what he is attempting to do.

  1package com.cisco.sample.phoneapplication;
  2
  3import com.cisco.telephony.CallEventID;
  4import com.cisco.telephony.CiscoTelephonyManager;
  5import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerBindFailed;
  6import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerDevice.CiscoTelephonyManagerDeviceInvalidObject;
  7import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerDeviceInfo;
  8import com.cisco.telephony.ICCDevice;
  9import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerCall;
 10import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerCallInfo;
 11import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerCallListener;
 12import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerDevice;
 13import com.cisco.telephony.CiscoTelephonyManager.CiscoTelephonyManagerCallInfo.CiscoTelephonyManagerCallInfoInvalidObject;
 14
 15import android.app.Service;
 16import android.content.Intent;
 17import android.os.Handler;
 18import android.os.IBinder;
 19import android.os.Message;
 20import android.util.Log;
 21
 22public class SamplePhoneApplicationService extends Service {
 23
 24    private String LOG_TAG = "SamplePhoneApplicationService";
 25   
 26        ICCDevice ccDeviceService;
 27    private CiscoTelephonyManager ctm = null;
 28    private CiscoTelephonyManagerDevice device = null;
 29    private CiscoTelephonyManagerCallListener callListener = null;
 30   
 31    @Override
 32    public void onCreate() {
 33        super.onCreate();
 34       
 35        try {
 36            ctm = new CiscoTelephonyManager(this, mHandler);
 37        } catch (CiscoTelephonyManagerBindFailed e1) {
 38            e1.printStackTrace();
 39        }
 40       
 41       
 42        callListener = ctm.new CiscoTelephonyManagerCallListener() {
 43
 44            @Override
 45            public void onCallEvent(CallEventID evID, CiscoTelephonyManagerCall ctmCall, CiscoTelephonyManagerCallInfo ctmCallInfo) {
 46                CiscoTelephonyManagerDevice myDevice = ctm.getCiscoTelephonyManagerDevice();
 47                if (myDevice != null)
 48                {
 49                   Log.d(LOG_TAG, "Got the device");
 50                   try
 51                   {
 52                       CiscoTelephonyManagerDeviceInfo myDeviceInfo = myDevice.getDeviceInfo();
 53                       Log.d(LOG_TAG, "Got the device info");
 54                   }
 55                   catch (Exception e)
 56                   {
 57                       e.printStackTrace();
 58                   }
 59                }
 60                else
 61                {
 62                   Log.d(LOG_TAG, "ERROR : getCiscoTelephonyManagerDevice() returned null");
 63                }       
 64            }   
 65        };   
 66    }
 67   
 68    private Handler mHandler = new Handler() {
 69
 70        @Override
 71        public void handleMessage(Message msg) {
 72            super.handleMessage(msg);
 73            switch(msg.what) {
 74            case CiscoTelephonyManager.CONNECTED:
 75                device = ctm.getCiscoTelephonyManagerDevice();
 76                try {
 77                    device.addCallListener(callListener);
 78                } catch (CiscoTelephonyManagerDeviceInvalidObject e) {
 79                    e.printStackTrace();
 80                }
 81                break;
 82            case CiscoTelephonyManager.DISCONNECTED:
 83               
 84                break;
 85            }
 86        }
 87       
 88    };
 89   
 90    @Override
 91    public IBinder onBind(Intent arg0) {
 92        // No one will bind to this service, therefore leave this null
 93        return null;
 94    }
 95
 96    @Override
 97    public int onStartCommand(Intent intent, int flags, int startId) {
 98        return START_STICKY;
 99    }
100
101    @Override
102    public void onDestroy() {
103        super.onDestroy();
104    }
105   
106   
107}


In addition to changing the SamplePhoneApplicationService.java. You need to add the following line with the other permissions in your AndroidManifest.xml file.

1<uses-permission android:name="cisco.telephony.permission.DEVICE_INFO_PERMISSION"></uses-permission>


Hope this helps!