Merge "[Renderscript] JAVA API update for Allocation.CopyTo add the following functions to make it more symmetric to copyFrom()."
diff --git a/core/java/android/webkit/WebMessage.java b/core/java/android/webkit/WebMessage.java
new file mode 100644
index 0000000..73ee03b
--- /dev/null
+++ b/core/java/android/webkit/WebMessage.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2015 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;
+
+/**
+ * The Java representation of the HTML5 PostMessage event. See
+ * https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces
+ * for definition of a MessageEvent in HTML5.
+ *
+ * @hide unhide when implementation is complete
+ */
+public class WebMessage {
+
+ private String mData;
+ private WebMessagePort[] mPorts;
+
+ /**
+ * Creates a WebMessage.
+ * @param data the data of the message.
+ */
+ public WebMessage(String data) {
+ mData = data;
+ }
+
+ /**
+ * Creates a WebMessage.
+ * @param data the data of the message.
+ * @param ports the ports array that are sent with the message.
+ */
+ public WebMessage(String data, WebMessagePort[] ports) {
+ mData = data;
+ mPorts = ports;
+ }
+
+ /**
+ * Returns the data of the message.
+ */
+ public String getData() {
+ return mData;
+ }
+
+ /**
+ * Returns the ports that are sent with the message, or null if no port
+ * is sent.
+ */
+ public WebMessagePort[] getPorts() {
+ return mPorts;
+ }
+}
diff --git a/core/java/android/webkit/WebMessagePort.java b/core/java/android/webkit/WebMessagePort.java
new file mode 100644
index 0000000..f4347a5
--- /dev/null
+++ b/core/java/android/webkit/WebMessagePort.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 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.os.Handler;
+
+/**
+ * The Java representation of the HTML5 Message Port. See
+ * https://html.spec.whatwg.org/multipage/comms.html#messageport
+ * for definition of MessagePort in HTML5.
+ *
+ * A Message port represents one endpoint of a Message Channel. In Android
+ * webview, there is no separate Message Channel object. When a message channel
+ * is created, both ports are tangled to each other and started, and then
+ * returned in a MessagePort array, see {@link WebView#createMessageChannel}
+ * for creating a message channel.
+ *
+ * When a message port is first created or received via transfer, it does not
+ * have a WebMessageListener to receive web messages. The messages are queued until
+ * a WebMessageListener is set.
+ *
+ * @hide unhide when implementation is complete
+ */
+public abstract class WebMessagePort {
+
+ /**
+ * The listener for handling MessagePort events. The message listener
+ * methods are called on the main thread. If the embedder application
+ * wants to receive the messages on a different thread, it can do this
+ * by passing a Handler in {@link setWebMessageListener(WebMessageListener, Handler)}.
+ * In the latter case, the application should be extra careful for thread safety
+ * since WebMessagePort methods should be called on main thread.
+ */
+ public static abstract class WebMessageListener {
+ /**
+ * Message listener for receiving onMessage events.
+ *
+ * @param port The WebMessagePort that the message is destined for
+ * @param message The message from the entangled port.
+ */
+ public abstract void onMessage(WebMessagePort port, WebMessage message);
+ }
+
+ /**
+ * Post a WebMessage to the entangled port.
+ *
+ * @param The message.
+ *
+ * @throws IllegalStateException If message port is already transferred or closed.
+ */
+ public abstract void postMessage(WebMessage message);
+
+ /**
+ * Close the message port and free any resources associated with it.
+ */
+ public abstract void close();
+
+ /**
+ * Sets a listener to receive message events on the main thread.
+ *
+ * @param listener The message listener.
+ */
+ public abstract void setWebMessageListener(WebMessageListener listener);
+
+ /**
+ * Sets a listener to receive message events on the handler that is provided
+ * by the application.
+ *
+ * @param listener The message listener.
+ * @param handler The handler to receive the message messages.
+ */
+ public abstract void setWebMessageListener(WebMessageListener listener, Handler handler);
+}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6793634..230c498 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -27,6 +27,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.http.SslCertificate;
+import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
@@ -1788,6 +1789,35 @@
}
/**
+ * Creates a message channel to communicate with JS and returns the message
+ * ports that represent the endpoints of this message channel. The HTML5 message
+ * channel functionality is described here:
+ * https://html.spec.whatwg.org/multipage/comms.html#messagechannel
+ *
+ * The returned message channels are entangled and already in started state.
+ *
+ * @return Two message ports that form the message channel.
+ *
+ * @hide unhide when implementation is complete
+ */
+ public WebMessagePort[] createWebMessageChannel() {
+ checkThread();
+ if (TRACE) Log.d(LOGTAG, "createWebMessageChannel");
+ return mProvider.createWebMessageChannel();
+ }
+
+ /**
+ * Post a message to main frame.
+ *
+ * @hide unhide when implementation is complete
+ */
+ public void postMessageToMainFrame(WebMessage message, Uri targetOrigin) {
+ checkThread();
+ if (TRACE) Log.d(LOGTAG, "postMessageToMainFrame. TargetOrigin=" + targetOrigin);
+ mProvider.postMessageToMainFrame(message, targetOrigin);
+ }
+
+ /**
* Gets the WebSettings object used to control the settings for this
* WebView.
*
diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java
index 2aee57b..2d8f1e4 100644
--- a/core/java/android/webkit/WebViewProvider.java
+++ b/core/java/android/webkit/WebViewProvider.java
@@ -228,6 +228,10 @@
public void removeJavascriptInterface(String interfaceName);
+ public WebMessagePort[] createWebMessageChannel();
+
+ public void postMessageToMainFrame(WebMessage message, Uri targetOrigin);
+
public WebSettings getSettings();
public void setMapTrackballToArrowKeys(boolean setMap);
diff --git a/core/java/android/widget/DatePickerCalendarDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java
old mode 100644
new mode 100755
index e71b383..69a2b06
--- a/core/java/android/widget/DatePickerCalendarDelegate.java
+++ b/core/java/android/widget/DatePickerCalendarDelegate.java
@@ -114,8 +114,8 @@
mTempDate = getCalendarForLocale(mMaxDate, locale);
mCurrentDate = getCalendarForLocale(mCurrentDate, locale);
- mMinDate.set(DEFAULT_START_YEAR, 1, 1);
- mMaxDate.set(DEFAULT_END_YEAR, 12, 31);
+ mMinDate.set(DEFAULT_START_YEAR, Calendar.JANUARY, 1);
+ mMaxDate.set(DEFAULT_END_YEAR, Calendar.DECEMBER, 31);
final Resources res = mDelegator.getResources();
final TypedArray a = mContext.obtainStyledAttributes(attrs,
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index d070c97..20ece24 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -5,7 +5,7 @@
LOCAL_CFLAGS += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA
LOCAL_CFLAGS += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL
LOCAL_CFLAGS += -U__APPLE__
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-int-to-pointer-cast
+LOCAL_CFLAGS += -Wno-unused-parameter
LOCAL_CFLAGS += -Wno-non-virtual-dtor
LOCAL_CFLAGS += -Wno-maybe-uninitialized -Wno-parentheses
LOCAL_CPPFLAGS += -Wno-conversion-null
diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp
index 1afcf73..36f7963 100644
--- a/core/jni/android_opengl_EGL14.cpp
+++ b/core/jni/android_opengl_EGL14.cpp
@@ -160,7 +160,8 @@
android_eglGetDisplayInt
(JNIEnv *_env, jobject _this, jint display_id) {
- if ((EGLNativeDisplayType)display_id != EGL_DEFAULT_DISPLAY) {
+ if (static_cast<uintptr_t>(display_id) !=
+ reinterpret_cast<uintptr_t>(EGL_DEFAULT_DISPLAY)) {
jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglGetDisplay");
return 0;
}
diff --git a/core/jni/android_opengl_GLES30.cpp b/core/jni/android_opengl_GLES30.cpp
index 713fff9..226162d 100644
--- a/core/jni/android_opengl_GLES30.cpp
+++ b/core/jni/android_opengl_GLES30.cpp
@@ -1935,7 +1935,11 @@
(GLsizei *)length,
(GLint *)size,
(GLenum *)type,
- (char *)name
+ // The cast below is incorrect. The driver will end up writing to the
+ // address specified by name, which will always crash the process since
+ // it is guaranteed to be in low memory. The additional static_cast
+ // suppresses the warning for now. http://b/19478262
+ (char *)static_cast<uintptr_t>(name)
);
if (_typeArray) {
releasePointer(_env, _typeArray, type, JNI_TRUE);
@@ -3643,7 +3647,7 @@
(GLenum)mode,
(GLsizei)count,
(GLenum)type,
- (GLvoid *)indicesOffset,
+ (GLvoid *)static_cast<uintptr_t>(indicesOffset),
(GLsizei)instanceCount
);
}
diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp
index 6c95b8a..5cb8b2e 100644
--- a/core/jni/android_util_EventLog.cpp
+++ b/core/jni/android_util_EventLog.cpp
@@ -188,6 +188,10 @@
break;
}
+ if (log_msg.id() != LOG_ID_EVENTS) {
+ continue;
+ }
+
int32_t tag = * (int32_t *) log_msg.msg();
int found = 0;
diff --git a/rs/java/android/renderscript/AllocationAdapter.java b/rs/java/android/renderscript/AllocationAdapter.java
index 9e28f7c..183726f 100644
--- a/rs/java/android/renderscript/AllocationAdapter.java
+++ b/rs/java/android/renderscript/AllocationAdapter.java
@@ -72,17 +72,19 @@
private void updateOffsets() {
int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
- if (mSelectedArray.length > 0) {
- a1 = mSelectedArray[0];
- }
- if (mSelectedArray.length > 1) {
- a2 = mSelectedArray[2];
- }
- if (mSelectedArray.length > 2) {
- a3 = mSelectedArray[2];
- }
- if (mSelectedArray.length > 3) {
- a4 = mSelectedArray[3];
+ if (mSelectedArray != null) {
+ if (mSelectedArray.length > 0) {
+ a1 = mSelectedArray[0];
+ }
+ if (mSelectedArray.length > 1) {
+ a2 = mSelectedArray[2];
+ }
+ if (mSelectedArray.length > 2) {
+ a3 = mSelectedArray[2];
+ }
+ if (mSelectedArray.length > 3) {
+ a4 = mSelectedArray[3];
+ }
}
mRS.nAllocationAdapterOffset(getID(mRS), mSelectedX, mSelectedY, mSelectedZ,
mSelectedLOD, mSelectedFace.mID, a1, a2, a3, a4);