Move showCallScreen & isInAPhoneCall to PhoneManager.

Change-Id: I852da78ae80eba120932fb7acb1e5c3db2a8f18a
This commit is contained in:
Santos Cordon
2014-07-07 14:53:10 -07:00
parent a433fa9c17
commit 0bae09fdde
6 changed files with 56 additions and 49 deletions

View File

@@ -21797,6 +21797,8 @@ package android.phone {
public final class PhoneManager {
method public void cancelMissedCallsNotification();
method public boolean handlePinMmi(java.lang.String);
method public boolean isInAPhoneCall();
method public void showCallScreen(boolean);
}
}

View File

@@ -26,7 +26,6 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -34,8 +33,8 @@ import android.os.SystemClock;
import android.os.UserHandle;
import android.os.storage.IMountService;
import android.os.storage.StorageManager;
import android.phone.PhoneManager;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.IWindowManager;
@@ -1323,19 +1322,11 @@ public class LockPatternUtils {
* to indicate what action will be taken.
*
* If there's currently a call in progress, the button will take them to the call
* @param button the button to update
* @param the phone state:
* {@link TelephonyManager#CALL_STATE_IDLE}
* {@link TelephonyManager#CALL_STATE_RINGING}
* {@link TelephonyManager#CALL_STATE_OFFHOOK}
* @param shown indicates whether the given screen wants the emergency button to show at all
* @param button
* @param phoneState
* @param shown shown if true; hidden if false
* @param upperCase if true, converts button label string to upper case
* @param button The button to update
* @param shown Indicates whether the given screen wants the emergency button to show at all
* @param showIcon Indicates whether to show a phone icon for the button.
*/
public void updateEmergencyCallButtonState(Button button, int phoneState, boolean shown,
boolean showIcon) {
public void updateEmergencyCallButtonState(Button button, boolean shown, boolean showIcon) {
if (isEmergencyCallCapable() && shown) {
button.setVisibility(View.VISIBLE);
} else {
@@ -1344,7 +1335,7 @@ public class LockPatternUtils {
}
int textId;
if (phoneState == TelephonyManager.CALL_STATE_OFFHOOK) {
if (getPhoneManager().isInAPhoneCall()) {
// show "return to call" text and show phone icon
textId = R.string.lockscreen_return_to_call;
int phoneCallIcon = showIcon ? R.drawable.stat_sys_phone_call : 0;
@@ -1362,9 +1353,11 @@ public class LockPatternUtils {
* on various lockscreens.
*/
public void resumeCall() {
TelephonyManager telephonyManager =
(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.showCallScreen();
getPhoneManager().showCallScreen(false);
}
private PhoneManager getPhoneManager() {
return (PhoneManager) mContext.getSystemService(Context.PHONE_SERVICE);
}
private void finishBiometricWeak() {

View File

@@ -128,7 +128,7 @@ public class EmergencyButton extends Button {
enabled = mLockPatternUtils.isSecure();
}
}
mLockPatternUtils.updateEmergencyCallButtonState(this, phoneState, enabled, false);
mLockPatternUtils.updateEmergencyCallButtonState(this, enabled, false);
}
}

View File

@@ -22,7 +22,6 @@ import android.os.ServiceManager;
import android.util.Log;
import com.android.internal.telecomm.ITelecommService;
import com.android.internal.telephony.ITelephony;
/**
* Exposes call-related functionality for use by phone and dialer apps.
@@ -49,15 +48,18 @@ public final class PhoneManager {
/**
* Processes the specified dial string as an MMI code.
* <p>
* Requires that the method-caller be set as the system dialer app.
* </p>
*
* @param dialString The digits to dial.
* @return True if the digits were processed as an MMI code, false otherwise.
*/
public boolean handlePinMmi(String dialString) {
try {
return getITelephony().handlePinMmi(dialString);
return mService.handlePinMmi(dialString);
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#handlePinMmi", e);
Log.e(TAG, "Error calling ITelecommService#handlePinMmi", e);
}
return false;
}
@@ -65,7 +67,7 @@ public final class PhoneManager {
/**
* Removes the missed-call notification if one is present.
* <p>
* Requires that the caller be set at the system dialer app.
* Requires that the method-caller be set as the system dialer app.
* </p>
*/
public void cancelMissedCallsNotification() {
@@ -76,7 +78,36 @@ public final class PhoneManager {
}
}
private ITelephony getITelephony() {
return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
/**
* Brings the in-call screen to the foreground if there is an ongoing call. If there is
* currently no ongoing call, then this method does nothing.
* <p>
* Requires that the method-caller be set as the system dialer app or have the
* {@link android.Manifest.permission#READ_PHONE_STATE} permission.
* </p>
*
* @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen.
*/
public void showCallScreen(boolean showDialpad) {
try {
mService.showCallScreen(showDialpad);
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecommService#showCallScreen", e);
}
}
/**
* Returns whether there is an ongoing phone call.
* <p>
* Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
* </p>
*/
public boolean isInAPhoneCall() {
try {
return mService.isInAPhoneCall();
} catch (RemoteException e) {
Log.e(TAG, "Error caling ITelecommService#isInAPhoneCall", e);
}
return false;
}
}

View File

@@ -85,4 +85,9 @@ interface ITelecommService {
* @see PhoneManager#cancelMissedCallsNotification
*/
void cancelMissedCallsNotification();
/**
* @see PhoneManager#handlePinMmi
*/
boolean handlePinMmi(String dialString);
}

View File

@@ -2888,30 +2888,6 @@ public class TelephonyManager {
}
}
/** @hide */
@SystemApi
public boolean showCallScreen() {
try {
getTelecommService().showCallScreen(false);
return true;
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecommService#showCallScreen", e);
}
return false;
}
/** @hide */
@SystemApi
public boolean showCallScreenWithDialpad(boolean showDialpad) {
try {
getTelecommService().showCallScreen(showDialpad);
return true;
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelecommService#showCallScreen(" + showDialpad + ")", e);
}
return false;
}
/** @hide */
@SystemApi
public boolean endCall() {