Phone State reading

Put your problem here if it does not fit any of the other categories.

Phone State reading

Postby BossOss » Fri Jan 27, 2012 11:49 am

Hey Guys,

I am able to read the following Phone states via intent.getExtras().getString(TelephonyManager.EXTRA_STATE) :

- IDLE
- RINGING
- OFFHOOK

Now i wanted to know if i could somehow check programmatically the Phone state indicating that a call on hold and an active call have been merged. I found the following code in the Android build source:

Code: Select all
/**
     * Returns true if the specified Call is a "conference call", meaning
     * that it owns more than one Connection object.  This information is
     * used to trigger certain UI changes that appear when a conference
     * call is active (like displaying the label "Conference call", and
     * enabling the "Manage conference" UI.)
     *
     * Watch out: This method simply checks the number of Connections,
     * *not* their states.  So if a Call has (for example) one ACTIVE
     * connection and one DISCONNECTED connection, this method will return
     * true (which is unintuitive, since the Call isn't *really* a
     * conference call any more.)
     *
     * @return true if the specified call has more than one connection (in any state.)
     */
    static boolean isConferenceCall(Call call) {
        // CDMA phones don't have the same concept of "conference call" as
        // GSM phones do; there's no special "conference call" state of
        // the UI or a "manage conference" function.  (Instead, when
        // you're in a 3-way call, all we can do is display the "generic"
        // state of the UI.)  So as far as the in-call UI is concerned,
        // Conference corresponds to generic display.
        PhoneApp app = PhoneApp.getInstance();
        int phoneType = app.phone.getPhoneType();
        if (phoneType == Phone.PHONE_TYPE_CDMA) {
            CdmaPhoneCallState.PhoneCallState state = app.cdmaPhoneCallState.getCurrentCallState();
            if ((state == CdmaPhoneCallState.PhoneCallState.CONF_CALL)
                    || ((state == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE)
                    && !app.cdmaPhoneCallState.IsThreeWayCallOrigStateDialing())) {
                return true;
            }
        } else if (phoneType == Phone.PHONE_TYPE_GSM) {
            List<Connection> connections = call.getConnections();
            if (connections != null && connections.size() > 1) {
                return true;
            }
        } else {
            throw new IllegalStateException("Unexpected phone type: " + phoneType);
        }
        return false;

        // TODO: We may still want to change the semantics of this method
        // to say that a given call is only really a conference call if
        // the number of ACTIVE connections, not the total number of
        // connections, is greater than one.  (See warning comment in the
        // javadoc above.)
        // Here's an implementation of that:
        //        if (connections == null) {
        //            return false;
        //        }
        //        int numActiveConnections = 0;
        //        for (Connection conn : connections) {
        //            if (DBG) log("  - CONN: " + conn + ", state = " + conn.getState());
        //            if (conn.getState() == Call.State.ACTIVE) numActiveConnections++;
        //            if (numActiveConnections > 1) {
        //                return true;
        //            }
        //        }
        //        return false;
    }


Has anyone an idea how to access this useful information??

Greetz bossoss
BossOss
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Jan 09, 2012 2:54 pm

Top

Re: Phone State reading

Postby Phyll » Fri Jan 27, 2012 12:58 pm

Hi BossOss,

I think the only way you can get a reference to PhoneUtils is to use reflection. This is how one guy tried to do it as you may know:

Class<?> phoneUtilsClass = Class.forName( "com.android.phone.PhoneUtils" );

He says it used to work and now it doesn't. Apparently these methods can change at any time for just about any reason. But it might work on your particular phone (<v2.3) if you want to try it. When he asked why it no longer worked on stackoverflow he didn't get an answer.

And, I can only repeat this link that seems to sum up the troubles of using hidden api's:

http://code.google.com/p/android/issues/detail?id=15022

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Phone State reading

Postby BossOss » Fri Jan 27, 2012 1:20 pm

Well if this isn't going to work, maybe another possibility is to let the broadcastreceiver check the
interaction of the user on the native call screen, when he presses the
mergecall()-Button while having on active call and on call on hold? Is there a way to check via broadcastreceiver interaction of the current activity?
Why does only Phyll answer my posts? :)

Thanks for replying
BossOss
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Jan 09, 2012 2:54 pm

Re: Phone State reading

Postby Phyll » Fri Jan 27, 2012 2:39 pm

Hi BossOss,

You know how a lot of times, there's somebody who knows the answer? Well, for what you are trying to do, you are going to be that guy. I'm sorry I don't know the answer to this phone answering stuff. Not my concentration but I do usually try to find out if I don't know.

Thanks for your difficult questions.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests