diff options
author | Santos Cordon <santoscordon@google.com> | 2013-07-19 17:14:06 -0700 |
---|---|---|
committer | Santos Cordon <santoscordon@google.com> | 2013-07-19 17:16:45 -0700 |
commit | ed6adb062b06a0ad4d7bd2c1d3ea5d04c3370a0f (patch) | |
tree | 12d8a94b9d4051d1b4f3e968a642edc83bb277eb /src/com/android/incallui/CallHandlerService.java | |
parent | 7df3ac3f95c9d23396e1319beb6ca34435d965f5 (diff) | |
download | packages_apps_InCallUI-ed6adb062b06a0ad4d7bd2c1d3ea5d04c3370a0f.tar.gz packages_apps_InCallUI-ed6adb062b06a0ad4d7bd2c1d3ea5d04c3370a0f.tar.bz2 packages_apps_InCallUI-ed6adb062b06a0ad4d7bd2c1d3ea5d04c3370a0f.zip |
Renaming CallMonitorService to CallHandlerService
Change-Id: I936341bbad768cc718e27faaef20b498479f0e28
Diffstat (limited to 'src/com/android/incallui/CallHandlerService.java')
-rw-r--r-- | src/com/android/incallui/CallHandlerService.java | 85 |
1 files changed, 85 insertions, 0 deletions
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); + } + } +} |