Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 1 | /* |
| 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 Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 17 | package com.android.telecomm; |
| 18 | |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 19 | import android.os.Handler; |
| 20 | import android.os.Looper; |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 21 | import android.telecomm.IInCallAdapter; |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 22 | |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 23 | /** |
| 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 | */ |
| 28 | class InCallAdapter extends IInCallAdapter.Stub { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame] | 29 | |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 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 |
Ben Gilad | 4074c2a | 2014-03-06 14:02:48 -0800 | [diff] [blame] | 41 | public void answerCall(final String callId) { |
Sailesh Nepal | f1c191d | 2014-03-07 18:17:39 -0800 | [diff] [blame^] | 42 | Log.d(this, "answerCall(%s)", callId); |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 43 | mHandler.post(new Runnable() { |
| 44 | @Override public void run() { |
| 45 | mCallsManager.answerCall(callId); |
| 46 | } |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | /** {@inheritDoc} */ |
| 51 | @Override |
Ben Gilad | 4074c2a | 2014-03-06 14:02:48 -0800 | [diff] [blame] | 52 | public void rejectCall(final String callId) { |
Sailesh Nepal | f1c191d | 2014-03-07 18:17:39 -0800 | [diff] [blame^] | 53 | Log.d(this, "rejectCall(%s)", callId); |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 54 | mHandler.post(new Runnable() { |
| 55 | @Override public void run() { |
| 56 | mCallsManager.rejectCall(callId); |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | /** {@inheritDoc} */ |
| 62 | @Override |
Ben Gilad | 4074c2a | 2014-03-06 14:02:48 -0800 | [diff] [blame] | 63 | public void disconnectCall(final String callId) { |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 64 | mHandler.post(new Runnable() { |
| 65 | @Override public void run() { |
| 66 | mCallsManager.disconnectCall(callId); |
| 67 | } |
| 68 | }); |
| 69 | } |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 70 | } |