am 7762d936: Unbundling work

Merge commit '7762d93621f508f4410fd37b5bbdfec0071b0420' into eclair-mr2-plus-aosp

* commit '7762d93621f508f4410fd37b5bbdfec0071b0420':
  Unbundling work
This commit is contained in:
Paul Westbrook
2009-12-14 10:10:20 -08:00
committed by Android Git Automerger
14 changed files with 59 additions and 58 deletions

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package android.net.http; package com.android.common;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
@@ -59,11 +59,12 @@ import java.util.zip.GZIPOutputStream;
import java.net.URI; import java.net.URI;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import android.util.Log;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.os.Looper;
import android.os.SystemProperties;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.os.SystemProperties; import android.util.Log;
/** /**
* Subclass of the Apache {@link DefaultHttpClient} that is configured with * Subclass of the Apache {@link DefaultHttpClient} that is configured with
@@ -86,15 +87,12 @@ public final class AndroidHttpClient implements HttpClient {
private static final String TAG = "AndroidHttpClient"; private static final String TAG = "AndroidHttpClient";
/** Set if HTTP requests are blocked from being executed on this thread */
private static final ThreadLocal<Boolean> sThreadBlocked =
new ThreadLocal<Boolean>();
/** Interceptor throws an exception if the executing thread is blocked */ /** Interceptor throws an exception if the executing thread is blocked */
private static final HttpRequestInterceptor sThreadCheckInterceptor = private static final HttpRequestInterceptor sThreadCheckInterceptor =
new HttpRequestInterceptor() { new HttpRequestInterceptor() {
public void process(HttpRequest request, HttpContext context) { public void process(HttpRequest request, HttpContext context) {
if (sThreadBlocked.get() != null && sThreadBlocked.get()) { // Prevent the HttpRequest from being sent on the main thread
if (Looper.myLooper() != null && Looper.myLooper() == Looper.getMainLooper() ) {
throw new RuntimeException("This thread forbids HTTP requests"); throw new RuntimeException("This thread forbids HTTP requests");
} }
} }
@@ -220,15 +218,6 @@ public final class AndroidHttpClient implements HttpClient {
} }
} }
/**
* Block this thread from executing HTTP requests.
* Used to guard against HTTP requests blocking the main application thread.
* @param blocked if HTTP requests run on this thread should be denied
*/
public static void setThreadBlocked(boolean blocked) {
sThreadBlocked.set(blocked);
}
/** /**
* Modifies a request to indicate to the server that we would like a * Modifies a request to indicate to the server that we would like a
* gzipped response. (Uses the "Accept-Encoding" HTTP header.) * gzipped response. (Uses the "Accept-Encoding" HTTP header.)

View File

@@ -1,4 +1,20 @@
package android.text.util; /*
* Copyright (C) 2008 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.common;
import android.text.InputFilter; import android.text.InputFilter;
import android.text.Spanned; import android.text.Spanned;

View File

@@ -14,9 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package android.text.util; package com.android.common;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Rfc822Token;
import android.text.util.Rfc822Tokenizer;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import java.util.regex.Pattern; import java.util.regex.Pattern;

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.internal.widget; package com.android.common.widget;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
@@ -104,7 +104,8 @@ public class NumberPicker extends LinearLayout implements OnClickListener,
public NumberPicker(Context context, AttributeSet attrs, int defStyle) { public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs); super(context, attrs);
setOrientation(VERTICAL); setOrientation(VERTICAL);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.number_picker, this, true); inflater.inflate(R.layout.number_picker, this, true);
mHandler = new Handler(); mHandler = new Handler();
InputFilter inputFilter = new NumberPickerInputFilter(); InputFilter inputFilter = new NumberPickerInputFilter();

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.internal.widget; package com.android.common.widget;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;

View File

@@ -40,7 +40,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDebug; import android.database.sqlite.SQLiteDebug;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.net.http.AndroidHttpClient;
import android.os.Bundle; import android.os.Bundle;
import android.os.Debug; import android.os.Debug;
import android.os.Handler; import android.os.Handler;
@@ -4303,7 +4302,6 @@ public final class ActivityThread {
private final void attach(boolean system) { private final void attach(boolean system) {
sThreadLocal.set(this); sThreadLocal.set(this);
mSystemThread = system; mSystemThread = system;
AndroidHttpClient.setThreadBlocked(true);
if (!system) { if (!system) {
android.ddm.DdmHandleAppName.setAppName("<pre-initialized>"); android.ddm.DdmHandleAppName.setAppName("<pre-initialized>");
RuntimeInit.setApplicationObject(mAppThread.asBinder()); RuntimeInit.setApplicationObject(mAppThread.asBinder());
@@ -4333,7 +4331,6 @@ public final class ActivityThread {
private final void detach() private final void detach()
{ {
AndroidHttpClient.setThreadBlocked(false);
sThreadLocal.set(null); sThreadLocal.set(null);
} }

View File

@@ -26,9 +26,9 @@ import android.util.AttributeSet;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import com.android.common.widget.NumberPicker;
import com.android.common.widget.NumberPicker.OnChangedListener;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.widget.NumberPicker;
import com.android.internal.widget.NumberPicker.OnChangedListener;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;

View File

@@ -25,7 +25,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.widget.NumberPicker; import com.android.common.widget.NumberPicker;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.util.Calendar; import java.util.Calendar;
@@ -357,4 +357,3 @@ public class TimePicker extends FrameLayout {
mOnTimeChangedListener.onTimeChanged(this, getCurrentHour(), getCurrentMinute()); mOnTimeChangedListener.onTimeChanged(this, getCurrentHour(), getCurrentMinute());
} }
} }

View File

@@ -20,12 +20,12 @@ import android.content.ContentResolver;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.net.TrafficStats; import android.net.TrafficStats;
import android.net.http.AndroidHttpClient;
import android.os.Build; import android.os.Build;
import android.os.SystemClock; import android.os.SystemClock;
import android.provider.Checkin; import android.provider.Checkin;
import android.util.Config; import android.util.Config;
import android.util.Log; import android.util.Log;
import com.android.common.AndroidHttpClient;
import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache; import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpEntityEnclosingRequest;

View File

@@ -32,10 +32,12 @@ import java.util.Random;
import android.content.Context; import android.content.Context;
import android.net.Proxy; import android.net.Proxy;
import android.net.http.AndroidHttpClient;
import android.util.Config; import android.util.Config;
import android.util.Log; import android.util.Log;
import com.android.common.AndroidHttpClient;
/** /**
* A class for downloading GPS XTRA data. * A class for downloading GPS XTRA data.
* *
@@ -169,4 +171,3 @@ public class GpsXtraDownloader {
} }
} }

View File

@@ -441,10 +441,6 @@ android.net.Uri$Part
android.net.Uri$PathSegments android.net.Uri$PathSegments
android.net.Uri$StringUri android.net.Uri$StringUri
android.net.WebAddress android.net.WebAddress
android.net.http.AndroidHttpClient
android.net.http.AndroidHttpClient$1
android.net.http.AndroidHttpClient$2
android.net.http.AndroidHttpClientConnection
android.net.http.CertificateChainValidator android.net.http.CertificateChainValidator
android.net.http.Connection android.net.http.Connection
android.net.http.ConnectionThread android.net.http.ConnectionThread
@@ -718,7 +714,6 @@ android.text.util.Linkify
android.text.util.Linkify$1 android.text.util.Linkify$1
android.text.util.Linkify$4 android.text.util.Linkify$4
android.text.util.Rfc822Tokenizer android.text.util.Rfc822Tokenizer
android.text.util.Rfc822Validator
android.util.AttributeSet android.util.AttributeSet
android.util.DayOfMonthCursor android.util.DayOfMonthCursor
android.util.DisplayMetrics android.util.DisplayMetrics
@@ -1077,10 +1072,6 @@ com.android.internal.widget.ContactHeaderWidget
com.android.internal.widget.DialogTitle com.android.internal.widget.DialogTitle
com.android.internal.widget.EditableInputConnection com.android.internal.widget.EditableInputConnection
com.android.internal.widget.LockPatternUtils com.android.internal.widget.LockPatternUtils
com.android.internal.widget.NumberPicker
com.android.internal.widget.NumberPicker$1
com.android.internal.widget.NumberPicker$NumberRangeKeyListener
com.android.internal.widget.NumberPickerButton
com.android.internal.widget.RotarySelector com.android.internal.widget.RotarySelector
com.android.internal.widget.Smileys com.android.internal.widget.Smileys
com.google.android.gles_jni.EGLDisplayImpl com.google.android.gles_jni.EGLDisplayImpl

View File

@@ -17,7 +17,6 @@
package com.android.unit_tests; package com.android.unit_tests;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.net.http.AndroidHttpClient;
import android.provider.Checkin; import android.provider.Checkin;
import android.provider.Settings; import android.provider.Settings;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
@@ -64,6 +63,10 @@ public class GoogleHttpClientTest extends AndroidTestCase {
if (mServer != null) mServer.shutdown(); if (mServer != null) mServer.shutdown();
} }
//
// Fix this test to use the new mechanism to indicate that the
// Http client is running in the UI thread
// bug: http://b/2322326
@LargeTest @LargeTest
public void testThreadCheck() throws Exception { public void testThreadCheck() throws Exception {
ContentResolver resolver = getContext().getContentResolver(); ContentResolver resolver = getContext().getContentResolver();
@@ -77,7 +80,9 @@ public class GoogleHttpClientTest extends AndroidTestCase {
// This is actually an AndroidHttpClient feature... // This is actually an AndroidHttpClient feature...
// TODO: somehow test that Activity threads have the flag set? // TODO: somehow test that Activity threads have the flag set?
AndroidHttpClient.setThreadBlocked(true); // Thus now uses the looper state to determine if it is in a UI
// thread
//AndroidHttpClient.setThreadBlocked(true);
try { try {
client.execute(method); client.execute(method);
@@ -85,7 +90,7 @@ public class GoogleHttpClientTest extends AndroidTestCase {
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (!e.toString().contains("forbids HTTP requests")) throw e; if (!e.toString().contains("forbids HTTP requests")) throw e;
} finally { } finally {
AndroidHttpClient.setThreadBlocked(false); // AndroidHttpClient.setThreadBlocked(false);
} }
HttpResponse response = client.execute(method); HttpResponse response = client.execute(method);

View File

@@ -16,9 +16,6 @@
package com.android.unit_tests; package com.android.unit_tests;
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
import android.graphics.Paint; import android.graphics.Paint;
import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
@@ -29,9 +26,12 @@ import android.text.SpannedString;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.text.util.Rfc822Validator;
import android.test.MoreAsserts; import android.test.MoreAsserts;
import com.android.common.Rfc822Validator;
import com.google.android.collect.Lists;
import com.google.android.collect.Maps;
import junit.framework.TestCase; import junit.framework.TestCase;
import java.util.List; import java.util.List;

View File

@@ -34,8 +34,8 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.net.http.AndroidHttpClient;
import android.util.Log; import android.util.Log;
import com.android.common.AndroidHttpClient;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler; import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;