diff --git a/api/current.txt b/api/current.txt index 82a2d8b8fd0b6..77bca42cd0c99 100644 --- a/api/current.txt +++ b/api/current.txt @@ -7353,7 +7353,6 @@ package android.content { field public static final java.lang.String NFC_SERVICE = "nfc"; field public static final java.lang.String NOTIFICATION_SERVICE = "notification"; field public static final java.lang.String NSD_SERVICE = "servicediscovery"; - field public static final java.lang.String PHONE_SERVICE = "phone_service"; field public static final java.lang.String POWER_SERVICE = "power"; field public static final java.lang.String PRINT_SERVICE = "print"; field public static final java.lang.String RESTRICTIONS_SERVICE = "restrictions"; @@ -22768,17 +22767,6 @@ package android.os.storage { } -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); - } - -} - package android.preference { public class CheckBoxPreference extends android.preference.TwoStatePreference { @@ -28758,12 +28746,16 @@ package android.telecomm { public class TelecommManager { method public void addNewIncomingCall(android.telecomm.PhoneAccountHandle, android.os.Bundle); + method public void cancelMissedCallsNotification(); method public void clearAccounts(java.lang.String); method public android.telecomm.PhoneAccountHandle getDefaultOutgoingPhoneAccount(); method public java.util.List getEnabledPhoneAccounts(); method public android.telecomm.PhoneAccount getPhoneAccount(android.telecomm.PhoneAccountHandle); + method public boolean handleMmi(java.lang.String); method public boolean hasMultipleEnabledAccounts(); + method public boolean isInCall(); method public void registerPhoneAccount(android.telecomm.PhoneAccount); + method public void showInCallScreen(boolean); method public void unregisterPhoneAccount(android.telecomm.PhoneAccountHandle); field public static final java.lang.String ACTION_CONNECTION_SERVICE_CONFIGURE = "android.intent.action.CONNECTION_SERVICE_CONFIGURE"; field public static final java.lang.String ACTION_SHOW_CALL_SETTINGS = "android.telecomm.intent.action.SHOW_CALL_SETTINGS"; diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index da343ac2f5dd6..884b04624ca48 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -122,7 +122,6 @@ import android.os.SystemVibrator; import android.os.UserManager; import android.os.storage.IMountService; import android.os.storage.StorageManager; -import android.phone.PhoneManager; import android.print.IPrintManager; import android.print.PrintManager; import android.service.fingerprint.IFingerprintService; @@ -570,11 +569,6 @@ class ContextImpl extends Context { return new TelecommManager(ctx.getOuterContext()); }}); - registerService(PHONE_SERVICE, new ServiceFetcher() { - public Object createService(ContextImpl ctx) { - return new PhoneManager(ctx.getOuterContext()); - }}); - registerService(UI_MODE_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { return new UiModeManager(); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index a13a9288f53f1..ebb1f77ad91e9 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -2203,8 +2203,6 @@ public abstract class Context { * @see android.media.MediaRouter * @see #TELEPHONY_SERVICE * @see android.telephony.TelephonyManager - * @see #PHONE_SERVICE - * @see android.phone.PhoneManager * @see #INPUT_METHOD_SERVICE * @see android.view.inputmethod.InputMethodManager * @see #UI_MODE_SERVICE @@ -2556,16 +2554,6 @@ public abstract class Context { */ public static final String TELECOMM_SERVICE = "telecomm"; - /** - * Use with {@link #getSystemService} to retrieve a - * {@link android.phone.PhoneManager} to manage phone-related features - * of the device. - * - * @see #getSystemService - * @see android.phone.PhoneManager - */ - public static final String PHONE_SERVICE = "phone_service"; // "phone" used by telephony. - /** * Use with {@link #getSystemService} to retrieve a * {@link android.text.ClipboardManager} for accessing and modifying diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index b06edc59c4d7e..71cf39112eb53 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -34,8 +34,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.telecomm.TelecommManager; import android.text.TextUtils; import android.util.Log; import android.view.IWindowManager; @@ -1440,7 +1440,7 @@ public class LockPatternUtils { } int textId; - if (getPhoneManager().isInAPhoneCall()) { + if (getTelecommManager().isInCall()) { // 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; @@ -1458,11 +1458,11 @@ public class LockPatternUtils { * on various lockscreens. */ public void resumeCall() { - getPhoneManager().showCallScreen(false); + getTelecommManager().showInCallScreen(false); } - private PhoneManager getPhoneManager() { - return (PhoneManager) mContext.getSystemService(Context.PHONE_SERVICE); + private TelecommManager getTelecommManager() { + return (TelecommManager) mContext.getSystemService(Context.TELECOMM_SERVICE); } private void finishBiometricWeak() { diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 0af24576012b5..dae539bd647b2 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -2912,13 +2912,13 @@ public class AudioService extends IAudioService.Stub { } private boolean isInCommunication() { - boolean isInAPhoneCall = false; + boolean IsInCall = false; TelecommManager telecommManager = (TelecommManager) mContext.getSystemService(Context.TELECOMM_SERVICE); - isInAPhoneCall = telecommManager.isInAPhoneCall(); + IsInCall = telecommManager.isInCall(); - return (isInAPhoneCall || getMode() == AudioManager.MODE_IN_COMMUNICATION); + return (IsInCall || getMode() == AudioManager.MODE_IN_COMMUNICATION); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index cb2d40a47d2de..c0b171aefafca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -29,7 +29,6 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.RemoteException; import android.os.UserHandle; -import android.phone.PhoneManager; import android.provider.MediaStore; import android.telecomm.TelecommManager; import android.util.AttributeSet; @@ -324,13 +323,12 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } public void launchPhone() { - TelecommManager tm = TelecommManager.from(mContext); - if (tm.isInAPhoneCall()) { - final PhoneManager pm = (PhoneManager) mContext.getSystemService(Context.PHONE_SERVICE); + final TelecommManager tm = TelecommManager.from(mContext); + if (tm.isInCall()) { AsyncTask.execute(new Runnable() { @Override public void run() { - pm.showCallScreen(false /* showDialpad */); + tm.showInCallScreen(false /* showDialpad */); } }); } else { diff --git a/phone/java/android/phone/PhoneManager.java b/phone/java/android/phone/PhoneManager.java deleted file mode 100644 index f61b0544c285d..0000000000000 --- a/phone/java/android/phone/PhoneManager.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.phone; - -import android.content.Context; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.util.Log; - -import com.android.internal.telecomm.ITelecommService; - -/** - * Exposes call-related functionality for use by phone and dialer apps. - */ -public final class PhoneManager { - private static final String TAG = PhoneManager.class.getSimpleName(); - - private final Context mContext; - - /** - * @hide - */ - public PhoneManager(Context context) { - Context appContext = context.getApplicationContext(); - if (appContext != null) { - mContext = appContext; - } else { - mContext = context; - } - } - - /** - * Processes the specified dial string as an MMI code. - *

- * Requires that the method-caller be set as the system dialer app. - *

- * - * @param dialString The digits to dial. - * @return True if the digits were processed as an MMI code, false otherwise. - */ - public boolean handlePinMmi(String dialString) { - ITelecommService service = getTelecommService(); - if (service != null) { - try { - return service.handlePinMmi(dialString); - } catch (RemoteException e) { - Log.e(TAG, "Error calling ITelecommService#handlePinMmi", e); - } - } - return false; - } - - /** - * Removes the missed-call notification if one is present. - *

- * Requires that the method-caller be set as the system dialer app. - *

- */ - public void cancelMissedCallsNotification() { - ITelecommService service = getTelecommService(); - if (service != null) { - try { - service.cancelMissedCallsNotification(); - } catch (RemoteException e) { - Log.e(TAG, "Error calling ITelecommService#cancelMissedCallsNotification", e); - } - } - } - - /** - * 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. - *

- * Requires that the method-caller be set as the system dialer app or have the - * {@link android.Manifest.permission#READ_PHONE_STATE} permission. - *

- * - * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen. - */ - public void showCallScreen(boolean showDialpad) { - ITelecommService service = getTelecommService(); - if (service != null) { - try { - service.showCallScreen(showDialpad); - } catch (RemoteException e) { - Log.e(TAG, "Error calling ITelecommService#showCallScreen", e); - } - } - } - - /** - * Returns whether there is an ongoing phone call. - *

- * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} - *

- */ - public boolean isInAPhoneCall() { - ITelecommService service = getTelecommService(); - if (service != null) { - try { - return service.isInAPhoneCall(); - } catch (RemoteException e) { - Log.e(TAG, "Error caling ITelecommService#isInAPhoneCall", e); - } - } - return false; - } - - private ITelecommService getTelecommService() { - return ITelecommService.Stub.asInterface( - ServiceManager.getService(Context.TELECOMM_SERVICE)); - } -} diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index c10d929bfcf24..c57563b2809cb 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -4274,7 +4274,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { result &= ~ACTION_PASS_TO_USER; break; } - if (telecommManager.isInAPhoneCall() + if (telecommManager.isInCall() && (result & ACTION_PASS_TO_USER) == 0) { // If we are in call but we decided not to pass the key to // the application, just pass it to the session service. @@ -4349,7 +4349,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { telecommManager.silenceRinger(); } else if ((mIncallPowerBehavior & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 - && telecommManager.isInAPhoneCall() && interactive) { + && telecommManager.isInCall() && interactive) { // Otherwise, if "Power button ends call" is enabled, // the Power button will hang up any current active call. hungUp = telecommManager.endCall(); @@ -4392,7 +4392,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (down) { TelecommManager telecommManager = getTelecommService(); if (telecommManager != null) { - if (telecommManager.isInAPhoneCall()) { + if (telecommManager.isInCall()) { // Suppress PLAY/PAUSE toggle when phone is ringing or in-call // to avoid music playback. break; diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java index e59fea16e660f..178a25fc7f8cc 100644 --- a/telecomm/java/android/telecomm/TelecommManager.java +++ b/telecomm/java/android/telecomm/TelecommManager.java @@ -17,7 +17,6 @@ package android.telecomm; import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; - import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; @@ -394,14 +393,15 @@ public class TelecommManager { /** * Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding * states). - * - * @hide + *

+ * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE} + *

*/ @SystemApi - public boolean isInAPhoneCall() { + public boolean isInCall() { try { if (isServiceConnected()) { - return getTelecommService().isInAPhoneCall(); + return getTelecommService().isInCall(); } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get default phone app.", e); @@ -541,6 +541,67 @@ public class TelecommManager { } } + /** + * Processes the specified dial string as an MMI code. + * MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". + * Some of these sequences launch special behavior through handled by Telephony. + *

+ * Requires that the method-caller be set as the system dialer app. + *

+ * + * @param dialString The digits to dial. + * @return True if the digits were processed as an MMI code, false otherwise. + */ + public boolean handleMmi(String dialString) { + ITelecommService service = getTelecommService(); + if (service != null) { + try { + return service.handlePinMmi(dialString); + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#handlePinMmi", e); + } + } + return false; + } + + /** + * Removes the missed-call notification if one is present. + *

+ * Requires that the method-caller be set as the system dialer app. + *

+ */ + public void cancelMissedCallsNotification() { + ITelecommService service = getTelecommService(); + if (service != null) { + try { + service.cancelMissedCallsNotification(); + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#cancelMissedCallsNotification", e); + } + } + } + + /** + * 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. + *

+ * Requires that the method-caller be set as the system dialer app or have the + * {@link android.Manifest.permission#READ_PHONE_STATE} permission. + *

+ * + * @param showDialpad Brings up the in-call dialpad as part of showing the in-call screen. + */ + public void showInCallScreen(boolean showDialpad) { + ITelecommService service = getTelecommService(); + if (service != null) { + try { + service.showInCallScreen(showDialpad); + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#showCallScreen", e); + } + } + } + private ITelecommService getTelecommService() { return ITelecommService.Stub.asInterface(ServiceManager.getService(TELECOMM_SERVICE_NAME)); } diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl index 3c1dea6cadfe7..0ac50786c3b6f 100644 --- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl @@ -32,7 +32,7 @@ interface ITelecommService { * * @param showDialpad if true, make the dialpad visible initially. */ - void showCallScreen(boolean showDialpad); + void showInCallScreen(boolean showDialpad); /** * @see TelecommManager#getDefaultOutgoingPhoneAccount @@ -79,9 +79,9 @@ interface ITelecommService { void silenceRinger(); /** - * @see TelecommManager#isInAPhoneCall + * @see TelecommManager#isInCall */ - boolean isInAPhoneCall(); + boolean isInCall(); /** * @see TelecomManager#isRinging @@ -99,12 +99,12 @@ interface ITelecommService { void acceptRingingCall(); /** - * @see PhoneManager#cancelMissedCallsNotification + * @see TelecommManager#cancelMissedCallsNotification */ void cancelMissedCallsNotification(); /** - * @see PhoneManager#handlePinMmi + * @see TelecommManager#handleMmi */ boolean handlePinMmi(String dialString);