blob: 9e14a2e0034f37b9254c683bb780829180041de8 [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;
Santos Cordone3d76ab2014-01-28 17:25:20 -080021import android.telecomm.IInCallAdapter;
Ben Gilad9f2bed32013-12-12 17:43:26 -080022
Santos Cordone3d76ab2014-01-28 17:25:20 -080023/**
24 * Receives call commands and updates from in-call app and passes them through to CallsManager.
25 * {@link InCallController} creates an instance of this class and passes it to the in-call app after
26 * binding to it. This adapter can receive commands and updates until the in-call app is unbound.
27 */
28class InCallAdapter extends IInCallAdapter.Stub {
Santos Cordon61d0f702014-02-19 02:52:23 -080029
Santos Cordone3d76ab2014-01-28 17:25:20 -080030 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
Ben Gilad4074c2a2014-03-06 14:02:48 -080041 public void answerCall(final String callId) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -080042 Log.d(this, "answerCall(%s)", callId);
Santos Cordone3d76ab2014-01-28 17:25:20 -080043 mHandler.post(new Runnable() {
44 @Override public void run() {
45 mCallsManager.answerCall(callId);
46 }
47 });
48 }
49
50 /** {@inheritDoc} */
51 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080052 public void rejectCall(final String callId) {
Sailesh Nepalf1c191d2014-03-07 18:17:39 -080053 Log.d(this, "rejectCall(%s)", callId);
Santos Cordone3d76ab2014-01-28 17:25:20 -080054 mHandler.post(new Runnable() {
55 @Override public void run() {
56 mCallsManager.rejectCall(callId);
57 }
58 });
59 }
60
61 /** {@inheritDoc} */
62 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080063 public void disconnectCall(final String callId) {
Santos Cordone3d76ab2014-01-28 17:25:20 -080064 mHandler.post(new Runnable() {
65 @Override public void run() {
66 mCallsManager.disconnectCall(callId);
67 }
68 });
69 }
Ben Gilad9f2bed32013-12-12 17:43:26 -080070}