merge from froyo-plus-aosp

Change-Id: Iad8617b45d406e7f737bf68ed723755363d27e9b
This commit is contained in:
Jean-Baptiste Queru
2010-06-09 16:09:19 -07:00
4 changed files with 49 additions and 11 deletions

View File

@@ -204,10 +204,13 @@ public class HttpsConnection extends Connection {
BasicHttpRequest proxyReq = new BasicHttpRequest BasicHttpRequest proxyReq = new BasicHttpRequest
("CONNECT", mHost.toHostString()); ("CONNECT", mHost.toHostString());
// add all 'proxy' headers from the original request // add all 'proxy' headers from the original request, we also need
// to add 'host' header unless we want proxy to answer us with a
// 400 Bad Request
for (Header h : req.mHttpRequest.getAllHeaders()) { for (Header h : req.mHttpRequest.getAllHeaders()) {
String headerName = h.getName().toLowerCase(); String headerName = h.getName().toLowerCase();
if (headerName.startsWith("proxy") || headerName.equals("keep-alive")) { if (headerName.startsWith("proxy") || headerName.equals("keep-alive")
|| headerName.equals("host")) {
proxyReq.addHeader(h); proxyReq.addHeader(h);
} }
} }

View File

@@ -30,6 +30,8 @@ import android.util.Log;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set; import java.util.Set;
import android.os.PowerManager;
/** /**
* TODO: Move this to * TODO: Move this to
@@ -51,6 +53,9 @@ class BluetoothEventLoop {
private final BluetoothService mBluetoothService; private final BluetoothService mBluetoothService;
private final BluetoothAdapter mAdapter; private final BluetoothAdapter mAdapter;
private final Context mContext; private final Context mContext;
// The WakeLock is used for bringing up the LCD during a pairing request
// from remote device when Android is in Suspend state.
private PowerManager.WakeLock mWakeLock;
private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1; private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1;
private static final int EVENT_RESTART_BLUETOOTH = 2; private static final int EVENT_RESTART_BLUETOOTH = 2;
@@ -121,6 +126,11 @@ class BluetoothEventLoop {
mContext = context; mContext = context;
mPasskeyAgentRequestData = new HashMap(); mPasskeyAgentRequestData = new HashMap();
mAdapter = adapter; mAdapter = adapter;
//WakeLock instantiation in BluetoothEventLoop class
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.ON_AFTER_RELEASE, TAG);
mWakeLock.setReferenceCounted(false);
initializeNativeDataNative(); initializeNativeDataNative();
} }
@@ -458,37 +468,46 @@ class BluetoothEventLoop {
mHandler.sendMessageDelayed(message, 1500); mHandler.sendMessageDelayed(message, 1500);
return; return;
} }
// Acquire wakelock during PIN code request to bring up LCD display
mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_CONSENT); BluetoothDevice.PAIRING_VARIANT_CONSENT);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
// Release wakelock to allow the LCD to go off after the PIN popup notifcation.
mWakeLock.release();
return; return;
} }
private void onRequestPasskeyConfirmation(String objectPath, int passkey, int nativeData) { private void onRequestPasskeyConfirmation(String objectPath, int passkey, int nativeData) {
String address = checkPairingRequestAndGetAddress(objectPath, nativeData); String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
if (address == null) return; if (address == null) return;
// Acquire wakelock during PIN code request to bring up LCD display
mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey); intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey);
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION); BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
// Release wakelock to allow the LCD to go off after the PIN popup notifcation.
mWakeLock.release();
return; return;
} }
private void onRequestPasskey(String objectPath, int nativeData) { private void onRequestPasskey(String objectPath, int nativeData) {
String address = checkPairingRequestAndGetAddress(objectPath, nativeData); String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
if (address == null) return; if (address == null) return;
// Acquire wakelock during PIN code request to bring up LCD display
mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_PASSKEY); BluetoothDevice.PAIRING_VARIANT_PASSKEY);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
// Release wakelock to allow the LCD to go off after the PIN popup notifcation.
mWakeLock.release();
return; return;
} }
@@ -526,10 +545,14 @@ class BluetoothEventLoop {
} }
} }
} }
// Acquire wakelock during PIN code request to bring up LCD display
mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN); intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
// Release wakelock to allow the LCD to go off after the PIN popup notifcation.
mWakeLock.release();
return; return;
} }
@@ -537,12 +560,16 @@ class BluetoothEventLoop {
String address = checkPairingRequestAndGetAddress(objectPath, nativeData); String address = checkPairingRequestAndGetAddress(objectPath, nativeData);
if (address == null) return; if (address == null) return;
// Acquire wakelock during PIN code request to bring up LCD display
mWakeLock.acquire();
Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey); intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey);
intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY); BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY);
mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
//Release wakelock to allow the LCD to go off after the PIN popup notifcation.
mWakeLock.release();
} }
private boolean onAgentAuthorize(String objectPath, String deviceUuid) { private boolean onAgentAuthorize(String objectPath, String deviceUuid) {

View File

@@ -369,10 +369,13 @@ public class MimeTypeMap {
sMimeTypeMap.loadEntry("application/x-xfig", "fig"); sMimeTypeMap.loadEntry("application/x-xfig", "fig");
sMimeTypeMap.loadEntry("application/xhtml+xml", "xhtml"); sMimeTypeMap.loadEntry("application/xhtml+xml", "xhtml");
sMimeTypeMap.loadEntry("audio/3gpp", "3gpp"); sMimeTypeMap.loadEntry("audio/3gpp", "3gpp");
sMimeTypeMap.loadEntry("audio/amr", "amr");
sMimeTypeMap.loadEntry("audio/basic", "snd"); sMimeTypeMap.loadEntry("audio/basic", "snd");
sMimeTypeMap.loadEntry("audio/midi", "mid"); sMimeTypeMap.loadEntry("audio/midi", "mid");
sMimeTypeMap.loadEntry("audio/midi", "midi"); sMimeTypeMap.loadEntry("audio/midi", "midi");
sMimeTypeMap.loadEntry("audio/midi", "kar"); sMimeTypeMap.loadEntry("audio/midi", "kar");
sMimeTypeMap.loadEntry("audio/midi", "xmf");
sMimeTypeMap.loadEntry("audio/mobile-xmf", "mxmf");
sMimeTypeMap.loadEntry("audio/mpeg", "mpga"); sMimeTypeMap.loadEntry("audio/mpeg", "mpga");
sMimeTypeMap.loadEntry("audio/mpeg", "mpega"); sMimeTypeMap.loadEntry("audio/mpeg", "mpega");
sMimeTypeMap.loadEntry("audio/mpeg", "mp2"); sMimeTypeMap.loadEntry("audio/mpeg", "mp2");

View File

@@ -4510,6 +4510,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
partialStartOffset = 0; partialStartOffset = 0;
partialEndOffset = N; partialEndOffset = N;
} else { } else {
// Now use the delta to determine the actual amount of text
// we need.
partialEndOffset += delta;
// Adjust offsets to ensure we contain full spans. // Adjust offsets to ensure we contain full spans.
if (content instanceof Spanned) { if (content instanceof Spanned) {
Spanned spanned = (Spanned)content; Spanned spanned = (Spanned)content;
@@ -4525,10 +4528,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} }
} }
outText.partialStartOffset = partialStartOffset; outText.partialStartOffset = partialStartOffset;
outText.partialEndOffset = partialEndOffset; outText.partialEndOffset = partialEndOffset - delta;
// Now use the delta to determine the actual amount of text
// we need.
partialEndOffset += delta;
if (partialStartOffset > N) { if (partialStartOffset > N) {
partialStartOffset = N; partialStartOffset = N;
} else if (partialStartOffset < 0) { } else if (partialStartOffset < 0) {
@@ -4592,6 +4593,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
+ ": " + ims.mTmpExtracted.text); + ": " + ims.mTmpExtracted.text);
imm.updateExtractedText(this, req.token, imm.updateExtractedText(this, req.token,
mInputMethodState.mTmpExtracted); mInputMethodState.mTmpExtracted);
ims.mChangedStart = EXTRACT_UNKNOWN;
ims.mChangedEnd = EXTRACT_UNKNOWN;
ims.mChangedDelta = 0;
ims.mContentChanged = false;
return true; return true;
} }
} }
@@ -6167,8 +6172,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
ims.mChangedStart = start; ims.mChangedStart = start;
ims.mChangedEnd = start+before; ims.mChangedEnd = start+before;
} else { } else {
if (ims.mChangedStart > start) ims.mChangedStart = start; ims.mChangedStart = Math.min(ims.mChangedStart, start);
if (ims.mChangedEnd < (start+before)) ims.mChangedEnd = start+before; ims.mChangedEnd = Math.max(ims.mChangedEnd, start + before - ims.mChangedDelta);
} }
ims.mChangedDelta += after-before; ims.mChangedDelta += after-before;
} }