blob: 37dc3b9cb5c3c1440367d5cbf3452713ac0f64d4 [file] [log] [blame]
Santos Cordone3d76ab2014-01-28 17:25:20 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ben Gilad9f2bed32013-12-12 17:43:26 -080017package com.android.telecomm;
18
Santos Cordone3d76ab2014-01-28 17:25:20 -080019import android.os.Handler;
20import android.os.Looper;
Sailesh Nepala439e1b2014-03-11 18:19:58 -070021
22import com.android.internal.telecomm.IInCallAdapter;
Ben Gilad9f2bed32013-12-12 17:43:26 -080023
Santos Cordone3d76ab2014-01-28 17:25:20 -080024/**
25 * Receives call commands and updates from in-call app and passes them through to CallsManager.
26 * {@link InCallController} creates an instance of this class and passes it to the in-call app after
27 * binding to it. This adapter can receive commands and updates until the in-call app is unbound.
28 */
29class InCallAdapter extends IInCallAdapter.Stub {
Santos Cordon61d0f702014-02-19 02:52:23 -080030
Santos Cordone3d76ab2014-01-28 17:25:20 -080031 private final CallsManager mCallsManager;
32
33 private final Handler mHandler = new Handler(Looper.getMainLooper());
34
35 /** Persists the specified parameters. */
36 public InCallAdapter(CallsManager callsManager) {
37 mCallsManager = callsManager;
38 }
39
40 /** {@inheritDoc} */
41 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080042 public void answerCall(final String callId) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -080043 Log.d(this, "answerCall(%s)", callId);
Santos Cordone3d76ab2014-01-28 17:25:20 -080044 mHandler.post(new Runnable() {
45 @Override public void run() {
46 mCallsManager.answerCall(callId);
47 }
48 });
49 }
50
51 /** {@inheritDoc} */
52 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080053 public void rejectCall(final String callId) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -080054 Log.d(this, "rejectCall(%s)", callId);
Santos Cordone3d76ab2014-01-28 17:25:20 -080055 mHandler.post(new Runnable() {
56 @Override public void run() {
57 mCallsManager.rejectCall(callId);
58 }
59 });
60 }
61
62 /** {@inheritDoc} */
63 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080064 public void disconnectCall(final String callId) {
Santos Cordone3d76ab2014-01-28 17:25:20 -080065 mHandler.post(new Runnable() {
66 @Override public void run() {
67 mCallsManager.disconnectCall(callId);
68 }
69 });
70 }
Yorke Leecdf3ebd2014-03-12 18:31:41 -070071
72 /** {@inheritDoc} */
73 @Override
74 public void holdCall(final String callId) {
75 mHandler.post(new Runnable() {
76 @Override public void run() {
77 mCallsManager.holdCall(callId);
78 }
79 });
80 }
81
82 /** {@inheritDoc} */
83 @Override
84 public void unholdCall(final String callId) {
85 mHandler.post(new Runnable() {
86 @Override public void run() {
87 mCallsManager.unholdCall(callId);
88 }
89 });
90 }
Ben Gilad9f2bed32013-12-12 17:43:26 -080091}