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; |
| 21 | import android.os.RemoteException; |
| 22 | import android.telecomm.IInCallAdapter; |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame^] | 23 | import android.util.Log; |
Ben Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 24 | |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 25 | /** |
| 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 | */ |
| 30 | class InCallAdapter extends IInCallAdapter.Stub { |
Santos Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame^] | 31 | |
| 32 | private static final String TAG = InCallAdapter.class.getSimpleName(); |
| 33 | |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 34 | 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 Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame^] | 46 | Log.d(TAG, "answerCall(" + callId + ")"); |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 47 | 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 Cordon | 61d0f70 | 2014-02-19 02:52:23 -0800 | [diff] [blame^] | 57 | Log.d(TAG, "rejectCall(" + callId + ")"); |
Santos Cordon | e3d76ab | 2014-01-28 17:25:20 -0800 | [diff] [blame] | 58 | 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 Gilad | 9f2bed3 | 2013-12-12 17:43:26 -0800 | [diff] [blame] | 75 | } |