blob: eb10318bf870a7015c6cdeed02c503d14dcb261e [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;
21import android.os.RemoteException;
22import android.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 {
30 private final CallsManager mCallsManager;
31
32 private final Handler mHandler = new Handler(Looper.getMainLooper());
33
34 /** Persists the specified parameters. */
35 public InCallAdapter(CallsManager callsManager) {
36 mCallsManager = callsManager;
37 }
38
39 /** {@inheritDoc} */
40 @Override
41 public void answerCall(final String callId) throws RemoteException {
42 mHandler.post(new Runnable() {
43 @Override public void run() {
44 mCallsManager.answerCall(callId);
45 }
46 });
47 }
48
49 /** {@inheritDoc} */
50 @Override
51 public void rejectCall(final String callId) throws RemoteException {
52 mHandler.post(new Runnable() {
53 @Override public void run() {
54 mCallsManager.rejectCall(callId);
55 }
56 });
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public void disconnectCall(final String callId) throws RemoteException {
62 mHandler.post(new Runnable() {
63 @Override public void run() {
64 mCallsManager.disconnectCall(callId);
65 }
66 });
67 }
68
Ben Gilad9f2bed32013-12-12 17:43:26 -080069}