Change incoming call intent to be an activity intent.
Change-Id: Ib8ed478a306e6efa474ad4c05a651cf651f76f8a
diff --git a/src/com/android/telecomm/CallActivity.java b/src/com/android/telecomm/CallActivity.java
index 1f1d778..3fbe756 100644
--- a/src/com/android/telecomm/CallActivity.java
+++ b/src/com/android/telecomm/CallActivity.java
@@ -21,6 +21,8 @@
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
+import android.telecomm.CallServiceDescriptor;
+import android.telecomm.TelecommConstants;
import android.util.Log;
import android.widget.Toast;
@@ -67,9 +69,9 @@
// TODO(santoscordon): Figure out if there is something to restore from bundle.
// See OutgoingCallBroadcaster in services/Telephony for more.
- processOutgoingCallIntent(intent);
+ processIntent(intent);
- // TODO(santoscordon): Remove this finish() once this app does more than just show a toast.
+ // This activity does not have associated UI, so close.
finish();
if (DEBUG) {
@@ -78,6 +80,23 @@
}
/**
+ * Processes intents sent to the activity.
+ *
+ * @param intent The intent.
+ */
+ private void processIntent(Intent intent) {
+ String action = intent.getAction();
+
+ if (Intent.ACTION_CALL.equals(action) ||
+ Intent.ACTION_CALL_PRIVILEGED.equals(action) ||
+ Intent.ACTION_CALL_EMERGENCY.equals(action)) {
+ processOutgoingCallIntent(intent);
+ } else if (TelecommConstants.ACTION_INCOMING_CALL.equals(action)) {
+ processIncomingCallIntent(intent);
+ }
+ }
+
+ /**
* Processes CALL, CALL_PRIVILEGED, and CALL_EMERGENCY intents.
*
* @param intent Call intent containing data about the handle to call.
@@ -103,4 +122,21 @@
// TODO(gilad): Handle or explicitly state to be ignored.
}
}
+
+ /**
+ * Processes INCOMING_CALL intents. Grabs the call service informations from the intent extra
+ * and forwards that to the CallsManager to start the incoming call flow.
+ *
+ * @param intent The incoming call intent.
+ */
+ private void processIncomingCallIntent(Intent intent) {
+ CallServiceDescriptor descriptor =
+ intent.getParcelableExtra(TelecommConstants.EXTRA_CALL_SERVICE_DESCRIPTOR);
+ if (descriptor == null) {
+ Log.w(TAG, "Rejecting incoming call due to null descriptor");
+ return;
+ }
+
+ // Notify CallsManager.
+ }
}
diff --git a/src/com/android/telecomm/TelecommReceiver.java b/src/com/android/telecomm/TelecommReceiver.java
deleted file mode 100644
index 342ef20..0000000
--- a/src/com/android/telecomm/TelecommReceiver.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2013 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.telecomm;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.telecomm.CallServiceDescriptor;
-import android.util.Log;
-
-import com.google.common.base.Strings;
-
-/**
- * Receiver for public intents relating to Telecomm.
- *
- * TODO(gilad): Unify the incoming/outgoing approach to use startActivity in both cases thereby
- * eliminating the incoming logic below, as well as this class as a whole.
- */
-public class TelecommReceiver extends BroadcastReceiver {
-
- private static final String TAG = TelecommReceiver.class.getSimpleName();
-
- /**
- * Action used by call services to notify Telecomm that there is an incoming call. This intent
- * starts the incoming call sequence which will ultimately connect to the call service described
- * in the intent extras. A new call object along with the token (also provided in the intent
- * extras) will ultimately be sent to the call service indicating that Telecomm has received its
- * incoming call.
- * Extras used: {@link #EXTRA_CALL_SERVICE_DESCRIPTOR}, {@link #EXTRA_INCOMING_CALL_TOKEN}
- * TODO(santoscordon): As this gets finalized, this should eventually move to TelecommConstants.
- * TODO(santoscordon): Expose a new service like TelephonyManager for Telecomm and expose
- * a method for incoming calls instead of forcing the call service to build and send an Intent.
- */
- public static final String ACTION_INCOMING_CALL = "com.android.telecomm.INCOMING_CALL";
-
- /**
- * The {@link CallServiceDescriptor} describing the call service for an incoming call.
- */
- static final String EXTRA_CALL_SERVICE_DESCRIPTOR = "com.android.telecomm.CALL_SERVICE_DESCRIPTOR";
-
- /**
- * A String-based token used to identify the incoming call. Telecomm will use this token when
- * providing a call object to the call service so that the call service can map the call object
- * with the appropriate incoming call. Telecomm does not use or manipulate this token in any
- * way; it simply passes it through to the call service. Cannot be empty or null.
- */
- static final String EXTRA_INCOMING_CALL_TOKEN = "com.android.telecomm.INCOMING_CALL_TOKEN";
-
- private CallsManager mCallsManager = CallsManager.getInstance();
-
- /** {@inheritDoc} */
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (ACTION_INCOMING_CALL.equals(action)) {
- handleIncomingCall(intent);
- }
- }
-
- /**
- * Notifies CallsManager that a call service has an incoming call and it should start the
- * incoming call sequence.
- *
- * @param intent The incoming call intent.
- */
- private void handleIncomingCall(Intent intent) {
- CallServiceDescriptor descriptor = intent.getParcelableExtra(EXTRA_CALL_SERVICE_DESCRIPTOR);
- if (descriptor == null) {
- Log.w(TAG, "Rejecting incoming call due to null descriptor");
- return;
- }
-
- String token = Strings.emptyToNull(intent.getStringExtra(EXTRA_INCOMING_CALL_TOKEN));
- if (token == null) {
- Log.w(TAG, "Rejecting incoming call due to null token");
- }
-
- // TODO(santoscordon): Notify CallsManager.
- }
-}