summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/database/DefaultDatabaseErrorHandler.java4
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java7
-rw-r--r--core/java/android/view/View.java17
-rw-r--r--core/java/android/view/ViewGroup.java2
-rw-r--r--core/java/android/view/ViewRoot.java1
-rw-r--r--core/java/android/webkit/BrowserFrame.java24
-rw-r--r--core/java/android/webkit/CertTool.java13
-rw-r--r--core/java/android/webkit/KeyStoreHandler.java77
-rw-r--r--core/java/android/webkit/LoadListener.java12
-rw-r--r--core/java/android/webkit/WebView.java8
-rw-r--r--core/java/android/webkit/WebViewCore.java9
-rw-r--r--core/java/android/widget/ListPopupWindow.java2
-rw-r--r--core/java/android/widget/Spinner.java1
-rw-r--r--core/java/android/widget/TextView.java46
14 files changed, 181 insertions, 42 deletions
diff --git a/core/java/android/database/DefaultDatabaseErrorHandler.java b/core/java/android/database/DefaultDatabaseErrorHandler.java
index 61337dd..a9e39c3 100644
--- a/core/java/android/database/DefaultDatabaseErrorHandler.java
+++ b/core/java/android/database/DefaultDatabaseErrorHandler.java
@@ -16,7 +16,7 @@
package android.database;
import java.io.File;
-import java.util.ArrayList;
+import java.util.List;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
@@ -65,7 +65,7 @@ public final class DefaultDatabaseErrorHandler implements DatabaseErrorHandler {
return;
}
- ArrayList<Pair<String, String>> attachedDbs = null;
+ List<Pair<String, String>> attachedDbs = null;
try {
// Close the database, which will cause subsequent operations to fail.
// before that, get the attached database list first.
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index 1a43b30..b3fd914 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -40,6 +40,7 @@ import dalvik.system.BlockGuard;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.List;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -2504,7 +2505,7 @@ public class SQLiteDatabase extends SQLiteClosable {
String lastnode = path.substring((indx != -1) ? ++indx : 0);
// get list of attached dbs and for each db, get its size and pagesize
- ArrayList<Pair<String, String>> attachedDbs = db.getAttachedDbs();
+ List<Pair<String, String>> attachedDbs = db.getAttachedDbs();
if (attachedDbs == null) {
continue;
}
@@ -2560,7 +2561,7 @@ public class SQLiteDatabase extends SQLiteClosable {
* @return ArrayList of pairs of (database name, database file path) or null if the database
* is not open.
*/
- public ArrayList<Pair<String, String>> getAttachedDbs() {
+ public List<Pair<String, String>> getAttachedDbs() {
if (!isOpen()) {
return null;
}
@@ -2613,7 +2614,7 @@ public class SQLiteDatabase extends SQLiteClosable {
*/
public boolean isDatabaseIntegrityOk() {
verifyDbIsOpen();
- ArrayList<Pair<String, String>> attachedDbs = null;
+ List<Pair<String, String>> attachedDbs = null;
try {
attachedDbs = getAttachedDbs();
if (attachedDbs == null) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c64f564..5e8f31a 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8227,6 +8227,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
* @hide
*/
protected void dispatchGetDisplayList() {}
+
+ /**
+ * A view that is not attached or hardware accelerated cannot create a display list.
+ * This method checks these conditions and returns the appropriate result.
+ *
+ * @return true if view has the ability to create a display list, false otherwise.
+ *
+ * @hide
+ */
+ public boolean canHaveDisplayList() {
+ if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
+ return false;
+ }
+ return true;
+ }
/**
* <p>Returns a display list that can be used to draw this view again
@@ -8237,7 +8252,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
* @hide
*/
public DisplayList getDisplayList() {
- if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
+ if (!canHaveDisplayList()) {
return null;
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 1313b78..d0509b2 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2381,7 +2381,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
} else if (layerType == LAYER_TYPE_NONE) {
// Delay getting the display list until animation-driven alpha values are
// set up and possibly passed on to the view
- hasDisplayList = true;
+ hasDisplayList = child.canHaveDisplayList();
}
}
}
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 41fc6c6..b21af41 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1537,6 +1537,7 @@ public final class ViewRoot extends Handler implements ViewParent,
int top = dirty.top;
int right = dirty.right;
int bottom = dirty.bottom;
+
canvas = surface.lockCanvas(dirty);
if (left != dirty.left || top != dirty.top || right != dirty.right ||
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index ec3c329..b7ffd14 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -88,6 +88,9 @@ class BrowserFrame extends Handler {
// Attached Javascript interfaces
private Map<String, Object> mJSInterfaceMap;
+ // Key store handler when Chromium HTTP stack is used.
+ private KeyStoreHandler mKeyStoreHandler = null;
+
// message ids
// a message posted when a frame loading is completed
static final int FRAME_COMPLETED = 1001;
@@ -1173,8 +1176,27 @@ class BrowserFrame extends Handler {
}
mimeType = MimeTypeMap.getSingleton().remapGenericMimeType(
mimeType, url, contentDisposition);
- mCallbackProxy.onDownloadStart(url, userAgent,
+
+ if (CertTool.getCertType(mimeType) != null) {
+ mKeyStoreHandler = new KeyStoreHandler(mimeType);
+ } else {
+ mCallbackProxy.onDownloadStart(url, userAgent,
contentDisposition, mimeType, contentLength);
+ }
+ }
+
+ /**
+ * Called by JNI for Chrome HTTP stack when the Java side needs to access the data.
+ */
+ private void didReceiveData(byte data[], int size) {
+ if (mKeyStoreHandler != null) mKeyStoreHandler.didReceiveData(data, size);
+ }
+
+ private void didFinishLoading() {
+ if (mKeyStoreHandler != null) {
+ mKeyStoreHandler.installCert(mContext);
+ mKeyStoreHandler = null;
+ }
}
/**
diff --git a/core/java/android/webkit/CertTool.java b/core/java/android/webkit/CertTool.java
index d25d970..4c534f9 100644
--- a/core/java/android/webkit/CertTool.java
+++ b/core/java/android/webkit/CertTool.java
@@ -29,6 +29,7 @@ import android.util.Log;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
+import java.util.HashMap;
class CertTool {
private static final String LOGTAG = "CertTool";
@@ -39,6 +40,14 @@ class CertTool {
static final String CERT = Credentials.CERTIFICATE;
static final String PKCS12 = Credentials.PKCS12;
+ private static HashMap<String, String> sCertificateTypeMap;
+ static {
+ sCertificateTypeMap = new HashMap<String, String>();
+ sCertificateTypeMap.put("application/x-x509-ca-cert", CertTool.CERT);
+ sCertificateTypeMap.put("application/x-x509-user-cert", CertTool.CERT);
+ sCertificateTypeMap.put("application/x-pkcs12", CertTool.PKCS12);
+ }
+
static String[] getKeyStrengthList() {
return new String[] {"High Grade", "Medium Grade"};
}
@@ -66,5 +75,9 @@ class CertTool {
Credentials.getInstance().install(context, type, value);
}
+ static String getCertType(String mimeType) {
+ return sCertificateTypeMap.get(mimeType);
+ }
+
private CertTool() {}
}
diff --git a/core/java/android/webkit/KeyStoreHandler.java b/core/java/android/webkit/KeyStoreHandler.java
new file mode 100644
index 0000000..849007e
--- /dev/null
+++ b/core/java/android/webkit/KeyStoreHandler.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2011 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 android.webkit;
+
+import android.content.Context;
+import android.os.Handler;
+import android.util.Log;
+
+/**
+ * KeyStoreHandler: class responsible for certificate installation to
+ * the system key store. It reads the certificates file from network
+ * then pass the bytes to class CertTool.
+ * This class is only needed if the Chromium HTTP stack is used.
+ */
+class KeyStoreHandler extends Handler {
+ private static final String LOGTAG = "KeyStoreHandler";
+
+ private final ByteArrayBuilder mDataBuilder = new ByteArrayBuilder();
+
+ private String mMimeType;
+
+ public KeyStoreHandler(String mimeType) {
+ mMimeType = mimeType;
+ }
+
+ /**
+ * Add data to the internal collection of data.
+ * @param data A byte array containing the content.
+ * @param length The length of data.
+ */
+ public void didReceiveData(byte[] data, int length) {
+ synchronized (mDataBuilder) {
+ mDataBuilder.append(data, 0, length);
+ }
+ }
+
+ public void installCert(Context context) {
+ String type = CertTool.getCertType(mMimeType);
+ if (type == null) return;
+
+ // This must be synchronized so that no more data can be added
+ // after getByteSize returns.
+ synchronized (mDataBuilder) {
+ // In the case of downloading certificate, we will save it
+ // to the KeyStore and stop the current loading so that it
+ // will not generate a new history page
+ byte[] cert = new byte[mDataBuilder.getByteSize()];
+ int offset = 0;
+ while (true) {
+ ByteArrayBuilder.Chunk c = mDataBuilder.getFirstChunk();
+ if (c == null) break;
+
+ if (c.mLength != 0) {
+ System.arraycopy(c.mArray, 0, cert, offset, c.mLength);
+ offset += c.mLength;
+ }
+ c.release();
+ }
+ CertTool.addCertificate(context, type, cert);
+ return;
+ }
+ }
+}
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java
index 6d1d39a..04af738 100644
--- a/core/java/android/webkit/LoadListener.java
+++ b/core/java/android/webkit/LoadListener.java
@@ -75,14 +75,6 @@ class LoadListener extends Handler implements EventHandler {
private static final int HTTP_NOT_FOUND = 404;
private static final int HTTP_PROXY_AUTH = 407;
- private static HashMap<String, String> sCertificateTypeMap;
- static {
- sCertificateTypeMap = new HashMap<String, String>();
- sCertificateTypeMap.put("application/x-x509-ca-cert", CertTool.CERT);
- sCertificateTypeMap.put("application/x-x509-user-cert", CertTool.CERT);
- sCertificateTypeMap.put("application/x-pkcs12", CertTool.PKCS12);
- }
-
private static int sNativeLoaderCount;
private final ByteArrayBuilder mDataBuilder = new ByteArrayBuilder();
@@ -1053,7 +1045,7 @@ class LoadListener extends Handler implements EventHandler {
// This commits the headers without checking the response status code.
private void commitHeaders() {
- if (mIsMainPageLoader && sCertificateTypeMap.containsKey(mMimeType)) {
+ if (mIsMainPageLoader && CertTool.getCertType(mMimeType) != null) {
// In the case of downloading certificate, we will save it to the
// KeyStore in commitLoad. Do not call webcore.
return;
@@ -1114,7 +1106,7 @@ class LoadListener extends Handler implements EventHandler {
}
if (mIsMainPageLoader) {
- String type = sCertificateTypeMap.get(mMimeType);
+ String type = CertTool.getCertType(mMimeType);
if (type != null) {
// This must be synchronized so that no more data can be added
// after getByteSize returns.
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 2a2b3af..6363299 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -673,6 +673,7 @@ public class WebView extends AbsoluteLayout
static final int AUTOFILL_COMPLETE = 134;
static final int SELECT_AT = 135;
+ static final int SCREEN_ON = 136;
private static final int FIRST_PACKAGE_MSG_ID = SCROLL_TO_MSG_ID;
private static final int LAST_PACKAGE_MSG_ID = SET_TOUCH_HIGHLIGHT_RECTS;
@@ -726,7 +727,8 @@ public class WebView extends AbsoluteLayout
"SAVE_WEBARCHIVE_FINISHED", // = 132;
"SET_AUTOFILLABLE", // = 133;
"AUTOFILL_COMPLETE", // = 134;
- "SELECT_AT" // = 135;
+ "SELECT_AT", // = 135;
+ "SCREEN_ON" // = 136;
};
// If the site doesn't use the viewport meta tag to specify the viewport,
@@ -7454,6 +7456,10 @@ public class WebView extends AbsoluteLayout
doMotionUp(msg.arg1, msg.arg2);
break;
+ case SCREEN_ON:
+ setKeepScreenOn(msg.arg1 == 1);
+ break;
+
case SHOW_FULLSCREEN: {
View view = (View) msg.obj;
int npp = msg.arg1;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 27bf51c..3bde000 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2549,6 +2549,15 @@ final class WebViewCore {
}
// called by JNI
+ private void keepScreenOn(boolean screenOn) {
+ if (mWebView != null) {
+ Message message = mWebView.mPrivateHandler.obtainMessage(WebView.SCREEN_ON);
+ message.arg1 = screenOn ? 1 : 0;
+ message.sendToTarget();
+ }
+ }
+
+ // called by JNI
private Class<?> getPluginClass(String libName, String clsName) {
if (mWebView == null) {
diff --git a/core/java/android/widget/ListPopupWindow.java b/core/java/android/widget/ListPopupWindow.java
index 5dc42e4..8116a12 100644
--- a/core/java/android/widget/ListPopupWindow.java
+++ b/core/java/android/widget/ListPopupWindow.java
@@ -190,6 +190,7 @@ public class ListPopupWindow {
public ListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
mContext = context;
mPopup = new PopupWindow(context, attrs, defStyleAttr, defStyleRes);
+ mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
}
/**
@@ -576,7 +577,6 @@ public class ListPopupWindow {
}
mPopup.setWindowLayoutMode(widthSpec, heightSpec);
- mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
mPopup.setClipToScreenEnabled(true);
// use outside touchable to dismiss drop down when touching outside of it, so
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index 0baddcb..a92272c 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -665,6 +665,7 @@ public class Spinner extends AbsSpinner implements OnClickListener {
@Override
public void show() {
setWidth(Spinner.this.getWidth());
+ setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
super.show();
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
setSelection(Spinner.this.getSelectedItemPosition());
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 213117d..b217052 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3320,7 +3320,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
} else if (actionCode == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null) {
+ if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
return;
@@ -4822,9 +4822,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (mOnClickListener == null) {
if (mMovement != null && mText instanceof Editable
&& mLayout != null && onCheckIsTextEditor()) {
- InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(this, 0);
+ InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) imm.showSoftInput(this, 0);
}
}
}
@@ -4877,7 +4876,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// No target for next focus, but make sure the IME
// if this came from it.
InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null) {
+ if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getWindowToken(), 0);
}
}
@@ -7149,10 +7148,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// the IME. Showing the IME while focus is moved using the D-Pad is a bad idea, however this
// does not happen in that case (using the arrows on a bluetooth keyboard).
if (focused && isTextEditable()) {
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-
- imm.showSoftInput(this, 0, null);
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) imm.showSoftInput(this, 0, null);
}
}
@@ -7346,10 +7343,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Show the IME, except when selecting in read-only text.
if (!mTextIsSelectable) {
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
-
- handled |= imm.showSoftInput(this, 0, csr) && (csr != null);
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ handled |= imm != null && imm.showSoftInput(this, 0, csr) && (csr != null);
}
stopSelectionActionMode();
@@ -8204,6 +8199,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* {@link android.R.id#selectAll}, {@link android.R.id#cut}, {@link android.R.id#copy} or
* {@link android.R.id#paste} ids as parameters.
*
+ * Returning false from {@link ActionMode.Callback#onCreateActionMode(ActionMode, Menu)} will
+ * prevent the action mode from being started.
+ *
* Action click events should be handled by the custom implementation of
* {@link ActionMode.Callback#onActionItemClicked(ActionMode, MenuItem)}.
*
@@ -8244,16 +8242,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
selectCurrentWord();
}
- if (!mTextIsSelectable) {
- // Show the IME, except when selection non editable text.
- final InputMethodManager imm = (InputMethodManager)
- getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(this, 0, null);
- }
-
ActionMode.Callback actionModeCallback = new SelectionActionModeCallback();
mSelectionActionMode = startActionMode(actionModeCallback);
- return mSelectionActionMode != null;
+ final boolean selectionStarted = mSelectionActionMode != null;
+
+ if (selectionStarted && !mTextIsSelectable) {
+ // Show the IME to be able to replace text, except when selecting non editable text.
+ final InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null) imm.showSoftInput(this, 0, null);
+ }
+
+ return selectionStarted;
}
/**
@@ -8364,7 +8363,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
styledAttributes.recycle();
if (mCustomSelectionActionModeCallback != null) {
- mCustomSelectionActionModeCallback.onCreateActionMode(mode, menu);
+ if (!mCustomSelectionActionModeCallback.onCreateActionMode(mode, menu)) {
+ // The custom mode can choose to cancel the action mode
+ return false;
+ }
}
if (menu.hasVisibleItems() || mode.getCustomView() != null) {