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