diff options
author | Mathias Agopian <mathias@google.com> | 2009-05-08 13:13:12 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-05-08 13:13:12 -0700 |
commit | 6ec72e3fa9cdf9e896f3042fb1b1b4f3f6cea541 (patch) | |
tree | c844365aa767f37da6081150dcf3caccb4fb6d46 /core | |
parent | 6bebbcd57b7b3ffad3af046f4899d885b30c828e (diff) | |
parent | 3cf650dec40c0e40d613c76bd70453205af76ed8 (diff) | |
download | frameworks_base-6ec72e3fa9cdf9e896f3042fb1b1b4f3f6cea541.zip frameworks_base-6ec72e3fa9cdf9e896f3042fb1b1b4f3f6cea541.tar.gz frameworks_base-6ec72e3fa9cdf9e896f3042fb1b1b4f3f6cea541.tar.bz2 |
Merge commit 'goog/master' into merge_master
Diffstat (limited to 'core')
19 files changed, 514 insertions, 128 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index dfa3fa8..2fc476e 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -316,18 +316,16 @@ public final class ActivityThread { float appScale = -1.0f; if (ai.supportsDensities != null) { - // TODO: precompute this in DisplayMetrics - float systemDensityDpi = metrics.density * DisplayMetrics.DEFAULT_DENSITY; int minDiff = Integer.MAX_VALUE; for (int density : ai.supportsDensities) { - int tmpDiff = (int) Math.abs(systemDensityDpi - density); + int tmpDiff = (int) Math.abs(DisplayMetrics.DEVICE_DENSITY - density); if (tmpDiff == 0) { appScale = 1.0f; break; } // prefer higher density (appScale>1.0), unless that's only option. if (tmpDiff < minDiff && appScale < 1.0f) { - appScale = systemDensityDpi / density; + appScale = DisplayMetrics.DEVICE_DENSITY / density; minDiff = tmpDiff; } } @@ -3482,6 +3480,8 @@ public final class ActivityThread { } mConfiguration.updateFrom(config); DisplayMetrics dm = getDisplayMetricsLocked(true); + DisplayMetrics appDm = new DisplayMetrics(); + appDm.setTo(dm); // set it for java, this also affects newly created Resources if (config.locale != null) { @@ -3501,7 +3501,9 @@ public final class ActivityThread { WeakReference<Resources> v = it.next(); Resources r = v.get(); if (r != null) { - r.updateConfiguration(config, dm); + // keep the original density based on application cale. + appDm.density = r.getDisplayMetrics().density; + r.updateConfiguration(config, appDm); //Log.i(TAG, "Updated app resources " + v.getKey() // + " " + r + ": " + r.getConfiguration()); } else { diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index 2d2f98a..90de40d 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -1182,6 +1182,17 @@ public class SearchManager * Typically you'll use this with a URI matcher. */ public final static String SUGGEST_URI_PATH_QUERY = "search_suggest_query"; + + /** + * Uri path for shortcut validation. This is the path that the search manager will use when + * querying your content provider to refresh a shortcutted suggestion result and to check if it + * is still valid. When asked, a source may return an up to date result, or no result. No + * result indicates the shortcut refers to a no longer valid sugggestion. + * + * @see #SUGGEST_COLUMN_SHORTCUT_ID + * @hide + */ + public final static String SUGGEST_URI_PATH_SHORTCUT = "search_suggest_shortcut"; /** * MIME type for suggestions data. You'll use this in your suggestions content provider @@ -1303,6 +1314,26 @@ public class SearchManager public final static String SUGGEST_COLUMN_QUERY = "suggest_intent_query"; /** + * Column name for suggestions cursor. <i>Optional.</i> This column is used to indicate whether + * a search suggestion should be stored as a shortcut, and whether it should be validated. If + * missing, the result will be stored as a shortcut and never validated. If set to + * {@link #SUGGEST_NEVER_MAKE_SHORTCUT}, the result will not be stored as a shortcut. + * Otherwise, the shortcut id will be used to check back for validation via + * {@link #SUGGEST_URI_PATH_SHORTCUT}. + * + * @hide Pending API council approval. + */ + public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id"; + + /** + * Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion + * should not be stored as a shortcut in global search. + * + * @hide Pending API council approval. + */ + public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1"; + + /** * If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION}, * the search dialog will switch to a different suggestion source when the * suggestion is clicked. diff --git a/core/java/android/backup/BackupDataOutput.java b/core/java/android/backup/BackupDataOutput.java new file mode 100644 index 0000000..6c47f7e --- /dev/null +++ b/core/java/android/backup/BackupDataOutput.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 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.backup; + +import android.content.Context; + +import java.io.FileDescriptor; + +public class BackupDataOutput { + /* package */ FileDescriptor fd; + + public static final int OP_UPDATE = 1; + public static final int OP_DELETE = 2; + + public BackupDataOutput(Context context, FileDescriptor fd) { + this.fd = fd; + } + + public void close() { + // do we close the fd? + } + public native void flush(); + public native void write(byte[] buffer); + public native void write(int oneByte); + public native void write(byte[] buffer, int offset, int count); + + public native void writeOperation(int op); + public native void writeKey(String key); +} + diff --git a/core/java/android/backup/FileBackupHelper.java b/core/java/android/backup/FileBackupHelper.java new file mode 100644 index 0000000..3b2122c --- /dev/null +++ b/core/java/android/backup/FileBackupHelper.java @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2009 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.backup; + +import android.content.Context; +import android.os.ParcelFileDescriptor; + +import java.io.FileDescriptor; + +public class FileBackupHelper { + /** + * Based on oldSnapshot, determine which of the files from the application's data directory + * need to be backed up, write them to the data stream, and fill in newSnapshot with the + * state as it exists now. + */ + public static void performBackup(Context context, + ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot, + BackupDataOutput data, String[] files) { + String basePath = context.getFilesDir().getAbsolutePath(); + performBackup_checked(basePath, oldSnapshot, newSnapshot, data, files); + } + + /** + * Check the parameters so the native code doens't have to throw all the exceptions + * since it's easier to do that from java. + */ + static void performBackup_checked(String basePath, + ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot, + BackupDataOutput data, String[] files) { + if (newSnapshot == null) { + throw new NullPointerException("newSnapshot==null"); + } + if (data == null) { + throw new NullPointerException("data==null"); + } + if (data.fd == null) { + throw new NullPointerException("data.fd==null"); + } + if (files == null) { + throw new NullPointerException("files==null"); + } + + int err = performBackup_native(basePath, oldSnapshot.getFileDescriptor(), + newSnapshot.getFileDescriptor(), data.fd, files); + + if (err != 0) { + throw new RuntimeException("Backup failed"); // TODO: more here + } + } + + native private static int performBackup_native(String basePath, + FileDescriptor oldSnapshot, FileDescriptor newSnapshot, + FileDescriptor data, String[] files); +} diff --git a/core/java/android/backup/SharedPreferencesBackupHelper.java b/core/java/android/backup/SharedPreferencesBackupHelper.java new file mode 100644 index 0000000..e839bb4 --- /dev/null +++ b/core/java/android/backup/SharedPreferencesBackupHelper.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2009 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.backup; + +import android.content.Context; +import android.os.ParcelFileDescriptor; + +import java.io.FileDescriptor; + +public class SharedPreferencesBackupHelper { + public static void performBackup(Context context, + ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot, + BackupDataOutput data, String[] prefGroups) { + String basePath = "/xxx"; //context.getPreferencesDir(); + + // make filenames for the prefGroups + final int N = prefGroups.length; + String[] files = new String[N]; + for (int i=0; i<N; i++) { + files[i] = prefGroups[i] + ".xml"; + } + + FileBackupHelper.performBackup_checked(basePath, oldSnapshot, newSnapshot, data, files); + } +} + diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java index 65c9893..8b474d5 100755 --- a/core/java/android/inputmethodservice/KeyboardView.java +++ b/core/java/android/inputmethodservice/KeyboardView.java @@ -407,7 +407,7 @@ public class KeyboardView extends View implements View.OnClickListener { // Release buffer, just in case the new keyboard has a different size. // It will be reallocated on the next draw. mBuffer = null; - invalidateAll(); + invalidateAllKeys(); computeProximityThreshold(keyboard); mMiniKeyboardCache.clear(); // Not really necessary to do every time, but will free up views } @@ -431,7 +431,7 @@ public class KeyboardView extends View implements View.OnClickListener { if (mKeyboard != null) { if (mKeyboard.setShifted(shifted)) { // The whole keyboard probably needs to be redrawn - invalidateAll(); + invalidateAllKeys(); return true; } } @@ -573,7 +573,7 @@ public class KeyboardView extends View implements View.OnClickListener { if (mBuffer == null) { mBuffer = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); mCanvas = new Canvas(mBuffer); - invalidateAll(); + invalidateAllKeys(); } final Canvas canvas = mCanvas; canvas.clipRect(mDirtyRect, Op.REPLACE); @@ -874,13 +874,27 @@ public class KeyboardView extends View implements View.OnClickListener { mPreviewText.setVisibility(VISIBLE); } - private void invalidateAll() { + /** + * Requests a redraw of the entire keyboard. Calling {@link #invalidate} is not sufficient + * because the keyboard renders the keys to an off-screen buffer and an invalidate() only + * draws the cached buffer. + * @see #invalidateKey(int) + */ + public void invalidateAllKeys() { mDirtyRect.union(0, 0, getWidth(), getHeight()); mDrawPending = true; invalidate(); } - - private void invalidateKey(int keyIndex) { + + /** + * Invalidates a key so that it will be redrawn on the next repaint. Use this method if only + * one key is changing it's content. Any changes that affect the position or size of the key + * may not be honored. + * @param keyIndex the index of the key in the attached {@link Keyboard}. + * @see #invalidateAllKeys + */ + public void invalidateKey(int keyIndex) { + if (mKeys == null) return; if (keyIndex < 0 || keyIndex >= mKeys.length) { return; } @@ -991,7 +1005,7 @@ public class KeyboardView extends View implements View.OnClickListener { mPopupKeyboard.showAtLocation(this, Gravity.NO_GRAVITY, x, y); mMiniKeyboardOnScreen = true; //mMiniKeyboard.onTouchEvent(getTranslatedEvent(me)); - invalidateAll(); + invalidateAllKeys(); return true; } return false; @@ -1164,7 +1178,7 @@ public class KeyboardView extends View implements View.OnClickListener { if (mPopupKeyboard.isShowing()) { mPopupKeyboard.dismiss(); mMiniKeyboardOnScreen = false; - invalidateAll(); + invalidateAllKeys(); } } diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 9de4cbe..095f4f4 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -31,7 +31,11 @@ public class DisplayMetrics { */ public static final int DEFAULT_DENSITY = 160; - private static final int sLcdDensity = SystemProperties.getInt("ro.sf.lcd_density", + /** + * The device's density. + * @hide + */ + public static final int DEVICE_DENSITY = SystemProperties.getInt("ro.sf.lcd_density", DEFAULT_DENSITY); /** @@ -90,9 +94,9 @@ public class DisplayMetrics { public void setToDefaults() { widthPixels = 0; heightPixels = 0; - density = sLcdDensity / (float) DEFAULT_DENSITY; + density = DEVICE_DENSITY / (float) DEFAULT_DENSITY; scaledDensity = density; - xdpi = sLcdDensity; - ydpi = sLcdDensity; + xdpi = DEVICE_DENSITY; + ydpi = DEVICE_DENSITY; } } diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index 0d55679..86261c4 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -228,8 +228,10 @@ public final class MotionEvent implements Parcelable { if (mHistory != null) { float[] history = mHistory; int length = history.length; - for (int i = 0; i < length; i++) { + for (int i = 0; i < length; i += 4) { history[i] *= scale; + history[i + 2] *= scale; + history[i + 3] *= scale; } } } diff --git a/core/java/com/android/internal/backup/IBackupTransport.aidl b/core/java/com/android/internal/backup/IBackupTransport.aidl index d64a303..ce39768 100644 --- a/core/java/com/android/internal/backup/IBackupTransport.aidl +++ b/core/java/com/android/internal/backup/IBackupTransport.aidl @@ -16,6 +16,54 @@ package com.android.internal.backup; +import android.os.ParcelFileDescriptor; + /** {@hide} */ interface IBackupTransport { +/* STOPSHIP - don't ship with this comment in place + Things the transport interface has to do: + 1. set up the connection to the destination + - set up encryption + - for Google cloud, log in using the user's gaia credential or whatever + - for sd, spin off the backup transport and establish communication with it + 2. send each app's backup transaction + - parse the data file for key/value pointers etc + - send key/blobsize set to the Google cloud, get back quota ok/rejected response + - sd/adb doesn't preflight; no per-app quota + - app's entire change is essentially atomic + - cloud transaction encrypts then sends each key/value pair separately; we already + parsed the data when preflighting so we don't have to again here + - sd target streams raw data into encryption envelope then to sd? + 3. shut down connection to destination + - cloud: tear down connection etc + - sd: close the file and shut down the writer proxy +*/ + /** + * Establish a connection to the back-end data repository, if necessary. If the transport + * needs to initialize state that is not tied to individual applications' backup operations, + * this is where it should be done. + * + * @return Zero on success; a nonzero error code on failure. + */ + int startSession(); + + /** + * Send one application's data to the backup destination. + * + * @param packageName The identity of the application whose data is being backed up. + * @param data The data stream that resulted from invoking the application's + * BackupService.doBackup() method. This may be a pipe rather than a + * file on persistent media, so it may not be seekable. + * @return Zero on success; a nonzero error code on failure. + */ + int performBackup(String packageName, in ParcelFileDescriptor data); + + /** + * Terminate the backup session, closing files, freeing memory, and cleaning up whatever + * other state the transport required. + * + * @return Zero on success; a nonzero error code on failure. Even on failure, the session + * is torn down and must be restarted if another backup is attempted. + */ + int endSession(); } diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 48675a1..702ea87 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -117,7 +117,8 @@ LOCAL_SRC_FILES:= \ android_ddm_DdmHandleNativeHeap.cpp \ android_location_GpsLocationProvider.cpp \ com_android_internal_os_ZygoteInit.cpp \ - com_android_internal_graphics_NativeUtils.cpp + com_android_internal_graphics_NativeUtils.cpp \ + android_backup_FileBackupHelper.cpp LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 422020e..d1e87f3 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -154,6 +154,7 @@ extern int register_android_ddm_DdmHandleNativeHeap(JNIEnv *env); extern int register_com_android_internal_os_ZygoteInit(JNIEnv* env); extern int register_android_util_Base64(JNIEnv* env); extern int register_android_location_GpsLocationProvider(JNIEnv* env); +extern int register_android_backup_FileBackupHelper(JNIEnv *env); static AndroidRuntime* gCurRuntime = NULL; @@ -1168,6 +1169,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_ddm_DdmHandleNativeHeap), REG_JNI(register_android_util_Base64), REG_JNI(register_android_location_GpsLocationProvider), + REG_JNI(register_android_backup_FileBackupHelper), }; /* diff --git a/core/jni/android_backup_FileBackupHelper.cpp b/core/jni/android_backup_FileBackupHelper.cpp new file mode 100644 index 0000000..e8d60a0 --- /dev/null +++ b/core/jni/android_backup_FileBackupHelper.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2009 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. + */ + +#include "JNIHelp.h" +#include <android_runtime/AndroidRuntime.h> + +#include <utils/backup_helpers.h> + +namespace android +{ + +static jfieldID s_descriptorField; + +static int +performBackup_native(JNIEnv* env, jstring basePath, + jobject oldSnapshot, jobject newSnapshot, + jobject data, jobjectArray files) +{ + int err; + + // all parameters have already been checked against null + + int oldSnapshotFD = env->GetIntField(oldSnapshot, s_descriptorField); + int newSnapshotFD = env->GetIntField(newSnapshot, s_descriptorField); + int dataFD = env->GetIntField(data, s_descriptorField); + + char const* basePathUTF = env->GetStringUTFChars(basePath, NULL); + const int fileCount = env->GetArrayLength(files); + char const** filesUTF = (char const**)malloc(sizeof(char*)*fileCount); + for (int i=0; i<fileCount; i++) { + filesUTF[i] = env->GetStringUTFChars((jstring)env->GetObjectArrayElement(files, i), NULL); + } + + err = back_up_files(oldSnapshotFD, newSnapshotFD, dataFD, basePathUTF, filesUTF, fileCount); + + for (int i=0; i<fileCount; i++) { + env->ReleaseStringUTFChars((jstring)env->GetObjectArrayElement(files, i), filesUTF[i]); + } + free(filesUTF); + env->ReleaseStringUTFChars(basePath, basePathUTF); + + return err; +} + +static const JNINativeMethod g_methods[] = { + { "performBackup_native", + "(Ljava/lang/String;Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;" + "Ljava/io/FileDescriptor;[Ljava/lang/String;)I", + (void*)performBackup_native }, +}; + +int register_android_backup_FileBackupHelper(JNIEnv* env) +{ + jclass clazz; + + clazz = env->FindClass("java/io/FileDescriptor"); + LOG_FATAL_IF(clazz == NULL, "Unable to find class java.io.FileDescriptor"); + s_descriptorField = env->GetFieldID(clazz, "descriptor", "I"); + LOG_FATAL_IF(s_descriptorField == NULL, + "Unable to find descriptor field in java.io.FileDescriptor"); + + return AndroidRuntime::registerNativeMethods(env, "android/backup/FileBackupHelper", + g_methods, NELEM(g_methods)); +} + +} diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp index bc644d2..7e388ef 100644 --- a/core/jni/android_opengl_GLES10.cpp +++ b/core/jni/android_opengl_GLES10.cpp @@ -22,11 +22,7 @@ #include <assert.h> #include <GLES/gl.h> - -#include <private/opengles/gl_context.h> - -#define _NUM_COMPRESSED_TEXTURE_FORMATS \ - (::android::OGLES_NUM_COMPRESSED_TEXTURE_FORMATS) +#include <GLES/glext.h> static int initialized = 0; @@ -67,7 +63,6 @@ nativeClassInitBuffer(JNIEnv *_env) _env->GetFieldID(bufferClass, "_elementSizeShift", "I"); } - static void nativeClassInit(JNIEnv *_env, jclass glImplClass) { @@ -118,7 +113,6 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) return (void *) ((char *) data + offset); } - static void releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) { @@ -126,6 +120,13 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) commit ? 0 : JNI_ABORT); } +static int +getNumCompressedTextureFormats() { + int numCompressedTextureFormats = 0; + glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCompressedTextureFormats); + return numCompressedTextureFormats; +} + // -------------------------------------------------------------------------- /* void glActiveTexture ( GLenum texture ) */ @@ -290,7 +291,13 @@ android_glColorPointerBounds__IIILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glColorPointerBounds( (GLint)size, (GLenum)type, @@ -298,9 +305,6 @@ android_glColorPointerBounds__IIILjava_nio_Buffer_2I (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glCompressedTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ) */ @@ -1022,6 +1026,12 @@ android_glGetIntegerv__I_3II #if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: #endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) +#if defined(GL_LIGHT_MODEL_COLOR_CONTROL) + case GL_LIGHT_MODEL_COLOR_CONTROL: +#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL) +#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER) + case GL_LIGHT_MODEL_LOCAL_VIEWER: +#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER) #if defined(GL_LIGHT_MODEL_TWO_SIDE) case GL_LIGHT_MODEL_TWO_SIDE: #endif // defined(GL_LIGHT_MODEL_TWO_SIDE) @@ -1236,6 +1246,12 @@ android_glGetIntegerv__I_3II #if defined(GL_COLOR_WRITEMASK) case GL_COLOR_WRITEMASK: #endif // defined(GL_COLOR_WRITEMASK) +#if defined(GL_FOG_COLOR) + case GL_FOG_COLOR: +#endif // defined(GL_FOG_COLOR) +#if defined(GL_LIGHT_MODEL_AMBIENT) + case GL_LIGHT_MODEL_AMBIENT: +#endif // defined(GL_LIGHT_MODEL_AMBIENT) #if defined(GL_SCISSOR_BOX) case GL_SCISSOR_BOX: #endif // defined(GL_SCISSOR_BOX) @@ -1267,13 +1283,7 @@ android_glGetIntegerv__I_3II #if defined(GL_COMPRESSED_TEXTURE_FORMATS) case GL_COMPRESSED_TEXTURE_FORMATS: #endif // defined(GL_COMPRESSED_TEXTURE_FORMATS) -#if defined(GL_FOG_COLOR) - case GL_FOG_COLOR: -#endif // defined(GL_FOG_COLOR) -#if defined(GL_LIGHT_MODEL_AMBIENT) - case GL_LIGHT_MODEL_AMBIENT: -#endif // defined(GL_LIGHT_MODEL_AMBIENT) - _needed = _NUM_COMPRESSED_TEXTURE_FORMATS; + _needed = getNumCompressedTextureFormats(); break; default: _needed = 0; @@ -1378,6 +1388,12 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2 #if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: #endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) +#if defined(GL_LIGHT_MODEL_COLOR_CONTROL) + case GL_LIGHT_MODEL_COLOR_CONTROL: +#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL) +#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER) + case GL_LIGHT_MODEL_LOCAL_VIEWER: +#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER) #if defined(GL_LIGHT_MODEL_TWO_SIDE) case GL_LIGHT_MODEL_TWO_SIDE: #endif // defined(GL_LIGHT_MODEL_TWO_SIDE) @@ -1592,6 +1608,12 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2 #if defined(GL_COLOR_WRITEMASK) case GL_COLOR_WRITEMASK: #endif // defined(GL_COLOR_WRITEMASK) +#if defined(GL_FOG_COLOR) + case GL_FOG_COLOR: +#endif // defined(GL_FOG_COLOR) +#if defined(GL_LIGHT_MODEL_AMBIENT) + case GL_LIGHT_MODEL_AMBIENT: +#endif // defined(GL_LIGHT_MODEL_AMBIENT) #if defined(GL_SCISSOR_BOX) case GL_SCISSOR_BOX: #endif // defined(GL_SCISSOR_BOX) @@ -1623,13 +1645,7 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2 #if defined(GL_COMPRESSED_TEXTURE_FORMATS) case GL_COMPRESSED_TEXTURE_FORMATS: #endif // defined(GL_COMPRESSED_TEXTURE_FORMATS) -#if defined(GL_FOG_COLOR) - case GL_FOG_COLOR: -#endif // defined(GL_FOG_COLOR) -#if defined(GL_LIGHT_MODEL_AMBIENT) - case GL_LIGHT_MODEL_AMBIENT: -#endif // defined(GL_LIGHT_MODEL_AMBIENT) - _needed = _NUM_COMPRESSED_TEXTURE_FORMATS; + _needed = getNumCompressedTextureFormats(); break; default: _needed = 0; @@ -2749,16 +2765,19 @@ android_glNormalPointerBounds__IILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glNormalPointerBounds( (GLenum)type, (GLsizei)stride, (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glOrthof ( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ) */ @@ -3001,7 +3020,13 @@ android_glTexCoordPointerBounds__IIILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glTexCoordPointerBounds( (GLint)size, (GLenum)type, @@ -3009,9 +3034,6 @@ android_glTexCoordPointerBounds__IIILjava_nio_Buffer_2I (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glTexEnvf ( GLenum target, GLenum pname, GLfloat param ) */ @@ -3356,7 +3378,13 @@ android_glVertexPointerBounds__IIILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glVertexPointerBounds( (GLint)size, (GLenum)type, @@ -3364,9 +3392,6 @@ android_glVertexPointerBounds__IIILjava_nio_Buffer_2I (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glViewport ( GLint x, GLint y, GLsizei width, GLsizei height ) */ diff --git a/core/jni/android_opengl_GLES10Ext.cpp b/core/jni/android_opengl_GLES10Ext.cpp index 6114d6a..f17ef21 100644 --- a/core/jni/android_opengl_GLES10Ext.cpp +++ b/core/jni/android_opengl_GLES10Ext.cpp @@ -22,11 +22,7 @@ #include <assert.h> #include <GLES/gl.h> - -#include <private/opengles/gl_context.h> - -#define _NUM_COMPRESSED_TEXTURE_FORMATS \ - (::android::OGLES_NUM_COMPRESSED_TEXTURE_FORMATS) +#include <GLES/glext.h> static int initialized = 0; diff --git a/core/jni/android_opengl_GLES11.cpp b/core/jni/android_opengl_GLES11.cpp index a7e59a8..ed8dfc8 100644 --- a/core/jni/android_opengl_GLES11.cpp +++ b/core/jni/android_opengl_GLES11.cpp @@ -22,11 +22,7 @@ #include <assert.h> #include <GLES/gl.h> - -#include <private/opengles/gl_context.h> - -#define _NUM_COMPRESSED_TEXTURE_FORMATS \ - (::android::OGLES_NUM_COMPRESSED_TEXTURE_FORMATS) +#include <GLES/glext.h> static int initialized = 0; diff --git a/core/jni/android_opengl_GLES11Ext.cpp b/core/jni/android_opengl_GLES11Ext.cpp index 069cec1..6f3495c 100644 --- a/core/jni/android_opengl_GLES11Ext.cpp +++ b/core/jni/android_opengl_GLES11Ext.cpp @@ -22,11 +22,7 @@ #include <assert.h> #include <GLES/gl.h> - -#include <private/opengles/gl_context.h> - -#define _NUM_COMPRESSED_TEXTURE_FORMATS \ - (::android::OGLES_NUM_COMPRESSED_TEXTURE_FORMATS) +#include <GLES/glext.h> static int initialized = 0; diff --git a/core/jni/android_os_ParcelFileDescriptor.cpp b/core/jni/android_os_ParcelFileDescriptor.cpp index 971f87c..848a57a 100644 --- a/core/jni/android_os_ParcelFileDescriptor.cpp +++ b/core/jni/android_os_ParcelFileDescriptor.cpp @@ -1,19 +1,18 @@ -/* //device/libs/android_runtime/android_os_ParcelFileDescriptor.cpp -** -** Copyright 2008, 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. -*/ +/* + * Copyright (C) 2008 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. + */ //#define LOG_NDEBUG 0 diff --git a/core/jni/android_server_BluetoothA2dpService.cpp b/core/jni/android_server_BluetoothA2dpService.cpp index b320c09..fe94642 100644 --- a/core/jni/android_server_BluetoothA2dpService.cpp +++ b/core/jni/android_server_BluetoothA2dpService.cpp @@ -45,7 +45,8 @@ static jmethodID method_onSinkPlaying; static jmethodID method_onSinkStopped; typedef struct { - JNIEnv *env; + JavaVM *vm; + int envVer; DBusConnection *conn; jobject me; // for callbacks to java } native_data_t; @@ -70,7 +71,8 @@ static bool initNative(JNIEnv* env, jobject object) { LOGE("%s: out of memory!", __FUNCTION__); return false; } - nat->env = env; + env->GetJavaVM( &(nat->vm) ); + nat->envVer = env->GetVersion(); nat->me = env->NewGlobalRef(object); DBusError err; @@ -239,8 +241,14 @@ static void onConnectSinkResult(DBusMessage *msg, void *user, void *natData) { char *c_path = (char *)user; DBusError err; + JNIEnv *env; + + if (nat->vm->GetEnv((void**)&env, nat->envVer) < 0) { + LOGE("%s: error finding Env for our VM\n", __FUNCTION__); + return; + } + dbus_error_init(&err); - JNIEnv *env = nat->env; LOGV("... path = %s", c_path); if (dbus_set_error_from_message(&err, msg)) { @@ -264,8 +272,14 @@ static void onDisconnectSinkResult(DBusMessage *msg, void *user, void *natData) char *c_path = (char *)user; DBusError err; + JNIEnv *env; + + if (nat->vm->GetEnv((void**)&env, nat->envVer) < 0) { + LOGE("%s: error finding Env for our VM\n", __FUNCTION__); + return; + } + dbus_error_init(&err); - JNIEnv *env = nat->env; LOGV("... path = %s", c_path); if (dbus_set_error_from_message(&err, msg)) { diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp index 4ca79b5..6f2a438 100644 --- a/core/jni/com_google_android_gles_jni_GLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp @@ -22,11 +22,7 @@ #include <assert.h> #include <GLES/gl.h> - -#include <private/opengles/gl_context.h> - -#define _NUM_COMPRESSED_TEXTURE_FORMATS \ - (::android::OGLES_NUM_COMPRESSED_TEXTURE_FORMATS) +#include <GLES/glext.h> static int initialized = 0; @@ -67,7 +63,6 @@ nativeClassInitBuffer(JNIEnv *_env) _env->GetFieldID(bufferClass, "_elementSizeShift", "I"); } - static void nativeClassInit(JNIEnv *_env, jclass glImplClass) { @@ -118,7 +113,6 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining) return (void *) ((char *) data + offset); } - static void releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) { @@ -126,6 +120,13 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) commit ? 0 : JNI_ABORT); } +static int +getNumCompressedTextureFormats() { + int numCompressedTextureFormats = 0; + glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numCompressedTextureFormats); + return numCompressedTextureFormats; +} + // -------------------------------------------------------------------------- /* void glActiveTexture ( GLenum texture ) */ @@ -290,7 +291,13 @@ android_glColorPointerBounds__IIILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glColorPointerBounds( (GLint)size, (GLenum)type, @@ -298,9 +305,6 @@ android_glColorPointerBounds__IIILjava_nio_Buffer_2I (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glCompressedTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ) */ @@ -1022,6 +1026,12 @@ android_glGetIntegerv__I_3II #if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: #endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) +#if defined(GL_LIGHT_MODEL_COLOR_CONTROL) + case GL_LIGHT_MODEL_COLOR_CONTROL: +#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL) +#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER) + case GL_LIGHT_MODEL_LOCAL_VIEWER: +#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER) #if defined(GL_LIGHT_MODEL_TWO_SIDE) case GL_LIGHT_MODEL_TWO_SIDE: #endif // defined(GL_LIGHT_MODEL_TWO_SIDE) @@ -1236,6 +1246,12 @@ android_glGetIntegerv__I_3II #if defined(GL_COLOR_WRITEMASK) case GL_COLOR_WRITEMASK: #endif // defined(GL_COLOR_WRITEMASK) +#if defined(GL_FOG_COLOR) + case GL_FOG_COLOR: +#endif // defined(GL_FOG_COLOR) +#if defined(GL_LIGHT_MODEL_AMBIENT) + case GL_LIGHT_MODEL_AMBIENT: +#endif // defined(GL_LIGHT_MODEL_AMBIENT) #if defined(GL_SCISSOR_BOX) case GL_SCISSOR_BOX: #endif // defined(GL_SCISSOR_BOX) @@ -1267,13 +1283,7 @@ android_glGetIntegerv__I_3II #if defined(GL_COMPRESSED_TEXTURE_FORMATS) case GL_COMPRESSED_TEXTURE_FORMATS: #endif // defined(GL_COMPRESSED_TEXTURE_FORMATS) -#if defined(GL_FOG_COLOR) - case GL_FOG_COLOR: -#endif // defined(GL_FOG_COLOR) -#if defined(GL_LIGHT_MODEL_AMBIENT) - case GL_LIGHT_MODEL_AMBIENT: -#endif // defined(GL_LIGHT_MODEL_AMBIENT) - _needed = _NUM_COMPRESSED_TEXTURE_FORMATS; + _needed = getNumCompressedTextureFormats(); break; default: _needed = 0; @@ -1378,6 +1388,12 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2 #if defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: #endif // defined(GL_IMPLEMENTATION_COLOR_READ_TYPE_OES) +#if defined(GL_LIGHT_MODEL_COLOR_CONTROL) + case GL_LIGHT_MODEL_COLOR_CONTROL: +#endif // defined(GL_LIGHT_MODEL_COLOR_CONTROL) +#if defined(GL_LIGHT_MODEL_LOCAL_VIEWER) + case GL_LIGHT_MODEL_LOCAL_VIEWER: +#endif // defined(GL_LIGHT_MODEL_LOCAL_VIEWER) #if defined(GL_LIGHT_MODEL_TWO_SIDE) case GL_LIGHT_MODEL_TWO_SIDE: #endif // defined(GL_LIGHT_MODEL_TWO_SIDE) @@ -1592,6 +1608,12 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2 #if defined(GL_COLOR_WRITEMASK) case GL_COLOR_WRITEMASK: #endif // defined(GL_COLOR_WRITEMASK) +#if defined(GL_FOG_COLOR) + case GL_FOG_COLOR: +#endif // defined(GL_FOG_COLOR) +#if defined(GL_LIGHT_MODEL_AMBIENT) + case GL_LIGHT_MODEL_AMBIENT: +#endif // defined(GL_LIGHT_MODEL_AMBIENT) #if defined(GL_SCISSOR_BOX) case GL_SCISSOR_BOX: #endif // defined(GL_SCISSOR_BOX) @@ -1623,13 +1645,7 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2 #if defined(GL_COMPRESSED_TEXTURE_FORMATS) case GL_COMPRESSED_TEXTURE_FORMATS: #endif // defined(GL_COMPRESSED_TEXTURE_FORMATS) -#if defined(GL_FOG_COLOR) - case GL_FOG_COLOR: -#endif // defined(GL_FOG_COLOR) -#if defined(GL_LIGHT_MODEL_AMBIENT) - case GL_LIGHT_MODEL_AMBIENT: -#endif // defined(GL_LIGHT_MODEL_AMBIENT) - _needed = _NUM_COMPRESSED_TEXTURE_FORMATS; + _needed = getNumCompressedTextureFormats(); break; default: _needed = 0; @@ -2749,16 +2765,19 @@ android_glNormalPointerBounds__IILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glNormalPointerBounds( (GLenum)type, (GLsizei)stride, (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glOrthof ( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ) */ @@ -3001,7 +3020,13 @@ android_glTexCoordPointerBounds__IIILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glTexCoordPointerBounds( (GLint)size, (GLenum)type, @@ -3009,9 +3034,6 @@ android_glTexCoordPointerBounds__IIILjava_nio_Buffer_2I (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glTexEnvf ( GLenum target, GLenum pname, GLfloat param ) */ @@ -3356,7 +3378,13 @@ android_glVertexPointerBounds__IIILjava_nio_Buffer_2I jint _remaining; GLvoid *pointer = (GLvoid *) 0; - pointer = (GLvoid *)getPointer(_env, pointer_buf, &_array, &_remaining); + if (pointer_buf) { + pointer = (GLvoid *) _env->GetDirectBufferAddress(pointer_buf); + if ( ! pointer ) { + _env->ThrowNew(IAEClass, "Must use a native order direct Buffer"); + return; + } + } glVertexPointerBounds( (GLint)size, (GLenum)type, @@ -3364,9 +3392,6 @@ android_glVertexPointerBounds__IIILjava_nio_Buffer_2I (GLvoid *)pointer, (GLsizei)remaining ); - if (_array) { - releasePointer(_env, _array, pointer, JNI_FALSE); - } } /* void glViewport ( GLint x, GLint y, GLsizei width, GLsizei height ) */ |