Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,7 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl \ telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \ telecomm/java/com/android/internal/telecomm/IInCallService.aidl \ telecomm/java/com/android/internal/telecomm/ITelecommService.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +65 −89 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.os.Vibrator; import android.provider.Settings; import android.service.dreams.DreamService; import android.service.dreams.IDreamManager; import android.telephony.TelephonyManager; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; Loading Loading @@ -1921,9 +1922,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { ServiceManager.checkService(DreamService.DREAM_SERVICE)); } static ITelephony getTelephonyService() { return ITelephony.Stub.asInterface( ServiceManager.checkService(Context.TELEPHONY_SERVICE)); TelephonyManager getTelephonyService() { return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); } static IAudioService getAudioService() { Loading Loading @@ -2006,15 +2006,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { // If an incoming call is ringing, HOME is totally disabled. // (The user is already on the InCallScreen at this point, // and his ONLY options are to answer or reject the call.) try { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null && telephonyService.isRinging()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null && telephonyManager.isRinging()) { Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); return -1; } } catch (RemoteException ex) { Log.w(TAG, "RemoteException from getPhoneInterface()", ex); } // Delay handling home if a double-tap is possible. if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { Loading Loading @@ -3957,10 +3953,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (down) { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { try { if (telephonyService.isRinging()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null) { if (telephonyManager.isRinging()) { // If an incoming call is ringing, either VOLUME key means // "silence ringer". We handle these keys here, rather than // in the InCallScreen, to make sure we'll respond to them Loading @@ -3972,23 +3967,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Silence the ringer. (It's safe to call this // even if the ringer has already been silenced.) telephonyService.silenceRinger(); telephonyManager.silenceRinger(); // And *don't* pass this key thru to the current activity // (which is probably the InCallScreen.) result &= ~ACTION_PASS_TO_USER; break; } if (telephonyService.isOffhook() if (telephonyManager.isOffhook() && (result & ACTION_PASS_TO_USER) == 0) { // If we are in call but we decided not to pass the key to // the application, handle the volume change here. handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); break; } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } } if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { Loading @@ -4004,14 +3996,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_ENDCALL: { result &= ~ACTION_PASS_TO_USER; if (down) { ITelephony telephonyService = getTelephonyService(); TelephonyManager telephonyManager = getTelephonyService(); boolean hungUp = false; if (telephonyService != null) { try { hungUp = telephonyService.endCall(); } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } if (telephonyManager != null) { hungUp = telephonyManager.endCall(); } interceptPowerKeyDown(!interactive || hungUp); } else { Loading Loading @@ -4047,23 +4035,19 @@ public class PhoneWindowManager implements WindowManagerPolicy { interceptScreenshotChord(); } ITelephony telephonyService = getTelephonyService(); TelephonyManager telephonyManager = getTelephonyService(); boolean hungUp = false; if (telephonyService != null) { try { if (telephonyService.isRinging()) { if (telephonyManager != null) { if (telephonyManager.isRinging()) { // Pressing Power while there's a ringing incoming // call should silence the ringer. telephonyService.silenceRinger(); telephonyManager.silenceRinger(); } else if ((mIncallPowerBehavior & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 && telephonyService.isOffhook() && interactive) { && telephonyManager.isOffhook() && interactive) { // Otherwise, if "Power button ends call" is enabled, // the Power button will hang up any current active call. hungUp = telephonyService.endCall(); } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); hungUp = telephonyManager.endCall(); } } interceptPowerKeyDown(!interactive || hungUp Loading Loading @@ -4096,17 +4080,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_MEDIA_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if (down) { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { try { if (!telephonyService.isIdle()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null) { if (!telephonyManager.isIdle()) { // Suppress PLAY/PAUSE toggle when phone is ringing or in-call // to avoid music playback. break; } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } } } case KeyEvent.KEYCODE_HEADSETHOOK: Loading Loading @@ -4135,21 +4115,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_CALL: { if (down) { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { try { if (telephonyService.isRinging()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null) { if (telephonyManager.isRinging()) { Log.i(TAG, "interceptKeyBeforeQueueing:" + " CALL key-down while ringing: Answer the call!"); telephonyService.answerRingingCall(); telephonyManager.answerRingingCall(); // And *don't* pass this key thru to the current activity // (which is presumably the InCallScreen.) result &= ~ACTION_PASS_TO_USER; } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } } } break; Loading telecomm/java/com/android/internal/telecomm/ITelecommService.aidl 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * 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 com.android.internal.telecomm; /** * Interface used to interact with Telecomm. Mostly this is used by TelephonyManager for passing * commands that were previously handled by ITelephony. * {@hide} */ oneway interface ITelecommService { /** * Silence the ringer if an incoming call is currently ringing. * (If vibrating, stop the vibrator also.) * * It's safe to call this if the ringer has already been silenced, or * even if there's no incoming call. (If so, this method will do nothing.) */ void silenceRinger(); } telephony/java/android/telephony/TelephonyManager.java +9 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.SystemProperties; import android.telephony.Rlog; import android.util.Log; import com.android.internal.telecomm.ITelecommService; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.ITelephonyRegistry; Loading Loading @@ -65,6 +66,8 @@ import java.util.regex.Pattern; public class TelephonyManager { private static final String TAG = "TelephonyManager"; private static final String TELECOMM_SERVICE_NAME = "telecomm"; private static ITelephonyRegistry sRegistry; /** Loading Loading @@ -1536,6 +1539,10 @@ public class TelephonyManager { return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); } private ITelecommService getTelecommService() { return ITelecommService.Stub.asInterface(ServiceManager.getService(TELECOMM_SERVICE_NAME)); } // // // PhoneStateListener Loading Loading @@ -2016,9 +2023,9 @@ public class TelephonyManager { @PrivateApi public void silenceRinger() { try { getITelephony().silenceRinger(); getTelecommService().silenceRinger(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#silenceRinger", e); Log.e(TAG, "Error calling ITelecommService#silenceRinger", e); } } Loading Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -325,6 +325,7 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl \ telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \ telecomm/java/com/android/internal/telecomm/IInCallService.aidl \ telecomm/java/com/android/internal/telecomm/ITelecommService.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +65 −89 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.os.Vibrator; import android.provider.Settings; import android.service.dreams.DreamService; import android.service.dreams.IDreamManager; import android.telephony.TelephonyManager; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Log; Loading Loading @@ -1921,9 +1922,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { ServiceManager.checkService(DreamService.DREAM_SERVICE)); } static ITelephony getTelephonyService() { return ITelephony.Stub.asInterface( ServiceManager.checkService(Context.TELEPHONY_SERVICE)); TelephonyManager getTelephonyService() { return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); } static IAudioService getAudioService() { Loading Loading @@ -2006,15 +2006,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { // If an incoming call is ringing, HOME is totally disabled. // (The user is already on the InCallScreen at this point, // and his ONLY options are to answer or reject the call.) try { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null && telephonyService.isRinging()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null && telephonyManager.isRinging()) { Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); return -1; } } catch (RemoteException ex) { Log.w(TAG, "RemoteException from getPhoneInterface()", ex); } // Delay handling home if a double-tap is possible. if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { Loading Loading @@ -3957,10 +3953,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } if (down) { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { try { if (telephonyService.isRinging()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null) { if (telephonyManager.isRinging()) { // If an incoming call is ringing, either VOLUME key means // "silence ringer". We handle these keys here, rather than // in the InCallScreen, to make sure we'll respond to them Loading @@ -3972,23 +3967,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Silence the ringer. (It's safe to call this // even if the ringer has already been silenced.) telephonyService.silenceRinger(); telephonyManager.silenceRinger(); // And *don't* pass this key thru to the current activity // (which is probably the InCallScreen.) result &= ~ACTION_PASS_TO_USER; break; } if (telephonyService.isOffhook() if (telephonyManager.isOffhook() && (result & ACTION_PASS_TO_USER) == 0) { // If we are in call but we decided not to pass the key to // the application, handle the volume change here. handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); break; } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } } if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { Loading @@ -4004,14 +3996,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_ENDCALL: { result &= ~ACTION_PASS_TO_USER; if (down) { ITelephony telephonyService = getTelephonyService(); TelephonyManager telephonyManager = getTelephonyService(); boolean hungUp = false; if (telephonyService != null) { try { hungUp = telephonyService.endCall(); } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } if (telephonyManager != null) { hungUp = telephonyManager.endCall(); } interceptPowerKeyDown(!interactive || hungUp); } else { Loading Loading @@ -4047,23 +4035,19 @@ public class PhoneWindowManager implements WindowManagerPolicy { interceptScreenshotChord(); } ITelephony telephonyService = getTelephonyService(); TelephonyManager telephonyManager = getTelephonyService(); boolean hungUp = false; if (telephonyService != null) { try { if (telephonyService.isRinging()) { if (telephonyManager != null) { if (telephonyManager.isRinging()) { // Pressing Power while there's a ringing incoming // call should silence the ringer. telephonyService.silenceRinger(); telephonyManager.silenceRinger(); } else if ((mIncallPowerBehavior & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 && telephonyService.isOffhook() && interactive) { && telephonyManager.isOffhook() && interactive) { // Otherwise, if "Power button ends call" is enabled, // the Power button will hang up any current active call. hungUp = telephonyService.endCall(); } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); hungUp = telephonyManager.endCall(); } } interceptPowerKeyDown(!interactive || hungUp Loading Loading @@ -4096,17 +4080,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_MEDIA_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if (down) { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { try { if (!telephonyService.isIdle()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null) { if (!telephonyManager.isIdle()) { // Suppress PLAY/PAUSE toggle when phone is ringing or in-call // to avoid music playback. break; } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } } } case KeyEvent.KEYCODE_HEADSETHOOK: Loading Loading @@ -4135,21 +4115,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { case KeyEvent.KEYCODE_CALL: { if (down) { ITelephony telephonyService = getTelephonyService(); if (telephonyService != null) { try { if (telephonyService.isRinging()) { TelephonyManager telephonyManager = getTelephonyService(); if (telephonyManager != null) { if (telephonyManager.isRinging()) { Log.i(TAG, "interceptKeyBeforeQueueing:" + " CALL key-down while ringing: Answer the call!"); telephonyService.answerRingingCall(); telephonyManager.answerRingingCall(); // And *don't* pass this key thru to the current activity // (which is presumably the InCallScreen.) result &= ~ACTION_PASS_TO_USER; } } catch (RemoteException ex) { Log.w(TAG, "ITelephony threw RemoteException", ex); } } } break; Loading
telecomm/java/com/android/internal/telecomm/ITelecommService.aidl 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * 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 com.android.internal.telecomm; /** * Interface used to interact with Telecomm. Mostly this is used by TelephonyManager for passing * commands that were previously handled by ITelephony. * {@hide} */ oneway interface ITelecommService { /** * Silence the ringer if an incoming call is currently ringing. * (If vibrating, stop the vibrator also.) * * It's safe to call this if the ringer has already been silenced, or * even if there's no incoming call. (If so, this method will do nothing.) */ void silenceRinger(); }
telephony/java/android/telephony/TelephonyManager.java +9 −2 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.SystemProperties; import android.telephony.Rlog; import android.util.Log; import com.android.internal.telecomm.ITelecommService; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.ITelephonyRegistry; Loading Loading @@ -65,6 +66,8 @@ import java.util.regex.Pattern; public class TelephonyManager { private static final String TAG = "TelephonyManager"; private static final String TELECOMM_SERVICE_NAME = "telecomm"; private static ITelephonyRegistry sRegistry; /** Loading Loading @@ -1536,6 +1539,10 @@ public class TelephonyManager { return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); } private ITelecommService getTelecommService() { return ITelecommService.Stub.asInterface(ServiceManager.getService(TELECOMM_SERVICE_NAME)); } // // // PhoneStateListener Loading Loading @@ -2016,9 +2023,9 @@ public class TelephonyManager { @PrivateApi public void silenceRinger() { try { getITelephony().silenceRinger(); getTelecommService().silenceRinger(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#silenceRinger", e); Log.e(TAG, "Error calling ITelecommService#silenceRinger", e); } } Loading