TestInCallServiceImpl.java revision 7cc70b4f0ad1064a4a0dce6056ad82b205887160
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
17package com.android.server.telecom.testapps;
18
19import android.telecom.InCallService;
20import android.telecom.Phone;
21import android.util.Log;
22
23import java.lang.Override;
24import java.lang.String;
25
26/**
27 * Test In-Call service implementation.  Logs incoming events.  Mainly used to test binding to
28 * multiple {@link InCallService} implementations.
29 */
30public class TestInCallServiceImpl extends InCallService {
31    private static final String TAG = "TestInCallServiceImpl";
32
33    private Phone mPhone;
34
35    private Phone.Listener mPhoneListener = new Phone.Listener() {
36        @Override
37        public void onCallAdded(Phone phone, android.telecom.Call call) {
38            Log.i(TAG, "onCallAdded: "+call.toString());
39        }
40        @Override
41        public void onCallRemoved(Phone phone, android.telecom.Call call) {
42            Log.i(TAG, "onCallRemoved: "+call.toString());
43        }
44    };
45
46    @Override
47    public void onPhoneCreated(Phone phone) {
48        Log.i(TAG, "onPhoneCreated");
49        mPhone = phone;
50        mPhone.addListener(mPhoneListener);
51
52    }
53
54    @Override
55    public void onPhoneDestroyed(Phone phone) {
56        Log.i(TAG, "onPhoneDestroyed");
57        mPhone.removeListener(mPhoneListener);
58        mPhone = null;
59    }
60}
61