summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/view/HardwareRenderer.java90
-rwxr-xr-xcore/java/android/view/InputDevice.java10
-rw-r--r--core/java/android/view/KeyCharacterMap.java15
-rw-r--r--core/java/android/view/WindowManagerImpl.java3
-rw-r--r--core/java/android/view/textservice/SpellCheckerSession.java3
-rw-r--r--core/java/android/webkit/WebSettings.java2
-rw-r--r--core/java/android/webkit/WebView.java10
-rw-r--r--core/java/android/webkit/WebViewCore.java5
-rw-r--r--core/java/android/webkit/ZoomManager.java2
-rw-r--r--core/java/android/widget/TextView.java4
10 files changed, 98 insertions, 46 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index e0167d8..8e39d6e 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -22,6 +22,9 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.opengl.GLUtils;
+import android.opengl.ManagedEGLContext;
+import android.os.Handler;
+import android.os.Looper;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.Log;
@@ -409,7 +412,8 @@ public abstract class HardwareRenderer {
static final Object[] sEglLock = new Object[0];
int mWidth = -1, mHeight = -1;
- static final ThreadLocal<EGLContext> sEglContextStorage = new ThreadLocal<EGLContext>();
+ static final ThreadLocal<Gl20Renderer.MyEGLContext> sEglContextStorage
+ = new ThreadLocal<Gl20Renderer.MyEGLContext>();
EGLContext mEglContext;
Thread mEglThread;
@@ -561,12 +565,13 @@ public abstract class HardwareRenderer {
}
}
- mEglContext = sEglContextStorage.get();
+ Gl20Renderer.MyEGLContext managedContext = sEglContextStorage.get();
+ mEglContext = managedContext != null ? managedContext.getContext() : null;
mEglThread = Thread.currentThread();
if (mEglContext == null) {
mEglContext = createContext(sEgl, sEglDisplay, sEglConfig);
- sEglContextStorage.set(mEglContext);
+ sEglContextStorage.set(new Gl20Renderer.MyEGLContext(mEglContext));
}
}
@@ -904,6 +909,51 @@ public abstract class HardwareRenderer {
private static EGLSurface sPbuffer;
private static final Object[] sPbufferLock = new Object[0];
+ static class MyEGLContext extends ManagedEGLContext {
+ final Handler mHandler = new Handler();
+
+ public MyEGLContext(EGLContext context) {
+ super(context);
+ }
+
+ @Override
+ public void onTerminate(final EGLContext eglContext) {
+ // Make sure we do this on the correct thread.
+ if (mHandler.getLooper() != Looper.myLooper()) {
+ mHandler.post(new Runnable() {
+ @Override public void run() {
+ onTerminate(eglContext);
+ }
+ });
+ return;
+ }
+
+ synchronized (sEglLock) {
+ if (sEgl == null) return;
+
+ if (EGLImpl.getInitCount(sEglDisplay) == 1) {
+ usePbufferSurface(eglContext);
+ GLES20Canvas.terminateCaches();
+
+ sEgl.eglDestroyContext(sEglDisplay, eglContext);
+ sEglContextStorage.remove();
+
+ sEgl.eglDestroySurface(sEglDisplay, sPbuffer);
+ sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+ sEgl.eglReleaseThread();
+ sEgl.eglTerminate(sEglDisplay);
+
+ sEgl = null;
+ sEglDisplay = null;
+ sEglConfig = null;
+ sPbuffer = null;
+ sEglContextStorage.set(null);
+ }
+ }
+ }
+ }
+
Gl20Renderer(boolean translucent) {
super(2, translucent);
}
@@ -1020,12 +1070,12 @@ public abstract class HardwareRenderer {
static void trimMemory(int level) {
if (sEgl == null || sEglConfig == null) return;
- EGLContext eglContext = sEglContextStorage.get();
+ Gl20Renderer.MyEGLContext managedContext = sEglContextStorage.get();
// We do not have OpenGL objects
- if (eglContext == null) {
+ if (managedContext == null) {
return;
} else {
- usePbufferSurface(eglContext);
+ usePbufferSurface(managedContext.getContext());
}
switch (level) {
@@ -1052,33 +1102,5 @@ public abstract class HardwareRenderer {
}
sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext);
}
-
- static void terminate() {
- synchronized (sEglLock) {
- if (sEgl == null) return;
-
- if (EGLImpl.getInitCount(sEglDisplay) == 1) {
- EGLContext eglContext = sEglContextStorage.get();
- if (eglContext == null) return;
-
- usePbufferSurface(eglContext);
- GLES20Canvas.terminateCaches();
-
- sEgl.eglDestroyContext(sEglDisplay, eglContext);
- sEglContextStorage.remove();
-
- sEgl.eglDestroySurface(sEglDisplay, sPbuffer);
- sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-
- sEgl.eglReleaseThread();
- sEgl.eglTerminate(sEglDisplay);
-
- sEgl = null;
- sEglDisplay = null;
- sEglConfig = null;
- sPbuffer = null;
- }
- }
- }
}
}
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index bfc7c31..8115b36 100755
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -19,7 +19,6 @@ package android.view;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
-import android.os.ServiceManager;
import java.util.ArrayList;
import java.util.List;
@@ -44,6 +43,7 @@ public final class InputDevice implements Parcelable {
private String mName;
private int mSources;
private int mKeyboardType;
+ private String mKeyCharacterMapFile;
private final ArrayList<MotionRange> mMotionRanges = new ArrayList<MotionRange>();
@@ -360,6 +360,10 @@ public final class InputDevice implements Parcelable {
return KeyCharacterMap.load(mId);
}
+ String getKeyCharacterMapFile() {
+ return mKeyCharacterMapFile;
+ }
+
/**
* Gets information about the range of values for a particular {@link MotionEvent} axis.
* If the device supports multiple sources, the same axis may have different meanings
@@ -532,6 +536,7 @@ public final class InputDevice implements Parcelable {
mName = in.readString();
mSources = in.readInt();
mKeyboardType = in.readInt();
+ mKeyCharacterMapFile = in.readString();
for (;;) {
int axis = in.readInt();
@@ -549,6 +554,7 @@ public final class InputDevice implements Parcelable {
out.writeString(mName);
out.writeInt(mSources);
out.writeInt(mKeyboardType);
+ out.writeString(mKeyCharacterMapFile);
final int numRanges = mMotionRanges.size();
for (int i = 0; i < numRanges; i++) {
@@ -587,6 +593,8 @@ public final class InputDevice implements Parcelable {
}
description.append("\n");
+ description.append(" Key Character Map: ").append(mKeyCharacterMapFile).append("\n");
+
description.append(" Sources: 0x").append(Integer.toHexString(mSources)).append(" (");
appendSourceDescriptionIfApplicable(description, SOURCE_KEYBOARD, "keyboard");
appendSourceDescriptionIfApplicable(description, SOURCE_DPAD, "dpad");
diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java
index 885a75f..575af3b 100644
--- a/core/java/android/view/KeyCharacterMap.java
+++ b/core/java/android/view/KeyCharacterMap.java
@@ -20,7 +20,6 @@ import android.text.method.MetaKeyKeyListener;
import android.util.AndroidRuntimeException;
import android.util.SparseIntArray;
import android.os.RemoteException;
-import android.os.ServiceManager;
import android.util.SparseArray;
import java.lang.Character;
@@ -140,7 +139,7 @@ public class KeyCharacterMap {
private final int mDeviceId;
private int mPtr;
- private static native int nativeLoad(int id);
+ private static native int nativeLoad(String file);
private static native void nativeDispose(int ptr);
private static native char nativeGetCharacter(int ptr, int keyCode, int metaState);
@@ -178,7 +177,17 @@ public class KeyCharacterMap {
synchronized (sInstances) {
KeyCharacterMap map = sInstances.get(deviceId);
if (map == null) {
- int ptr = nativeLoad(deviceId); // might throw
+ String kcm = null;
+ if (deviceId != VIRTUAL_KEYBOARD) {
+ InputDevice device = InputDevice.getDevice(deviceId);
+ if (device != null) {
+ kcm = device.getKeyCharacterMapFile();
+ }
+ }
+ if (kcm == null || kcm.length() == 0) {
+ kcm = "/system/usr/keychars/Virtual.kcm";
+ }
+ int ptr = nativeLoad(kcm); // might throw
map = new KeyCharacterMap(deviceId, ptr);
sInstances.put(deviceId, map);
}
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index d89bc36..660e3f4 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -21,6 +21,7 @@ import android.content.ComponentCallbacks2;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
+import android.opengl.ManagedEGLContext;
import android.os.IBinder;
import android.util.AndroidRuntimeException;
import android.util.Log;
@@ -428,7 +429,7 @@ public class WindowManagerImpl implements WindowManager {
}
}
// Terminate the hardware renderer to free all resources
- HardwareRenderer.terminate();
+ ManagedEGLContext.doTerminate();
break;
}
// high end gfx devices fall through to next case
diff --git a/core/java/android/view/textservice/SpellCheckerSession.java b/core/java/android/view/textservice/SpellCheckerSession.java
index 0eb6e27..489587e 100644
--- a/core/java/android/view/textservice/SpellCheckerSession.java
+++ b/core/java/android/view/textservice/SpellCheckerSession.java
@@ -201,7 +201,7 @@ public class SpellCheckerSession {
private static final int TASK_CLOSE = 3;
private final Queue<SpellCheckerParams> mPendingTasks =
new LinkedList<SpellCheckerParams>();
- private final Handler mHandler;
+ private Handler mHandler;
private boolean mOpened;
private ISpellCheckerSession mISpellCheckerSession;
@@ -334,6 +334,7 @@ public class SpellCheckerSession {
try {
mISpellCheckerSession.onClose();
mISpellCheckerSession = null;
+ mHandler = null;
} catch (RemoteException e) {
Log.e(TAG, "Failed to close " + e);
}
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index f240a2e..0c3f94e 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -799,7 +799,7 @@ public class WebSettings {
public void setDefaultZoom(ZoomDensity zoom) {
if (mDefaultZoom != zoom) {
mDefaultZoom = zoom;
- mWebView.updateDefaultZoomDensity(zoom.value);
+ mWebView.adjustDefaultZoomDensity(zoom.value);
}
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index ec2f55b..907e8db 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1341,9 +1341,13 @@ public class WebView extends AbsoluteLayout
}
}
- /* package */void updateDefaultZoomDensity(int zoomDensity) {
+ /* package */ void adjustDefaultZoomDensity(int zoomDensity) {
final float density = mContext.getResources().getDisplayMetrics().density
* 100 / zoomDensity;
+ updateDefaultZoomDensity(density);
+ }
+
+ /* package */ void updateDefaultZoomDensity(float density) {
mNavSlop = (int) (16 * density);
mZoomManager.updateDefaultZoomDensity(density);
}
@@ -2469,7 +2473,9 @@ public class WebView extends AbsoluteLayout
* Set the initial scale for the WebView. 0 means default. If
* {@link WebSettings#getUseWideViewPort()} is true, it zooms out all the
* way. Otherwise it starts with 100%. If initial scale is greater than 0,
- * WebView starts will this value as initial scale.
+ * WebView starts with this value as initial scale.
+ * Please note that unlike the scale properties in the viewport meta tag,
+ * this method doesn't take the screen density into account.
*
* @param scaleInPercent The initial scale in percent.
*/
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index cd61481..a97f4dd 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2336,6 +2336,9 @@ public final class WebViewCore {
adjust = (float) mContext.getResources().getDisplayMetrics().densityDpi
/ mViewportDensityDpi;
}
+ if (adjust != mWebView.getDefaultZoomScale()) {
+ mWebView.updateDefaultZoomDensity(adjust);
+ }
int defaultScale = (int) (adjust * 100);
if (mViewportInitialScale > 0) {
@@ -2546,7 +2549,7 @@ public final class WebViewCore {
// called by JNI
private void restoreScale(float scale, float textWrapScale) {
if (mBrowserFrame.firstLayoutDone() == false) {
- mIsRestored = scale > 0;
+ mIsRestored = true;
mRestoredScale = scale;
if (mSettings.getUseWideViewPort()) {
mRestoredTextWrapScale = textWrapScale;
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index f599dba..84d00c9 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -349,7 +349,7 @@ class ZoomManager {
}
public final void setInitialScaleInPercent(int scaleInPercent) {
- mInitialScale = scaleInPercent * mDisplayDensity * 0.01f;
+ mInitialScale = scaleInPercent * 0.01f;
}
public final float computeScaleWithLimits(float scale) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index f422f60..185cfa9 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -3785,7 +3785,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
}
-
+
// This is the handling for some default action.
// Note that for backwards compatibility we don't do this
// default handling if explicit ime options have not been given,
@@ -5594,6 +5594,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
outAttrs.extras = mInputContentType.extras;
} else {
outAttrs.imeOptions = EditorInfo.IME_NULL;
+ // May not be defined otherwise and needed by onEditorAction
+ mInputContentType = new InputContentType();
}
if (focusSearch(FOCUS_DOWN) != null) {
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;