Merge "Show gateway UI when dialing via a gateway" into klp-dev
diff --git a/InCallUI/res/layout/answer_fragment.xml b/InCallUI/res/layout/answer_fragment.xml
index 1594f03..f6b1320 100644
--- a/InCallUI/res/layout/answer_fragment.xml
+++ b/InCallUI/res/layout/answer_fragment.xml
@@ -31,9 +31,9 @@
android:layout_gravity="bottom|center_horizontal"
android:background="@android:color/black"
- dc:targetDrawables="@array/incoming_call_widget_3way_targets"
- dc:targetDescriptions="@array/incoming_call_widget_3way_target_descriptions"
- dc:directionDescriptions="@array/incoming_call_widget_3way_direction_descriptions"
+ dc:targetDrawables="@array/incoming_call_widget_2way_targets"
+ dc:targetDescriptions="@array/incoming_call_widget_2way_target_descriptions"
+ dc:directionDescriptions="@array/incoming_call_widget_2way_direction_descriptions"
dc:handleDrawable="@drawable/ic_in_call_touch_handle"
dc:outerRingDrawable="@*android:drawable/ic_lockscreen_outerring"
dc:outerRadius="@dimen/glowpadview_target_placement_radius"
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index f53807a..78ee0f1 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -76,7 +76,8 @@
}
public void onText() {
- getUi().showMessageDialogue();
+ // No-op for now. b/10424370
+ // getUi().showMessageDialogue();
}
public void rejectCallWithMessage(String message) {
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index da87f99..b77dc4c 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -123,7 +123,9 @@
@Override
public void setImage(Bitmap image) {
- setDrawableToImageView(mPhoto, new BitmapDrawable(getResources(), image));
+ if (image != null) {
+ setDrawableToImageView(mPhoto, new BitmapDrawable(getResources(), image));
+ }
}
@Override
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index f233d78..cc2e3bf 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -21,7 +21,6 @@
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.text.format.DateUtils;
@@ -32,12 +31,9 @@
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.incallui.service.PhoneNumberService;
-import com.android.incallui.util.HttpFetcher;
import com.android.services.telephony.common.AudioMode;
import com.android.services.telephony.common.Call;
-import java.io.IOException;
-
/**
* Presenter for the Call Card Fragment.
* <p>
@@ -349,13 +345,7 @@
@Override
protected Bitmap doInBackground(Void... params) {
// Fetch the image
- try {
- final byte[] image = HttpFetcher.getRequestAsByteArray(url);
- return BitmapFactory.decodeByteArray(image, 0, image.length);
- } catch (IOException e) {
- Log.e(TAG, "Unable to download/decode photo.", e);
- }
- return null;
+ return mPhoneNumberService.fetchImage(url);
}
@Override
diff --git a/InCallUI/src/com/android/incallui/Log.java b/InCallUI/src/com/android/incallui/Log.java
index 029bace..bc57ed7 100644
--- a/InCallUI/src/com/android/incallui/Log.java
+++ b/InCallUI/src/com/android/incallui/Log.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 The Android Open Source Project
+ * 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.
diff --git a/InCallUI/src/com/android/incallui/service/PhoneNumberService.java b/InCallUI/src/com/android/incallui/service/PhoneNumberService.java
index 1e0cb95..4566388 100644
--- a/InCallUI/src/com/android/incallui/service/PhoneNumberService.java
+++ b/InCallUI/src/com/android/incallui/service/PhoneNumberService.java
@@ -16,12 +16,16 @@
package com.android.incallui.service;
+import android.graphics.Bitmap;
+
/**
*
*/
public interface PhoneNumberService {
public void getPhoneNumberInfo(String phoneNumber, PhoneNumberServiceListener listener);
+ public Bitmap fetchImage(String url);
+
public interface PhoneNumberServiceListener {
/**
diff --git a/InCallUI/src/com/android/incallui/util/HttpFetcher.java b/InCallUI/src/com/android/incallui/util/HttpFetcher.java
deleted file mode 100644
index 6548a5a..0000000
--- a/InCallUI/src/com/android/incallui/util/HttpFetcher.java
+++ /dev/null
@@ -1,111 +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.incallui.util;
-
-import android.os.SystemClock;
-
-import com.android.incallui.Log;
-import com.google.common.io.Closeables;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-/**
- * Utility for making http requests.
- */
-public class HttpFetcher {
-
- private static final String TAG = HttpFetcher.class.getSimpleName();
-
- /**
- * Send a http request to the given url.
- *
- * @param urlString The url to request.
- * @return The response body as a byte array. Or {@literal null} if status code is not 2xx.
- * @throws java.io.IOException when an error occurs.
- */
- public static byte[] getRequestAsByteArray(String urlString) throws IOException {
- Log.d(TAG, "fetching " + urlString);
- HttpURLConnection conn = null;
- InputStream is = null;
- boolean isError = false;
- final long start = SystemClock.uptimeMillis();
- try {
- final URL url = new URL(urlString);
- conn = (HttpURLConnection) url.openConnection();
- Log.d(TAG, "response code: " + conn.getResponseCode());
- // All 2xx codes are successful.
- if (conn.getResponseCode() / 100 == 2) {
- is = conn.getInputStream();
- } else {
- is = conn.getErrorStream();
- isError = true;
- }
-
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final byte[] buffer = new byte[1024];
- int bytesRead;
-
- while ((bytesRead = is.read(buffer)) != -1) {
- baos.write(buffer, 0, bytesRead);
- }
-
- if (isError) {
- handleBadResponse(urlString, baos.toByteArray());
- return null;
- }
-
- final byte[] response = baos.toByteArray();
- Log.d(TAG, "received " + response.length + " bytes");
- final long end = SystemClock.uptimeMillis();
- Log.d(TAG, "fetch took " + (end - start) + " ms");
- return response;
- } finally {
- Closeables.closeQuietly(is);
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
-
- /**
- * Send a http request to the given url.
- *
- * @param urlString The url to request.
- * @return The response body as a String. Or {@literal null} if status code is not 2xx.
- * @throws java.io.IOException when an error occurs.
- */
- public static String getRequestAsString(String urlString) throws IOException {
- final byte[] byteArr = getRequestAsByteArray(urlString);
- if (byteArr == null) {
- // Encountered error response... just return.
- return null;
- }
- final String response = new String(byteArr);
- Log.d(TAG, "response body: ");
- Log.d(TAG, response);
- return response;
- }
-
- private static void handleBadResponse(String url, byte[] response) {
- Log.w(TAG, "Got bad response code from url: " + url);
- Log.w(TAG, new String(response));
- }
-}