Methods Summary |
---|
public void | answerRingingCall()
if (DBG) log("answerRingingCall...");
// TODO: there should eventually be a separate "ANSWER_PHONE" permission,
// but that can probably wait till the big TelephonyManager API overhaul.
// For now, protect this call with the MODIFY_PHONE_STATE permission.
enforceModifyPermission();
sendRequestAsync(CMD_ANSWER_RINGING_CALL);
|
private void | answerRingingCallInternal()Make the actual telephony calls to implement answerRingingCall().
This should only be called from the main thread of the Phone app.
final boolean hasRingingCall = !mPhone.getRingingCall().isIdle();
if (hasRingingCall) {
final boolean hasActiveCall = !mPhone.getForegroundCall().isIdle();
final boolean hasHoldingCall = !mPhone.getBackgroundCall().isIdle();
if (hasActiveCall && hasHoldingCall) {
// Both lines are in use!
// TODO: provide a flag to let the caller specify what
// policy to use if both lines are in use. (The current
// behavior is hardwired to "answer incoming, end ongoing",
// which is how the CALL button is specced to behave.)
PhoneUtils.answerAndEndActive(mPhone);
return;
} else {
// answerCall() will automatically hold the current active
// call, if there is one.
PhoneUtils.answerCall(mPhone);
return;
}
} else {
// No call was ringing.
return;
}
|
public void | call(java.lang.String number)
if (DBG) log("call: " + number);
// This is just a wrapper around the ACTION_CALL intent, but we still
// need to do a permission check since we're calling startActivity()
// from the context of the phone app.
enforceCallPermission();
String url = createTelUrl(number);
if (url == null) {
return;
}
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClassName(mApp, PhoneApp.getCallScreenClassName());
mApp.startActivity(intent);
|
public void | cancelMissedCallsNotification()
enforceModifyPermission();
NotificationMgr.getDefault().cancelMissedCallNotification();
|
private java.lang.String | createTelUrl(java.lang.String number)
if (TextUtils.isEmpty(number)) {
return null;
}
StringBuilder buf = new StringBuilder("tel:");
buf.append(number);
return buf.toString();
|
public void | dial(java.lang.String number)
if (DBG) log("dial: " + number);
// No permission check needed here: This is just a wrapper around the
// ACTION_DIAL intent, which is available to any app since it puts up
// the UI before it does anything.
String url = createTelUrl(number);
if (url == null) {
return;
}
// PENDING: should we just silently fail if phone is offhook or ringing?
Phone.State state = mPhone.getState();
if (state != Phone.State.OFFHOOK && state != Phone.State.RINGING) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mApp.startActivity(intent);
}
|
public int | disableApnType(java.lang.String type)
enforceModifyPermission();
return mPhone.disableApnType(type);
|
public boolean | disableDataConnectivity()
enforceModifyPermission();
return mPhone.disableDataConnectivity();
|
public void | disableLocationUpdates()
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
mPhone.disableLocationUpdates();
|
public int | enableApnType(java.lang.String type)
enforceModifyPermission();
return mPhone.enableApnType(type);
|
public boolean | enableDataConnectivity()
enforceModifyPermission();
return mPhone.enableDataConnectivity();
|
public void | enableLocationUpdates()
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
mPhone.enableLocationUpdates();
|
public boolean | endCall()
enforceCallPermission();
boolean hungUp = PhoneUtils.hangup(mPhone);
if (DBG) log("endCall: " + (hungUp ? "hung up!" : "no call to hang up"));
return hungUp;
|
private void | enforceCallPermission()Make sure the caller has the CALL_PHONE permission.
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.CALL_PHONE, null);
|
private void | enforceModifyPermission()Make sure the caller has the MODIFY_PHONE_STATE permission.
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE, null);
|
private void | enforceReadPermission()Make sure the caller has the READ_PHONE_STATE permission.
mApp.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE, null);
|
public int | getCallState()
return DefaultPhoneNotifier.convertCallState(mPhone.getState());
|
public android.os.Bundle | getCellLocation()
try {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_FINE_LOCATION, null);
} catch (SecurityException e) {
// If we have ACCESS_FINE_LOCATION permission, skip the check for ACCESS_COARSE_LOCATION
// A failure should throw the SecurityException from ACCESS_COARSE_LOCATION since this
// is the weaker precondition
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
}
Bundle data = new Bundle();
mPhone.getCellLocation().fillInNotifierBundle(data);
return data;
|
public int | getDataActivity()
return DefaultPhoneNotifier.convertDataActivityState(mPhone.getDataActivityState());
|
public int | getDataState()
return DefaultPhoneNotifier.convertDataState(mPhone.getDataConnectionState());
|
public java.util.List | getNeighboringCellInfo()
try {
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_FINE_LOCATION, null);
} catch (SecurityException e) {
// If we have ACCESS_FINE_LOCATION permission, skip the check
// for ACCESS_COARSE_LOCATION
// A failure should throw the SecurityException from
// ACCESS_COARSE_LOCATION since this is the weaker precondition
mApp.enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
}
ArrayList<NeighboringCellInfo> cells = null;
try {
cells = (ArrayList<NeighboringCellInfo>) sendRequest(
CMD_HANDLE_NEIGHBORING_CELL, null);
} catch (RuntimeException e) {
}
return (List <NeighboringCellInfo>) cells;
|
public boolean | handlePinMmi(java.lang.String dialString)
enforceModifyPermission();
return (Boolean) sendRequest(CMD_HANDLE_PIN_MMI, dialString);
|
public boolean | isDataConnectivityPossible()
return mPhone.isDataConnectivityPossible();
|
public boolean | isIdle()
return (mPhone.getState() == Phone.State.IDLE);
|
public boolean | isOffhook()
return (mPhone.getState() == Phone.State.OFFHOOK);
|
public boolean | isRadioOn()
return mPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
|
public boolean | isRinging()
return (mPhone.getState() == Phone.State.RINGING);
|
public boolean | isSimPinEnabled()
enforceReadPermission();
return (PhoneApp.getInstance().isSimPinEnabled());
|
private void | log(java.lang.String msg)
Log.d(LOG_TAG, "[PhoneIntfMgr] " + msg);
|
private void | publish()
if (DBG) log("publish: " + this);
ServiceManager.addService("phone", this);
|
private java.lang.Object | sendRequest(int command, java.lang.Object argument)Posts the specified command to be executed on the main thread,
waits for the request to complete, and returns the result.
if (Looper.myLooper() == mMainThreadHandler.getLooper()) {
throw new RuntimeException("This method will deadlock if called from the main thread.");
}
MainThreadRequest request = new MainThreadRequest(argument);
Message msg = mMainThreadHandler.obtainMessage(command, request);
msg.sendToTarget();
// Wait for the request to complete
synchronized (request) {
while (request.result == null) {
try {
request.wait();
} catch (InterruptedException e) {
// Do nothing, go back and wait until the request is complete
}
}
}
return request.result;
|
private void | sendRequestAsync(int command)Asynchronous ("fire and forget") version of sendRequest():
Posts the specified command to be executed on the main thread, and
returns immediately.
mMainThreadHandler.sendEmptyMessage(command);
|
public boolean | setRadio(boolean turnOn)
enforceModifyPermission();
if ((mPhone.getServiceState().getState() != ServiceState.STATE_POWER_OFF) != turnOn) {
toggleRadioOnOff();
}
return true;
|
public boolean | showCallScreen()
return showCallScreenInternal(false, false);
|
private boolean | showCallScreenInternal(boolean specifyInitialDialpadState, boolean initialDialpadState)
if (isIdle()) {
return false;
}
// If the phone isn't idle then go to the in-call screen
long callingId = Binder.clearCallingIdentity();
try {
Intent intent;
if (specifyInitialDialpadState) {
intent = PhoneApp.createInCallIntent(initialDialpadState);
} else {
intent = PhoneApp.createInCallIntent();
}
mApp.startActivity(intent);
} finally {
Binder.restoreCallingIdentity(callingId);
}
return true;
|
public boolean | showCallScreenWithDialpad(boolean showDialpad)
return showCallScreenInternal(true, showDialpad);
|
public void | silenceRinger()
if (DBG) log("silenceRinger...");
// TODO: find a more appropriate permission to check here.
// (That can probably wait till the big TelephonyManager API overhaul.
// For now, protect this call with the MODIFY_PHONE_STATE permission.)
enforceModifyPermission();
sendRequestAsync(CMD_SILENCE_RINGER);
|
private void | silenceRingerInternal()Internal implemenation of silenceRinger().
This should only be called from the main thread of the Phone app.
if ((mPhone.getState() == Phone.State.RINGING)
&& mApp.notifier.isRinging()) {
// Ringer is actually playing, so silence it.
if (DBG) log("silenceRingerInternal: silencing...");
PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_IDLE);
mApp.notifier.silenceRinger();
}
|
public boolean | supplyPin(java.lang.String pin)
enforceModifyPermission();
final CheckSimPin checkSimPin = new CheckSimPin(mPhone.getSimCard());
checkSimPin.start();
return checkSimPin.checkPin(pin);
|
public void | toggleRadioOnOff()
enforceModifyPermission();
mPhone.setRadioPower(!isRadioOn());
|
public void | updateServiceLocation()
// No permission check needed here: this call is harmless, and it's
// needed for the ServiceState.requestStateUpdate() call (which is
// already intentionally exposed to 3rd parties.)
mPhone.updateServiceLocation(null);
|