Merge "Support for tapping on an immersive-mode priority notification." into gingerbread
diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp
index 5e5e47e..a22b353 100644
--- a/core/jni/android_app_NativeActivity.cpp
+++ b/core/jni/android_app_NativeActivity.cpp
@@ -29,7 +29,7 @@
 {
 
 struct NativeCode {
-    NativeCode(void* _dlhandle, android_activity_create_t* _createFunc) {
+    NativeCode(void* _dlhandle, ANativeActivity_createFunc* _createFunc) {
         memset(&activity, sizeof(activity), 0);
         memset(&callbacks, sizeof(callbacks), 0);
         dlhandle = _dlhandle;
@@ -73,7 +73,7 @@
             sp<InputChannel> ic =
                     android_view_InputChannel_getInputChannel(activity.env, _channel);
             if (ic != NULL) {
-                nativeInputQueue = new input_queue_t(ic);
+                nativeInputQueue = new AInputQueue(ic);
                 if (nativeInputQueue->getConsumer().initialize() != android::OK) {
                     delete nativeInputQueue;
                     nativeInputQueue = NULL;
@@ -86,15 +86,15 @@
         return OK;
     }
     
-    android_activity_t activity;
-    android_activity_callbacks_t callbacks;
+    ANativeActivity activity;
+    ANativeActivityCallbacks callbacks;
     
     void* dlhandle;
-    android_activity_create_t* createActivityFunc;
+    ANativeActivity_createFunc* createActivityFunc;
     
     jobject surface;
     jobject inputChannel;
-    struct input_queue_t* nativeInputQueue;
+    struct AInputQueue* nativeInputQueue;
 };
 
 static jint
@@ -108,14 +108,19 @@
     env->ReleaseStringUTFChars(path, pathStr);
     
     if (handle != NULL) {
-        code = new NativeCode(handle, (android_activity_create_t*)
-                dlsym(handle, "android_onCreateActivity"));
+        code = new NativeCode(handle, (ANativeActivity_createFunc*)
+                dlsym(handle, "ANativeActivity_onCreate"));
         if (code->createActivityFunc == NULL) {
-            LOGW("android_onCreateActivity not found");
+            LOGW("ANativeActivity_onCreate not found");
             delete code;
             return 0;
         }
         code->activity.callbacks = &code->callbacks;
+        if (env->GetJavaVM(&code->activity.vm) < 0) {
+            LOGW("NativeActivity GetJavaVM failed");
+            delete code;
+            return 0;
+        }
         code->activity.env = env;
         code->activity.clazz = clazz;
         code->createActivityFunc(&code->activity, NULL, 0);
@@ -219,7 +224,7 @@
         code->setSurface(surface);
         if (code->callbacks.onSurfaceCreated != NULL) {
             code->callbacks.onSurfaceCreated(&code->activity,
-                    (android_surface_t*)code->surface);
+                    (ASurfaceHolder*)code->surface);
         }
     }
 }
@@ -232,7 +237,7 @@
         NativeCode* code = (NativeCode*)handle;
         if (code->surface != NULL && code->callbacks.onSurfaceChanged != NULL) {
             code->callbacks.onSurfaceChanged(&code->activity,
-                    (android_surface_t*)code->surface, format, width, height);
+                    (ASurfaceHolder*)code->surface, format, width, height);
         }
     }
 }
@@ -244,7 +249,7 @@
         NativeCode* code = (NativeCode*)handle;
         if (code->surface != NULL && code->callbacks.onSurfaceDestroyed != NULL) {
             code->callbacks.onSurfaceDestroyed(&code->activity,
-                    (android_surface_t*)code->surface);
+                    (ASurfaceHolder*)code->surface);
         }
         code->setSurface(NULL);
     }
diff --git a/core/tests/ConnectivityManagerTest/AndroidManifest.xml b/core/tests/ConnectivityManagerTest/AndroidManifest.xml
index 5480993..d298d40 100644
--- a/core/tests/ConnectivityManagerTest/AndroidManifest.xml
+++ b/core/tests/ConnectivityManagerTest/AndroidManifest.xml
@@ -43,6 +43,16 @@
         android:label="Test runner for Connectivity Manager Tests"
     />
 
+    <!--
+     To run the unit tests use the command:
+     "adb shell am instrument -w
+     com.android.connectivitymanagertest/.ConnectivityManagerUnitTestRunner"
+    -->
+    <instrumentation android:name=".ConnectivityManagerUnitTestRunner"
+        android:targetPackage="com.android.connectivitymanagertest"
+        android.label="Test runner for unit tests"
+    />
+
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerUnitTestRunner.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerUnitTestRunner.java
new file mode 100644
index 0000000..6adfc74
--- /dev/null
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerUnitTestRunner.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010, 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.connectivitymanagertest;
+
+import android.os.Bundle;
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+import android.util.Log;
+import com.android.connectivitymanagertest.unit.WifiSoftAPTest;
+
+import junit.framework.TestSuite;
+
+/**
+ * Instrumentation Test Runner for all unit tests
+ *
+ * adb shell am instrument \
+ *     -w com.android.connectivitymanagertest/.ConnectivityManagerUnitTestRunner
+ */
+
+public class ConnectivityManagerUnitTestRunner extends InstrumentationTestRunner {
+    @Override
+    public TestSuite getAllTests() {
+        TestSuite suite = new InstrumentationTestSuite(this);
+        suite.addTestSuite(WifiSoftAPTest.class);
+        return suite;
+    }
+
+
+    @Override
+    public ClassLoader getLoader() {
+        return ConnectivityManagerUnitTestRunner.class.getClassLoader();
+    }
+}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiSoftAPTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiSoftAPTest.java
new file mode 100644
index 0000000..3f43e48
--- /dev/null
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/unit/WifiSoftAPTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 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.connectivitymanagertest.unit;
+
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.Context;
+import android.app.Instrumentation;
+import android.os.Handler;
+import android.os.Message;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
+
+import android.test.suitebuilder.annotation.LargeTest;
+import android.test.AndroidTestCase;
+
+import java.util.ArrayList;
+
+import android.util.Log;
+
+/**
+ * Test Wifi soft AP configuration
+ */
+public class WifiSoftAPTest extends AndroidTestCase {
+
+    private WifiManager mWifiManager;
+    private WifiConfiguration mWifiConfig = null;
+    private final String TAG = "WifiSoftAPTest";
+    private final int DURATION = 10000;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
+        assertNotNull(mWifiManager);
+        assertTrue(mWifiManager.setWifiApEnabled(null, true));
+        mWifiConfig = mWifiManager.getWifiApConfiguration();
+        if (mWifiConfig != null) {
+            Log.v(TAG, "mWifiConfig is " + mWifiConfig.toString());
+        } else {
+            Log.v(TAG, "mWifiConfig is null.");
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        Log.v(TAG, "turn off wifi tethering");
+        mWifiManager.setWifiApEnabled(null, false);
+        super.tearDown();
+    }
+
+    // Test case 1: Test the soft AP SSID with letters
+    @LargeTest
+    public void testApSsidWithAlphabet() {
+        WifiConfiguration config = new WifiConfiguration();
+        config.SSID = "abcdefghijklmnopqrstuvwxyz";
+        config.allowedKeyManagement.set(KeyMgmt.NONE);
+        mWifiConfig = config;
+        assertTrue(mWifiManager.setWifiApEnabled(mWifiConfig, true));
+        try {
+            Thread.sleep(DURATION);
+        } catch (InterruptedException e) {
+            Log.v(TAG, "exception " + e.getStackTrace());
+            assertFalse(true);
+        }
+        assertNotNull(mWifiManager.getWifiApConfiguration());
+        assertEquals("wifi AP state is not enabled", WifiManager.WIFI_AP_STATE_ENABLED,
+                     mWifiManager.getWifiApState());
+    }
+}
diff --git a/include/ui/Input.h b/include/ui/Input.h
index 57b292b..8890789 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -43,7 +43,7 @@
 /*
  * Declare a concrete type for the NDK's input event forward declaration.
  */
-struct input_event_t { };
+struct AInputEvent { };
 
 namespace android {
 
@@ -136,7 +136,7 @@
 /*
  * Input events.
  */
-class InputEvent : public input_event_t {
+class InputEvent : public AInputEvent {
 public:
     virtual ~InputEvent() { }
 
diff --git a/include/ui/InputTransport.h b/include/ui/InputTransport.h
index d6bded6..4e76051 100644
--- a/include/ui/InputTransport.h
+++ b/include/ui/InputTransport.h
@@ -333,13 +333,13 @@
 /*
  * NDK input queue API.
  */
-struct input_queue_t {
+struct AInputQueue {
 public:
     /* Creates a consumer associated with an input channel. */
-    explicit input_queue_t(const android::sp<android::InputChannel>& channel);
+    explicit AInputQueue(const android::sp<android::InputChannel>& channel);
 
     /* Destroys the consumer and releases its input channel. */
-    ~input_queue_t();
+    ~AInputQueue();
 
     inline android::InputConsumer& getConsumer() { return mConsumer; }
     
diff --git a/libs/ui/InputTransport.cpp b/libs/ui/InputTransport.cpp
index f56537a..25def3c 100644
--- a/libs/ui/InputTransport.cpp
+++ b/libs/ui/InputTransport.cpp
@@ -691,7 +691,7 @@
 
 } // namespace android
 
-// --- input_queue_t ---
+// --- AInputQueue ---
 
 using android::InputEvent;
 using android::InputChannel;
@@ -699,13 +699,13 @@
 using android::sp;
 using android::status_t;
 
-input_queue_t::input_queue_t(const sp<InputChannel>& channel) :
+AInputQueue::AInputQueue(const sp<InputChannel>& channel) :
         mConsumer(channel) {
 }
 
-input_queue_t::~input_queue_t() {
+AInputQueue::~AInputQueue() {
 }
 
-status_t input_queue_t::consume(InputEvent** event) {
+status_t AInputQueue::consume(InputEvent** event) {
     return mConsumer.consume(&mInputEventFactory, event);
 }
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 02a073e..c01ea10 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -149,13 +149,16 @@
     { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.decode" },
     { MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder" },
 //    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.PV.aacdec" },
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.7x30.video.decoder.mpeg4" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.video.decoder.mpeg4" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.Decoder" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "M4vH263Decoder" },
 //    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.PV.mpeg4dec" },
+    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.7x30.video.decoder.h263" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.video.decoder.h263" },
     { MEDIA_MIMETYPE_VIDEO_H263, "M4vH263Decoder" },
 //    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.PV.h263dec" },
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.7x30.video.decoder.avc" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.video.decoder.avc" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.Video.Decoder" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "AVCDecoder" },
@@ -171,16 +174,19 @@
     { MEDIA_MIMETYPE_AUDIO_AMR_WB, "AMRWBEncoder" },
     { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.encode" },
     { MEDIA_MIMETYPE_AUDIO_AAC, "AACEncoder" },
-    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.PV.aacenc" },
+//    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.PV.aacenc" },
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.7x30.video.encoder.mpeg4" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.video.encoder.mpeg4" },
     { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.encoder" },
-    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.PV.mpeg4enc" },
+//    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.PV.mpeg4enc" },
+    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.7x30.video.encoder.h263" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.video.encoder.h263" },
     { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.Video.encoder" },
-    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.PV.h263enc" },
+//    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.PV.h263enc" },
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.7x30.video.encoder.avc" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.video.encoder.avc" },
     { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.Video.encoder" },
-    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.PV.avcenc" },
+//    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.PV.avcenc" },
 };
 
 #undef OPTIONAL
@@ -334,10 +340,17 @@
         quirks |= kRequiresAllocateBufferOnInputPorts;
         quirks |= kRequiresAllocateBufferOnOutputPorts;
     }
+    if (!strncmp(componentName, "OMX.qcom.7x30.video.encoder.", 28)) {
+    }
     if (!strncmp(componentName, "OMX.qcom.video.decoder.", 23)) {
         quirks |= kRequiresAllocateBufferOnOutputPorts;
         quirks |= kDefersOutputBufferAllocation;
     }
+    if (!strncmp(componentName, "OMX.qcom.7x30.video.decoder.", 28)) {
+        quirks |= kRequiresAllocateBufferOnInputPorts;
+        quirks |= kRequiresAllocateBufferOnOutputPorts;
+        quirks |= kDefersOutputBufferAllocation;
+    }
 
     if (!strncmp(componentName, "OMX.TI.", 7)) {
         // Apparently I must not use OMX_UseBuffer on either input or
diff --git a/native/android/input.cpp b/native/android/input.cpp
index 38d8567..e0544a1 100644
--- a/native/android/input.cpp
+++ b/native/android/input.cpp
@@ -27,168 +27,168 @@
 using android::KeyEvent;
 using android::MotionEvent;
 
-int32_t input_event_get_type(const input_event_t* event) {
+int32_t AInputEvent_getType(const AInputEvent* event) {
     return static_cast<const InputEvent*>(event)->getType();
 }
 
-int32_t input_event_get_device_id(const input_event_t* event) {
+int32_t AInputEvent_getDeviceId(const AInputEvent* event) {
     return static_cast<const InputEvent*>(event)->getDeviceId();
 }
 
-int32_t input_event_get_nature(const input_event_t* event) {
+int32_t AInputEvent_getNature(const AInputEvent* event) {
     return static_cast<const InputEvent*>(event)->getNature();
 }
 
-int32_t key_event_get_action(const input_event_t* key_event) {
+int32_t AKeyEvent_getAction(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getAction();
 }
 
-int32_t key_event_get_flags(const input_event_t* key_event) {
+int32_t AKeyEvent_getFlags(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getFlags();
 }
 
-int32_t key_event_get_key_code(const input_event_t* key_event) {
+int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getKeyCode();
 }
 
-int32_t key_event_get_scan_code(const input_event_t* key_event) {
+int32_t AKeyEvent_getScanCode(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getScanCode();
 }
 
-int32_t key_event_get_meta_state(const input_event_t* key_event) {
+int32_t AKeyEvent_getMetaState(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getMetaState();
 }
-int32_t key_event_get_repeat_count(const input_event_t* key_event) {
+int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getRepeatCount();
 }
 
-int64_t key_event_get_down_time(const input_event_t* key_event) {
+int64_t AKeyEvent_getDownTime(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getDownTime();
 }
 
-int64_t key_event_get_event_time(const input_event_t* key_event) {
+int64_t AKeyEvent_getEventTime(const AInputEvent* key_event) {
     return static_cast<const KeyEvent*>(key_event)->getEventTime();
 }
 
-int32_t motion_event_get_action(const input_event_t* motion_event) {
+int32_t AMotionEvent_getAction(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getAction();
 }
 
-int32_t motion_event_get_meta_state(const input_event_t* motion_event) {
+int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getMetaState();
 }
 
-int32_t motion_event_get_edge_flags(const input_event_t* motion_event) {
+int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event) {
     return reinterpret_cast<const MotionEvent*>(motion_event)->getEdgeFlags();
 }
 
-int64_t motion_event_get_down_time(const input_event_t* motion_event) {
+int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getDownTime();
 }
 
-int64_t motion_event_get_event_time(const input_event_t* motion_event) {
+int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getEventTime();
 }
 
-float motion_event_get_x_offset(const input_event_t* motion_event) {
+float AMotionEvent_getXOffset(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getXOffset();
 }
 
-float motion_event_get_y_offset(const input_event_t* motion_event) {
+float AMotionEvent_getYOffset(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getYOffset();
 }
 
-float motion_event_get_x_precision(const input_event_t* motion_event) {
+float AMotionEvent_getXPrecision(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getXPrecision();
 }
 
-float motion_event_get_y_precision(const input_event_t* motion_event) {
+float AMotionEvent_getYPrecision(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getYPrecision();
 }
 
-size_t motion_event_get_pointer_count(const input_event_t* motion_event) {
+size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getPointerCount();
 }
 
-int32_t motion_event_get_pointer_id(const input_event_t* motion_event, size_t pointer_index) {
+int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getPointerId(pointer_index);
 }
 
-float motion_event_get_raw_x(const input_event_t* motion_event, size_t pointer_index) {
+float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getRawX(pointer_index);
 }
 
-float motion_event_get_raw_y(const input_event_t* motion_event, size_t pointer_index) {
+float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getRawY(pointer_index);
 }
 
-float motion_event_get_x(const input_event_t* motion_event, size_t pointer_index) {
+float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getX(pointer_index);
 }
 
-float motion_event_get_y(const input_event_t* motion_event, size_t pointer_index) {
+float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getY(pointer_index);
 }
 
-float motion_event_get_pressure(const input_event_t* motion_event, size_t pointer_index) {
+float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getPressure(pointer_index);
 }
 
-float motion_event_get_size(const input_event_t* motion_event, size_t pointer_index) {
+float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index) {
     return static_cast<const MotionEvent*>(motion_event)->getSize(pointer_index);
 }
 
-size_t motion_event_get_history_size(const input_event_t* motion_event) {
+size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event) {
     return static_cast<const MotionEvent*>(motion_event)->getHistorySize();
 }
 
-int64_t motion_event_get_historical_event_time(input_event_t* motion_event,
+int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalEventTime(
             history_index);
 }
 
-float motion_event_get_historical_raw_x(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalRawX(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalRawX(
             pointer_index, history_index);
 }
 
-float motion_event_get_historical_raw_y(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalRawY(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalRawY(
             pointer_index, history_index);
 }
 
-float motion_event_get_historical_x(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalX(
             pointer_index, history_index);
 }
 
-float motion_event_get_historical_y(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalY(
             pointer_index, history_index);
 }
 
-float motion_event_get_historical_pressure(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalPressure(
             pointer_index, history_index);
 }
 
-float motion_event_get_historical_size(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index) {
     return static_cast<const MotionEvent*>(motion_event)->getHistoricalSize(
             pointer_index, history_index);
 }
 
-int input_queue_get_fd(input_queue_t* queue) {
+int AInputQueue_getFd(AInputQueue* queue) {
     return queue->getConsumer().getChannel()->getReceivePipeFd();
 }
 
-int input_queue_has_events(input_queue_t* queue) {
+int AInputQueue_hasEvents(AInputQueue* queue) {
     struct pollfd pfd;
     
     pfd.fd = queue->getConsumer().getChannel()->getReceivePipeFd();
@@ -200,7 +200,7 @@
     return pfd.revents == POLLIN ? 1 : -1;
 }
 
-int32_t input_queue_get_event(input_queue_t* queue, input_event_t** outEvent) {
+int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent) {
     *outEvent = NULL;
     
     int32_t res = queue->getConsumer().receiveDispatchSignal();
@@ -223,7 +223,7 @@
     return 0;
 }
 
-void input_queue_finish_event(input_queue_t* queue, input_event_t* event,
+void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event,
         int handled) {
     int32_t res = queue->getConsumer().sendFinishedSignal();
     if (res != android::OK) {
diff --git a/native/include/android/input.h b/native/include/android/input.h
index 2441af0..7617662 100644
--- a/native/include/android/input.h
+++ b/native/include/android/input.h
@@ -125,8 +125,8 @@
  * Input events are opaque structures.  Use the provided accessors functions to
  * read their properties.
  */
-struct input_event_t;
-typedef struct input_event_t input_event_t;
+struct AInputEvent;
+typedef struct AInputEvent AInputEvent;
 
 /*
  * Input event types.
@@ -319,7 +319,7 @@
 /*** Accessors for all input events. ***/
 
 /* Get the input event type. */
-int32_t input_event_get_type(const input_event_t* event);
+int32_t AInputEvent_getType(const AInputEvent* event);
 
 /* Get the id for the device that an input event came from.
  *
@@ -331,128 +331,128 @@
  * other numbers are arbitrary and you shouldn't depend on the values.
  * Use the provided input device query API to obtain information about input devices.
  */
-int32_t input_event_get_device_id(const input_event_t* event);
+int32_t AInputEvent_getDeviceId(const AInputEvent* event);
 
 /* Get the input event nature. */
-int32_t input_event_get_nature(const input_event_t* event);
+int32_t AInputEvent_getNature(const AInputEvent* event);
 
 /*** Accessors for key events only. ***/
 
 /* Get the key event action. */
-int32_t key_event_get_action(const input_event_t* key_event);
+int32_t AKeyEvent_getAction(const AInputEvent* key_event);
 
 /* Get the key event flags. */
-int32_t key_event_get_flags(const input_event_t* key_event);
+int32_t AKeyEvent_getFlags(const AInputEvent* key_event);
 
 /* Get the key code of the key event.
  * This is the physical key that was pressed, not the Unicode character. */
-int32_t key_event_get_key_code(const input_event_t* key_event);
+int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event);
 
 /* Get the hardware key id of this key event.
  * These values are not reliable and vary from device to device. */
-int32_t key_event_get_scan_code(const input_event_t* key_event);
+int32_t AKeyEvent_getScanCode(const AInputEvent* key_event);
 
 /* Get the meta key state. */
-int32_t key_event_get_meta_state(const input_event_t* key_event);
+int32_t AKeyEvent_getMetaState(const AInputEvent* key_event);
 
 /* Get the repeat count of the event.
  * For both key up an key down events, this is the number of times the key has
  * repeated with the first down starting at 0 and counting up from there.  For
  * multiple key events, this is the number of down/up pairs that have occurred. */
-int32_t key_event_get_repeat_count(const input_event_t* key_event);
+int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event);
 
 /* Get the time of the most recent key down event, in the
  * java.lang.System.nanoTime() time base.  If this is a down event,
  * this will be the same as eventTime.
  * Note that when chording keys, this value is the down time of the most recently
  * pressed key, which may not be the same physical key of this event. */
-int64_t key_event_get_down_time(const input_event_t* key_event);
+int64_t AKeyEvent_getDownTime(const AInputEvent* key_event);
 
 /* Get the time this event occurred, in the
  * java.lang.System.nanoTime() time base. */
-int64_t key_event_get_event_time(const input_event_t* key_event);
+int64_t AKeyEvent_getEventTime(const AInputEvent* key_event);
 
 /*** Accessors for motion events only. ***/
 
 /* Get the combined motion event action code and pointer index. */
-int32_t motion_event_get_action(const input_event_t* motion_event);
+int32_t AMotionEvent_getAction(const AInputEvent* motion_event);
 
 /* Get the state of any meta / modifier keys that were in effect when the
  * event was generated. */
-int32_t motion_event_get_meta_state(const input_event_t* motion_event);
+int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
 
 /* Get a bitfield indicating which edges, if any, were touched by this motion event.
  * For touch events, clients can use this to determine if the user's finger was
  * touching the edge of the display. */
-int32_t motion_event_get_edge_flags(const input_event_t* motion_event);
+int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event);
 
 /* Get the time when the user originally pressed down to start a stream of
  * position events, in the java.lang.System.nanoTime() time base. */
-int64_t motion_event_get_down_time(const input_event_t* motion_event);
+int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event);
 
 /* Get the time when this specific event was generated,
  * in the java.lang.System.nanoTime() time base. */
-int64_t motion_event_get_event_time(const input_event_t* motion_event);
+int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event);
 
 /* Get the X coordinate offset.
  * For touch events on the screen, this is the delta that was added to the raw
  * screen coordinates to adjust for the absolute position of the containing windows
  * and views. */
-float motion_event_get_x_offset(const input_event_t* motion_event);
+float AMotionEvent_getXOffset(const AInputEvent* motion_event);
 
 /* Get the precision of the Y coordinates being reported.
  * For touch events on the screen, this is the delta that was added to the raw
  * screen coordinates to adjust for the absolute position of the containing windows
  * and views. */
-float motion_event_get_y_offset(const input_event_t* motion_event);
+float AMotionEvent_getYOffset(const AInputEvent* motion_event);
 
 /* Get the precision of the X coordinates being reported.
  * You can multiply this number with an X coordinate sample to find the
  * actual hardware value of the X coordinate. */
-float motion_event_get_x_precision(const input_event_t* motion_event);
+float AMotionEvent_getXPrecision(const AInputEvent* motion_event);
 
 /* Get the precision of the Y coordinates being reported.
  * You can multiply this number with a Y coordinate sample to find the
  * actual hardware value of the Y coordinate. */
-float motion_event_get_y_precision(const input_event_t* motion_event);
+float AMotionEvent_getYPrecision(const AInputEvent* motion_event);
 
 /* Get the number of pointers of data contained in this event.
  * Always >= 1. */
-size_t motion_event_get_pointer_count(const input_event_t* motion_event);
+size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event);
 
 /* Get the pointer identifier associated with a particular pointer
  * data index is this event.  The identifier tells you the actual pointer
  * number associated with the data, accounting for individual pointers
  * going up and down since the start of the current gesture. */
-int32_t motion_event_get_pointer_id(const input_event_t* motion_event, size_t pointer_index);
+int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the original raw X coordinate of this event.
  * For touch events on the screen, this is the original location of the event
  * on the screen, before it had been adjusted for the containing window
  * and views. */
-float motion_event_get_raw_x(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the original raw X coordinate of this event.
  * For touch events on the screen, this is the original location of the event
  * on the screen, before it had been adjusted for the containing window
  * and views. */
-float motion_event_get_raw_y(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the current X coordinate of this event for the given pointer index.
  * Whole numbers are pixels; the value may have a fraction for input devices
  * that are sub-pixel precise. */
-float motion_event_get_x(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the current Y coordinate of this event for the given pointer index.
  * Whole numbers are pixels; the value may have a fraction for input devices
  * that are sub-pixel precise. */
-float motion_event_get_y(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the current pressure of this event for the given pointer index.
  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
  * however values higher than 1 may be generated depending on the calibration of
  * the input device. */
-float motion_event_get_pressure(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the current scaled value of the approximate size for the given pointer index.
  * This represents some approximation of the area of the screen being
@@ -460,17 +460,17 @@
  * touch is normalized with the device specific range of values
  * and scaled to a value between 0 and 1.  The value of size can be used to
  * determine fat touch events. */
-float motion_event_get_size(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the number of historical points in this event.  These are movements that
  * have occurred between this event and the previous event.  This only applies
  * to MOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
  * Historical samples are indexed from oldest to newest. */
-size_t motion_event_get_history_size(const input_event_t* motion_event);
+size_t AMotionEvent_get_history_size(const AInputEvent* motion_event);
 
 /* Get the time that a historical movement occurred between this event and
  * the previous event, in the java.lang.System.nanoTime() time base. */
-int64_t motion_event_get_historical_event_time(input_event_t* motion_event,
+int64_t AMotionEvent_getHistoricalEventTime(AInputEvent* motion_event,
         size_t history_index);
 
 /* Get the historical raw X coordinate of this event for the given pointer index that
@@ -480,7 +480,7 @@
  * and views.
  * Whole numbers are pixels; the value may have a fraction for input devices
  * that are sub-pixel precise. */
-float motion_event_get_historical_raw_x(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the historical raw Y coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
@@ -489,20 +489,20 @@
  * and views.
  * Whole numbers are pixels; the value may have a fraction for input devices
  * that are sub-pixel precise. */
-float motion_event_get_historical_raw_y(const input_event_t* motion_event, size_t pointer_index);
+float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index);
 
 /* Get the historical X coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * Whole numbers are pixels; the value may have a fraction for input devices
  * that are sub-pixel precise. */
-float motion_event_get_historical_x(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalX(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
 /* Get the historical Y coordinate of this event for the given pointer index that
  * occurred between this event and the previous motion event.
  * Whole numbers are pixels; the value may have a fraction for input devices
  * that are sub-pixel precise. */
-float motion_event_get_historical_y(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalY(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
 /* Get the historical pressure of this event for the given pointer index that
@@ -510,7 +510,7 @@
  * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
  * however values higher than 1 may be generated depending on the calibration of
  * the input device. */
-float motion_event_get_historical_pressure(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalPressure(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
 /* Get the current scaled value of the approximate size for the given pointer index that
@@ -520,7 +520,7 @@
  * touch is normalized with the device specific range of values
  * and scaled to a value between 0 and 1.  The value of size can be used to
  * determine fat touch events. */
-float motion_event_get_historical_size(input_event_t* motion_event, size_t pointer_index,
+float AMotionEvent_getHistoricalSize(AInputEvent* motion_event, size_t pointer_index,
         size_t history_index);
 
 /*
@@ -529,8 +529,8 @@
  * An input queue is the facility through which you retrieve input
  * events.
  */
-struct input_queue_t;
-typedef struct input_queue_t input_queue_t;
+struct AInputQueue;
+typedef struct AInputQueue AInputQueue;
 
 /*
  * Return a file descriptor for the queue, which you
@@ -538,26 +538,26 @@
  * is typically used with select() or poll() to multiplex
  * with other kinds of events.
  */
-int input_queue_get_fd(input_queue_t* queue);
+int AInputQueue_getFd(AInputQueue* queue);
 
 /*
  * Returns true if there are one or more events available in the
  * input queue.  Returns 1 if the queue has events; 0 if
  * it does not have events; and a negative value if there is an error.
  */
-int input_queue_has_events(input_queue_t* queue);
+int AInputQueue_hasEvents(AInputQueue* queue);
 
 /*
  * Returns the next available event from the queue.  Returns a negative
  * value if no events are available or an error has occurred.
  */
-int32_t input_queue_get_event(input_queue_t* queue, input_event_t** outEvent);
+int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent);
 
 /*
  * Report that dispatching has finished with the given event.
- * This must be called after receiving an event with input_queue_get_event().
+ * This must be called after receiving an event with AInputQueue_get_event().
  */
-void input_queue_finish_event(input_queue_t* queue, input_event_t* event, int handled);
+void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled);
 
 #ifdef __cplusplus
 }
diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h
index a58a7d2..c5c8f9d 100644
--- a/native/include/android/native_activity.h
+++ b/native/include/android/native_activity.h
@@ -30,30 +30,37 @@
 #endif
 
 // Temporary until native surface API is defined.
-struct android_surface_t;
-typedef struct android_surface_t android_surface_t;
+struct ASurfaceHolder;
+typedef struct ASurfaceHolder ASurfaceHolder;
 
-struct android_activity_callbacks_t;
+struct ANativeActivityCallbacks;
 
 /**
  * This structure defines the native side of an android.app.NativeActivity.
  * It is created by the framework, and handed to the application's native
  * code as it is being launched.
  */
-typedef struct android_activity_t {
+typedef struct ANativeActivity {
     /**
      * Pointer to the callback function table of the native application.
      * You can set the functions here to your own callbacks.  The callbacks
      * pointer itself here should not be changed; it is allocated and managed
      * for you by the framework.
      */
-    struct android_activity_callbacks_t* callbacks;
+    struct ANativeActivityCallbacks* callbacks;
 
     /**
-     * JNI context for the main thread of the app.
+     * The global handle on the process's Java VM.
+     */
+    JavaVM* vm;
+
+    /**
+     * JNI context for the main thread of the app.  Note that this field
+     * can ONLY be used from the main thread of the process; that is, the
+     * thread that calls into the ANativeActivityCallbacks.
      */
     JNIEnv* env;
-    
+
     /**
      * The NativeActivity Java class.
      */
@@ -65,7 +72,7 @@
      * state.
      */
     void* instance;
-} android_activity_t;
+} ANativeActivity;
 
 /**
  * These are the callbacks the framework makes into a native application.
@@ -73,18 +80,18 @@
  * By default, all callbacks are NULL; set to a pointer to your own function
  * to have it called.
  */
-typedef struct android_activity_callbacks_t {
+typedef struct ANativeActivityCallbacks {
     /**
      * NativeActivity has started.  See Java documentation for Activity.onStart()
      * for more information.
      */
-    void (*onStart)(android_activity_t* activity);
+    void (*onStart)(ANativeActivity* activity);
     
     /**
      * NativeActivity has resumed.  See Java documentation for Activity.onResume()
      * for more information.
      */
-    void (*onResume)(android_activity_t* activity);
+    void (*onResume)(ANativeActivity* activity);
     
     /**
      * Framework is asking NativeActivity to save its current instance state.
@@ -95,38 +102,38 @@
      * saved state will be persisted, so it can not contain any active
      * entities (pointers to memory, file descriptors, etc).
      */
-    void* (*onSaveInstanceState)(android_activity_t* activity, size_t* outSize);
+    void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize);
     
     /**
      * NativeActivity has paused.  See Java documentation for Activity.onPause()
      * for more information.
      */
-    void (*onPause)(android_activity_t* activity);
+    void (*onPause)(ANativeActivity* activity);
     
     /**
      * NativeActivity has stopped.  See Java documentation for Activity.onStop()
      * for more information.
      */
-    void (*onStop)(android_activity_t* activity);
+    void (*onStop)(ANativeActivity* activity);
     
     /**
      * NativeActivity is being destroyed.  See Java documentation for Activity.onDestroy()
      * for more information.
      */
-    void (*onDestroy)(android_activity_t* activity);
+    void (*onDestroy)(ANativeActivity* activity);
 
     /**
      * Focus has changed in this NativeActivity's window.  This is often used,
      * for example, to pause a game when it loses input focus.
      */
-    void (*onWindowFocusChanged)(android_activity_t* activity, int hasFocus);
+    void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus);
     
     /**
      * The drawing surface for this native activity has been created.  You
      * can use the given surface object to start drawing.  NOTE: surface
      * drawing API is not yet defined.
      */
-    void (*onSurfaceCreated)(android_activity_t* activity, android_surface_t* surface);
+    void (*onSurfaceCreated)(ANativeActivity* activity, ASurfaceHolder* surface);
 
     /**
      * The drawing surface for this native activity has changed.  The surface
@@ -134,7 +141,7 @@
      * onSurfaceCreated.  This is simply to inform you about interesting
      * changed to that surface.
      */
-    void (*onSurfaceChanged)(android_activity_t* activity, android_surface_t* surface,
+    void (*onSurfaceChanged)(ANativeActivity* activity, ASurfaceHolder* surface,
             int format, int width, int height);
 
     /**
@@ -145,28 +152,28 @@
      * properly synchronize with the other thread to stop its drawing before
      * returning from here.
      */
-    void (*onSurfaceDestroyed)(android_activity_t* activity, android_surface_t* surface);
+    void (*onSurfaceDestroyed)(ANativeActivity* activity, ASurfaceHolder* surface);
     
     /**
      * The input queue for this native activity's window has been created.
      * You can use the given input queue to start retrieving input events.
      */
-    void (*onInputQueueCreated)(android_activity_t* activity, input_queue_t* queue);
+    void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue);
     
     /**
      * The input queue for this native activity's window is being destroyed.
      * You should no longer try to reference this object upon returning from this
      * function.
      */
-    void (*onInputQueueDestroyed)(android_activity_t* activity, input_queue_t* queue);
+    void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue);
 
     /**
      * The system is running low on memory.  Use this callback to release
      * resources you do not need, to help the system avoid killing more
      * important processes.
      */
-    void (*onLowMemory)(android_activity_t* activity);
-} android_activity_callbacks_t;
+    void (*onLowMemory)(ANativeActivity* activity);
+} ANativeActivityCallbacks;
 
 /**
  * This is the function that must be in the native code to instantiate the
@@ -174,14 +181,14 @@
  * above); if the code is being instantiated from a previously saved instance,
  * the savedState will be non-NULL and point to the saved data.
  */
-typedef void android_activity_create_t(android_activity_t* activity,
+typedef void ANativeActivity_createFunc(ANativeActivity* activity,
         void* savedState, size_t savedStateSize);
 
 /**
  * The name of the function that NativeInstance looks for when launching its
  * native code.
  */
-extern android_activity_create_t android_onCreateActivity;
+extern ANativeActivity_createFunc ANativeActivity_onCreate;
 
 #ifdef __cplusplus
 };