diff options
Diffstat (limited to 'telecomm/java/android/telecomm/TelecommManager.java')
-rw-r--r-- | telecomm/java/android/telecomm/TelecommManager.java | 115 |
1 files changed, 105 insertions, 10 deletions
diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java index a0abc286144e..6bb75be5bd67 100644 --- a/telecomm/java/android/telecomm/TelecommManager.java +++ b/telecomm/java/android/telecomm/TelecommManager.java @@ -1,17 +1,15 @@ /* * 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 + * 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 + * 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. + * 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.telecomm; @@ -62,14 +60,111 @@ public class TelecommManager { @SystemApi public ComponentName getDefaultPhoneApp() { try { - return getTelecommService().getDefaultPhoneApp(); + if (isServiceConnected()) { + return getTelecommService().getDefaultPhoneApp(); + } } catch (RemoteException e) { Log.e(TAG, "RemoteException attempting to get the default phone app.", e); } return null; } + /** + * Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding + * states). + * + * @hide + */ + @SystemApi + public boolean isInAPhoneCall() { + try { + if (isServiceConnected()) { + return getTelecommService().isInAPhoneCall(); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException attempting to get default phone app.", e); + } + return false; + } + + /** + * Returns whether there currently exists is a ringing incoming-call. + * + * @hide + */ + @SystemApi + public boolean isRinging() { + try { + if (isServiceConnected()) { + return getTelecommService().isRinging(); + } + } catch (RemoteException e) { + Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e); + } + return false; + } + + /** + * Ends an ongoing call. TODO(santoscordon): L-release - need to convert all invocations of + * ITelephony#endCall to use this method (clockwork & gearhead). + * + * @hide + */ + @SystemApi + public boolean endCall() { + try { + if (isServiceConnected()) { + return getTelecommService().endCall(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#endCall", e); + } + return false; + } + + /** + * If there is a ringing incoming call, this method accepts the call on behalf of the user. + * TODO(santoscordon): L-release - need to convert all invocation of + * ITelephony#answerRingingCall to use this method (clockwork & gearhead). + * + * @hide + */ + @SystemApi + public void acceptRingingCall() { + try { + if (isServiceConnected()) { + getTelecommService().acceptRingingCall(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#acceptRingingCall", e); + } + } + + /** + * Silences the ringer if a ringing call exists. + * + * @hide + */ + @SystemApi + public void silenceRinger() { + try { + if (isServiceConnected()) { + getTelecommService().silenceRinger(); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelecommService#silenceRinger", e); + } + } + private ITelecommService getTelecommService() { return ITelecommService.Stub.asInterface(ServiceManager.getService(TELECOMM_SERVICE_NAME)); } + + private boolean isServiceConnected() { + boolean isConnected = getTelecommService() != null; + if (!isConnected) { + Log.w(TAG, "Telecomm Service not found."); + } + return isConnected; + } } |