blob: 170f66bd0c68cdbff8876dae5f1c14017f8b7531 [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;
Santos Cordon61d0f702014-02-19 02:52:23 -080022import android.util.Log;
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
31 private static final String TAG = InCallAdapter.class.getSimpleName();
32
Santos Cordone3d76ab2014-01-28 17:25:20 -080033 private final CallsManager mCallsManager;
34
35 private final Handler mHandler = new Handler(Looper.getMainLooper());
36
37 /** Persists the specified parameters. */
38 public InCallAdapter(CallsManager callsManager) {
39 mCallsManager = callsManager;
40 }
41
42 /** {@inheritDoc} */
43 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080044 public void answerCall(final String callId) {
Santos Cordon61d0f702014-02-19 02:52:23 -080045 Log.d(TAG, "answerCall(" + callId + ")");
Santos Cordone3d76ab2014-01-28 17:25:20 -080046 mHandler.post(new Runnable() {
47 @Override public void run() {
48 mCallsManager.answerCall(callId);
49 }
50 });
51 }
52
53 /** {@inheritDoc} */
54 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080055 public void rejectCall(final String callId) {
Santos Cordon61d0f702014-02-19 02:52:23 -080056 Log.d(TAG, "rejectCall(" + callId + ")");
Santos Cordone3d76ab2014-01-28 17:25:20 -080057 mHandler.post(new Runnable() {
58 @Override public void run() {
59 mCallsManager.rejectCall(callId);
60 }
61 });
62 }
63
64 /** {@inheritDoc} */
65 @Override
Ben Gilad4074c2a2014-03-06 14:02:48 -080066 public void disconnectCall(final String callId) {
Santos Cordone3d76ab2014-01-28 17:25:20 -080067 mHandler.post(new Runnable() {
68 @Override public void run() {
69 mCallsManager.disconnectCall(callId);
70 }
71 });
72 }
Ben Gilad9f2bed32013-12-12 17:43:26 -080073}