blob: 9faa472c5b92ff6db1912dfe254836a50dfcd43f [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;
Santos Cordon61d0f702014-02-19 02:52:23 -080023import android.util.Log;
Ben Gilad9f2bed32013-12-12 17:43:26 -080024
Santos Cordone3d76ab2014-01-28 17:25:20 -080025/**
26 * Receives call commands and updates from in-call app and passes them through to CallsManager.
27 * {@link InCallController} creates an instance of this class and passes it to the in-call app after
28 * binding to it. This adapter can receive commands and updates until the in-call app is unbound.
29 */
30class InCallAdapter extends IInCallAdapter.Stub {
Santos Cordon61d0f702014-02-19 02:52:23 -080031
32 private static final String TAG = InCallAdapter.class.getSimpleName();
33
Santos Cordone3d76ab2014-01-28 17:25:20 -080034 private final CallsManager mCallsManager;
35
36 private final Handler mHandler = new Handler(Looper.getMainLooper());
37
38 /** Persists the specified parameters. */
39 public InCallAdapter(CallsManager callsManager) {
40 mCallsManager = callsManager;
41 }
42
43 /** {@inheritDoc} */
44 @Override
45 public void answerCall(final String callId) throws RemoteException {
Santos Cordon61d0f702014-02-19 02:52:23 -080046 Log.d(TAG, "answerCall(" + callId + ")");
Santos Cordone3d76ab2014-01-28 17:25:20 -080047 mHandler.post(new Runnable() {
48 @Override public void run() {
49 mCallsManager.answerCall(callId);
50 }
51 });
52 }
53
54 /** {@inheritDoc} */
55 @Override
56 public void rejectCall(final String callId) throws RemoteException {
Santos Cordon61d0f702014-02-19 02:52:23 -080057 Log.d(TAG, "rejectCall(" + callId + ")");
Santos Cordone3d76ab2014-01-28 17:25:20 -080058 mHandler.post(new Runnable() {
59 @Override public void run() {
60 mCallsManager.rejectCall(callId);
61 }
62 });
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public void disconnectCall(final String callId) throws RemoteException {
68 mHandler.post(new Runnable() {
69 @Override public void run() {
70 mCallsManager.disconnectCall(callId);
71 }
72 });
73 }
74
Ben Gilad9f2bed32013-12-12 17:43:26 -080075}