tags:

views:

312

answers:

2

Hi,

I'm newbie in Android.

I'm programing Instrumentation Tests for SIM ToolKit (STK)

I need to use CommandsInterface which is available only in PhoneBase Interface. Once I have a Phone i'd like to use the following line:

private Phone   mPhone;
private Context    mContext;
private Handler    mHandler;
private CommandsInterface            mCmdIf;
private PhoneBase    mPhoneBase;

mPhoneBase = ((PhoneBase)mPhone);  <==== uncaught exception 
mCmdIf = mPhoneBase.mCM;

It compiled successfully, however gives uncaught exception (group=0x4001b188) Please advice how to overcome this issue. Thanks In Advance Micha

+1  A: 

You can't use PhoneBase directly because it's an internal in android and not visible in the SDK. You can check your exception msg using logcat.

From the source code:

/**
 * (<em>Not for SDK use</em>) 
 * A base implementation for the com.android.internal.telephony.Phone interface.
 * 
 * Note that implementations of Phone.java are expected to be used
 * from a single application thread. This should be the same thread that
 * originally called PhoneFactory to obtain the interface.
 *
 *  {@hide}
 *
 */

I don't know what mCM is, but I guess you can get that information from TelephonyManager. You can get it doing

Context.getSystemService(Context.TELEPHONY_SERVICE);
Macarse
Thanks Macarse for your replay.I didn't find any way to use TelephonyManager context in order to get the required CommandsInterface.Does it mean it is private for PhoneApp only?
Micha Valach
What I tried to explain is that the CommandsInterface is not available in the SDK. I guess you want that to get info from the phone, then you should get it from the TelephonyManager.
Macarse
Macarse, Thanks a Lot.
Micha Valach
+1  A: 

Hi Macarse,

Unfortunately, I found that TelephonyManager doesn't expose many "Internal" APIs, which are "required" for my Phone tests - please advice how to proceed?

Basic example is also my first line in my test at setup() routine which is:

mPhone = PhoneFactory.getDefaultPhone(); it runs OK - however if I later use the following lines:

mTelMgr = (TelephonyManager)getInstrumentation().getContext(). getSystemService(Context.TELEPHONY_SERVICE); int simState = mTelMgr.getSimState();

The simState gives the correct state answer only after the SIM is in ReadyState

My Questions: 1) How can I verify if specific class or package is private for PhoneApp? 2) what is the TelephonyManager replacement (if any) to PhoneFactory.getDefaultPhone() ?

Thanks In Advance, Micha

Micha Valach