From ed6adb062b06a0ad4d7bd2c1d3ea5d04c3370a0f Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 19 Jul 2013 17:14:06 -0700 Subject: Renaming CallMonitorService to CallHandlerService Change-Id: I936341bbad768cc718e27faaef20b498479f0e28 --- src/com/android/incallui/CallHandlerService.java | 85 ++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/com/android/incallui/CallHandlerService.java (limited to 'src/com/android/incallui/CallHandlerService.java') diff --git a/src/com/android/incallui/CallHandlerService.java b/src/com/android/incallui/CallHandlerService.java new file mode 100644 index 00000000..741701ce --- /dev/null +++ b/src/com/android/incallui/CallHandlerService.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.incallui; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; +import android.os.RemoteException; +import android.util.Log; + +import com.android.internal.util.Preconditions; +import com.android.services.telephony.common.ICallCommandService; +import com.android.services.telephony.common.ICallHandlerService; + +/** + * Service used to listen for call state changes. + */ +public class CallHandlerService extends Service { + + private static final String TAG = CallHandlerService.class.getSimpleName(); + private static final boolean DBG = false; // TODO: Have a shared location for this. + + private static ICallCommandService mCallCommandService; + + @Override + public void onCreate() { + super.onCreate(); + } + + @Override + public void onDestroy() { + } + + @Override + public IBinder onBind(Intent intent) { + return mBinder; + } + + private final ICallHandlerService.Stub mBinder = new ICallHandlerService.Stub() { + + @Override + public void setCallCommandService(ICallCommandService service) { + logD("onConnected: " + service.toString()); + mCallCommandService = service; + } + + @Override + public void onIncomingCall(int callId) { + final Intent intent = new Intent(getApplication(), InCallActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + }; + + // TODO(klp): Not sure if static call is ok. Might need to switch to normal service binding. + public static void answerCall(int callId) { + Preconditions.checkState(mCallCommandService != null); + + try { + mCallCommandService.answerCall(callId); + } catch (RemoteException e) { + Log.e(TAG, "answerCall : " + e); + } + } + + private void logD(String message) { + if (DBG) { + Log.d(TAG, message); + } + } +} -- cgit v1.2.3