Pipe TelephonyManager.getCallState through TelecommManager

* Add TelecommManager.getCallState (hidden API)
* Make TelephonyManager.getCallState call through to
TelecommManager, to be consistent with
TelephonyManager.ACTION_PHONE_STATE_CHANGED broadcasts for
overall call state. Telephony continues to manage call states for
individual subscriptions.

Bug: 17378767
Change-Id: Ia5e8b21df801ed3af4f6e14c110a72c92f077f88
This commit is contained in:
Yorke Lee
2014-09-12 17:58:48 -07:00
parent c68f27625b
commit 2ae312e306
3 changed files with 38 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.internal.telecom.ITelecomService;
@@ -661,11 +662,35 @@ public class TelecomManager {
return getTelecomService().isInCall();
}
} catch (RemoteException e) {
Log.e(TAG, "RemoteException attempting to get default phone app.", e);
Log.e(TAG, "RemoteException calling isInCall().", e);
}
return false;
}
/**
* Returns one of the following constants that represents the current state of Telecom:
*
* {@link TelephonyManager#CALL_STATE_RINGING}
* {@link TelephonyManager#CALL_STATE_OFFHOOK}
* {@link TelephonyManager#CALL_STATE_IDLE}
*
* <p>
* Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
* </p>
* @hide
*/
@SystemApi
public int getCallState() {
try {
if (isServiceConnected()) {
return getTelecomService().getCallState();
}
} catch (RemoteException e) {
Log.d(TAG, "RemoteException calling getCallState().", e);
}
return TelephonyManager.CALL_STATE_IDLE;
}
/**
* Returns whether there currently exists is a ringing incoming-call.
*