summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/ActivityManager.java61
-rw-r--r--core/java/android/app/ActivityManagerNative.java50
-rw-r--r--core/java/android/app/ActivityThread.java12
-rw-r--r--core/java/android/app/ApplicationThreadNative.java6
-rw-r--r--core/java/android/app/IActivityManager.java6
-rw-r--r--core/java/android/app/IApplicationThread.java4
-rw-r--r--core/java/android/app/Service.java20
-rw-r--r--core/java/android/content/pm/PackageParser.java7
-rw-r--r--core/java/android/content/pm/ServiceInfo.java20
-rw-r--r--core/java/android/hardware/Camera.java115
-rw-r--r--core/java/android/os/BatteryStats.java298
-rw-r--r--core/java/android/os/ParcelFileDescriptor.java67
-rw-r--r--core/java/android/os/RecoverySystem.java7
-rw-r--r--core/java/android/text/CharSequenceIterator.java29
-rw-r--r--core/java/android/text/TextUtils.java7
-rw-r--r--core/java/android/text/method/ArrowKeyMovementMethod.java6
-rw-r--r--core/java/android/text/style/SuggestionSpan.java4
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java50
-rw-r--r--core/java/android/webkit/webdriver/WebDriver.java216
-rw-r--r--core/java/android/webkit/webdriver/WebchromeClientWrapper.java193
-rw-r--r--core/java/android/widget/FrameLayout.java3
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java234
-rw-r--r--core/java/com/android/internal/view/IInputMethodManager.aidl1
-rw-r--r--core/jni/AndroidRuntime.cpp202
-rw-r--r--core/jni/android/graphics/Bitmap.cpp1
-rw-r--r--core/jni/android/graphics/BitmapFactory.cpp71
-rw-r--r--core/jni/android/graphics/BitmapRegionDecoder.cpp24
-rw-r--r--core/jni/android/graphics/Camera.cpp2
-rw-r--r--core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp63
-rw-r--r--core/jni/android/graphics/Graphics.cpp37
-rw-r--r--core/jni/android/graphics/Interpolator.cpp5
-rw-r--r--core/jni/android/graphics/LayerRasterizer.cpp4
-rw-r--r--core/jni/android/graphics/MaskFilter.cpp8
-rw-r--r--core/jni/android/graphics/Movie.cpp7
-rw-r--r--core/jni/android/graphics/NinePatch.cpp1
-rw-r--r--core/jni/android/graphics/PathEffect.cpp20
-rw-r--r--core/jni/android/graphics/Region.cpp31
-rw-r--r--core/jni/android/graphics/Shader.cpp22
-rw-r--r--core/jni/android/graphics/Typeface.cpp27
-rw-r--r--core/jni/android/graphics/YuvToJpegEncoder.cpp1
-rw-r--r--core/jni/android_backup_BackupDataInput.cpp17
-rw-r--r--core/jni/android_backup_BackupDataOutput.cpp15
-rw-r--r--core/jni/android_backup_BackupHelperDispatcher.cpp29
-rw-r--r--core/jni/android_backup_FileBackupHelperBase.cpp17
-rw-r--r--core/jni/android_content_res_ObbScanner.cpp2
-rw-r--r--core/jni/android_database_SQLiteStatement.cpp2
-rw-r--r--core/jni/android_emoji_EmojiFactory.cpp31
-rw-r--r--core/jni/android_hardware_UsbDevice.cpp7
-rw-r--r--core/jni/android_hardware_UsbDeviceConnection.cpp2
-rw-r--r--core/jni/android_media_JetPlayer.cpp2
-rw-r--r--core/jni/android_net_NetUtils.cpp19
-rw-r--r--core/jni/android_net_TrafficStats.cpp14
-rw-r--r--core/jni/android_net_wifi_Wifi.cpp414
-rw-r--r--core/jni/android_nio_utils.cpp9
-rw-r--r--core/jni/android_opengl_GLES10.cpp186
-rw-r--r--core/jni/android_opengl_GLES10Ext.cpp65
-rw-r--r--core/jni/android_opengl_GLES11.cpp236
-rw-r--r--core/jni/android_opengl_GLES11Ext.cpp236
-rw-r--r--core/jni/android_opengl_GLES20.cpp398
-rw-r--r--core/jni/android_os_FileUtils.cpp27
-rw-r--r--core/jni/android_os_MemoryFile.cpp9
-rw-r--r--core/jni/android_os_ParcelFileDescriptor.cpp75
-rw-r--r--core/jni/android_pim_EventRecurrence.cpp6
-rw-r--r--core/jni/android_text_AndroidBidi.cpp23
-rw-r--r--core/jni/android_text_AndroidCharacter.cpp3
-rw-r--r--core/jni/android_util_AssetManager.cpp2
-rw-r--r--core/jni/android_util_Binder.cpp63
-rw-r--r--core/jni/android_util_Binder.h17
-rw-r--r--core/jni/android_util_EventLog.cpp3
-rw-r--r--core/jni/android_util_Process.cpp16
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp10
-rw-r--r--core/jni/com_android_internal_graphics_NativeUtils.cpp5
-rw-r--r--core/jni/com_google_android_gles_jni_EGLImpl.cpp44
-rw-r--r--core/jni/com_google_android_gles_jni_GLImpl.cpp558
-rw-r--r--core/res/AndroidManifest.xml7
-rw-r--r--core/res/res/values/attrs_manifest.xml4
-rw-r--r--core/res/res/values/public.xml1
-rwxr-xr-xcore/res/res/values/strings.xml7
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java1
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java47
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java35
-rw-r--r--core/tests/overlaytests/Android.mk4
-rw-r--r--core/tests/overlaytests/OverlayTest/Android.mk10
-rw-r--r--core/tests/overlaytests/OverlayTest/AndroidManifest.xml10
-rw-r--r--core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java118
-rw-r--r--core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java7
-rw-r--r--core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java7
-rw-r--r--core/tests/overlaytests/OverlayTestOverlay/Android.mk14
-rw-r--r--core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml6
-rw-r--r--core/tests/overlaytests/OverlayTestOverlay/res/drawable/default_wallpaper.jpgbin0 -> 399 bytes
-rw-r--r--core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml4
-rw-r--r--core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml13
-rw-r--r--core/tests/overlaytests/README15
-rwxr-xr-xcore/tests/overlaytests/runtests.sh89
94 files changed, 2729 insertions, 2174 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index ebe403b..fca6868 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -205,13 +205,6 @@ public class ActivityManager {
public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002;
/**
- * Flag for use with {@link #getRecentTasks}: also return the thumbnail
- * bitmap (if available) for each recent task.
- * @hide
- */
- public static final int TASKS_GET_THUMBNAILS = 0x0001000;
-
- /**
* Return a list of the tasks that the user has recently launched, with
* the most recent being first and older ones after in order.
*
@@ -241,7 +234,7 @@ public class ActivityManager {
/**
* Information you can retrieve about a particular task that is currently
* "running" in the system. Note that a running task does not mean the
- * given task actual has a process it is actively running in; it simply
+ * given task actually has a process it is actively running in; it simply
* means that the user has gone to it and never closed it, but currently
* the system may have killed its process and is only holding on to its
* last state in order to restart it when the user returns.
@@ -396,6 +389,55 @@ public class ActivityManager {
return getRunningTasks(maxNum, 0, null);
}
+ /**
+ * Remove some end of a task's activity stack that is not part of
+ * the main application. The selected activities will be finished, so
+ * they are no longer part of the main task.
+ *
+ * @param taskId The identifier of the task.
+ * @param subTaskIndex The number of the sub-task; this corresponds
+ * to the index of the thumbnail returned by {@link #getTaskThumbnails(int)}.
+ * @return Returns true if the sub-task was found and was removed.
+ *
+ * @hide
+ */
+ public boolean removeSubTask(int taskId, int subTaskIndex)
+ throws SecurityException {
+ try {
+ return ActivityManagerNative.getDefault().removeSubTask(taskId, subTaskIndex);
+ } catch (RemoteException e) {
+ // System dead, we will be dead too soon!
+ return false;
+ }
+ }
+
+ /**
+ * If set, the process of the root activity of the task will be killed
+ * as part of removing the task.
+ * @hide
+ */
+ public static final int REMOVE_TASK_KILL_PROCESS = 0x0001;
+
+ /**
+ * Completely remove the given task.
+ *
+ * @param taskId Identifier of the task to be removed.
+ * @param flags Additional operational flags. May be 0 or
+ * {@link #REMOVE_TASK_KILL_PROCESS}.
+ * @return Returns true if the given task was found and removed.
+ *
+ * @hide
+ */
+ public boolean removeTask(int taskId, int flags)
+ throws SecurityException {
+ try {
+ return ActivityManagerNative.getDefault().removeTask(taskId, flags);
+ } catch (RemoteException e) {
+ // System dead, we will be dead too soon!
+ return false;
+ }
+ }
+
/** @hide */
public static class TaskThumbnails implements Parcelable {
public Bitmap mainThumbnail;
@@ -405,9 +447,6 @@ public class ActivityManager {
/** @hide */
public IThumbnailRetriever retriever;
- /** @hide Magic for ActivityManagerService. Not marshalled */
- public ArrayList<Bitmap> otherThumbnails;
-
public TaskThumbnails() {
}
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index d41c2d0..4b09b34c 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1405,6 +1405,28 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
reply.writeInt(result ? 1 : 0);
return true;
}
+
+ case REMOVE_SUB_TASK_TRANSACTION:
+ {
+ data.enforceInterface(IActivityManager.descriptor);
+ int taskId = data.readInt();
+ int subTaskIndex = data.readInt();
+ boolean result = removeSubTask(taskId, subTaskIndex);
+ reply.writeNoException();
+ reply.writeInt(result ? 1 : 0);
+ return true;
+ }
+
+ case REMOVE_TASK_TRANSACTION:
+ {
+ data.enforceInterface(IActivityManager.descriptor);
+ int taskId = data.readInt();
+ int fl = data.readInt();
+ boolean result = removeTask(taskId, fl);
+ reply.writeNoException();
+ reply.writeInt(result ? 1 : 0);
+ return true;
+ }
}
@@ -3162,6 +3184,34 @@ class ActivityManagerProxy implements IActivityManager
data.recycle();
return result;
}
+
+ public boolean removeSubTask(int taskId, int subTaskIndex) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeInt(taskId);
+ data.writeInt(subTaskIndex);
+ mRemote.transact(REMOVE_SUB_TASK_TRANSACTION, data, reply, 0);
+ reply.readException();
+ boolean result = reply.readInt() != 0;
+ reply.recycle();
+ data.recycle();
+ return result;
+ }
+
+ public boolean removeTask(int taskId, int flags) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeInt(taskId);
+ data.writeInt(flags);
+ mRemote.transact(REMOVE_TASK_TRANSACTION, data, reply, 0);
+ reply.readException();
+ boolean result = reply.readInt() != 0;
+ reply.recycle();
+ data.recycle();
+ return result;
+ }
private IBinder mRemote;
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 57a79a9..4dfba91 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -334,6 +334,7 @@ public final class ActivityThread {
private static final class ServiceArgsData {
IBinder token;
+ boolean taskRemoved;
int startId;
int flags;
Intent args;
@@ -534,10 +535,11 @@ public final class ActivityThread {
queueOrSendMessage(H.UNBIND_SERVICE, s);
}
- public final void scheduleServiceArgs(IBinder token, int startId,
+ public final void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
int flags ,Intent args) {
ServiceArgsData s = new ServiceArgsData();
s.token = token;
+ s.taskRemoved = taskRemoved;
s.startId = startId;
s.flags = flags;
s.args = args;
@@ -2129,7 +2131,13 @@ public final class ActivityThread {
if (data.args != null) {
data.args.setExtrasClassLoader(s.getClassLoader());
}
- int res = s.onStartCommand(data.args, data.flags, data.startId);
+ int res;
+ if (!data.taskRemoved) {
+ res = s.onStartCommand(data.args, data.flags, data.startId);
+ } else {
+ s.onTaskRemoved(data.args);
+ res = Service.START_TASK_REMOVED_COMPLETE;
+ }
QueuedWork.waitToFinish();
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index a82234e..0e511f2 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -219,6 +219,7 @@ public abstract class ApplicationThreadNative extends Binder
{
data.enforceInterface(IApplicationThread.descriptor);
IBinder token = data.readStrongBinder();
+ boolean taskRemoved = data.readInt() != 0;
int startId = data.readInt();
int fl = data.readInt();
Intent args;
@@ -227,7 +228,7 @@ public abstract class ApplicationThreadNative extends Binder
} else {
args = null;
}
- scheduleServiceArgs(token, startId, fl, args);
+ scheduleServiceArgs(token, taskRemoved, startId, fl, args);
return true;
}
@@ -688,11 +689,12 @@ class ApplicationThreadProxy implements IApplicationThread {
data.recycle();
}
- public final void scheduleServiceArgs(IBinder token, int startId,
+ public final void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
int flags, Intent args) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
data.writeStrongBinder(token);
+ data.writeInt(taskRemoved ? 1 : 0);
data.writeInt(startId);
data.writeInt(flags);
if (args != null) {
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 5a15b08..bec697a 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -344,6 +344,10 @@ public interface IActivityManager extends IInterface {
// Multi-user APIs
public boolean switchUser(int userid) throws RemoteException;
+
+ public boolean removeSubTask(int taskId, int subTaskIndex) throws RemoteException;
+
+ public boolean removeTask(int taskId, int flags) throws RemoteException;
/*
* Private non-Binder interfaces
@@ -561,4 +565,6 @@ public interface IActivityManager extends IInterface {
int START_ACTIVITIES_IN_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+121;
int ACTIVITY_SLEPT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+122;
int SWITCH_USER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+123;
+ int REMOVE_SUB_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+124;
+ int REMOVE_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+125;
}
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index 55177a9..b29b088 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -73,8 +73,8 @@ public interface IApplicationThread extends IInterface {
Intent intent, boolean rebind) throws RemoteException;
void scheduleUnbindService(IBinder token,
Intent intent) throws RemoteException;
- void scheduleServiceArgs(IBinder token, int startId, int flags, Intent args)
- throws RemoteException;
+ void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
+ int flags, Intent args) throws RemoteException;
void scheduleStopService(IBinder token) throws RemoteException;
static final int DEBUG_OFF = 0;
static final int DEBUG_ON = 1;
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java
index 05b9781..c179b35 100644
--- a/core/java/android/app/Service.java
+++ b/core/java/android/app/Service.java
@@ -371,6 +371,13 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
public static final int START_REDELIVER_INTENT = 3;
/**
+ * Special constant for reporting that we are done processing
+ * {@link #onTaskRemoved(Intent)}.
+ * @hide
+ */
+ public static final int START_TASK_REMOVED_COMPLETE = 1000;
+
+ /**
* This flag is set in {@link #onStartCommand} if the Intent is a
* re-delivery of a previously delivered intent, because the service
* had previously returned {@link #START_REDELIVER_INTENT} but had been
@@ -500,6 +507,19 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
}
/**
+ * This is called if the service is currently running and the user has
+ * removed a task that comes from the service's application. If you have
+ * set {@link android.content.pm.ServiceInfo#FLAG_STOP_WITH_TASK ServiceInfo.FLAG_STOP_WITH_TASK}
+ * then you will not receive this callback; instead, the service will simply
+ * be stopped.
+ *
+ * @param rootIntent The original root Intent that was used to launch
+ * the task that is being removed.
+ */
+ public void onTaskRemoved(Intent rootIntent) {
+ }
+
+ /**
* Stop the service, if it was previously started. This is the same as
* calling {@link android.content.Context#stopService} for this particular service.
*
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 67cd4a2..54a8842 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2473,6 +2473,13 @@ public class PackageParser {
s.info.permission = str.length() > 0 ? str.toString().intern() : null;
}
+ s.info.flags = 0;
+ if (sa.getBoolean(
+ com.android.internal.R.styleable.AndroidManifestService_stopWithTask,
+ false)) {
+ s.info.flags |= ServiceInfo.FLAG_STOP_WITH_TASK;
+ }
+
sa.recycle();
if ((owner.applicationInfo.flags&ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index 087a4fe..612e345 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -33,17 +33,35 @@ public class ServiceInfo extends ComponentInfo
*/
public String permission;
+ /**
+ * Bit in {@link #flags}: If set, the service will automatically be
+ * stopped by the system if the user removes a task that is rooted
+ * in one of the application's activities. Set from the
+ * {@link android.R.attr#stopWithTask} attribute.
+ */
+ public static final int FLAG_STOP_WITH_TASK = 0x0001;
+
+ /**
+ * Options that have been set in the service declaration in the
+ * manifest.
+ * These include:
+ * {@link #FLAG_STOP_WITH_TASK}
+ */
+ public int flags;
+
public ServiceInfo() {
}
public ServiceInfo(ServiceInfo orig) {
super(orig);
permission = orig.permission;
+ flags = orig.flags;
}
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "permission=" + permission);
+ pw.println(prefix + "flags=0x" + Integer.toHexString(flags));
}
public String toString() {
@@ -59,6 +77,7 @@ public class ServiceInfo extends ComponentInfo
public void writeToParcel(Parcel dest, int parcelableFlags) {
super.writeToParcel(dest, parcelableFlags);
dest.writeString(permission);
+ dest.writeInt(flags);
}
public static final Creator<ServiceInfo> CREATOR =
@@ -74,5 +93,6 @@ public class ServiceInfo extends ComponentInfo
private ServiceInfo(Parcel source) {
super(source);
permission = source.readString();
+ flags = source.readInt();
}
}
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 0a13b4e6..6c6a72d 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -1180,6 +1180,8 @@ public class Camera {
private static final String KEY_MAX_EXPOSURE_COMPENSATION = "max-exposure-compensation";
private static final String KEY_MIN_EXPOSURE_COMPENSATION = "min-exposure-compensation";
private static final String KEY_EXPOSURE_COMPENSATION_STEP = "exposure-compensation-step";
+ private static final String KEY_METERING_AREAS = "metering-areas";
+ private static final String KEY_MAX_NUM_METERING_AREAS = "max-num-metering-areas";
private static final String KEY_ZOOM = "zoom";
private static final String KEY_MAX_ZOOM = "max-zoom";
private static final String KEY_ZOOM_RATIOS = "zoom-ratios";
@@ -1518,6 +1520,27 @@ public class Camera {
mMap.put(key, Integer.toString(value));
}
+ private void set(String key, List<Area> areas) {
+ StringBuilder buffer = new StringBuilder();
+ for (int i = 0; i < areas.size(); i++) {
+ Area area = areas.get(i);
+ Rect rect = area.rect;
+ buffer.append('(');
+ buffer.append(rect.left);
+ buffer.append(',');
+ buffer.append(rect.top);
+ buffer.append(',');
+ buffer.append(rect.right);
+ buffer.append(',');
+ buffer.append(rect.bottom);
+ buffer.append(',');
+ buffer.append(area.weight);
+ buffer.append(')');
+ if (i != areas.size() - 1) buffer.append(',');
+ }
+ set(key, buffer.toString());
+ }
+
/**
* Returns the value of a String parameter.
*
@@ -2562,7 +2585,8 @@ public class Camera {
}
/**
- * Gets the current focus areas.
+ * Gets the current focus areas. Camera driver uses the areas to decide
+ * focus.
*
* Before using this API or {@link #setFocusAreas(List<int>)}, apps
* should call {@link #getMaxNumFocusArea()} to know the maximum number of
@@ -2610,25 +2634,76 @@ public class Camera {
* @see #getFocusAreas()
* @hide
*/
- public void setFocusAreas(List<Area> focusArea) {
- StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < focusArea.size(); i++) {
- Area area = focusArea.get(i);
- Rect rect = area.rect;
- buffer.append('(');
- buffer.append(rect.left);
- buffer.append(',');
- buffer.append(rect.top);
- buffer.append(',');
- buffer.append(rect.right);
- buffer.append(',');
- buffer.append(rect.bottom);
- buffer.append(',');
- buffer.append(area.weight);
- buffer.append(')');
- if (i != focusArea.size() - 1) buffer.append(',');
- }
- set(KEY_FOCUS_AREAS, buffer.toString());
+ public void setFocusAreas(List<Area> focusAreas) {
+ set(KEY_FOCUS_AREAS, focusAreas);
+ }
+
+ /**
+ * Gets the maximum number of metering areas supported. This is the
+ * maximum length of the list in {@link #setMeteringArea(List<Area>)}
+ * and {@link #getMeteringArea()}.
+ *
+ * @return the maximum number of metering areas supported by the camera.
+ * @see #getMeteringAreas()
+ * @hide
+ */
+ public int getMaxNumMeteringAreas() {
+ return getInt(KEY_MAX_NUM_METERING_AREAS, 0);
+ }
+
+ /**
+ * Gets the current metering areas. Camera driver uses these areas to
+ * decide exposure.
+ *
+ * Before using this API or {@link #setMeteringAreas(List<int>)}, apps
+ * should call {@link #getMaxNumMeteringArea()} to know the maximum
+ * number of metering areas first. If the value is 0, metering area is
+ * not supported.
+ *
+ * Each metering area is a rectangle with specified weight. The
+ * direction is relative to the sensor orientation, that is, what the
+ * sensor sees. The direction is not affected by the rotation or
+ * mirroring of {@link #setDisplayOrientation(int)}. Coordinates of the
+ * rectangle range from -1000 to 1000. (-1000, -1000) is the upper left
+ * point. (1000, 1000) is the lower right point. The length and width of
+ * metering areas cannot be 0 or negative.
+ *
+ * The weight ranges from 1 to 1000. The sum of the weights of all
+ * metering areas must be 1000. Metering areas can partially overlap and
+ * the driver will add the weights in the overlap region. But apps
+ * should not set two metering areas that have identical coordinates.
+ *
+ * A special case of all-zero single metering area means driver to
+ * decide the metering area. For example, the driver may use more
+ * signals to decide metering areas and change them dynamically. Apps
+ * can set all-zero if they want the driver to decide metering areas.
+ *
+ * Metering areas are relative to the current field of view
+ * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000)
+ * represents the top of the currently visible camera frame. The
+ * metering area cannot be set to be outside the current field of view,
+ * even when using zoom.
+ *
+ * No matter what metering areas are, the final exposure are compensated
+ * by {@link setExposureCompensation(int)}.
+ *
+ * @return a list of current metering areas
+ * @hide
+ */
+ public List<Area> getMeteringAreas() {
+ return splitArea(KEY_METERING_AREAS);
+ }
+
+ /**
+ * Sets metering areas. See {@link #getMeteringAreas()} for
+ * documentation.
+ *
+ * @param meteringArea the metering areas
+ * @see #getMeteringAreas()
+ * @hide
+ */
+ public void setMeteringAreas(List<Area> meteringAreas) {
+ set(KEY_METERING_AREAS, meteringAreas);
}
// Splits a comma delimited string to an ArrayList of String.
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 90e2e79..d7483ba 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -412,6 +412,7 @@ public abstract class BatteryStats implements Parcelable {
public long time;
+ public static final byte CMD_NULL = -1;
public static final byte CMD_UPDATE = 0;
public static final byte CMD_START = 1;
public static final byte CMD_OVERFLOW = 2;
@@ -466,16 +467,7 @@ public abstract class BatteryStats implements Parcelable {
public HistoryItem(long time, Parcel src) {
this.time = time;
- int bat = src.readInt();
- cmd = (byte)(bat&0xff);
- batteryLevel = (byte)((bat>>8)&0xff);
- batteryStatus = (byte)((bat>>16)&0xf);
- batteryHealth = (byte)((bat>>20)&0xf);
- batteryPlugType = (byte)((bat>>24)&0xf);
- bat = src.readInt();
- batteryTemperature = (char)(bat&0xffff);
- batteryVoltage = (char)((bat>>16)&0xffff);
- states = src.readInt();
+ readFromParcel(src);
}
public int describeContents() {
@@ -496,6 +488,28 @@ public abstract class BatteryStats implements Parcelable {
dest.writeInt(states);
}
+ public void writeDelta(Parcel dest, HistoryItem last) {
+ writeToParcel(dest, 0);
+ }
+
+ private void readFromParcel(Parcel src) {
+ int bat = src.readInt();
+ cmd = (byte)(bat&0xff);
+ batteryLevel = (byte)((bat>>8)&0xff);
+ batteryStatus = (byte)((bat>>16)&0xf);
+ batteryHealth = (byte)((bat>>20)&0xf);
+ batteryPlugType = (byte)((bat>>24)&0xf);
+ bat = src.readInt();
+ batteryTemperature = (char)(bat&0xffff);
+ batteryVoltage = (char)((bat>>16)&0xffff);
+ states = src.readInt();
+ }
+
+ public void readDelta(Parcel src, HistoryItem last) {
+ time = src.readLong();
+ readFromParcel(src);
+ }
+
public void setTo(HistoryItem o) {
time = o.time;
cmd = o.cmd;
@@ -556,11 +570,14 @@ public abstract class BatteryStats implements Parcelable {
public abstract boolean getNextHistoryLocked(HistoryItem out);
- /**
- * Return the current history of battery state changes.
- */
- public abstract HistoryItem getHistory();
-
+ public abstract void finishIteratingHistoryLocked();
+
+ public abstract boolean startIteratingOldHistoryLocked();
+
+ public abstract boolean getNextOldHistoryLocked(HistoryItem out);
+
+ public abstract void finishIteratingOldHistoryLocked();
+
/**
* Return the base time offset for the battery history.
*/
@@ -1729,7 +1746,7 @@ public abstract class BatteryStats implements Parcelable {
}
}
- void printBitDescriptions(PrintWriter pw, int oldval, int newval, BitDescription[] descriptions) {
+ static void printBitDescriptions(PrintWriter pw, int oldval, int newval, BitDescription[] descriptions) {
int diff = oldval ^ newval;
if (diff == 0) return;
for (int i=0; i<descriptions.length; i++) {
@@ -1753,6 +1770,125 @@ public abstract class BatteryStats implements Parcelable {
}
}
+ public void prepareForDumpLocked() {
+ }
+
+ public static class HistoryPrinter {
+ int oldState = 0;
+ int oldStatus = -1;
+ int oldHealth = -1;
+ int oldPlug = -1;
+ int oldTemp = -1;
+ int oldVolt = -1;
+
+ public void printNextItem(PrintWriter pw, HistoryItem rec, long now) {
+ pw.print(" ");
+ TimeUtils.formatDuration(rec.time-now, pw, TimeUtils.HUNDRED_DAY_FIELD_LEN);
+ pw.print(" ");
+ if (rec.cmd == HistoryItem.CMD_START) {
+ pw.println(" START");
+ } else if (rec.cmd == HistoryItem.CMD_OVERFLOW) {
+ pw.println(" *OVERFLOW*");
+ } else {
+ if (rec.batteryLevel < 10) pw.print("00");
+ else if (rec.batteryLevel < 100) pw.print("0");
+ pw.print(rec.batteryLevel);
+ pw.print(" ");
+ if (rec.states < 0x10) pw.print("0000000");
+ else if (rec.states < 0x100) pw.print("000000");
+ else if (rec.states < 0x1000) pw.print("00000");
+ else if (rec.states < 0x10000) pw.print("0000");
+ else if (rec.states < 0x100000) pw.print("000");
+ else if (rec.states < 0x1000000) pw.print("00");
+ else if (rec.states < 0x10000000) pw.print("0");
+ pw.print(Integer.toHexString(rec.states));
+ if (oldStatus != rec.batteryStatus) {
+ oldStatus = rec.batteryStatus;
+ pw.print(" status=");
+ switch (oldStatus) {
+ case BatteryManager.BATTERY_STATUS_UNKNOWN:
+ pw.print("unknown");
+ break;
+ case BatteryManager.BATTERY_STATUS_CHARGING:
+ pw.print("charging");
+ break;
+ case BatteryManager.BATTERY_STATUS_DISCHARGING:
+ pw.print("discharging");
+ break;
+ case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
+ pw.print("not-charging");
+ break;
+ case BatteryManager.BATTERY_STATUS_FULL:
+ pw.print("full");
+ break;
+ default:
+ pw.print(oldStatus);
+ break;
+ }
+ }
+ if (oldHealth != rec.batteryHealth) {
+ oldHealth = rec.batteryHealth;
+ pw.print(" health=");
+ switch (oldHealth) {
+ case BatteryManager.BATTERY_HEALTH_UNKNOWN:
+ pw.print("unknown");
+ break;
+ case BatteryManager.BATTERY_HEALTH_GOOD:
+ pw.print("good");
+ break;
+ case BatteryManager.BATTERY_HEALTH_OVERHEAT:
+ pw.print("overheat");
+ break;
+ case BatteryManager.BATTERY_HEALTH_DEAD:
+ pw.print("dead");
+ break;
+ case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
+ pw.print("over-voltage");
+ break;
+ case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
+ pw.print("failure");
+ break;
+ default:
+ pw.print(oldHealth);
+ break;
+ }
+ }
+ if (oldPlug != rec.batteryPlugType) {
+ oldPlug = rec.batteryPlugType;
+ pw.print(" plug=");
+ switch (oldPlug) {
+ case 0:
+ pw.print("none");
+ break;
+ case BatteryManager.BATTERY_PLUGGED_AC:
+ pw.print("ac");
+ break;
+ case BatteryManager.BATTERY_PLUGGED_USB:
+ pw.print("usb");
+ break;
+ default:
+ pw.print(oldPlug);
+ break;
+ }
+ }
+ if (oldTemp != rec.batteryTemperature) {
+ oldTemp = rec.batteryTemperature;
+ pw.print(" temp=");
+ pw.print(oldTemp);
+ }
+ if (oldVolt != rec.batteryVoltage) {
+ oldVolt = rec.batteryVoltage;
+ pw.print(" volt=");
+ pw.print(oldVolt);
+ }
+ printBitDescriptions(pw, oldState, rec.states,
+ HISTORY_STATE_DESCRIPTIONS);
+ pw.println();
+ }
+ oldState = rec.states;
+ }
+ }
+
/**
* Dumps a human-readable summary of the battery statistics to the given PrintWriter.
*
@@ -1760,122 +1896,28 @@ public abstract class BatteryStats implements Parcelable {
*/
@SuppressWarnings("unused")
public void dumpLocked(PrintWriter pw) {
+ prepareForDumpLocked();
+
+ long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
+
final HistoryItem rec = new HistoryItem();
if (startIteratingHistoryLocked()) {
pw.println("Battery History:");
- long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
- int oldState = 0;
- int oldStatus = -1;
- int oldHealth = -1;
- int oldPlug = -1;
- int oldTemp = -1;
- int oldVolt = -1;
+ HistoryPrinter hprinter = new HistoryPrinter();
while (getNextHistoryLocked(rec)) {
- pw.print(" ");
- TimeUtils.formatDuration(rec.time-now, pw, TimeUtils.HUNDRED_DAY_FIELD_LEN);
- pw.print(" ");
- if (rec.cmd == HistoryItem.CMD_START) {
- pw.println(" START");
- } else if (rec.cmd == HistoryItem.CMD_OVERFLOW) {
- pw.println(" *OVERFLOW*");
- } else {
- if (rec.batteryLevel < 10) pw.print("00");
- else if (rec.batteryLevel < 100) pw.print("0");
- pw.print(rec.batteryLevel);
- pw.print(" ");
- if (rec.states < 0x10) pw.print("0000000");
- else if (rec.states < 0x100) pw.print("000000");
- else if (rec.states < 0x1000) pw.print("00000");
- else if (rec.states < 0x10000) pw.print("0000");
- else if (rec.states < 0x100000) pw.print("000");
- else if (rec.states < 0x1000000) pw.print("00");
- else if (rec.states < 0x10000000) pw.print("0");
- pw.print(Integer.toHexString(rec.states));
- if (oldStatus != rec.batteryStatus) {
- oldStatus = rec.batteryStatus;
- pw.print(" status=");
- switch (oldStatus) {
- case BatteryManager.BATTERY_STATUS_UNKNOWN:
- pw.print("unknown");
- break;
- case BatteryManager.BATTERY_STATUS_CHARGING:
- pw.print("charging");
- break;
- case BatteryManager.BATTERY_STATUS_DISCHARGING:
- pw.print("discharging");
- break;
- case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
- pw.print("not-charging");
- break;
- case BatteryManager.BATTERY_STATUS_FULL:
- pw.print("full");
- break;
- default:
- pw.print(oldStatus);
- break;
- }
- }
- if (oldHealth != rec.batteryHealth) {
- oldHealth = rec.batteryHealth;
- pw.print(" health=");
- switch (oldHealth) {
- case BatteryManager.BATTERY_HEALTH_UNKNOWN:
- pw.print("unknown");
- break;
- case BatteryManager.BATTERY_HEALTH_GOOD:
- pw.print("good");
- break;
- case BatteryManager.BATTERY_HEALTH_OVERHEAT:
- pw.print("overheat");
- break;
- case BatteryManager.BATTERY_HEALTH_DEAD:
- pw.print("dead");
- break;
- case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
- pw.print("over-voltage");
- break;
- case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
- pw.print("failure");
- break;
- default:
- pw.print(oldHealth);
- break;
- }
- }
- if (oldPlug != rec.batteryPlugType) {
- oldPlug = rec.batteryPlugType;
- pw.print(" plug=");
- switch (oldPlug) {
- case 0:
- pw.print("none");
- break;
- case BatteryManager.BATTERY_PLUGGED_AC:
- pw.print("ac");
- break;
- case BatteryManager.BATTERY_PLUGGED_USB:
- pw.print("usb");
- break;
- default:
- pw.print(oldPlug);
- break;
- }
- }
- if (oldTemp != rec.batteryTemperature) {
- oldTemp = rec.batteryTemperature;
- pw.print(" temp=");
- pw.print(oldTemp);
- }
- if (oldVolt != rec.batteryVoltage) {
- oldVolt = rec.batteryVoltage;
- pw.print(" volt=");
- pw.print(oldVolt);
- }
- printBitDescriptions(pw, oldState, rec.states,
- HISTORY_STATE_DESCRIPTIONS);
- pw.println();
- }
- oldState = rec.states;
+ hprinter.printNextItem(pw, rec, now);
+ }
+ finishIteratingHistoryLocked();
+ pw.println("");
+ }
+
+ if (startIteratingOldHistoryLocked()) {
+ pw.println("Old battery History:");
+ HistoryPrinter hprinter = new HistoryPrinter();
+ while (getNextOldHistoryLocked(rec)) {
+ hprinter.printNextItem(pw, rec, now);
}
+ finishIteratingOldHistoryLocked();
pw.println("");
}
@@ -1918,6 +1960,8 @@ public abstract class BatteryStats implements Parcelable {
@SuppressWarnings("unused")
public void dumpCheckinLocked(PrintWriter pw, String[] args, List<ApplicationInfo> apps) {
+ prepareForDumpLocked();
+
boolean isUnpluggedOnly = false;
for (String arg : args) {
diff --git a/core/java/android/os/ParcelFileDescriptor.java b/core/java/android/os/ParcelFileDescriptor.java
index aa959b4..f7661b6 100644
--- a/core/java/android/os/ParcelFileDescriptor.java
+++ b/core/java/android/os/ParcelFileDescriptor.java
@@ -35,64 +35,64 @@ public class ParcelFileDescriptor implements Parcelable {
//consider ParcelFileDescriptor A(fileDescriptor fd), ParcelFileDescriptor B(A)
//in this particular case fd.close might be invoked twice.
private final ParcelFileDescriptor mParcelDescriptor;
-
+
/**
* For use with {@link #open}: if {@link #MODE_CREATE} has been supplied
* and this file doesn't already exist, then create the file with
* permissions such that any application can read it.
*/
public static final int MODE_WORLD_READABLE = 0x00000001;
-
+
/**
* For use with {@link #open}: if {@link #MODE_CREATE} has been supplied
* and this file doesn't already exist, then create the file with
* permissions such that any application can write it.
*/
public static final int MODE_WORLD_WRITEABLE = 0x00000002;
-
+
/**
* For use with {@link #open}: open the file with read-only access.
*/
public static final int MODE_READ_ONLY = 0x10000000;
-
+
/**
* For use with {@link #open}: open the file with write-only access.
*/
public static final int MODE_WRITE_ONLY = 0x20000000;
-
+
/**
* For use with {@link #open}: open the file with read and write access.
*/
public static final int MODE_READ_WRITE = 0x30000000;
-
+
/**
* For use with {@link #open}: create the file if it doesn't already exist.
*/
public static final int MODE_CREATE = 0x08000000;
-
+
/**
* For use with {@link #open}: erase contents of file when opening.
*/
public static final int MODE_TRUNCATE = 0x04000000;
-
+
/**
* For use with {@link #open}: append to end of file while writing.
*/
public static final int MODE_APPEND = 0x02000000;
-
+
/**
* Create a new ParcelFileDescriptor accessing a given file.
- *
+ *
* @param file The file to be opened.
* @param mode The desired access mode, must be one of
* {@link #MODE_READ_ONLY}, {@link #MODE_WRITE_ONLY}, or
* {@link #MODE_READ_WRITE}; may also be any combination of
* {@link #MODE_CREATE}, {@link #MODE_TRUNCATE},
* {@link #MODE_WORLD_READABLE}, and {@link #MODE_WORLD_WRITEABLE}.
- *
+ *
* @return Returns a new ParcelFileDescriptor pointing to the given
* file.
- *
+ *
* @throws FileNotFoundException Throws FileNotFoundException if the given
* file does not exist or can not be opened with the requested mode.
*/
@@ -106,12 +106,12 @@ public class ParcelFileDescriptor implements Parcelable {
security.checkWrite(path);
}
}
-
+
if ((mode&MODE_READ_WRITE) == 0) {
throw new IllegalArgumentException(
"Must specify MODE_READ_ONLY, MODE_WRITE_ONLY, or MODE_READ_WRITE");
}
-
+
FileDescriptor fd = Parcel.openFileDescriptor(path, mode);
return fd != null ? new ParcelFileDescriptor(fd) : null;
}
@@ -137,13 +137,10 @@ public class ParcelFileDescriptor implements Parcelable {
* specified Socket.
*/
public static ParcelFileDescriptor fromSocket(Socket socket) {
- FileDescriptor fd = getFileDescriptorFromSocket(socket);
+ FileDescriptor fd = socket.getFileDescriptor$();
return fd != null ? new ParcelFileDescriptor(fd) : null;
}
- // Extracts the file descriptor from the specified socket and returns it untouched
- private static native FileDescriptor getFileDescriptorFromSocket(Socket socket);
-
/**
* Create two ParcelFileDescriptors structured as a data pipe. The first
* ParcelFileDescriptor in the returned array is the read side; the second
@@ -187,26 +184,26 @@ public class ParcelFileDescriptor implements Parcelable {
/**
* Retrieve the actual FileDescriptor associated with this object.
- *
+ *
* @return Returns the FileDescriptor associated with this object.
*/
public FileDescriptor getFileDescriptor() {
return mFileDescriptor;
}
-
+
/**
* Return the total size of the file representing this fd, as determined
* by stat(). Returns -1 if the fd is not a file.
*/
public native long getStatSize();
-
+
/**
* This is needed for implementing AssetFileDescriptor.AutoCloseOutputStream,
* and I really don't think we want it to be public.
* @hide
*/
public native long seekTo(long pos);
-
+
/**
* Return the native fd int for this ParcelFileDescriptor. The
* ParcelFileDescriptor still owns the fd, and it still must be closed
@@ -218,9 +215,9 @@ public class ParcelFileDescriptor implements Parcelable {
}
return getFdNative();
}
-
+
private native int getFdNative();
-
+
/**
* Return the native fd int for this ParcelFileDescriptor and detach it
* from the object here. You are now responsible for closing the fd in
@@ -240,11 +237,11 @@ public class ParcelFileDescriptor implements Parcelable {
Parcel.clearFileDescriptor(mFileDescriptor);
return fd;
}
-
+
/**
* Close the ParcelFileDescriptor. This implementation closes the underlying
* OS resources allocated to represent this stream.
- *
+ *
* @throws IOException
* If an error occurs attempting to close this ParcelFileDescriptor.
*/
@@ -261,7 +258,7 @@ public class ParcelFileDescriptor implements Parcelable {
Parcel.closeFileDescriptor(mFileDescriptor);
}
}
-
+
/**
* An InputStream you can create on a ParcelFileDescriptor, which will
* take care of calling {@link ParcelFileDescriptor#close
@@ -269,7 +266,7 @@ public class ParcelFileDescriptor implements Parcelable {
*/
public static class AutoCloseInputStream extends FileInputStream {
private final ParcelFileDescriptor mFd;
-
+
public AutoCloseInputStream(ParcelFileDescriptor fd) {
super(fd.getFileDescriptor());
mFd = fd;
@@ -284,7 +281,7 @@ public class ParcelFileDescriptor implements Parcelable {
}
}
}
-
+
/**
* An OutputStream you can create on a ParcelFileDescriptor, which will
* take care of calling {@link ParcelFileDescriptor#close
@@ -292,7 +289,7 @@ public class ParcelFileDescriptor implements Parcelable {
*/
public static class AutoCloseOutputStream extends FileOutputStream {
private final ParcelFileDescriptor mFd;
-
+
public AutoCloseOutputStream(ParcelFileDescriptor fd) {
super(fd.getFileDescriptor());
mFd = fd;
@@ -307,12 +304,12 @@ public class ParcelFileDescriptor implements Parcelable {
}
}
}
-
+
@Override
public String toString() {
return "{ParcelFileDescriptor: " + mFileDescriptor + "}";
}
-
+
@Override
protected void finalize() throws Throwable {
try {
@@ -323,13 +320,13 @@ public class ParcelFileDescriptor implements Parcelable {
super.finalize();
}
}
-
+
public ParcelFileDescriptor(ParcelFileDescriptor descriptor) {
super();
mParcelDescriptor = descriptor;
mFileDescriptor = mParcelDescriptor.mFileDescriptor;
}
-
+
/*package */ParcelFileDescriptor(FileDescriptor descriptor) {
super();
if (descriptor == null) {
@@ -338,7 +335,7 @@ public class ParcelFileDescriptor implements Parcelable {
mFileDescriptor = descriptor;
mParcelDescriptor = null;
}
-
+
/* Parcelable interface */
public int describeContents() {
return Parcelable.CONTENTS_FILE_DESCRIPTOR;
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index c1dd911..ae605fb 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -70,7 +70,7 @@ public class RecoverySystem {
private static File RECOVERY_DIR = new File("/cache/recovery");
private static File COMMAND_FILE = new File(RECOVERY_DIR, "command");
private static File LOG_FILE = new File(RECOVERY_DIR, "log");
- private static String LAST_LOG_FILENAME = "last_log";
+ private static String LAST_PREFIX = "last_";
// Length limits for reading files.
private static int LOG_FILE_MAX_LENGTH = 64 * 1024;
@@ -415,10 +415,11 @@ public class RecoverySystem {
Log.e(TAG, "Error reading recovery log", e);
}
- // Delete everything in RECOVERY_DIR except LAST_LOG_FILENAME
+ // Delete everything in RECOVERY_DIR except those beginning
+ // with LAST_PREFIX
String[] names = RECOVERY_DIR.list();
for (int i = 0; names != null && i < names.length; i++) {
- if (names[i].equals(LAST_LOG_FILENAME)) continue;
+ if (names[i].startsWith(LAST_PREFIX)) continue;
File f = new File(RECOVERY_DIR, names[i]);
if (!f.delete()) {
Log.e(TAG, "Can't delete: " + f);
diff --git a/core/java/android/text/CharSequenceIterator.java b/core/java/android/text/CharSequenceIterator.java
index 4946406..4b8ac10 100644
--- a/core/java/android/text/CharSequenceIterator.java
+++ b/core/java/android/text/CharSequenceIterator.java
@@ -16,22 +16,18 @@
package android.text;
-import android.util.MathUtils;
-
import java.text.CharacterIterator;
/** {@hide} */
public class CharSequenceIterator implements CharacterIterator {
private final CharSequence mValue;
- private final int mStart;
- private final int mEnd;
+ private final int mLength;
private int mIndex;
public CharSequenceIterator(CharSequence value) {
mValue = value;
- mStart = 0;
- mEnd = value.length();
+ mLength = value.length();
mIndex = 0;
}
@@ -46,7 +42,7 @@ public class CharSequenceIterator implements CharacterIterator {
/** {@inheritDoc} */
public char current() {
- if (mIndex == mEnd) {
+ if (mIndex == mLength) {
return DONE;
}
return mValue.charAt(mIndex);
@@ -54,12 +50,12 @@ public class CharSequenceIterator implements CharacterIterator {
/** {@inheritDoc} */
public int getBeginIndex() {
- return mStart;
+ return 0;
}
/** {@inheritDoc} */
public int getEndIndex() {
- return mEnd;
+ return mLength;
}
/** {@inheritDoc} */
@@ -69,27 +65,36 @@ public class CharSequenceIterator implements CharacterIterator {
/** {@inheritDoc} */
public char first() {
- return setIndex(mStart);
+ return setIndex(0);
}
/** {@inheritDoc} */
public char last() {
- return setIndex(mEnd - 1);
+ return setIndex(mLength - 1);
}
/** {@inheritDoc} */
public char next() {
+ if (mIndex == mLength) {
+ return DONE;
+ }
return setIndex(mIndex + 1);
}
/** {@inheritDoc} */
public char previous() {
+ if (mIndex == 0) {
+ return DONE;
+ }
return setIndex(mIndex - 1);
}
/** {@inheritDoc} */
public char setIndex(int index) {
- mIndex = MathUtils.constrain(index, mStart, mEnd);
+ if ((index < 0) || (index > mLength)) {
+ throw new IllegalArgumentException("Valid range is [" + 0 + "..." + mLength + "]");
+ }
+ mIndex = index;
return current();
}
}
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index ee6342a..ac5db62 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -37,6 +37,7 @@ import android.text.style.ScaleXSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.SubscriptSpan;
+import android.text.style.SuggestionSpan;
import android.text.style.SuperscriptSpan;
import android.text.style.TextAppearanceSpan;
import android.text.style.TypefaceSpan;
@@ -566,7 +567,7 @@ public class TextUtils {
/** @hide */
public static final int ANNOTATION = 18;
/** @hide */
- public static final int CORRECTION_SPAN = 19;
+ public static final int SUGGESTION_SPAN = 19;
/**
* Flatten a CharSequence and whatever styles can be copied across processes
@@ -712,6 +713,10 @@ public class TextUtils {
readSpan(p, sp, new Annotation(p));
break;
+ case SUGGESTION_SPAN:
+ readSpan(p, sp, new SuggestionSpan(p));
+ break;
+
default:
throw new RuntimeException("bogus span encoding " + kind);
}
diff --git a/core/java/android/text/method/ArrowKeyMovementMethod.java b/core/java/android/text/method/ArrowKeyMovementMethod.java
index 80c0106..b25ba8d 100644
--- a/core/java/android/text/method/ArrowKeyMovementMethod.java
+++ b/core/java/android/text/method/ArrowKeyMovementMethod.java
@@ -390,7 +390,7 @@ public class ArrowKeyMovementMethod extends BaseMovementMethod implements Moveme
}
private boolean isValidOffset(int offset) {
- return offset >= 0 && offset < mCurrent.length();
+ return offset >= 0 && offset <= mCurrent.length();
}
private boolean isLetterOrDigit(int offset) {
@@ -404,7 +404,7 @@ public class ArrowKeyMovementMethod extends BaseMovementMethod implements Moveme
/** {@inheritDoc} */
public int preceding(int offset) {
// always round cursor index into valid string index
- offset = MathUtils.constrain(offset, 0, mCurrent.length() - 1);
+ offset = MathUtils.constrain(offset, 0, mCurrent.length());
do {
offset = mIterator.preceding(offset);
@@ -417,7 +417,7 @@ public class ArrowKeyMovementMethod extends BaseMovementMethod implements Moveme
/** {@inheritDoc} */
public int following(int offset) {
// always round cursor index into valid string index
- offset = MathUtils.constrain(offset, 0, mCurrent.length() - 1);
+ offset = MathUtils.constrain(offset, 0, mCurrent.length());
do {
offset = mIterator.following(offset);
diff --git a/core/java/android/text/style/SuggestionSpan.java b/core/java/android/text/style/SuggestionSpan.java
index 5091c9e..7083641 100644
--- a/core/java/android/text/style/SuggestionSpan.java
+++ b/core/java/android/text/style/SuggestionSpan.java
@@ -26,7 +26,7 @@ import java.util.Arrays;
import java.util.Locale;
/**
- * Sets correction candidates of words under this span.
+ * Holds suggestion candidates of words under this span.
*/
public class SuggestionSpan implements ParcelableSpan {
@@ -139,7 +139,7 @@ public class SuggestionSpan implements ParcelableSpan {
@Override
public int getSpanTypeId() {
- return TextUtils.CORRECTION_SPAN;
+ return TextUtils.SUGGESTION_SPAN;
}
public static final Parcelable.Creator<SuggestionSpan> CREATOR =
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index a39c7c7..eef2a33 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -505,6 +505,13 @@ public final class InputMethodManager {
}
}
+ /**
+ * Returns a list of enabled input method subtypes for the specified input method info.
+ * @param imi An input method info whose subtypes list will be returned.
+ * @param allowsImplicitlySelectedSubtypes A boolean flag to allow to return the implicitly
+ * selected subtypes. If an input method info doesn't have enabled subtypes, the framework
+ * will implicitly enable subtypes according to the current system language.
+ */
public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo imi,
boolean allowsImplicitlySelectedSubtypes) {
try {
@@ -1429,16 +1436,26 @@ public final class InputMethodManager {
}
}
- public void showInputMethodAndSubtypeEnabler(String topId) {
+ /**
+ * Show the settings for enabling subtypes of the specified input method.
+ * @param imiId An input method, whose subtypes settings will be shown. If imiId is null,
+ * subtypes of all input methods will be shown.
+ */
+ public void showInputMethodAndSubtypeEnabler(String imiId) {
synchronized (mH) {
try {
- mService.showInputMethodAndSubtypeEnablerFromClient(mClient, topId);
+ mService.showInputMethodAndSubtypeEnablerFromClient(mClient, imiId);
} catch (RemoteException e) {
Log.w(TAG, "IME died: " + mCurId, e);
}
}
}
+ /**
+ * Returns the current input method subtype. This subtype is one of the subtypes in
+ * the current input method. This method returns null when the current input method doesn't
+ * have any input method subtype.
+ */
public InputMethodSubtype getCurrentInputMethodSubtype() {
synchronized (mH) {
try {
@@ -1450,6 +1467,12 @@ public final class InputMethodManager {
}
}
+ /**
+ * Switch to a new input method subtype of the current input method.
+ * @param subtype A new input method subtype to switch.
+ * @return true if the current subtype was successfully switched. When the specified subtype is
+ * null, this method returns false.
+ */
public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {
synchronized (mH) {
try {
@@ -1461,6 +1484,9 @@ public final class InputMethodManager {
}
}
+ /**
+ * Returns a map of all shortcut input method info and their subtypes.
+ */
public Map<InputMethodInfo, List<InputMethodSubtype>> getShortcutInputMethodsAndSubtypes() {
synchronized (mH) {
HashMap<InputMethodInfo, List<InputMethodSubtype>> ret =
@@ -1493,6 +1519,15 @@ public final class InputMethodManager {
}
}
+ /**
+ * Force switch to the last used input method and subtype. If the last input method didn't have
+ * any subtypes, the framework will simply switch to the last input method with no subtype
+ * specified.
+ * @param imeToken Supplies the identifying token given to an input method when it was started,
+ * which allows it to perform this operation on itself.
+ * @return true if the current input method and subtype was successfully switched to the last
+ * used input method and subtype.
+ */
public boolean switchToLastInputMethod(IBinder imeToken) {
synchronized (mH) {
try {
@@ -1504,6 +1539,17 @@ public final class InputMethodManager {
}
}
+ public InputMethodSubtype getLastInputMethodSubtype() {
+ synchronized (mH) {
+ try {
+ return mService.getLastInputMethodSubtype();
+ } catch (RemoteException e) {
+ Log.w(TAG, "IME died: " + mCurId, e);
+ return null;
+ }
+ }
+ }
+
void doDump(FileDescriptor fd, PrintWriter fout, String[] args) {
final Printer p = new PrintWriterPrinter(fout);
p.println("Input method client state for " + this + ":");
diff --git a/core/java/android/webkit/webdriver/WebDriver.java b/core/java/android/webkit/webdriver/WebDriver.java
new file mode 100644
index 0000000..7a25390
--- /dev/null
+++ b/core/java/android/webkit/webdriver/WebDriver.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.webkit.webdriver;
+
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.Message;
+import android.view.View;
+import android.webkit.ConsoleMessage;
+import android.webkit.GeolocationPermissions;
+import android.webkit.JsPromptResult;
+import android.webkit.JsResult;
+import android.webkit.ValueCallback;
+import android.webkit.WebChromeClient;
+import android.webkit.WebStorage;
+import android.webkit.WebView;
+
+/**
+ * Drives a web application by controlling the WebView. This class
+ * provides a DOM-like API allowing to get information about the page,
+ * navigate, and interact with the web application. This is particularly useful
+ * for testing a web application.
+ *
+ * <p/>{@link android.webkit.webdriver.WebDriver} should be created in the main
+ * thread, and invoked from another thread. Here is a sample usage:
+ *
+ * public class WebDriverStubActivity extends Activity {
+ * private WebDriver mDriver;
+ *
+ * public void onCreate(Bundle savedInstanceState) {
+ * super.onCreate(savedInstanceState);
+ * WebView view = new WebView(this);
+ * mDriver = new WebDriver(view);
+ * setContentView(view);
+ * }
+ *
+ *
+ * public WebDriver getDriver() {
+ * return mDriver;
+ * }
+ *}
+ *
+ * public class WebDriverTest extends
+ * ActivityInstrumentationTestCase2<WebDriverStubActivity>{
+ * private WebDriver mDriver;
+ *
+ * public WebDriverTest() {
+ * super(WebDriverStubActivity.class);
+ * }
+ *
+ * protected void setUp() throws Exception {
+ * super.setUp();
+ * mDriver = getActivity().getDriver();
+ * }
+ *
+ * public void testGetIsBlocking() {
+ * mDriver.get("http://google.com");
+ * assertTrue(mDriver.getPageSource().startsWith("<html"));
+ * }
+ *}
+ *
+ * @hide
+ */
+public class WebDriver {
+ // Timeout for page load in milliseconds
+ private static final int LOADING_TIMEOUT = 30000;
+ // Timeout for executing JavaScript in the WebView in milliseconds
+ private static final int JS_EXECUTION_TIMEOUT = 10000;
+
+ // Commands posted to the handler
+ private static final int GET_URL = 1;
+ private static final int EXECUTE_SCRIPT = 2;
+
+ private static final long MAIN_THREAD = Thread.currentThread().getId();
+
+ // This is updated by a callabck from JavaScript when the result is ready
+ private String mJsResult;
+
+ // Used for synchronization
+ private final Object mSyncObject;
+
+ // Updated when the command is done executing in the main thread.
+ private volatile boolean mCommandDone;
+
+ private WebView mWebView;
+
+ // This Handler runs in the main UI thread
+ private final Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ if (msg.what == GET_URL) {
+ final String url = (String) msg.obj;
+ mWebView.loadUrl(url);
+ } else if (msg.what == EXECUTE_SCRIPT) {
+ executeScript((String) msg.obj);
+ }
+ }
+ };
+
+ public WebDriver(WebView webview) {
+ if (!mWebView.getSettings().getJavaScriptEnabled()) {
+ throw new RuntimeException("Javascript is disabled in the WebView. "
+ + "Enable it to use WebDriver");
+ }
+ shouldRunInMainThread(true);
+ mSyncObject = new Object();
+ this.mWebView = webview;
+ WebchromeClientWrapper chromeWrapper = new WebchromeClientWrapper(
+ webview.getWebChromeClient(), this);
+ mWebView.setWebChromeClient(chromeWrapper);
+ mWebView.addJavascriptInterface(new JavascriptResultReady(),
+ "webdriver");
+ }
+
+ /**
+ * Loads a URL in the WebView. This function is blocking and will return
+ * when the page has finished loading.
+ *
+ * @param url The URL to load.
+ */
+ public void get(String url) {
+ executeCommand(GET_URL, url, LOADING_TIMEOUT);
+ }
+
+ /**
+ * @return The source page of the currently loaded page in WebView.
+ */
+ public String getPageSource() {
+ executeCommand(EXECUTE_SCRIPT, "return (new XMLSerializer())"
+ + ".serializeToString(document.documentElement);",
+ JS_EXECUTION_TIMEOUT);
+ return mJsResult;
+ }
+
+ private void executeScript(String script) {
+ mWebView.loadUrl("javascript:" + script);
+ }
+
+ private void shouldRunInMainThread(boolean value) {
+ assert (value == (MAIN_THREAD == Thread.currentThread().getId()));
+ }
+
+ /**
+ * Interface called from JavaScript when the result is ready.
+ */
+ private class JavascriptResultReady {
+
+ /**
+ * A callback from JavaScript to Java that passes the result as a
+ * parameter. This method is available from the WebView's
+ * JavaScript DOM as window.webdriver.resultReady().
+ *
+ * @param result The result that should be sent to Java from Javascript.
+ */
+ public void resultReady(String result) {
+ synchronized (mSyncObject) {
+ mJsResult = result;
+ mCommandDone = true;
+ mSyncObject.notify();
+ }
+ }
+ }
+
+ /* package */ void notifyCommandDone() {
+ synchronized (mSyncObject) {
+ mCommandDone = true;
+ mSyncObject.notify();
+ }
+ }
+
+ /**
+ * Executes the given command by posting a message to mHandler. This thread
+ * will block until the command which runs in the main thread is done.
+ *
+ * @param command The command to run.
+ * @param arg The argument for that command.
+ * @param timeout A timeout in milliseconds.
+ */
+ private void executeCommand(int command, String arg, long timeout) {
+ shouldRunInMainThread(false);
+
+ synchronized (mSyncObject) {
+ mCommandDone = false;
+ Message msg = mHandler.obtainMessage(command);
+ msg.obj = arg;
+ mHandler.sendMessage(msg);
+
+ long end = System.currentTimeMillis() + timeout;
+ while (!mCommandDone) {
+ if (System.currentTimeMillis() >= end) {
+ throw new RuntimeException("Timeout executing command.");
+ }
+ try {
+ mSyncObject.wait(timeout);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+}
diff --git a/core/java/android/webkit/webdriver/WebchromeClientWrapper.java b/core/java/android/webkit/webdriver/WebchromeClientWrapper.java
new file mode 100644
index 0000000..ea33c5b
--- /dev/null
+++ b/core/java/android/webkit/webdriver/WebchromeClientWrapper.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.webkit.webdriver;
+
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Message;
+import android.view.View;
+import android.webkit.ConsoleMessage;
+import android.webkit.GeolocationPermissions;
+import android.webkit.JsPromptResult;
+import android.webkit.JsResult;
+import android.webkit.ValueCallback;
+import android.webkit.WebChromeClient;
+import android.webkit.WebStorage;
+import android.webkit.WebView;
+
+/* package */ class WebchromeClientWrapper extends WebChromeClient {
+
+ private final WebChromeClient mDelegate;
+ private final WebDriver mDriver;
+
+ public WebchromeClientWrapper(WebChromeClient delegate, WebDriver driver) {
+ if (delegate == null) {
+ this.mDelegate = new WebChromeClient();
+ } else {
+ this.mDelegate = delegate;
+ }
+ this.mDriver = driver;
+ }
+
+ @Override
+ public void onProgressChanged(WebView view, int newProgress) {
+ if (newProgress == 100) {
+ mDriver.notifyCommandDone();
+ }
+ mDelegate.onProgressChanged(view, newProgress);
+ }
+
+ @Override
+ public void onReceivedTitle(WebView view, String title) {
+ mDelegate.onReceivedTitle(view, title);
+ }
+
+ @Override
+ public void onReceivedIcon(WebView view, Bitmap icon) {
+ mDelegate.onReceivedIcon(view, icon);
+ }
+
+ @Override
+ public void onReceivedTouchIconUrl(WebView view, String url,
+ boolean precomposed) {
+ mDelegate.onReceivedTouchIconUrl(view, url, precomposed);
+ }
+
+ @Override
+ public void onShowCustomView(View view,
+ CustomViewCallback callback) {
+ mDelegate.onShowCustomView(view, callback);
+ }
+
+ @Override
+ public void onHideCustomView() {
+ mDelegate.onHideCustomView();
+ }
+
+ @Override
+ public boolean onCreateWindow(WebView view, boolean dialog,
+ boolean userGesture, Message resultMsg) {
+ return mDelegate.onCreateWindow(view, dialog, userGesture, resultMsg);
+ }
+
+ @Override
+ public void onRequestFocus(WebView view) {
+ mDelegate.onRequestFocus(view);
+ }
+
+ @Override
+ public void onCloseWindow(WebView window) {
+ mDelegate.onCloseWindow(window);
+ }
+
+ @Override
+ public boolean onJsAlert(WebView view, String url, String message,
+ JsResult result) {
+ return mDelegate.onJsAlert(view, url, message, result);
+ }
+
+ @Override
+ public boolean onJsConfirm(WebView view, String url, String message,
+ JsResult result) {
+ return mDelegate.onJsConfirm(view, url, message, result);
+ }
+
+ @Override
+ public boolean onJsPrompt(WebView view, String url, String message,
+ String defaultValue, JsPromptResult result) {
+ return mDelegate.onJsPrompt(view, url, message, defaultValue, result);
+ }
+
+ @Override
+ public boolean onJsBeforeUnload(WebView view, String url, String message,
+ JsResult result) {
+ return mDelegate.onJsBeforeUnload(view, url, message, result);
+ }
+
+ @Override
+ public void onExceededDatabaseQuota(String url, String databaseIdentifier,
+ long currentQuota, long estimatedSize, long totalUsedQuota,
+ WebStorage.QuotaUpdater quotaUpdater) {
+ mDelegate.onExceededDatabaseQuota(url, databaseIdentifier, currentQuota,
+ estimatedSize, totalUsedQuota, quotaUpdater);
+ }
+
+ @Override
+ public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota,
+ WebStorage.QuotaUpdater quotaUpdater) {
+ mDelegate.onReachedMaxAppCacheSize(spaceNeeded, totalUsedQuota,
+ quotaUpdater);
+ }
+
+ @Override
+ public void onGeolocationPermissionsShowPrompt(String origin,
+ GeolocationPermissions.Callback callback) {
+ mDelegate.onGeolocationPermissionsShowPrompt(origin, callback);
+ }
+
+ @Override
+ public void onGeolocationPermissionsHidePrompt() {
+ mDelegate.onGeolocationPermissionsHidePrompt();
+ }
+
+ @Override
+ public boolean onJsTimeout() {
+ return mDelegate.onJsTimeout();
+ }
+
+ @Override
+ public void onConsoleMessage(String message, int lineNumber,
+ String sourceID) {
+ mDelegate.onConsoleMessage(message, lineNumber, sourceID);
+ }
+
+ @Override
+ public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
+ return mDelegate.onConsoleMessage(consoleMessage);
+ }
+
+ @Override
+ public Bitmap getDefaultVideoPoster() {
+ return mDelegate.getDefaultVideoPoster();
+ }
+
+ @Override
+ public View getVideoLoadingProgressView() {
+ return mDelegate.getVideoLoadingProgressView();
+ }
+
+ @Override
+ public void getVisitedHistory(ValueCallback<String[]> callback) {
+ mDelegate.getVisitedHistory(callback);
+ }
+
+ @Override
+ public void openFileChooser(ValueCallback<Uri> uploadFile,
+ String acceptType) {
+ mDelegate.openFileChooser(uploadFile, acceptType);
+ }
+
+ @Override
+ public void setInstallableWebApp() {
+ mDelegate.setInstallableWebApp();
+ }
+
+ @Override
+ public void setupAutoFill(Message msg) {
+ mDelegate.setupAutoFill(msg);
+ }
+}
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index f659ead..590a768 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -39,7 +39,7 @@ import java.util.ArrayList;
* Children are drawn in a stack, with the most recently added child on top.
* The size of the frame layout is the size of its largest child (plus padding), visible
* or not (if the FrameLayout's parent permits). Views that are GONE are used for sizing
- * only if {@link #setMeasureAllChildren(boolean) setConsiderGoneChildrenWhenMeasuring()}
+ * only if {@link #setMeasureAllChildren(boolean) setMeasureAllChildren()}
* is set to true.
*
* @attr ref android.R.styleable#FrameLayout_foreground
@@ -566,4 +566,3 @@ public class FrameLayout extends ViewGroup {
}
}
}
-
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index d86504d..fcda673 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -36,6 +36,7 @@ import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.util.Log;
+import android.util.LogWriter;
import android.util.PrintWriterPrinter;
import android.util.Printer;
import android.util.Slog;
@@ -70,7 +71,7 @@ public final class BatteryStatsImpl extends BatteryStats {
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 54;
+ private static final int VERSION = 57;
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -154,11 +155,26 @@ public final class BatteryStatsImpl extends BatteryStats {
boolean mHaveBatteryLevel = false;
boolean mRecordingHistory = true;
int mNumHistoryItems;
+
+ static final int MAX_HISTORY_BUFFER = 64*1024; // 64KB
+ static final int MAX_MAX_HISTORY_BUFFER = 92*1024; // 92KB
+ final Parcel mHistoryBuffer = Parcel.obtain();
+ final HistoryItem mHistoryLastWritten = new HistoryItem();
+ final HistoryItem mHistoryLastLastWritten = new HistoryItem();
+ int mHistoryBufferLastPos = -1;
+ boolean mHistoryOverflow = false;
+ long mLastHistoryTime = 0;
+
+ final HistoryItem mHistoryCur = new HistoryItem();
+
HistoryItem mHistory;
HistoryItem mHistoryEnd;
HistoryItem mHistoryLastEnd;
HistoryItem mHistoryCache;
- final HistoryItem mHistoryCur = new HistoryItem();
+
+ private HistoryItem mHistoryIterator;
+ private boolean mReadOverflow;
+ private boolean mIteratingHistory;
int mStartCount;
@@ -1189,9 +1205,82 @@ public final class BatteryStatsImpl extends BatteryStats {
mBtHeadset = headset;
}
+ int mChangedBufferStates = 0;
+
+ void addHistoryBufferLocked(long curTime) {
+ if (!mHaveBatteryLevel || !mRecordingHistory) {
+ return;
+ }
+
+ if (mHistoryBufferLastPos >= 0 && mHistoryLastWritten.cmd == HistoryItem.CMD_UPDATE
+ && (mHistoryBaseTime+curTime) < (mHistoryLastWritten.time+2000)
+ && ((mHistoryLastWritten.states^mHistoryCur.states)&mChangedBufferStates) == 0) {
+ // If the current is the same as the one before, then we no
+ // longer need the entry.
+ mHistoryBuffer.setDataSize(mHistoryBufferLastPos);
+ mHistoryBuffer.setDataPosition(mHistoryBufferLastPos);
+ mHistoryBufferLastPos = -1;
+ if (mHistoryLastLastWritten.cmd == HistoryItem.CMD_UPDATE
+ && mHistoryLastLastWritten.same(mHistoryCur)) {
+ // If this results in us returning to the state written
+ // prior to the last one, then we can just delete the last
+ // written one and drop the new one. Nothing more to do.
+ mHistoryLastWritten.setTo(mHistoryLastLastWritten);
+ mHistoryLastLastWritten.cmd = HistoryItem.CMD_NULL;
+ return;
+ }
+ mChangedBufferStates |= mHistoryLastWritten.states^mHistoryCur.states;
+ curTime = mHistoryLastWritten.time - mHistoryBaseTime;
+ } else {
+ mChangedBufferStates = 0;
+ }
+
+ final int dataSize = mHistoryBuffer.dataSize();
+ if (dataSize >= MAX_HISTORY_BUFFER) {
+ if (!mHistoryOverflow) {
+ mHistoryOverflow = true;
+ addHistoryBufferLocked(curTime, HistoryItem.CMD_OVERFLOW);
+ }
+
+ // Once we've reached the maximum number of items, we only
+ // record changes to the battery level and the most interesting states.
+ // Once we've reached the maximum maximum number of items, we only
+ // record changes to the battery level.
+ if (mHistoryLastWritten.batteryLevel == mHistoryCur.batteryLevel &&
+ (dataSize >= MAX_MAX_HISTORY_BUFFER
+ || ((mHistoryEnd.states^mHistoryCur.states)
+ & HistoryItem.MOST_INTERESTING_STATES) == 0)) {
+ return;
+ }
+ }
+
+ addHistoryBufferLocked(curTime, HistoryItem.CMD_UPDATE);
+ }
+
+ void addHistoryBufferLocked(long curTime, byte cmd) {
+ int origPos = 0;
+ if (mIteratingHistory) {
+ origPos = mHistoryBuffer.dataPosition();
+ mHistoryBuffer.setDataPosition(mHistoryBuffer.dataSize());
+ }
+ mHistoryBufferLastPos = mHistoryBuffer.dataPosition();
+ mHistoryLastLastWritten.setTo(mHistoryLastWritten);
+ mHistoryLastWritten.setTo(mHistoryBaseTime + curTime, cmd, mHistoryCur);
+ mHistoryLastWritten.writeDelta(mHistoryBuffer, mHistoryLastLastWritten);
+ mLastHistoryTime = curTime;
+ if (DEBUG_HISTORY) Slog.i(TAG, "Writing history buffer: was " + mHistoryBufferLastPos
+ + " now " + mHistoryBuffer.dataPosition()
+ + " size is now " + mHistoryBuffer.dataSize());
+ if (mIteratingHistory) {
+ mHistoryBuffer.setDataPosition(origPos);
+ }
+ }
+
int mChangedStates = 0;
void addHistoryRecordLocked(long curTime) {
+ addHistoryBufferLocked(curTime);
+
if (!mHaveBatteryLevel || !mRecordingHistory) {
return;
}
@@ -1268,6 +1357,7 @@ public final class BatteryStatsImpl extends BatteryStats {
}
void clearHistoryLocked() {
+ if (DEBUG_HISTORY) Slog.i(TAG, "********** CLEARING HISTORY!");
if (mHistory != null) {
mHistoryEnd.next = mHistoryCache;
mHistoryCache = mHistory;
@@ -1275,6 +1365,15 @@ public final class BatteryStatsImpl extends BatteryStats {
}
mNumHistoryItems = 0;
mHistoryBaseTime = 0;
+ mLastHistoryTime = 0;
+
+ mHistoryBuffer.setDataSize(0);
+ mHistoryBuffer.setDataPosition(0);
+ mHistoryBuffer.setDataCapacity(MAX_HISTORY_BUFFER/2);
+ mHistoryLastLastWritten.cmd = HistoryItem.CMD_NULL;
+ mHistoryLastWritten.cmd = HistoryItem.CMD_NULL;
+ mHistoryBufferLastPos = -1;
+ mHistoryOverflow = false;
}
public void doUnplugLocked(long batteryUptime, long batteryRealtime) {
@@ -3910,11 +4009,13 @@ public final class BatteryStatsImpl extends BatteryStats {
mDischargeUnplugLevel = 0;
mDischargeCurrentLevel = 0;
initDischarge();
+ clearHistoryLocked();
}
public BatteryStatsImpl(Parcel p) {
mFile = null;
mHandler = null;
+ clearHistoryLocked();
readFromParcel(p);
}
@@ -3932,25 +4033,79 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
- private HistoryItem mHistoryIterator;
-
- public boolean startIteratingHistoryLocked() {
+ @Override
+ public boolean startIteratingOldHistoryLocked() {
+ if (DEBUG_HISTORY) Slog.i(TAG, "ITERATING: buff size=" + mHistoryBuffer.dataSize()
+ + " pos=" + mHistoryBuffer.dataPosition());
+ mHistoryBuffer.setDataPosition(0);
+ mReadOverflow = false;
+ mIteratingHistory = true;
return (mHistoryIterator = mHistory) != null;
}
- public boolean getNextHistoryLocked(HistoryItem out) {
+ @Override
+ public boolean getNextOldHistoryLocked(HistoryItem out) {
+ boolean end = mHistoryBuffer.dataPosition() >= mHistoryBuffer.dataSize();
+ if (!end) {
+ mHistoryLastWritten.readDelta(mHistoryBuffer, null);
+ mReadOverflow |= mHistoryLastWritten.cmd == HistoryItem.CMD_OVERFLOW;
+ }
HistoryItem cur = mHistoryIterator;
if (cur == null) {
+ if (!mReadOverflow && !end) {
+ Slog.w(TAG, "Old history ends before new history!");
+ }
return false;
}
out.setTo(cur);
mHistoryIterator = cur.next;
+ if (!mReadOverflow) {
+ if (end) {
+ Slog.w(TAG, "New history ends before old history!");
+ } else if (!out.same(mHistoryLastWritten)) {
+ long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
+ PrintWriter pw = new PrintWriter(new LogWriter(android.util.Log.WARN, TAG));
+ pw.println("Histories differ!");
+ pw.println("Old history:");
+ (new HistoryPrinter()).printNextItem(pw, out, now);
+ pw.println("New history:");
+ (new HistoryPrinter()).printNextItem(pw, mHistoryLastWritten, now);
+ }
+ }
return true;
}
@Override
- public HistoryItem getHistory() {
- return mHistory;
+ public void finishIteratingOldHistoryLocked() {
+ mIteratingHistory = false;
+ mHistoryBuffer.setDataPosition(mHistoryBuffer.dataSize());
+ }
+
+ @Override
+ public boolean startIteratingHistoryLocked() {
+ if (DEBUG_HISTORY) Slog.i(TAG, "ITERATING: buff size=" + mHistoryBuffer.dataSize()
+ + " pos=" + mHistoryBuffer.dataPosition());
+ mHistoryBuffer.setDataPosition(0);
+ mReadOverflow = false;
+ mIteratingHistory = true;
+ return mHistoryBuffer.dataSize() > 0;
+ }
+
+ @Override
+ public boolean getNextHistoryLocked(HistoryItem out) {
+ boolean end = mHistoryBuffer.dataPosition() >= mHistoryBuffer.dataSize();
+ if (end) {
+ return false;
+ }
+
+ out.readDelta(mHistoryBuffer, null);
+ return true;
+ }
+
+ @Override
+ public void finishIteratingHistoryLocked() {
+ mIteratingHistory = false;
+ mHistoryBuffer.setDataPosition(mHistoryBuffer.dataSize());
}
@Override
@@ -4697,7 +4852,9 @@ public final class BatteryStatsImpl extends BatteryStats {
Slog.e("BatteryStats", "Error reading battery statistics", e);
}
- addHistoryRecordLocked(SystemClock.elapsedRealtime(), HistoryItem.CMD_START);
+ long now = SystemClock.elapsedRealtime();
+ addHistoryRecordLocked(now, HistoryItem.CMD_START);
+ addHistoryBufferLocked(now, HistoryItem.CMD_START);
}
public int describeContents() {
@@ -4705,30 +4862,54 @@ public final class BatteryStatsImpl extends BatteryStats {
}
void readHistory(Parcel in) {
- mHistory = mHistoryEnd = mHistoryCache = null;
- mHistoryBaseTime = 0;
- long time;
- while ((time=in.readLong()) >= 0) {
- HistoryItem rec = new HistoryItem(time, in);
- addHistoryRecordLocked(rec);
- if (rec.time > mHistoryBaseTime) {
- mHistoryBaseTime = rec.time;
- }
+ mHistoryBaseTime = in.readLong();
+
+ mHistoryBuffer.setDataSize(0);
+ mHistoryBuffer.setDataPosition(0);
+
+ int bufSize = in.readInt();
+ int curPos = in.dataPosition();
+ if (bufSize >= (MAX_MAX_HISTORY_BUFFER*3)) {
+ Slog.w(TAG, "File corrupt: history data buffer too large " + bufSize);
+ } else if ((bufSize&~3) != bufSize) {
+ Slog.w(TAG, "File corrupt: history data buffer not aligned " + bufSize);
+ } else {
+ if (DEBUG_HISTORY) Slog.i(TAG, "***************** READING NEW HISTORY: " + bufSize
+ + " bytes at " + curPos);
+ mHistoryBuffer.appendFrom(in, curPos, bufSize);
+ in.setDataPosition(curPos + bufSize);
}
- long oldnow = SystemClock.elapsedRealtime() - (5*60*100);
+ long oldnow = SystemClock.elapsedRealtime() - (5*60*1000);
if (oldnow > 0) {
// If the system process has restarted, but not the entire
// system, then the mHistoryBaseTime already accounts for
// much of the elapsed time. We thus want to adjust it back,
// to avoid large gaps in the data. We determine we are
// in this case by arbitrarily saying it is so if at this
- // point in boot the elapsed time is already more than 5 seconds.
+ // point in boot the elapsed time is already more than 5 minutes.
mHistoryBaseTime -= oldnow;
}
}
+ void readOldHistory(Parcel in) {
+ mHistory = mHistoryEnd = mHistoryCache = null;
+ long time;
+ while ((time=in.readLong()) >= 0) {
+ HistoryItem rec = new HistoryItem(time, in);
+ addHistoryRecordLocked(rec);
+ }
+ }
+
void writeHistory(Parcel out) {
+ out.writeLong(mLastHistoryTime);
+ out.writeInt(mHistoryBuffer.dataSize());
+ if (DEBUG_HISTORY) Slog.i(TAG, "***************** WRITING HISTORY: "
+ + mHistoryBuffer.dataSize() + " bytes at " + out.dataPosition());
+ out.appendFrom(mHistoryBuffer, 0, mHistoryBuffer.dataSize());
+ }
+
+ void writeOldHistory(Parcel out) {
HistoryItem rec = mHistory;
while (rec != null) {
if (rec.time >= 0) rec.writeToParcel(out, 0);
@@ -4746,6 +4927,7 @@ public final class BatteryStatsImpl extends BatteryStats {
}
readHistory(in);
+ readOldHistory(in);
mStartCount = in.readInt();
mBatteryUptime = in.readLong();
@@ -4935,6 +5117,9 @@ public final class BatteryStatsImpl extends BatteryStats {
* @param out the Parcel to be written to.
*/
public void writeSummaryToParcel(Parcel out) {
+ // Need to update with current kernel wake lock counts.
+ updateKernelWakelocksLocked();
+
final long NOW_SYS = SystemClock.uptimeMillis() * 1000;
final long NOWREAL_SYS = SystemClock.elapsedRealtime() * 1000;
final long NOW = getBatteryUptimeLocked(NOW_SYS);
@@ -4943,6 +5128,7 @@ public final class BatteryStatsImpl extends BatteryStats {
out.writeInt(VERSION);
writeHistory(out);
+ writeOldHistory(out);
out.writeInt(mStartCount);
out.writeLong(computeBatteryUptime(NOW_SYS, STATS_SINCE_CHARGED));
@@ -5256,6 +5442,9 @@ public final class BatteryStatsImpl extends BatteryStats {
@SuppressWarnings("unused")
void writeToParcelLocked(Parcel out, boolean inclUids, int flags) {
+ // Need to update with current kernel wake lock counts.
+ updateKernelWakelocksLocked();
+
final long uSecUptime = SystemClock.uptimeMillis() * 1000;
final long uSecRealtime = SystemClock.elapsedRealtime() * 1000;
final long batteryUptime = getBatteryUptimeLocked(uSecUptime);
@@ -5358,6 +5547,11 @@ public final class BatteryStatsImpl extends BatteryStats {
}
};
+ public void prepareForDumpLocked() {
+ // Need to retrieve current kernel wake lock stats before printing.
+ updateKernelWakelocksLocked();
+ }
+
public void dumpLocked(PrintWriter pw) {
if (DEBUG) {
Printer pr = new PrintWriterPrinter(pw);
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index 611d987..4ffa4e1 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -33,6 +33,7 @@ interface IInputMethodManager {
List<InputMethodInfo> getEnabledInputMethodList();
List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in InputMethodInfo imi,
boolean allowsImplicitlySelectedSubtypes);
+ InputMethodSubtype getLastInputMethodSubtype();
// TODO: We should change the return type from List to List<Parcelable>
// Currently there is a bug that aidl doesn't accept List<Parcelable>
List getShortcutInputMethodsAndSubtypes();
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index f29d83e..b628b9d 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -1,19 +1,18 @@
-/* //device/libs/android_runtime/AndroidRuntime.cpp
-**
-** Copyright 2006, 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) 2006 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_TAG "AndroidRuntime"
//#define LOG_NDEBUG 0
@@ -212,7 +211,7 @@ static jint com_android_internal_os_RuntimeInit_getQwertyKeyboard(JNIEnv* env, j
if (value != NULL && strcmp(value, "true") == 0) {
return 1;
}
-
+
return 0;
}
@@ -227,7 +226,7 @@ static JNINativeMethod gMethods[] = {
{ "isComputerOn", "()I",
(void*) com_android_internal_os_RuntimeInit_isComputerOn },
{ "turnComputerOn", "()V",
- (void*) com_android_internal_os_RuntimeInit_turnComputerOn },
+ (void*) com_android_internal_os_RuntimeInit_turnComputerOn },
{ "getQwertyKeyboard", "()I",
(void*) com_android_internal_os_RuntimeInit_getQwertyKeyboard },
};
@@ -278,51 +277,16 @@ AndroidRuntime::~AndroidRuntime()
return jniRegisterNativeMethods(env, className, gMethods, numMethods);
}
-/*
- * Call a static Java Programming Language function that takes no arguments and returns void.
- */
-status_t AndroidRuntime::callStatic(const char* className, const char* methodName)
+status_t AndroidRuntime::callMain(const char* className,
+ jclass clazz, int argc, const char* const argv[])
{
JNIEnv* env;
- jclass clazz;
- jmethodID methodId;
-
- env = getJNIEnv();
- if (env == NULL)
- return UNKNOWN_ERROR;
-
- clazz = findClass(env, className);
- if (clazz == NULL) {
- LOGE("ERROR: could not find class '%s'\n", className);
- return UNKNOWN_ERROR;
- }
- methodId = env->GetStaticMethodID(clazz, methodName, "()V");
- if (methodId == NULL) {
- LOGE("ERROR: could not find method %s.%s\n", className, methodName);
- return UNKNOWN_ERROR;
- }
-
- env->CallStaticVoidMethod(clazz, methodId);
-
- return NO_ERROR;
-}
-
-status_t AndroidRuntime::callMain(
- const char* className, int argc, const char* const argv[])
-{
- JNIEnv* env;
- jclass clazz;
jmethodID methodId;
LOGD("Calling main entry %s", className);
env = getJNIEnv();
- if (env == NULL)
- return UNKNOWN_ERROR;
-
- clazz = findClass(env, className);
- if (clazz == NULL) {
- LOGE("ERROR: could not find class '%s'\n", className);
+ if (clazz == NULL || env == NULL) {
return UNKNOWN_ERROR;
}
@@ -352,70 +316,6 @@ status_t AndroidRuntime::callMain(
}
/*
- * Find the named class.
- */
-jclass AndroidRuntime::findClass(JNIEnv* env, const char* className)
-{
- if (env->ExceptionCheck()) {
- LOGE("ERROR: exception pending on entry to findClass()");
- return NULL;
- }
-
- /*
- * This is a little awkward because the JNI FindClass call uses the
- * class loader associated with the native method we're executing in.
- * Because this native method is part of a "boot" class, JNI doesn't
- * look for the class in CLASSPATH, which unfortunately is a likely
- * location for it. (Had we issued the FindClass call before calling
- * into the VM -- at which point there isn't a native method frame on
- * the stack -- the VM would have checked CLASSPATH. We have to do
- * this because we call into Java Programming Language code and
- * bounce back out.)
- *
- * JNI lacks a "find class in a specific class loader" operation, so we
- * have to do things the hard way.
- */
- jclass cls = NULL;
-
- jclass javaLangClassLoader;
- jmethodID getSystemClassLoader, loadClass;
- jobject systemClassLoader;
- jstring strClassName;
-
- /* find the "system" class loader; none of this is expected to fail */
- javaLangClassLoader = env->FindClass("java/lang/ClassLoader");
- assert(javaLangClassLoader != NULL);
- getSystemClassLoader = env->GetStaticMethodID(javaLangClassLoader,
- "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
- loadClass = env->GetMethodID(javaLangClassLoader,
- "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
- assert(getSystemClassLoader != NULL && loadClass != NULL);
- systemClassLoader = env->CallStaticObjectMethod(javaLangClassLoader,
- getSystemClassLoader);
- assert(systemClassLoader != NULL);
-
- /* create an object for the class name string; alloc could fail */
- strClassName = env->NewStringUTF(className);
- if (env->ExceptionCheck()) {
- LOGE("ERROR: unable to convert '%s' to string", className);
- return NULL;
- }
- LOGV("system class loader is %p, loading %p (%s)",
- systemClassLoader, strClassName, className);
-
- /* try to find the named class */
- cls = (jclass) env->CallObjectMethod(systemClassLoader, loadClass,
- strClassName);
- if (env->ExceptionCheck()) {
- LOGE("ERROR: unable to load class '%s' from %p",
- className, systemClassLoader);
- return NULL;
- }
-
- return cls;
-}
-
-/*
* The VM calls this through the "exit" hook.
*/
static void runtime_exit(int code)
@@ -457,7 +357,7 @@ static bool runtime_isSensitiveThread() {
int AndroidRuntime::addVmArguments(int argc, const char* const argv[])
{
int i;
-
+
for (i = 0; i<argc; i++) {
if (argv[i][0] != '-') {
return i;
@@ -890,6 +790,17 @@ bail:
return result;
}
+char* AndroidRuntime::toSlashClassName(const char* className)
+{
+ char* result = strdup(className);
+ for (char* cp = result; *cp != '\0'; cp++) {
+ if (*cp == '.') {
+ *cp = '/';
+ }
+ }
+ return result;
+}
+
/*
* Start the Android runtime. This involves starting the virtual machine
* and calling the "static void main(String[] args)" method in the class
@@ -900,20 +811,16 @@ void AndroidRuntime::start(const char* className, const bool startSystemServer)
LOGD("\n>>>>>> AndroidRuntime START %s <<<<<<\n",
className != NULL ? className : "(unknown)");
- char* slashClassName = NULL;
- char* cp;
- JNIEnv* env;
-
blockSigpipe();
- /*
- * 'startSystemServer == true' means runtime is obsolete and not run from
+ /*
+ * 'startSystemServer == true' means runtime is obsolete and not run from
* init.rc anymore, so we print out the boot start event here.
*/
if (startSystemServer) {
/* track our progress through the boot sequence */
const int LOG_BOOT_PROGRESS_START = 3000;
- LOG_EVENT_LONG(LOG_BOOT_PROGRESS_START,
+ LOG_EVENT_LONG(LOG_BOOT_PROGRESS_START,
ns2ms(systemTime(SYSTEM_TIME_MONOTONIC)));
}
@@ -922,7 +829,7 @@ void AndroidRuntime::start(const char* className, const bool startSystemServer)
rootDir = "/system";
if (!hasDir("/system")) {
LOG_FATAL("No root directory specified, and /android does not exist.");
- goto bail;
+ return;
}
setenv("ANDROID_ROOT", rootDir, 1);
}
@@ -931,15 +838,18 @@ void AndroidRuntime::start(const char* className, const bool startSystemServer)
//LOGD("Found LD_ASSUME_KERNEL='%s'\n", kernelHack);
/* start the virtual machine */
- if (startVm(&mJavaVM, &env) != 0)
- goto bail;
+ JNIEnv* env;
+ if (startVm(&mJavaVM, &env) != 0) {
+ return;
+ }
+ onVmCreated(env);
/*
* Register android functions.
*/
if (startReg(env) < 0) {
LOGE("Unable to register all android natives\n");
- goto bail;
+ return;
}
/*
@@ -959,7 +869,7 @@ void AndroidRuntime::start(const char* className, const bool startSystemServer)
classNameStr = env->NewStringUTF(className);
assert(classNameStr != NULL);
env->SetObjectArrayElement(strArray, 0, classNameStr);
- startSystemServerStr = env->NewStringUTF(startSystemServer ?
+ startSystemServerStr = env->NewStringUTF(startSystemServer ?
"true" : "false");
env->SetObjectArrayElement(strArray, 1, startSystemServerStr);
@@ -967,20 +877,13 @@ void AndroidRuntime::start(const char* className, const bool startSystemServer)
* Start VM. This thread becomes the main thread of the VM, and will
* not return until the VM exits.
*/
- jclass startClass;
- jmethodID startMeth;
-
- slashClassName = strdup(className);
- for (cp = slashClassName; *cp != '\0'; cp++)
- if (*cp == '.')
- *cp = '/';
-
- startClass = env->FindClass(slashClassName);
+ char* slashClassName = toSlashClassName(className);
+ jclass startClass = env->FindClass(slashClassName);
if (startClass == NULL) {
LOGE("JavaVM unable to locate class '%s'\n", slashClassName);
/* keep going */
} else {
- startMeth = env->GetStaticMethodID(startClass, "main",
+ jmethodID startMeth = env->GetStaticMethodID(startClass, "main",
"([Ljava/lang/String;)V");
if (startMeth == NULL) {
LOGE("JavaVM unable to find main() in '%s'\n", className);
@@ -994,15 +897,13 @@ void AndroidRuntime::start(const char* className, const bool startSystemServer)
#endif
}
}
+ free(slashClassName);
LOGD("Shutting down VM\n");
if (mJavaVM->DetachCurrentThread() != JNI_OK)
LOGW("Warning: unable to detach main thread\n");
if (mJavaVM->DestroyJavaVM() != 0)
LOGW("Warning: VM did not shut down cleanly\n");
-
-bail:
- free(slashClassName);
}
void AndroidRuntime::start()
@@ -1017,6 +918,11 @@ void AndroidRuntime::onExit(int code)
exit(code);
}
+void AndroidRuntime::onVmCreated(JNIEnv* env)
+{
+ // If AndroidRuntime had anything to do here, we'd have done it in 'start'.
+}
+
/*
* Get the JNIEnv pointer for this thread.
*
@@ -1111,7 +1017,7 @@ static int javaDetachThread(void)
* into the VM before it really starts executing.
*/
/*static*/ int AndroidRuntime::javaCreateThreadEtc(
- android_thread_func_t entryFunction,
+ android_thread_func_t entryFunction,
void* userData,
const char* threadName,
int32_t threadPriority,
@@ -1299,7 +1205,7 @@ static const RegJNIRec gRegJNI[] = {
REG_JNI(register_android_backup_BackupDataOutput),
REG_JNI(register_android_backup_FileBackupHelperBase),
REG_JNI(register_android_backup_BackupHelperDispatcher),
-
+
REG_JNI(register_android_app_ActivityThread),
REG_JNI(register_android_app_NativeActivity),
REG_JNI(register_android_view_InputChannel),
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 05a46a8..1b22e2d 100644
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -655,7 +655,6 @@ static JNINativeMethod gBitmapMethods[] = {
#define kClassPathName "android/graphics/Bitmap"
-int register_android_graphics_Bitmap(JNIEnv* env);
int register_android_graphics_Bitmap(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 1034fbd..258ffa5 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -12,6 +12,7 @@
#include "CreateJavaOutputStreamAdaptor.h"
#include "AutoDecodeCancel.h"
#include "Utils.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/Asset.h>
@@ -20,7 +21,6 @@
#include <sys/mman.h>
#include <sys/stat.h>
-jclass gOptions_class;
jfieldID gOptions_justBoundsFieldID;
jfieldID gOptions_sampleSizeFieldID;
jfieldID gOptions_configFieldID;
@@ -34,12 +34,8 @@ jfieldID gOptions_heightFieldID;
jfieldID gOptions_mimeFieldID;
jfieldID gOptions_mCancelID;
jfieldID gOptions_bitmapFieldID;
-jclass gBitmap_class;
jfieldID gBitmap_nativeBitmapFieldID;
-static jclass gFileDescriptor_class;
-static jfieldID gFileDescriptor_descriptor;
-
#if 0
#define TRACE_BITMAP(code) code
#else
@@ -66,7 +62,7 @@ jstring getMimeTypeString(JNIEnv* env, SkImageDecoder::Format format) {
{ SkImageDecoder::kPNG_Format, "image/png" },
{ SkImageDecoder::kWBMP_Format, "image/vnd.wap.wbmp" }
};
-
+
const char* cstr = NULL;
for (size_t i = 0; i < SK_ARRAY_COUNT(gMimeTypes); i++) {
if (gMimeTypes[i].fFormat == format) {
@@ -127,7 +123,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
(allowPurgeable && optionsPurgeable(env, options));
bool preferQualityOverSpeed = false;
jobject javaBitmap = NULL;
-
+
if (NULL != options) {
sampleSize = env->GetIntField(options, gOptions_sampleSizeFieldID);
if (optionsJustBounds(env, options)) {
@@ -137,7 +133,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
env->SetIntField(options, gOptions_widthFieldID, -1);
env->SetIntField(options, gOptions_heightFieldID, -1);
env->SetObjectField(options, gOptions_mimeFieldID, 0);
-
+
jobject jconfig = env->GetObjectField(options, gOptions_configFieldID);
prefConfig = GraphicsJNI::getNativeBitmapConfig(env, jconfig);
isMutable = env->GetBooleanField(options, gOptions_mutableFieldID);
@@ -151,7 +147,7 @@ static jobject doDecode(JNIEnv* env, SkStream* stream, jobject padding,
if (NULL == decoder) {
return nullObjectReturn("SkImageDecoder::Factory returned null");
}
-
+
decoder->setSampleSize(sampleSize);
decoder->setDitherImage(doDither);
decoder->setPreferQualityOverSpeed(preferQualityOverSpeed);
@@ -298,8 +294,7 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz,
jobject bitmapFactoryOptions) {
NPE_CHECK_RETURN_ZERO(env, fileDescriptor);
- jint descriptor = env->GetIntField(fileDescriptor,
- gFileDescriptor_descriptor);
+ jint descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor);
bool isPurgeable = optionsPurgeable(env, bitmapFactoryOptions);
bool isShareable = optionsShareable(env, bitmapFactoryOptions);
@@ -424,7 +419,7 @@ static jbyteArray nativeScaleNinePatch(JNIEnv* env, jobject, jbyteArray chunkObj
}
for (int i = 0; i < chunk->numYDivs; i++) {
- chunk->yDivs[i] = int(chunk->yDivs[i] * scale + 0.5f);
+ chunk->yDivs[i] = int(chunk->yDivs[i] * scale + 0.5f);
if (i > 0 && chunk->yDivs[i] == chunk->yDivs[i - 1]) {
chunk->yDivs[i]++;
}
@@ -460,7 +455,7 @@ static void nativeSetDefaultConfig(JNIEnv* env, jobject, int nativeConfig) {
}
static jboolean nativeIsSeekable(JNIEnv* env, jobject, jobject fileDescriptor) {
- jint descriptor = env->GetIntField(fileDescriptor, gFileDescriptor_descriptor);
+ jint descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor);
return ::lseek64(descriptor, 0, SEEK_CUR) != -1 ? JNI_TRUE : JNI_FALSE;
}
@@ -504,12 +499,6 @@ static JNINativeMethod gOptionsMethods[] = {
{ "requestCancel", "()V", (void*)nativeRequestCancel }
};
-static jclass make_globalref(JNIEnv* env, const char classname[]) {
- jclass c = env->FindClass(classname);
- SkASSERT(c);
- return (jclass)env->NewGlobalRef(c);
-}
-
static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
const char fieldname[], const char type[]) {
jfieldID id = env->GetFieldID(clazz, fieldname, type);
@@ -517,35 +506,29 @@ static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
return id;
}
-#define kClassPathName "android/graphics/BitmapFactory"
-
-#define RETURN_ERR_IF_NULL(value) \
- do { if (!(value)) { assert(0); return -1; } } while (false)
-
-int register_android_graphics_BitmapFactory(JNIEnv* env);
int register_android_graphics_BitmapFactory(JNIEnv* env) {
- gOptions_class = make_globalref(env, "android/graphics/BitmapFactory$Options");
- gOptions_bitmapFieldID = getFieldIDCheck(env, gOptions_class, "inBitmap",
+ jclass options_class = env->FindClass("android/graphics/BitmapFactory$Options");
+ SkASSERT(options_class);
+ gOptions_bitmapFieldID = getFieldIDCheck(env, options_class, "inBitmap",
"Landroid/graphics/Bitmap;");
- gOptions_justBoundsFieldID = getFieldIDCheck(env, gOptions_class, "inJustDecodeBounds", "Z");
- gOptions_sampleSizeFieldID = getFieldIDCheck(env, gOptions_class, "inSampleSize", "I");
- gOptions_configFieldID = getFieldIDCheck(env, gOptions_class, "inPreferredConfig",
+ gOptions_justBoundsFieldID = getFieldIDCheck(env, options_class, "inJustDecodeBounds", "Z");
+ gOptions_sampleSizeFieldID = getFieldIDCheck(env, options_class, "inSampleSize", "I");
+ gOptions_configFieldID = getFieldIDCheck(env, options_class, "inPreferredConfig",
"Landroid/graphics/Bitmap$Config;");
- gOptions_mutableFieldID = getFieldIDCheck(env, gOptions_class, "inMutable", "Z");
- gOptions_ditherFieldID = getFieldIDCheck(env, gOptions_class, "inDither", "Z");
- gOptions_purgeableFieldID = getFieldIDCheck(env, gOptions_class, "inPurgeable", "Z");
- gOptions_shareableFieldID = getFieldIDCheck(env, gOptions_class, "inInputShareable", "Z");
- gOptions_preferQualityOverSpeedFieldID = getFieldIDCheck(env, gOptions_class,
+ gOptions_mutableFieldID = getFieldIDCheck(env, options_class, "inMutable", "Z");
+ gOptions_ditherFieldID = getFieldIDCheck(env, options_class, "inDither", "Z");
+ gOptions_purgeableFieldID = getFieldIDCheck(env, options_class, "inPurgeable", "Z");
+ gOptions_shareableFieldID = getFieldIDCheck(env, options_class, "inInputShareable", "Z");
+ gOptions_preferQualityOverSpeedFieldID = getFieldIDCheck(env, options_class,
"inPreferQualityOverSpeed", "Z");
- gOptions_widthFieldID = getFieldIDCheck(env, gOptions_class, "outWidth", "I");
- gOptions_heightFieldID = getFieldIDCheck(env, gOptions_class, "outHeight", "I");
- gOptions_mimeFieldID = getFieldIDCheck(env, gOptions_class, "outMimeType", "Ljava/lang/String;");
- gOptions_mCancelID = getFieldIDCheck(env, gOptions_class, "mCancel", "Z");
+ gOptions_widthFieldID = getFieldIDCheck(env, options_class, "outWidth", "I");
+ gOptions_heightFieldID = getFieldIDCheck(env, options_class, "outHeight", "I");
+ gOptions_mimeFieldID = getFieldIDCheck(env, options_class, "outMimeType", "Ljava/lang/String;");
+ gOptions_mCancelID = getFieldIDCheck(env, options_class, "mCancel", "Z");
- gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
- gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "I");
- gFileDescriptor_class = make_globalref(env, "java/io/FileDescriptor");
- gFileDescriptor_descriptor = getFieldIDCheck(env, gFileDescriptor_class, "descriptor", "I");
+ jclass bitmap_class = env->FindClass("android/graphics/Bitmap");
+ SkASSERT(bitmap_class);
+ gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "I");
int ret = AndroidRuntime::registerNativeMethods(env,
"android/graphics/BitmapFactory$Options",
@@ -554,6 +537,6 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) {
if (ret) {
return ret;
}
- return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
+ return android::AndroidRuntime::registerNativeMethods(env, "android/graphics/BitmapFactory",
gMethods, SK_ARRAY_COUNT(gMethods));
}
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index ee3e209..d437929 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -28,6 +28,7 @@
#include "SkBitmapRegionDecoder.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include "Utils.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "android_util_Binder.h"
@@ -39,9 +40,6 @@
#include <utils/Asset.h>
#include <sys/stat.h>
-static jclass gFileDescriptor_class;
-static jfieldID gFileDescriptor_descriptor;
-
#if 0
#define TRACE_BITMAP(code) code
#else
@@ -111,8 +109,7 @@ static jobject nativeNewInstanceFromFileDescriptor(JNIEnv* env, jobject clazz,
jobject fileDescriptor, jboolean isShareable) {
NPE_CHECK_RETURN_ZERO(env, fileDescriptor);
- jint descriptor = env->GetIntField(fileDescriptor,
- gFileDescriptor_descriptor);
+ jint descriptor = jniGetFDFromFileDescriptor(env, fileDescriptor);
SkStream *stream = NULL;
struct stat fdStat;
int newFD;
@@ -300,25 +297,8 @@ static JNINativeMethod gBitmapRegionDecoderMethods[] = {
#define kClassPathName "android/graphics/BitmapRegionDecoder"
-static jclass make_globalref(JNIEnv* env, const char classname[]) {
- jclass c = env->FindClass(classname);
- SkASSERT(c);
- return (jclass)env->NewGlobalRef(c);
-}
-
-static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
- const char fieldname[], const char type[]) {
- jfieldID id = env->GetFieldID(clazz, fieldname, type);
- SkASSERT(id);
- return id;
-}
-
-int register_android_graphics_BitmapRegionDecoder(JNIEnv* env);
int register_android_graphics_BitmapRegionDecoder(JNIEnv* env)
{
-
- gFileDescriptor_class = make_globalref(env, "java/io/FileDescriptor");
- gFileDescriptor_descriptor = getFieldIDCheck(env, gFileDescriptor_class, "descriptor", "I");
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
gBitmapRegionDecoderMethods, SK_ARRAY_COUNT(gBitmapRegionDecoderMethods));
}
diff --git a/core/jni/android/graphics/Camera.cpp b/core/jni/android/graphics/Camera.cpp
index 0d715fd..76d415a 100644
--- a/core/jni/android/graphics/Camera.cpp
+++ b/core/jni/android/graphics/Camera.cpp
@@ -98,7 +98,6 @@ static JNINativeMethod gCameraMethods[] = {
{ "dotWithNormal", "(FFF)F", (void*)Camera_dotWithNormal }
};
-int register_android_graphics_Camera(JNIEnv* env);
int register_android_graphics_Camera(JNIEnv* env) {
jclass clazz = env->FindClass("android/graphics/Camera");
if (clazz == 0) {
@@ -113,4 +112,3 @@ int register_android_graphics_Camera(JNIEnv* env) {
gCameraMethods,
SK_ARRAY_COUNT(gCameraMethods));
}
-
diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
index 137acc6..6ce3f51 100644
--- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
+++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
@@ -3,7 +3,6 @@
#define RETURN_NULL_IF_NULL(value) \
do { if (!(value)) { SkASSERT(0); return NULL; } } while (false)
-static jclass gInputStream_Clazz;
static jmethodID gInputStream_resetMethodID;
static jmethodID gInputStream_markMethodID;
static jmethodID gInputStream_availableMethodID;
@@ -19,10 +18,10 @@ public:
SkASSERT(fCapacity > 0);
fBytesRead = 0;
}
-
+
virtual bool rewind() {
JNIEnv* env = fEnv;
-
+
fBytesRead = 0;
env->CallVoidMethod(fJavaInputStream, gInputStream_resetMethodID);
@@ -34,7 +33,7 @@ public:
}
return true;
}
-
+
size_t doRead(void* buffer, size_t size) {
JNIEnv* env = fEnv;
size_t bytesRead = 0;
@@ -43,7 +42,7 @@ public:
size_t requested = size;
if (requested > fCapacity)
requested = fCapacity;
-
+
jint n = env->CallIntMethod(fJavaInputStream,
gInputStream_readMethodID, fJavaByteArray, 0, requested);
if (env->ExceptionCheck()) {
@@ -52,11 +51,11 @@ public:
SkDebugf("---- read threw an exception\n");
return 0;
}
-
+
if (n < 0) { // n == 0 should not be possible, see InputStream read() specifications.
break; // eof
}
-
+
env->GetByteArrayRegion(fJavaByteArray, 0, n,
reinterpret_cast<jbyte*>(buffer));
if (env->ExceptionCheck()) {
@@ -65,16 +64,16 @@ public:
SkDebugf("---- read:GetByteArrayRegion threw an exception\n");
return 0;
}
-
+
buffer = (void*)((char*)buffer + n);
bytesRead += n;
size -= n;
fBytesRead += n;
} while (size != 0);
-
+
return bytesRead;
}
-
+
size_t doSkip(size_t size) {
JNIEnv* env = fEnv;
@@ -92,7 +91,7 @@ public:
return (size_t)skipped;
}
-
+
size_t doSize() {
JNIEnv* env = fEnv;
jint avail = env->CallIntMethod(fJavaInputStream,
@@ -105,7 +104,7 @@ public:
}
return avail;
}
-
+
virtual size_t read(void* buffer, size_t size) {
JNIEnv* env = fEnv;
if (NULL == buffer) {
@@ -134,7 +133,7 @@ public:
}
return this->doRead(buffer, size);
}
-
+
private:
JNIEnv* fEnv;
jobject fJavaInputStream; // the caller owns this object
@@ -148,19 +147,18 @@ SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream,
static bool gInited;
if (!gInited) {
- gInputStream_Clazz = env->FindClass("java/io/InputStream");
- RETURN_NULL_IF_NULL(gInputStream_Clazz);
- gInputStream_Clazz = (jclass)env->NewGlobalRef(gInputStream_Clazz);
+ jclass inputStream_Clazz = env->FindClass("java/io/InputStream");
+ RETURN_NULL_IF_NULL(inputStream_Clazz);
- gInputStream_resetMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_resetMethodID = env->GetMethodID(inputStream_Clazz,
"reset", "()V");
- gInputStream_markMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_markMethodID = env->GetMethodID(inputStream_Clazz,
"mark", "(I)V");
- gInputStream_availableMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_availableMethodID = env->GetMethodID(inputStream_Clazz,
"available", "()I");
- gInputStream_readMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_readMethodID = env->GetMethodID(inputStream_Clazz,
"read", "([BII)I");
- gInputStream_skipMethodID = env->GetMethodID(gInputStream_Clazz,
+ gInputStream_skipMethodID = env->GetMethodID(inputStream_Clazz,
"skip", "(J)J");
RETURN_NULL_IF_NULL(gInputStream_resetMethodID);
@@ -181,7 +179,6 @@ SkStream* CreateJavaInputStreamAdaptor(JNIEnv* env, jobject stream,
///////////////////////////////////////////////////////////////////////////////
-static jclass gOutputStream_Clazz;
static jmethodID gOutputStream_writeMethodID;
static jmethodID gOutputStream_flushMethodID;
@@ -191,11 +188,11 @@ public:
: fEnv(env), fJavaOutputStream(stream), fJavaByteArray(storage) {
fCapacity = env->GetArrayLength(storage);
}
-
+
virtual bool write(const void* buffer, size_t size) {
JNIEnv* env = fEnv;
jbyteArray storage = fJavaByteArray;
-
+
while (size > 0) {
size_t requested = size;
if (requested > fCapacity) {
@@ -210,7 +207,7 @@ public:
SkDebugf("--- write:SetByteArrayElements threw an exception\n");
return false;
}
-
+
fEnv->CallVoidMethod(fJavaOutputStream, gOutputStream_writeMethodID,
storage, 0, requested);
if (env->ExceptionCheck()) {
@@ -219,17 +216,17 @@ public:
SkDebugf("------- write threw an exception\n");
return false;
}
-
+
buffer = (void*)((char*)buffer + requested);
size -= requested;
}
return true;
}
-
+
virtual void flush() {
fEnv->CallVoidMethod(fJavaOutputStream, gOutputStream_flushMethodID);
}
-
+
private:
JNIEnv* fEnv;
jobject fJavaOutputStream; // the caller owns this object
@@ -242,14 +239,13 @@ SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream,
static bool gInited;
if (!gInited) {
- gOutputStream_Clazz = env->FindClass("java/io/OutputStream");
- RETURN_NULL_IF_NULL(gOutputStream_Clazz);
- gOutputStream_Clazz = (jclass)env->NewGlobalRef(gOutputStream_Clazz);
+ jclass outputStream_Clazz = env->FindClass("java/io/OutputStream");
+ RETURN_NULL_IF_NULL(outputStream_Clazz);
- gOutputStream_writeMethodID = env->GetMethodID(gOutputStream_Clazz,
+ gOutputStream_writeMethodID = env->GetMethodID(outputStream_Clazz,
"write", "([BII)V");
RETURN_NULL_IF_NULL(gOutputStream_writeMethodID);
- gOutputStream_flushMethodID = env->GetMethodID(gOutputStream_Clazz,
+ gOutputStream_flushMethodID = env->GetMethodID(outputStream_Clazz,
"flush", "()V");
RETURN_NULL_IF_NULL(gOutputStream_flushMethodID);
@@ -258,4 +254,3 @@ SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream,
return new SkJavaOutputStream(env, stream, storage);
}
-
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 6c28e65..64bd207 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -350,14 +350,10 @@ jobject GraphicsJNI::createBitmap(JNIEnv* env, SkBitmap* bitmap, jbyteArray buff
SkASSERT(bitmap);
SkASSERT(bitmap->pixelRef());
- jobject obj = env->AllocObject(gBitmap_class);
- if (obj) {
- env->CallVoidMethod(obj, gBitmap_constructorMethodID,
- (jint)bitmap, buffer, isMutable, ninepatch, density);
- if (hasException(env)) {
- obj = NULL;
- }
- }
+ jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID,
+ static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)),
+ buffer, isMutable, ninepatch, density);
+ hasException(env); // For the side effect of logging.
return obj;
}
@@ -372,30 +368,19 @@ jobject GraphicsJNI::createBitmapRegionDecoder(JNIEnv* env, SkBitmapRegionDecode
{
SkASSERT(bitmap != NULL);
- jobject obj = env->AllocObject(gBitmapRegionDecoder_class);
- if (hasException(env)) {
- obj = NULL;
- return obj;
- }
- if (obj) {
- env->CallVoidMethod(obj, gBitmapRegionDecoder_constructorMethodID, (jint)bitmap);
- if (hasException(env)) {
- obj = NULL;
- }
- }
+ jobject obj = env->NewObject(gBitmapRegionDecoder_class,
+ gBitmapRegionDecoder_constructorMethodID,
+ static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)));
+ hasException(env); // For the side effect of logging.
return obj;
}
jobject GraphicsJNI::createRegion(JNIEnv* env, SkRegion* region)
{
SkASSERT(region != NULL);
- jobject obj = env->AllocObject(gRegion_class);
- if (obj) {
- env->CallVoidMethod(obj, gRegion_constructorMethodID, (jint)region, 0);
- if (hasException(env)) {
- obj = NULL;
- }
- }
+ jobject obj = env->NewObject(gRegion_class, gRegion_constructorMethodID,
+ static_cast<jint>(reinterpret_cast<uintptr_t>(region)), 0);
+ hasException(env); // For the side effect of logging.
return obj;
}
diff --git a/core/jni/android/graphics/Interpolator.cpp b/core/jni/android/graphics/Interpolator.cpp
index beec351..aa33c3d 100644
--- a/core/jni/android/graphics/Interpolator.cpp
+++ b/core/jni/android/graphics/Interpolator.cpp
@@ -61,7 +61,7 @@ static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator*
float* values = valueArray ? env->GetFloatArrayElements(valueArray, NULL) : NULL;
result = interp->timeToValues(msec, (SkScalar*)values);
-
+
if (valueArray) {
int n = env->GetArrayLength(valueArray);
for (int i = 0; i < n; i++) {
@@ -69,7 +69,7 @@ static int Interpolator_timeToValues(JNIEnv* env, jobject clazz, SkInterpolator*
}
env->ReleaseFloatArrayElements(valueArray, values, 0);
}
-
+
return result;
}
@@ -87,7 +87,6 @@ static JNINativeMethod gInterpolatorMethods[] = {
{ "nativeTimeToValues", "(II[F)I", (void*)Interpolator_timeToValues }
};
-int register_android_graphics_Interpolator(JNIEnv* env);
int register_android_graphics_Interpolator(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
diff --git a/core/jni/android/graphics/LayerRasterizer.cpp b/core/jni/android/graphics/LayerRasterizer.cpp
index 7c45889..e5bc6f8 100644
--- a/core/jni/android/graphics/LayerRasterizer.cpp
+++ b/core/jni/android/graphics/LayerRasterizer.cpp
@@ -11,7 +11,7 @@ public:
SkASSERT(layer);
SkASSERT(paint);
layer->addLayer(*paint, SkFloatToScalar(dx), SkFloatToScalar(dy));
- }
+ }
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -23,7 +23,6 @@ static JNINativeMethod gLayerRasterizerMethods[] = {
{ "nativeAddLayer", "(IIFF)V", (void*)SkLayerRasterizerGlue::addLayer }
};
-int register_android_graphics_LayerRasterizer(JNIEnv* env);
int register_android_graphics_LayerRasterizer(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
@@ -31,4 +30,3 @@ int register_android_graphics_LayerRasterizer(JNIEnv* env)
gLayerRasterizerMethods,
SK_ARRAY_COUNT(gLayerRasterizerMethods));
}
-
diff --git a/core/jni/android/graphics/MaskFilter.cpp b/core/jni/android/graphics/MaskFilter.cpp
index d3f9b78..d954ddf 100644
--- a/core/jni/android/graphics/MaskFilter.cpp
+++ b/core/jni/android/graphics/MaskFilter.cpp
@@ -23,7 +23,7 @@ public:
ThrowIAE_IfNull(env, filter);
return filter;
}
-
+
static SkMaskFilter* createEmboss(JNIEnv* env, jobject, jfloatArray dirArray, float ambient, float specular, float radius) {
SkScalar direction[3];
@@ -79,16 +79,14 @@ static JNINativeMethod gTableMaskFilterMethods[] = {
result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \
if (result < 0) return result
-int register_android_graphics_MaskFilter(JNIEnv* env);
int register_android_graphics_MaskFilter(JNIEnv* env)
{
int result;
-
+
REG(env, "android/graphics/MaskFilter", gMaskFilterMethods);
REG(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods);
REG(env, "android/graphics/EmbossMaskFilter", gEmbossMaskFilterMethods);
REG(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods);
-
+
return 0;
}
-
diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp
index 7145433..c112423 100644
--- a/core/jni/android/graphics/Movie.cpp
+++ b/core/jni/android/graphics/Movie.cpp
@@ -23,11 +23,8 @@ jobject create_jmovie(JNIEnv* env, SkMovie* moov) {
if (NULL == moov) {
return NULL;
}
- jobject obj = env->AllocObject(gMovie_class);
- if (obj) {
- env->CallVoidMethod(obj, gMovie_constructorMethodID, (jint)moov);
- }
- return obj;
+ return env->NewObject(gMovie_class, gMovie_constructorMethodID,
+ static_cast<jint>(reinterpret_cast<uintptr_t>(moov)));
}
static SkMovie* J2Movie(JNIEnv* env, jobject movie) {
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index f9a3518..0c8a8a3 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -182,7 +182,6 @@ static JNINativeMethod gNinePatchMethods[] = {
(void*)SkNinePatchGlue::getTransparentRegion }
};
-int register_android_graphics_NinePatch(JNIEnv* env);
int register_android_graphics_NinePatch(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
diff --git a/core/jni/android/graphics/PathEffect.cpp b/core/jni/android/graphics/PathEffect.cpp
index cfa9ce4..0503614 100644
--- a/core/jni/android/graphics/PathEffect.cpp
+++ b/core/jni/android/graphics/PathEffect.cpp
@@ -19,12 +19,12 @@ public:
SkPathEffect* outer, SkPathEffect* inner) {
return new SkComposePathEffect(outer, inner);
}
-
+
static SkPathEffect* Sum_constructor(JNIEnv* env, jobject,
SkPathEffect* first, SkPathEffect* second) {
return new SkSumPathEffect(first, second);
}
-
+
static SkPathEffect* Dash_constructor(JNIEnv* env, jobject,
jfloatArray intervalArray, float phase) {
AutoJavaFloatArray autoInterval(env, intervalArray);
@@ -32,30 +32,30 @@ public:
float* values = autoInterval.ptr();
SkAutoSTMalloc<32, SkScalar> storage(count);
- SkScalar* intervals = storage.get();
+ SkScalar* intervals = storage.get();
for (int i = 0; i < count; i++) {
intervals[i] = SkFloatToScalar(values[i]);
}
return new SkDashPathEffect(intervals, count, SkFloatToScalar(phase));
}
-
+
static SkPathEffect* OneD_constructor(JNIEnv* env, jobject,
const SkPath* shape, float advance, float phase, int style) {
SkASSERT(shape != NULL);
return new SkPath1DPathEffect(*shape, SkFloatToScalar(advance),
SkFloatToScalar(phase), (SkPath1DPathEffect::Style)style);
}
-
+
static SkPathEffect* Corner_constructor(JNIEnv* env, jobject, float radius){
return new SkCornerPathEffect(SkFloatToScalar(radius));
}
-
+
static SkPathEffect* Discrete_constructor(JNIEnv* env, jobject,
float length, float deviation) {
return new SkDiscretePathEffect(SkFloatToScalar(length),
SkFloatToScalar(deviation));
}
-
+
};
////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -95,11 +95,10 @@ static JNINativeMethod gDiscretePathEffectMethods[] = {
SK_ARRAY_COUNT(array)); \
if (result < 0) return result
-int register_android_graphics_PathEffect(JNIEnv* env);
int register_android_graphics_PathEffect(JNIEnv* env)
{
int result;
-
+
REG(env, "android/graphics/PathEffect", gPathEffectMethods);
REG(env, "android/graphics/ComposePathEffect", gComposePathEffectMethods);
REG(env, "android/graphics/SumPathEffect", gSumPathEffectMethods);
@@ -107,7 +106,6 @@ int register_android_graphics_PathEffect(JNIEnv* env)
REG(env, "android/graphics/PathDashPathEffect", gPathDashPathEffectMethods);
REG(env, "android/graphics/CornerPathEffect", gCornerPathEffectMethods);
REG(env, "android/graphics/DiscretePathEffect", gDiscretePathEffectMethods);
-
+
return 0;
}
-
diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp
index 2445229..5c6ebdf 100644
--- a/core/jni/android/graphics/Region.cpp
+++ b/core/jni/android/graphics/Region.cpp
@@ -69,7 +69,7 @@ static jboolean Region_getBoundaryPath(JNIEnv* env, jobject, const SkRegion* reg
static jboolean Region_op0(JNIEnv* env, jobject, SkRegion* dst, int left, int top, int right, int bottom, int op) {
SkIRect ir;
-
+
ir.set(left, top, right, bottom);
return dst->op(ir, (SkRegion::Op)op);
}
@@ -84,16 +84,16 @@ static jboolean Region_op2(JNIEnv* env, jobject, SkRegion* dst, const SkRegion*
return dst->op(*region1, *region2, (SkRegion::Op)op);
}
-//////////////////////////////////// These are methods, not static
+//////////////////////////////////// These are methods, not static
static jboolean Region_isEmpty(JNIEnv* env, jobject region) {
return GetSkRegion(env, region)->isEmpty();
}
-
+
static jboolean Region_isRect(JNIEnv* env, jobject region) {
return GetSkRegion(env, region)->isRect();
}
-
+
static jboolean Region_isComplex(JNIEnv* env, jobject region) {
return GetSkRegion(env, region)->isComplex();
}
@@ -101,21 +101,21 @@ static jboolean Region_isComplex(JNIEnv* env, jobject region) {
static jboolean Region_contains(JNIEnv* env, jobject region, int x, int y) {
return GetSkRegion(env, region)->contains(x, y);
}
-
+
static jboolean Region_quickContains(JNIEnv* env, jobject region, int left, int top, int right, int bottom) {
return GetSkRegion(env, region)->quickContains(left, top, right, bottom);
}
-
+
static jboolean Region_quickRejectIIII(JNIEnv* env, jobject region, int left, int top, int right, int bottom) {
SkIRect ir;
ir.set(left, top, right, bottom);
return GetSkRegion(env, region)->quickReject(ir);
}
-
+
static jboolean Region_quickRejectRgn(JNIEnv* env, jobject region, jobject other) {
return GetSkRegion(env, region)->quickReject(*GetSkRegion(env, other));
}
-
+
static void Region_translate(JNIEnv* env, jobject region, int x, int y, jobject dst) {
SkRegion* rgn = GetSkRegion(env, region);
if (dst)
@@ -171,13 +171,13 @@ static SkRegion* Region_createFromParcel(JNIEnv* env, jobject clazz, jobject par
if (parcel == NULL) {
return NULL;
}
-
+
android::Parcel* p = android::parcelForJavaObject(env, parcel);
-
+
SkRegion* region = new SkRegion;
size_t size = p->readInt32();
region->unflatten(p->readInplace(size));
-
+
return region;
}
@@ -186,7 +186,7 @@ static jboolean Region_writeToParcel(JNIEnv* env, jobject clazz, const SkRegion*
if (parcel == NULL) {
return false;
}
-
+
android::Parcel* p = android::parcelForJavaObject(env, parcel);
size_t size = region->flatten(NULL);
@@ -208,7 +208,7 @@ static jboolean Region_equals(JNIEnv* env, jobject clazz, const SkRegion *r1, co
struct RgnIterPair {
SkRegion fRgn; // a copy of the caller's region
SkRegion::Iterator fIter; // an iterator acting upon the copy (fRgn)
-
+
RgnIterPair(const SkRegion& rgn) : fRgn(rgn) {
// have our iterator reference our copy (fRgn), so we know it will be
// unchanged for the lifetime of the iterator
@@ -218,7 +218,7 @@ struct RgnIterPair {
static RgnIterPair* RegionIter_constructor(JNIEnv* env, jobject, const SkRegion* region)
{
- SkASSERT(region);
+ SkASSERT(region);
return new RgnIterPair(*region);
}
@@ -279,12 +279,11 @@ static JNINativeMethod gRegionMethods[] = {
{ "nativeEquals", "(II)Z", (void*)Region_equals },
};
-int register_android_graphics_Region(JNIEnv* env);
int register_android_graphics_Region(JNIEnv* env)
{
jclass clazz = env->FindClass("android/graphics/Region");
SkASSERT(clazz);
-
+
gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "I");
SkASSERT(gRegion_nativeInstanceFieldID);
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp
index 7fdad10..f4cc9e4 100644
--- a/core/jni/android/graphics/Shader.cpp
+++ b/core/jni/android/graphics/Shader.cpp
@@ -35,7 +35,7 @@ static void Color_RGBToHSV(JNIEnv* env, jobject, int red, int green, int blue, j
values[i] = SkScalarToFloat(hsv[i]);
}
}
-
+
static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArray)
{
AutoJavaFloatArray autoHSV(env, hsvArray, 3);
@@ -45,7 +45,7 @@ static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArra
for (int i = 0; i < 3; i++) {
hsv[i] = SkFloatToScalar(values[i]);
}
-
+
return SkHSVToColor(alpha, hsv);
}
@@ -104,7 +104,7 @@ static SkiaShader* BitmapShader_postConstructor(JNIEnv* env, jobject o, SkShader
return NULL;
#endif
}
-
+
///////////////////////////////////////////////////////////////////////////////////////////////
static SkShader* LinearGradient_create1(JNIEnv* env, jobject o,
@@ -129,7 +129,7 @@ static SkShader* LinearGradient_create1(JNIEnv* env, jobject o,
pos[i] = SkFloatToScalar(posValues[i]);
}
}
-
+
SkShader* shader = SkGradientShader::CreateLinear(pts,
reinterpret_cast<const SkColor*>(colorValues),
pos, count,
@@ -218,7 +218,7 @@ static SkShader* LinearGradient_create2(JNIEnv* env, jobject o,
SkColor colors[2];
colors[0] = color0;
colors[1] = color1;
-
+
SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, (SkShader::TileMode)tileMode);
ThrowIAE_IfNull(env, s);
@@ -237,7 +237,7 @@ static SkShader* RadialGradient_create1(JNIEnv* env, jobject, float x, float y,
SkAutoSTMalloc<8, SkScalar> storage(posArray ? count : 0);
SkScalar* pos = NULL;
-
+
if (posArray) {
AutoJavaFloatArray autoPos(env, posArray, count);
const float* posValues = autoPos.ptr();
@@ -338,10 +338,10 @@ static SkShader* SweepGradient_create1(JNIEnv* env, jobject, float x, float y,
jintArray jcolors, jfloatArray jpositions) {
size_t count = env->GetArrayLength(jcolors);
const jint* colors = env->GetIntArrayElements(jcolors, NULL);
-
+
SkAutoSTMalloc<8, SkScalar> storage(jpositions ? count : 0);
SkScalar* pos = NULL;
-
+
if (NULL != jpositions) {
AutoJavaFloatArray autoPos(env, jpositions, count);
const float* posValues = autoPos.ptr();
@@ -520,11 +520,10 @@ static JNINativeMethod gComposeShaderMethods[] = {
result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \
if (result < 0) return result
-int register_android_graphics_Shader(JNIEnv* env);
int register_android_graphics_Shader(JNIEnv* env)
{
int result;
-
+
REG(env, "android/graphics/Color", gColorMethods);
REG(env, "android/graphics/Shader", gShaderMethods);
REG(env, "android/graphics/BitmapShader", gBitmapShaderMethods);
@@ -532,7 +531,6 @@ int register_android_graphics_Shader(JNIEnv* env)
REG(env, "android/graphics/RadialGradient", gRadialGradientMethods);
REG(env, "android/graphics/SweepGradient", gSweepGradientMethods);
REG(env, "android/graphics/ComposeShader", gComposeShaderMethods);
-
+
return result;
}
-
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index 53a5c0a..b25598a 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -44,7 +44,7 @@ static SkTypeface* Typeface_create(JNIEnv* env, jobject, jstring name,
static SkTypeface* Typeface_createFromTypeface(JNIEnv* env, jobject, SkTypeface* family, int style) {
return SkTypeface::CreateFromTypeface(family, (SkTypeface::Style)style);
}
-
+
static void Typeface_unref(JNIEnv* env, jobject obj, SkTypeface* face) {
SkSafeUnref(face);
}
@@ -64,7 +64,7 @@ public:
{
delete fAsset;
}
-
+
virtual const void* getMemoryBase()
{
return fMemoryBase;
@@ -75,38 +75,38 @@ public:
off64_t pos = fAsset->seek(0, SEEK_SET);
return pos != (off64_t)-1;
}
-
+
virtual size_t read(void* buffer, size_t size)
{
ssize_t amount;
-
+
if (NULL == buffer)
{
if (0 == size) // caller is asking us for our total length
return fAsset->getLength();
-
+
// asset->seek returns new total offset
// we want to return amount that was skipped
-
+
off64_t oldOffset = fAsset->seek(0, SEEK_CUR);
if (-1 == oldOffset)
return 0;
off64_t newOffset = fAsset->seek(size, SEEK_CUR);
if (-1 == newOffset)
return 0;
-
+
amount = newOffset - oldOffset;
}
else
{
amount = fAsset->read(buffer, size);
}
-
+
if (amount < 0)
amount = 0;
return amount;
}
-
+
private:
Asset* fAsset;
const void* fMemoryBase;
@@ -115,21 +115,21 @@ private:
static SkTypeface* Typeface_createFromAsset(JNIEnv* env, jobject,
jobject jassetMgr,
jstring jpath) {
-
+
NPE_CHECK_RETURN_ZERO(env, jassetMgr);
NPE_CHECK_RETURN_ZERO(env, jpath);
-
+
AssetManager* mgr = assetManagerForJavaObject(env, jassetMgr);
if (NULL == mgr) {
return NULL;
}
-
+
AutoJavaStringToUTF8 str(env, jpath);
Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER);
if (NULL == asset) {
return NULL;
}
-
+
SkStream* stream = new AssetStream(asset, true);
SkTypeface* face = SkTypeface::CreateFromStream(stream);
// SkTypeFace::CreateFromStream calls ref() on the stream, so we
@@ -180,7 +180,6 @@ static JNINativeMethod gTypefaceMethods[] = {
{ "setGammaForText", "(FF)V", (void*)Typeface_setGammaForText },
};
-int register_android_graphics_Typeface(JNIEnv* env);
int register_android_graphics_Typeface(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
diff --git a/core/jni/android/graphics/YuvToJpegEncoder.cpp b/core/jni/android/graphics/YuvToJpegEncoder.cpp
index 0a0c5b3..8333e00 100644
--- a/core/jni/android/graphics/YuvToJpegEncoder.cpp
+++ b/core/jni/android/graphics/YuvToJpegEncoder.cpp
@@ -242,7 +242,6 @@ static JNINativeMethod gYuvImageMethods[] = {
#define kClassPathName "android/graphics/YuvImage"
-int register_android_graphics_YuvImage(JNIEnv* env);
int register_android_graphics_YuvImage(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
diff --git a/core/jni/android_backup_BackupDataInput.cpp b/core/jni/android_backup_BackupDataInput.cpp
index b03dd16..c174a41 100644
--- a/core/jni/android_backup_BackupDataInput.cpp
+++ b/core/jni/android_backup_BackupDataInput.cpp
@@ -25,9 +25,6 @@
namespace android
{
-// java.io.FileDescriptor
-static jfieldID s_descriptorField = 0;
-
// android.app.backup.BackupDataInput$EntityHeader
static jfieldID s_keyField = 0;
static jfieldID s_dataSizeField = 0;
@@ -35,9 +32,7 @@ static jfieldID s_dataSizeField = 0;
static int
ctor_native(JNIEnv* env, jobject clazz, jobject fileDescriptor)
{
- int err;
-
- int fd = env->GetIntField(fileDescriptor, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (fd == -1) {
return NULL;
}
@@ -140,15 +135,7 @@ int register_android_backup_BackupDataInput(JNIEnv* env)
{
//LOGD("register_android_backup_BackupDataInput");
- 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");
-
- clazz = env->FindClass("android/app/backup/BackupDataInput$EntityHeader");
+ jclass clazz = env->FindClass("android/app/backup/BackupDataInput$EntityHeader");
LOG_FATAL_IF(clazz == NULL, "Unable to find class android.app.backup.BackupDataInput.EntityHeader");
s_keyField = env->GetFieldID(clazz, "key", "Ljava/lang/String;");
LOG_FATAL_IF(s_keyField == NULL,
diff --git a/core/jni/android_backup_BackupDataOutput.cpp b/core/jni/android_backup_BackupDataOutput.cpp
index b895d11..144a10c 100644
--- a/core/jni/android_backup_BackupDataOutput.cpp
+++ b/core/jni/android_backup_BackupDataOutput.cpp
@@ -25,14 +25,10 @@
namespace android
{
-static jfieldID s_descriptorField = 0;
-
static int
ctor_native(JNIEnv* env, jobject clazz, jobject fileDescriptor)
{
- int err;
-
- int fd = env->GetIntField(fileDescriptor, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
if (fd == -1) {
return NULL;
}
@@ -112,15 +108,6 @@ static const JNINativeMethod g_methods[] = {
int register_android_backup_BackupDataOutput(JNIEnv* env)
{
//LOGD("register_android_backup_BackupDataOutput");
-
- 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/app/backup/BackupDataOutput",
g_methods, NELEM(g_methods));
}
diff --git a/core/jni/android_backup_BackupHelperDispatcher.cpp b/core/jni/android_backup_BackupHelperDispatcher.cpp
index 26e7d66..49f1cd4 100644
--- a/core/jni/android_backup_BackupHelperDispatcher.cpp
+++ b/core/jni/android_backup_BackupHelperDispatcher.cpp
@@ -37,8 +37,6 @@ struct chunk_header_v1 {
int nameLength; // not including the NULL terminator, which is not written to the file
};
-// java.io.FileDescriptor
-static jfieldID s_descriptorField = 0;
static jfieldID s_chunkSizeField = 0;
static jfieldID s_keyPrefixField = 0;
@@ -46,12 +44,11 @@ static int
readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj)
{
chunk_header_v1 flattenedHeader;
- int fd;
ssize_t amt;
String8 keyPrefix;
char* buf;
- fd = env->GetIntField(fdObj, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fdObj);
amt = read(fd, &flattenedHeader.headerSize, sizeof(flattenedHeader.headerSize));
if (amt != sizeof(flattenedHeader.headerSize)) {
@@ -128,9 +125,7 @@ readHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj)
static int
skipChunk_native(JNIEnv* env, jobject clazz, jobject fdObj, jint bytesToSkip)
{
- int fd;
-
- fd = env->GetIntField(fdObj, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fdObj);
lseek(fd, bytesToSkip, SEEK_CUR);
@@ -152,9 +147,8 @@ allocateHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdO
int nameLength;
int namePadding;
int headerSize;
- int fd;
- fd = env->GetIntField(fdObj, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fdObj);
nameObj = (jstring)env->GetObjectField(headerObj, s_keyPrefixField);
@@ -166,7 +160,7 @@ allocateHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdO
pos = lseek(fd, 0, SEEK_CUR);
lseek(fd, headerSize, SEEK_CUR);
-
+
return pos;
}
@@ -175,13 +169,12 @@ writeHeader_native(JNIEnv* env, jobject clazz, jobject headerObj, jobject fdObj,
{
int err;
chunk_header_v1 header;
- int fd;
int namePadding;
int prevPos;
jstring nameObj;
const char* buf;
- fd = env->GetIntField(fdObj, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fdObj);
prevPos = lseek(fd, 0, SEEK_CUR);
nameObj = (jstring)env->GetObjectField(headerObj, s_keyPrefixField);
@@ -234,15 +227,7 @@ static const JNINativeMethod g_methods[] = {
int register_android_backup_BackupHelperDispatcher(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");
-
- clazz = env->FindClass("android/app/backup/BackupHelperDispatcher$Header");
+ jclass clazz = env->FindClass("android/app/backup/BackupHelperDispatcher$Header");
LOG_FATAL_IF(clazz == NULL,
"Unable to find class android.app.backup.BackupHelperDispatcher.Header");
s_chunkSizeField = env->GetFieldID(clazz, "chunkSize", "I");
@@ -251,7 +236,7 @@ int register_android_backup_BackupHelperDispatcher(JNIEnv* env)
s_keyPrefixField = env->GetFieldID(clazz, "keyPrefix", "Ljava/lang/String;");
LOG_FATAL_IF(s_keyPrefixField == NULL,
"Unable to find keyPrefix field in android.app.backup.BackupHelperDispatcher.Header");
-
+
return AndroidRuntime::registerNativeMethods(env, "android/app/backup/BackupHelperDispatcher",
g_methods, NELEM(g_methods));
}
diff --git a/core/jni/android_backup_FileBackupHelperBase.cpp b/core/jni/android_backup_FileBackupHelperBase.cpp
index 0137a06..0dfd8db 100644
--- a/core/jni/android_backup_FileBackupHelperBase.cpp
+++ b/core/jni/android_backup_FileBackupHelperBase.cpp
@@ -25,9 +25,6 @@
namespace android
{
-// java.io.FileDescriptor
-static jfieldID s_descriptorField = 0;
-
static int
ctor(JNIEnv* env, jobject clazz)
{
@@ -47,8 +44,8 @@ performBackup_native(JNIEnv* env, jobject clazz, jobject oldState, int data,
int err;
// all parameters have already been checked against null
- int oldStateFD = oldState != NULL ? env->GetIntField(oldState, s_descriptorField) : -1;
- int newStateFD = env->GetIntField(newState, s_descriptorField);
+ int oldStateFD = oldState != NULL ? jniGetFDFromFileDescriptor(env, oldState) : -1;
+ int newStateFD = jniGetFDFromFileDescriptor(env, newState);
BackupDataWriter* dataStream = (BackupDataWriter*)data;
const int fileCount = env->GetArrayLength(files);
@@ -102,7 +99,7 @@ writeSnapshot_native(JNIEnv* env, jobject clazz, jint ptr, jobject fileDescripto
int err;
RestoreHelperBase* restore = (RestoreHelperBase*)ptr;
- int fd = env->GetIntField(fileDescriptor, s_descriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
err = restore->WriteSnapshot(fd);
@@ -121,14 +118,6 @@ static const JNINativeMethod g_methods[] = {
int register_android_backup_FileBackupHelperBase(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/app/backup/FileBackupHelperBase",
g_methods, NELEM(g_methods));
}
diff --git a/core/jni/android_content_res_ObbScanner.cpp b/core/jni/android_content_res_ObbScanner.cpp
index 404a87d..8837538 100644
--- a/core/jni/android_content_res_ObbScanner.cpp
+++ b/core/jni/android_content_res_ObbScanner.cpp
@@ -39,7 +39,7 @@ static struct {
static void android_content_res_ObbScanner_getObbInfo(JNIEnv* env, jobject clazz, jstring file,
jobject obbInfo)
{
- const char* filePath = env->GetStringUTFChars(file, JNI_FALSE);
+ const char* filePath = env->GetStringUTFChars(file, NULL);
sp<ObbFile> obb = new ObbFile();
if (!obb->readFrom(filePath)) {
diff --git a/core/jni/android_database_SQLiteStatement.cpp b/core/jni/android_database_SQLiteStatement.cpp
index 97e0483..05ffbb1 100644
--- a/core/jni/android_database_SQLiteStatement.cpp
+++ b/core/jni/android_database_SQLiteStatement.cpp
@@ -143,7 +143,7 @@ static jstring native_1x1_string(JNIEnv* env, jobject object)
static jobject createParcelFileDescriptor(JNIEnv * env, int fd)
{
// Create FileDescriptor object
- jobject fileDesc = newFileDescriptor(env, fd);
+ jobject fileDesc = jniCreateFileDescriptor(env, fd);
if (fileDesc == NULL) {
// FileDescriptor constructor has thrown an exception
close(fd);
diff --git a/core/jni/android_emoji_EmojiFactory.cpp b/core/jni/android_emoji_EmojiFactory.cpp
index 1ebb36c..81dae88 100644
--- a/core/jni/android_emoji_EmojiFactory.cpp
+++ b/core/jni/android_emoji_EmojiFactory.cpp
@@ -93,8 +93,6 @@ static EmojiFactoryCaller* gCaller;
static pthread_once_t g_once = PTHREAD_ONCE_INIT;
static bool lib_emoji_factory_is_ready;
-static jclass gString_class;
-
static jclass gBitmap_class;
static jmethodID gBitmap_constructorMethodID;
@@ -108,15 +106,11 @@ static void InitializeCaller() {
static jobject create_java_EmojiFactory(
JNIEnv* env, EmojiFactory* factory, jstring name) {
- jobject obj = env->AllocObject(gEmojiFactory_class);
- if (obj) {
- env->CallVoidMethod(obj, gEmojiFactory_constructorMethodID,
- (jint)factory, name);
- if (env->ExceptionCheck() != 0) {
- LOGE("*** Uncaught exception returned from Java call!\n");
- env->ExceptionDescribe();
- obj = NULL;
- }
+ jobject obj = env->NewObject(gEmojiFactory_class, gEmojiFactory_constructorMethodID,
+ static_cast<jint>(reinterpret_cast<uintptr_t>(factory)), name);
+ if (env->ExceptionCheck() != 0) {
+ LOGE("*** Uncaught exception returned from Java call!\n");
+ env->ExceptionDescribe();
}
return obj;
}
@@ -182,17 +176,12 @@ static jobject android_emoji_EmojiFactory_getBitmapFromAndroidPua(
return NULL;
}
- jobject obj = env->AllocObject(gBitmap_class);
- if (obj) {
- env->CallVoidMethod(obj, gBitmap_constructorMethodID,
- reinterpret_cast<jint>(bitmap), NULL, false, NULL, -1);
- if (env->ExceptionCheck() != 0) {
- LOGE("*** Uncaught exception returned from Java call!\n");
- env->ExceptionDescribe();
- return NULL;
- }
+ jobject obj = env->NewObject(gBitmap_class, gBitmap_constructorMethodID,
+ static_cast<jint>(reinterpret_cast<uintptr_t>(bitmap)), NULL, false, NULL, -1);
+ if (env->ExceptionCheck() != 0) {
+ LOGE("*** Uncaught exception returned from Java call!\n");
+ env->ExceptionDescribe();
}
-
return obj;
}
diff --git a/core/jni/android_hardware_UsbDevice.cpp b/core/jni/android_hardware_UsbDevice.cpp
index c2950ea..25f901b 100644
--- a/core/jni/android_hardware_UsbDevice.cpp
+++ b/core/jni/android_hardware_UsbDevice.cpp
@@ -54,13 +54,6 @@ static JNINativeMethod method_table[] = {
int register_android_hardware_UsbDevice(JNIEnv *env)
{
- jclass clazz = env->FindClass("android/hardware/usb/UsbDevice");
- if (clazz == NULL) {
- LOGE("Can't find android/hardware/usb/UsbDevice");
- return -1;
- }
-
return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbDevice",
method_table, NELEM(method_table));
}
-
diff --git a/core/jni/android_hardware_UsbDeviceConnection.cpp b/core/jni/android_hardware_UsbDeviceConnection.cpp
index e259514..4d73bf3 100644
--- a/core/jni/android_hardware_UsbDeviceConnection.cpp
+++ b/core/jni/android_hardware_UsbDeviceConnection.cpp
@@ -42,7 +42,7 @@ static jboolean
android_hardware_UsbDeviceConnection_open(JNIEnv *env, jobject thiz, jstring deviceName,
jobject fileDescriptor)
{
- int fd = getParcelFileDescriptorFD(env, fileDescriptor);
+ int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
// duplicate the file descriptor, since ParcelFileDescriptor will eventually close its copy
fd = dup(fd);
if (fd < 0)
diff --git a/core/jni/android_media_JetPlayer.cpp b/core/jni/android_media_JetPlayer.cpp
index a7ffff4..e124069 100644
--- a/core/jni/android_media_JetPlayer.cpp
+++ b/core/jni/android_media_JetPlayer.cpp
@@ -175,7 +175,7 @@ android_media_JetPlayer_loadFromFileD(JNIEnv *env, jobject thiz,
lpJet->setEventCallback(jetPlayerEventCallback);
LOGV("android_media_JetPlayer_openFileDescr(): trying to load JET file through its fd" );
- EAS_RESULT result = lpJet->loadFromFD(getParcelFileDescriptorFD(env, fileDescriptor),
+ EAS_RESULT result = lpJet->loadFromFD(jniGetFDFromFileDescriptor(env, fileDescriptor),
(long long)offset, (long long)length); // cast params to types used by EAS_FILE
if(result==EAS_SUCCESS) {
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index db132ec..4a0e68e 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -1,16 +1,16 @@
/*
* 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
+ * 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
+ * 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
+ * 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.
*/
@@ -225,9 +225,6 @@ static JNINativeMethod gNetworkUtilMethods[] = {
int register_android_net_NetworkUtils(JNIEnv* env)
{
- jclass netutils = env->FindClass(NETUTILS_PKG_NAME);
- LOG_FATAL_IF(netutils == NULL, "Unable to find class " NETUTILS_PKG_NAME);
-
jclass dhcpInfoInternalClass = env->FindClass("android/net/DhcpInfoInternal");
LOG_FATAL_IF(dhcpInfoInternalClass == NULL, "Unable to find class android/net/DhcpInfoInternal");
dhcpInfoInternalFieldIds.constructorId = env->GetMethodID(dhcpInfoInternalClass, "<init>", "()V");
diff --git a/core/jni/android_net_TrafficStats.cpp b/core/jni/android_net_TrafficStats.cpp
index 0c84f11..203b5ef 100644
--- a/core/jni/android_net_TrafficStats.cpp
+++ b/core/jni/android_net_TrafficStats.cpp
@@ -25,6 +25,7 @@
#include <android_runtime/AndroidRuntime.h>
#include <cutils/logger.h>
#include <jni.h>
+#include <ScopedUtfChars.h>
#include <utils/misc.h>
#include <utils/Log.h>
@@ -130,13 +131,14 @@ static jlong getMobileRxBytes(JNIEnv* env, jobject clazz) {
"/sys/class/net/ppp0/statistics/rx_bytes");
}
-static jlong getData(JNIEnv* env, char *what, jstring interface) {
- char filename[80];
- jboolean isCopy;
-
- const char *interfaceStr = env->GetStringUTFChars(interface, &isCopy);
- snprintf(filename, sizeof(filename), "/sys/class/net/%s/statistics/%s", interfaceStr, what);
+static jlong getData(JNIEnv* env, const char* what, jstring javaInterface) {
+ ScopedUtfChars interface(env, javaInterface);
+ if (interface.c_str() == NULL) {
+ return -1;
+ }
+ char filename[80];
+ snprintf(filename, sizeof(filename), "/sys/class/net/%s/statistics/%s", interface.c_str(), what);
return readNumber(filename);
}
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index 494dc27..9d17fe9 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "wifi"
#include "jni.h"
+#include <ScopedUtfChars.h>
#include <utils/misc.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/Log.h>
@@ -47,82 +48,100 @@ static int doCommand(const char *cmd, char *replybuf, int replybuflen)
}
}
-static jint doIntCommand(const char *cmd)
+static jint doIntCommand(const char* fmt, ...)
{
+ char buf[BUF_SIZE];
+ va_list args;
+ va_start(args, fmt);
+ int byteCount = vsnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+ if (byteCount < 0 || byteCount >= BUF_SIZE) {
+ return -1;
+ }
char reply[BUF_SIZE];
-
- if (doCommand(cmd, reply, sizeof(reply)) != 0) {
- return (jint)-1;
- } else {
- return (jint)atoi(reply);
+ if (doCommand(buf, reply, sizeof(reply)) != 0) {
+ return -1;
}
+ return static_cast<jint>(atoi(reply));
}
-static jboolean doBooleanCommand(const char *cmd, const char *expect)
+static jboolean doBooleanCommand(const char* expect, const char* fmt, ...)
{
+ char buf[BUF_SIZE];
+ va_list args;
+ va_start(args, fmt);
+ int byteCount = vsnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+ if (byteCount < 0 || byteCount >= BUF_SIZE) {
+ return JNI_FALSE;
+ }
char reply[BUF_SIZE];
-
- if (doCommand(cmd, reply, sizeof(reply)) != 0) {
- return (jboolean)JNI_FALSE;
- } else {
- return (jboolean)(strcmp(reply, expect) == 0);
+ if (doCommand(buf, reply, sizeof(reply)) != 0) {
+ return JNI_FALSE;
}
+ return (strcmp(reply, expect) == 0);
}
// Send a command to the supplicant, and return the reply as a String
-static jstring doStringCommand(JNIEnv *env, const char *cmd)
-{
+static jstring doStringCommand(JNIEnv* env, const char* fmt, ...) {
+ char buf[BUF_SIZE];
+ va_list args;
+ va_start(args, fmt);
+ int byteCount = vsnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+ if (byteCount < 0 || byteCount >= BUF_SIZE) {
+ return NULL;
+ }
char reply[4096];
-
- if (doCommand(cmd, reply, sizeof(reply)) != 0) {
- return env->NewStringUTF(NULL);
- } else {
- String16 str((char *)reply);
- return env->NewString((const jchar *)str.string(), str.size());
+ if (doCommand(buf, reply, sizeof(reply)) != 0) {
+ return NULL;
}
+ // TODO: why not just NewStringUTF?
+ String16 str((char *)reply);
+ return env->NewString((const jchar *)str.string(), str.size());
}
-static jboolean android_net_wifi_isDriverLoaded(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_isDriverLoaded(JNIEnv* env, jobject)
{
return (jboolean)(::is_wifi_driver_loaded() == 1);
}
-static jboolean android_net_wifi_loadDriver(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_loadDriver(JNIEnv* env, jobject)
{
return (jboolean)(::wifi_load_driver() == 0);
}
-static jboolean android_net_wifi_unloadDriver(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_unloadDriver(JNIEnv* env, jobject)
{
return (jboolean)(::wifi_unload_driver() == 0);
}
-static jboolean android_net_wifi_startSupplicant(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_startSupplicant(JNIEnv* env, jobject)
{
return (jboolean)(::wifi_start_supplicant() == 0);
}
-static jboolean android_net_wifi_stopSupplicant(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_stopSupplicant(JNIEnv* env, jobject)
{
- return doBooleanCommand("TERMINATE", "OK");
+ return doBooleanCommand("OK", "TERMINATE");
}
-static jboolean android_net_wifi_killSupplicant(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_killSupplicant(JNIEnv* env, jobject)
{
return (jboolean)(::wifi_stop_supplicant() == 0);
}
-static jboolean android_net_wifi_connectToSupplicant(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_connectToSupplicant(JNIEnv* env, jobject)
{
return (jboolean)(::wifi_connect_to_supplicant() == 0);
}
-static void android_net_wifi_closeSupplicantConnection(JNIEnv* env, jobject clazz)
+static void android_net_wifi_closeSupplicantConnection(JNIEnv* env, jobject)
{
::wifi_close_supplicant_connection();
}
-static jstring android_net_wifi_waitForEvent(JNIEnv* env, jobject clazz)
+static jstring android_net_wifi_waitForEvent(JNIEnv* env, jobject)
{
char buf[BUF_SIZE];
@@ -130,197 +149,143 @@ static jstring android_net_wifi_waitForEvent(JNIEnv* env, jobject clazz)
if (nread > 0) {
return env->NewStringUTF(buf);
} else {
- return env->NewStringUTF(NULL);
+ return NULL;
}
}
-static jstring android_net_wifi_listNetworksCommand(JNIEnv* env, jobject clazz)
+static jstring android_net_wifi_listNetworksCommand(JNIEnv* env, jobject)
{
return doStringCommand(env, "LIST_NETWORKS");
}
-static jint android_net_wifi_addNetworkCommand(JNIEnv* env, jobject clazz)
+static jint android_net_wifi_addNetworkCommand(JNIEnv* env, jobject)
{
return doIntCommand("ADD_NETWORK");
}
-static jboolean android_net_wifi_wpsPbcCommand(JNIEnv* env, jobject clazz, jstring bssid)
+static jboolean android_net_wifi_wpsPbcCommand(JNIEnv* env, jobject, jstring javaBssid)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy);
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "WPS_PBC %s", bssidStr);
- env->ReleaseStringUTFChars(bssid, bssidStr);
-
- if ((numWritten == -1) || (numWritten >= sizeof(cmdstr))) {
- return false;
+ ScopedUtfChars bssid(env, javaBssid);
+ if (bssid.c_str() == NULL) {
+ return JNI_FALSE;
}
- return doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "WPS_PBC %s", bssid.c_str());
}
-static jboolean android_net_wifi_wpsPinFromAccessPointCommand(JNIEnv* env, jobject clazz,
- jstring bssid, jstring apPin)
+static jboolean android_net_wifi_wpsPinFromAccessPointCommand(JNIEnv* env, jobject,
+ jstring javaBssid, jstring javaApPin)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy);
- const char *apPinStr = env->GetStringUTFChars(apPin, &isCopy);
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "WPS_REG %s %s", bssidStr, apPinStr);
- env->ReleaseStringUTFChars(bssid, bssidStr);
- env->ReleaseStringUTFChars(apPin, apPinStr);
-
- if ((numWritten == -1) || (numWritten >= (int)sizeof(cmdstr))) {
- return false;
+ ScopedUtfChars bssid(env, javaBssid);
+ if (bssid.c_str() == NULL) {
+ return JNI_FALSE;
+ }
+ ScopedUtfChars apPin(env, javaApPin);
+ if (apPin.c_str() == NULL) {
+ return JNI_FALSE;
}
- return doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "WPS_REG %s %s", bssid.c_str(), apPin.c_str());
}
-static jstring android_net_wifi_wpsPinFromDeviceCommand(JNIEnv* env, jobject clazz, jstring bssid)
+static jstring android_net_wifi_wpsPinFromDeviceCommand(JNIEnv* env, jobject, jstring javaBssid)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy);
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "WPS_PIN %s", bssidStr);
- env->ReleaseStringUTFChars(bssid, bssidStr);
-
- if ((numWritten == -1) || (numWritten >= (int)sizeof(cmdstr))) {
+ ScopedUtfChars bssid(env, javaBssid);
+ if (bssid.c_str() == NULL) {
return NULL;
}
- return doStringCommand(env, cmdstr);
+ return doStringCommand(env, "WPS_PIN %s", bssid.c_str());
}
-static jboolean android_net_wifi_setCountryCodeCommand(JNIEnv* env, jobject clazz, jstring country)
+static jboolean android_net_wifi_setCountryCodeCommand(JNIEnv* env, jobject, jstring javaCountry)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *countryStr = env->GetStringUTFChars(country, &isCopy);
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER COUNTRY %s", countryStr);
- env->ReleaseStringUTFChars(country, countryStr);
-
- if ((numWritten == -1) || (numWritten >= (int)sizeof(cmdstr))) {
- return false;
+ ScopedUtfChars country(env, javaCountry);
+ if (country.c_str() == NULL) {
+ return JNI_FALSE;
}
- return doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DRIVER COUNTRY %s", country.c_str());
}
static jboolean android_net_wifi_setNetworkVariableCommand(JNIEnv* env,
- jobject clazz,
+ jobject,
jint netId,
- jstring name,
- jstring value)
+ jstring javaName,
+ jstring javaValue)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *nameStr = env->GetStringUTFChars(name, &isCopy);
- const char *valueStr = env->GetStringUTFChars(value, &isCopy);
-
- if (nameStr == NULL || valueStr == NULL)
+ ScopedUtfChars name(env, javaName);
+ if (name.c_str() == NULL) {
return JNI_FALSE;
-
- int cmdTooLong = snprintf(cmdstr, sizeof(cmdstr), "SET_NETWORK %d %s %s",
- netId, nameStr, valueStr) >= (int)sizeof(cmdstr);
-
- env->ReleaseStringUTFChars(name, nameStr);
- env->ReleaseStringUTFChars(value, valueStr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ }
+ ScopedUtfChars value(env, javaValue);
+ if (value.c_str() == NULL) {
+ return JNI_FALSE;
+ }
+ return doBooleanCommand("OK", "SET_NETWORK %d %s %s", netId, name.c_str(), value.c_str());
}
static jstring android_net_wifi_getNetworkVariableCommand(JNIEnv* env,
- jobject clazz,
+ jobject,
jint netId,
- jstring name)
+ jstring javaName)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *nameStr = env->GetStringUTFChars(name, &isCopy);
-
- if (nameStr == NULL)
- return env->NewStringUTF(NULL);
-
- int cmdTooLong = snprintf(cmdstr, sizeof(cmdstr), "GET_NETWORK %d %s",
- netId, nameStr) >= (int)sizeof(cmdstr);
-
- env->ReleaseStringUTFChars(name, nameStr);
-
- return cmdTooLong ? env->NewStringUTF(NULL) : doStringCommand(env, cmdstr);
+ ScopedUtfChars name(env, javaName);
+ if (name.c_str() == NULL) {
+ return NULL;
+ }
+ return doStringCommand(env, "GET_NETWORK %d %s", netId, name.c_str());
}
-static jboolean android_net_wifi_removeNetworkCommand(JNIEnv* env, jobject clazz, jint netId)
+static jboolean android_net_wifi_removeNetworkCommand(JNIEnv* env, jobject, jint netId)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "REMOVE_NETWORK %d", netId);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "REMOVE_NETWORK %d", netId);
}
static jboolean android_net_wifi_enableNetworkCommand(JNIEnv* env,
- jobject clazz,
+ jobject,
jint netId,
jboolean disableOthers)
{
- char cmdstr[BUF_SIZE];
- const char *cmd = disableOthers ? "SELECT_NETWORK" : "ENABLE_NETWORK";
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "%s %d", cmd, netId);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "%s_NETWORK %d", disableOthers ? "SELECT" : "ENABLE", netId);
}
-static jboolean android_net_wifi_disableNetworkCommand(JNIEnv* env, jobject clazz, jint netId)
+static jboolean android_net_wifi_disableNetworkCommand(JNIEnv* env, jobject, jint netId)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DISABLE_NETWORK %d", netId);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DISABLE_NETWORK %d", netId);
}
-static jstring android_net_wifi_statusCommand(JNIEnv* env, jobject clazz)
+static jstring android_net_wifi_statusCommand(JNIEnv* env, jobject)
{
return doStringCommand(env, "STATUS");
}
-static jboolean android_net_wifi_pingCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_pingCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("PING", "PONG");
+ return doBooleanCommand("PONG", "PING");
}
-static jstring android_net_wifi_scanResultsCommand(JNIEnv* env, jobject clazz)
+static jstring android_net_wifi_scanResultsCommand(JNIEnv* env, jobject)
{
return doStringCommand(env, "SCAN_RESULTS");
}
-static jboolean android_net_wifi_disconnectCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_disconnectCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("DISCONNECT", "OK");
+ return doBooleanCommand("OK", "DISCONNECT");
}
-static jboolean android_net_wifi_reconnectCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_reconnectCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("RECONNECT", "OK");
+ return doBooleanCommand("OK", "RECONNECT");
}
-static jboolean android_net_wifi_reassociateCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_reassociateCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("REASSOCIATE", "OK");
+ return doBooleanCommand("OK", "REASSOCIATE");
}
static jboolean doSetScanMode(jboolean setActive)
{
- return doBooleanCommand((setActive ? "DRIVER SCAN-ACTIVE" : "DRIVER SCAN-PASSIVE"), "OK");
+ return doBooleanCommand("OK", (setActive ? "DRIVER SCAN-ACTIVE" : "DRIVER SCAN-PASSIVE"));
}
-static jboolean android_net_wifi_scanCommand(JNIEnv* env, jobject clazz, jboolean forceActive)
+static jboolean android_net_wifi_scanCommand(JNIEnv* env, jobject, jboolean forceActive)
{
jboolean result;
@@ -328,43 +293,43 @@ static jboolean android_net_wifi_scanCommand(JNIEnv* env, jobject clazz, jboolea
// The scan will still work.
if (forceActive && !sScanModeActive)
doSetScanMode(true);
- result = doBooleanCommand("SCAN", "OK");
+ result = doBooleanCommand("OK", "SCAN");
if (forceActive && !sScanModeActive)
doSetScanMode(sScanModeActive);
return result;
}
-static jboolean android_net_wifi_setScanModeCommand(JNIEnv* env, jobject clazz, jboolean setActive)
+static jboolean android_net_wifi_setScanModeCommand(JNIEnv* env, jobject, jboolean setActive)
{
sScanModeActive = setActive;
return doSetScanMode(setActive);
}
-static jboolean android_net_wifi_startDriverCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_startDriverCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("DRIVER START", "OK");
+ return doBooleanCommand("OK", "DRIVER START");
}
-static jboolean android_net_wifi_stopDriverCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_stopDriverCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("DRIVER STOP", "OK");
+ return doBooleanCommand("OK", "DRIVER STOP");
}
-static jboolean android_net_wifi_startPacketFiltering(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_startPacketFiltering(JNIEnv* env, jobject)
{
- return doBooleanCommand("DRIVER RXFILTER-ADD 0", "OK")
- && doBooleanCommand("DRIVER RXFILTER-ADD 1", "OK")
- && doBooleanCommand("DRIVER RXFILTER-ADD 3", "OK")
- && doBooleanCommand("DRIVER RXFILTER-START", "OK");
+ return doBooleanCommand("OK", "DRIVER RXFILTER-ADD 0")
+ && doBooleanCommand("OK", "DRIVER RXFILTER-ADD 1")
+ && doBooleanCommand("OK", "DRIVER RXFILTER-ADD 3")
+ && doBooleanCommand("OK", "DRIVER RXFILTER-START");
}
-static jboolean android_net_wifi_stopPacketFiltering(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_stopPacketFiltering(JNIEnv* env, jobject)
{
- jboolean result = doBooleanCommand("DRIVER RXFILTER-STOP", "OK");
+ jboolean result = doBooleanCommand("OK", "DRIVER RXFILTER-STOP");
if (result) {
- (void)doBooleanCommand("DRIVER RXFILTER-REMOVE 3", "OK");
- (void)doBooleanCommand("DRIVER RXFILTER-REMOVE 1", "OK");
- (void)doBooleanCommand("DRIVER RXFILTER-REMOVE 0", "OK");
+ (void)doBooleanCommand("OK", "DRIVER RXFILTER-REMOVE 3");
+ (void)doBooleanCommand("OK", "DRIVER RXFILTER-REMOVE 1");
+ (void)doBooleanCommand("OK", "DRIVER RXFILTER-REMOVE 0");
}
return result;
@@ -399,17 +364,17 @@ static jint android_net_wifi_getRssiHelper(const char *cmd)
return (jint)rssi;
}
-static jint android_net_wifi_getRssiCommand(JNIEnv* env, jobject clazz)
+static jint android_net_wifi_getRssiCommand(JNIEnv* env, jobject)
{
return android_net_wifi_getRssiHelper("DRIVER RSSI");
}
-static jint android_net_wifi_getRssiApproxCommand(JNIEnv* env, jobject clazz)
+static jint android_net_wifi_getRssiApproxCommand(JNIEnv* env, jobject)
{
return android_net_wifi_getRssiHelper("DRIVER RSSI-APPROX");
}
-static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject clazz)
+static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject)
{
char reply[BUF_SIZE];
int linkspeed;
@@ -423,33 +388,28 @@ static jint android_net_wifi_getLinkSpeedCommand(JNIEnv* env, jobject clazz)
return (jint)linkspeed;
}
-static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject clazz)
+static jstring android_net_wifi_getMacAddressCommand(JNIEnv* env, jobject)
{
char reply[BUF_SIZE];
char buf[BUF_SIZE];
if (doCommand("DRIVER MACADDR", reply, sizeof(reply)) != 0) {
- return env->NewStringUTF(NULL);
+ return NULL;
}
// reply comes back in the form "Macaddr = XX.XX.XX.XX.XX.XX" where XX
// is the part of the string we're interested in.
- if (sscanf(reply, "%*s = %255s", buf) == 1)
+ if (sscanf(reply, "%*s = %255s", buf) == 1) {
return env->NewStringUTF(buf);
- else
- return env->NewStringUTF(NULL);
+ }
+ return NULL;
}
-static jboolean android_net_wifi_setPowerModeCommand(JNIEnv* env, jobject clazz, jint mode)
+static jboolean android_net_wifi_setPowerModeCommand(JNIEnv* env, jobject, jint mode)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER POWERMODE %d", mode);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DRIVER POWERMODE %d", mode);
}
-static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz)
+static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject)
{
char reply[BUF_SIZE];
int power;
@@ -463,17 +423,12 @@ static jint android_net_wifi_getPowerModeCommand(JNIEnv* env, jobject clazz)
return (jint)power;
}
-static jboolean android_net_wifi_setBandCommand(JNIEnv* env, jobject clazz, jint band)
+static jboolean android_net_wifi_setBandCommand(JNIEnv* env, jobject, jint band)
{
- char cmdstr[25];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER SETBAND %d", band);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DRIVER SETBAND %d", band);
}
-static jint android_net_wifi_getBandCommand(JNIEnv* env, jobject clazz)
+static jint android_net_wifi_getBandCommand(JNIEnv* env, jobject)
{
char reply[25];
int band;
@@ -487,94 +442,66 @@ static jint android_net_wifi_getBandCommand(JNIEnv* env, jobject clazz)
return (jint)band;
}
-static jboolean android_net_wifi_setBluetoothCoexistenceModeCommand(JNIEnv* env, jobject clazz, jint mode)
+static jboolean android_net_wifi_setBluetoothCoexistenceModeCommand(JNIEnv* env, jobject, jint mode)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER BTCOEXMODE %d", mode);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DRIVER BTCOEXMODE %d", mode);
}
-static jboolean android_net_wifi_setBluetoothCoexistenceScanModeCommand(JNIEnv* env, jobject clazz, jboolean setCoexScanMode)
+static jboolean android_net_wifi_setBluetoothCoexistenceScanModeCommand(JNIEnv* env, jobject, jboolean setCoexScanMode)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "DRIVER BTCOEXSCAN-%s", setCoexScanMode ? "START" : "STOP");
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DRIVER BTCOEXSCAN-%s", setCoexScanMode ? "START" : "STOP");
}
-static jboolean android_net_wifi_saveConfigCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_saveConfigCommand(JNIEnv* env, jobject)
{
// Make sure we never write out a value for AP_SCAN other than 1
- (void)doBooleanCommand("AP_SCAN 1", "OK");
- return doBooleanCommand("SAVE_CONFIG", "OK");
+ (void)doBooleanCommand("OK", "AP_SCAN 1");
+ return doBooleanCommand("OK", "SAVE_CONFIG");
}
-static jboolean android_net_wifi_reloadConfigCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_reloadConfigCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("RECONFIGURE", "OK");
+ return doBooleanCommand("OK", "RECONFIGURE");
}
-static jboolean android_net_wifi_setScanResultHandlingCommand(JNIEnv* env, jobject clazz, jint mode)
+static jboolean android_net_wifi_setScanResultHandlingCommand(JNIEnv* env, jobject, jint mode)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "AP_SCAN %d", mode);
- int cmdTooLong = numWritten >= (int)sizeof(cmdstr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "AP_SCAN %d", mode);
}
-static jboolean android_net_wifi_addToBlacklistCommand(JNIEnv* env, jobject clazz, jstring bssid)
+static jboolean android_net_wifi_addToBlacklistCommand(JNIEnv* env, jobject, jstring javaBssid)
{
- char cmdstr[BUF_SIZE];
- jboolean isCopy;
-
- const char *bssidStr = env->GetStringUTFChars(bssid, &isCopy);
-
- int cmdTooLong = snprintf(cmdstr, sizeof(cmdstr), "BLACKLIST %s", bssidStr) >= (int)sizeof(cmdstr);
-
- env->ReleaseStringUTFChars(bssid, bssidStr);
-
- return (jboolean)!cmdTooLong && doBooleanCommand(cmdstr, "OK");
+ ScopedUtfChars bssid(env, javaBssid);
+ if (bssid.c_str() == NULL) {
+ return JNI_FALSE;
+ }
+ return doBooleanCommand("OK", "BLACKLIST %s", bssid.c_str());
}
-static jboolean android_net_wifi_clearBlacklistCommand(JNIEnv* env, jobject clazz)
+static jboolean android_net_wifi_clearBlacklistCommand(JNIEnv* env, jobject)
{
- return doBooleanCommand("BLACKLIST clear", "OK");
+ return doBooleanCommand("OK", "BLACKLIST clear");
}
-static jboolean android_net_wifi_setSuspendOptimizationsCommand(JNIEnv* env, jobject clazz, jboolean enabled)
+static jboolean android_net_wifi_setSuspendOptimizationsCommand(JNIEnv* env, jobject, jboolean enabled)
{
- char cmdstr[BUF_SIZE];
-
- snprintf(cmdstr, sizeof(cmdstr), "DRIVER SETSUSPENDOPT %d", enabled ? 0 : 1);
- return doBooleanCommand(cmdstr, "OK");
+ return doBooleanCommand("OK", "DRIVER SETSUSPENDOPT %d", enabled ? 0 : 1);
}
-static void android_net_wifi_enableBackgroundScanCommand(JNIEnv* env, jobject clazz, jboolean enable)
+static void android_net_wifi_enableBackgroundScanCommand(JNIEnv* env, jobject, jboolean enable)
{
//Note: BGSCAN-START and BGSCAN-STOP are documented in core/res/res/values/config.xml
//and will need an update if the names are changed
if (enable) {
- doBooleanCommand("DRIVER BGSCAN-START", "OK");
- }
- else {
- doBooleanCommand("DRIVER BGSCAN-STOP", "OK");
+ doBooleanCommand("OK", "DRIVER BGSCAN-START");
+ } else {
+ doBooleanCommand("OK", "DRIVER BGSCAN-STOP");
}
}
-static void android_net_wifi_setScanIntervalCommand(JNIEnv* env, jobject clazz, jint scanInterval)
+static void android_net_wifi_setScanIntervalCommand(JNIEnv* env, jobject, jint scanInterval)
{
- char cmdstr[BUF_SIZE];
-
- int numWritten = snprintf(cmdstr, sizeof(cmdstr), "SCAN_INTERVAL %d", scanInterval);
-
- if(numWritten < (int)sizeof(cmdstr)) doBooleanCommand(cmdstr, "OK");
+ doBooleanCommand("OK", "SCAN_INTERVAL %d", scanInterval);
}
@@ -651,9 +578,6 @@ static JNINativeMethod gWifiMethods[] = {
int register_android_net_wifi_WifiManager(JNIEnv* env)
{
- jclass wifi = env->FindClass(WIFI_PKG_NAME);
- LOG_FATAL_IF(wifi == NULL, "Unable to find class " WIFI_PKG_NAME);
-
return AndroidRuntime::registerNativeMethods(env,
WIFI_PKG_NAME, gWifiMethods, NELEM(gWifiMethods));
}
diff --git a/core/jni/android_nio_utils.cpp b/core/jni/android_nio_utils.cpp
index 584e7a4..7cbbe12 100644
--- a/core/jni/android_nio_utils.cpp
+++ b/core/jni/android_nio_utils.cpp
@@ -32,20 +32,20 @@ void* android::nio_getPointer(JNIEnv *_env, jobject buffer, jarray *array) {
jlong pointer;
jint offset;
void *data;
-
+
pointer = _env->CallStaticLongMethod(gNioJNI.nioAccessClass,
gNioJNI.getBasePointerID, buffer);
if (pointer != 0L) {
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(gNioJNI.nioAccessClass,
gNioJNI.getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(gNioJNI.nioAccessClass,
gNioJNI.getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -94,8 +94,7 @@ static jfieldID getFieldID(JNIEnv* env, jclass c, const char name[],
}
namespace android {
-
-int register_android_nio_utils(JNIEnv* env);
+
int register_android_nio_utils(JNIEnv* env) {
jclass localClass = findClass(env, "java/nio/NIOAccess");
gNioJNI.getBasePointerID = findStaticMethod(env, localClass,
diff --git a/core/jni/android_opengl_GLES10.cpp b/core/jni/android_opengl_GLES10.cpp
index 2685d75..6c29d6c 100644
--- a/core/jni/android_opengl_GLES10.cpp
+++ b/core/jni/android_opengl_GLES10.cpp
@@ -2,21 +2,23 @@
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
// This source file is automatically generated
+#include "jni.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
@@ -41,10 +43,6 @@ static int initialized = 0;
static jclass nioAccessClass;
static jclass bufferClass;
-static jclass OOMEClass;
-static jclass UOEClass;
-static jclass IAEClass;
-static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
@@ -55,7 +53,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
static void
-nativeClassInitBuffer(JNIEnv *_env)
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -76,26 +74,6 @@ nativeClassInitBuffer(JNIEnv *_env)
_env->GetFieldID(bufferClass, "_elementSizeShift", "I");
}
-static void
-nativeClassInit(JNIEnv *_env, jclass glImplClass)
-{
- nativeClassInitBuffer(_env);
-
- jclass IAEClassLocal =
- _env->FindClass("java/lang/IllegalArgumentException");
- jclass OOMEClassLocal =
- _env->FindClass("java/lang/OutOfMemoryError");
- jclass UOEClassLocal =
- _env->FindClass("java/lang/UnsupportedOperationException");
- jclass AIOOBEClassLocal =
- _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
-
- IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
- OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
- UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
- AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
-}
-
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
@@ -116,13 +94,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -141,7 +119,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
buf += position << elementSizeShift;
} else {
- _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
+ jniThrowException(_env, "java/lang/IllegalArgumentException",
+ "Must use a native order direct Buffer");
}
return (void*) buf;
}
@@ -154,7 +133,6 @@ getNumCompressedTextureFormats() {
}
// --------------------------------------------------------------------------
-
/* void glActiveTexture ( GLenum texture ) */
static void
android_glActiveTexture__I
@@ -431,16 +409,16 @@ android_glDeleteTextures__I_3II
GLuint *textures = (GLuint *) 0;
if (!textures_ref) {
- _env->ThrowNew(IAEClass, "textures == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "textures == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(textures_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
textures_base = (GLuint *)
@@ -469,7 +447,7 @@ android_glDeleteTextures__ILjava_nio_IntBuffer_2
textures = (GLuint *)getPointer(_env, textures_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteTextures(
@@ -560,7 +538,7 @@ android_glDrawElements__IIILjava_nio_Buffer_2
indices = (GLvoid *)getPointer(_env, indices_buf, &_array, &_remaining);
if (_remaining < count) {
- _env->ThrowNew(AIOOBEClass, "remaining() < count");
+ jniThrowException(_env, "java/lang/ArrayIndexOutOfBoundsException", "remaining() < count");
goto exit;
}
glDrawElements(
@@ -627,11 +605,11 @@ android_glFogfv__I_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -661,7 +639,7 @@ android_glFogfv__I_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -715,7 +693,7 @@ android_glFogfv__ILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glFogfv(
@@ -748,11 +726,11 @@ android_glFogxv__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -782,7 +760,7 @@ android_glFogxv__I_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -836,7 +814,7 @@ android_glFogxv__ILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glFogxv(
@@ -898,18 +876,18 @@ android_glGenTextures__I_3II
if (!textures_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "textures == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "textures == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(textures_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
textures_base = (GLuint *)
@@ -940,7 +918,7 @@ android_glGenTextures__ILjava_nio_IntBuffer_2
textures = (GLuint *)getPointer(_env, textures_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenTextures(
@@ -974,12 +952,12 @@ android_glGetIntegerv__I_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1316,7 +1294,7 @@ android_glGetIntegerv__I_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -1678,7 +1656,7 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetIntegerv(
@@ -1692,16 +1670,10 @@ exit:
}
}
-#include <string.h>
-
/* const GLubyte * glGetString ( GLenum name ) */
-static
-jstring
-android_glGetString
- (JNIEnv *_env, jobject _this, jint name) {
- const char * chars = (const char *)glGetString((GLenum)name);
- jstring output = _env->NewStringUTF(chars);
- return output;
+static jstring android_glGetString(JNIEnv* _env, jobject, jint name) {
+ const char* chars = (const char*) glGetString((GLenum) name);
+ return _env->NewStringUTF(chars);
}
/* void glHint ( GLenum target, GLenum mode ) */
static void
@@ -1732,11 +1704,11 @@ android_glLightModelfv__I_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1757,7 +1729,7 @@ android_glLightModelfv__I_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -1802,7 +1774,7 @@ android_glLightModelfv__ILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightModelfv(
@@ -1835,11 +1807,11 @@ android_glLightModelxv__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1860,7 +1832,7 @@ android_glLightModelxv__I_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -1905,7 +1877,7 @@ android_glLightModelxv__ILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightModelxv(
@@ -1939,11 +1911,11 @@ android_glLightfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1990,7 +1962,7 @@ android_glLightfv__II_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -2062,7 +2034,7 @@ android_glLightfv__IILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightfv(
@@ -2097,11 +2069,11 @@ android_glLightxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2148,7 +2120,7 @@ android_glLightxv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -2220,7 +2192,7 @@ android_glLightxv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightxv(
@@ -2269,11 +2241,11 @@ android_glLoadMatrixf___3FI
GLfloat *m = (GLfloat *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -2318,11 +2290,11 @@ android_glLoadMatrixx___3II
GLfixed *m = (GLfixed *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -2387,11 +2359,11 @@ android_glMaterialfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2424,7 +2396,7 @@ android_glMaterialfv__II_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -2482,7 +2454,7 @@ android_glMaterialfv__IILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glMaterialfv(
@@ -2517,11 +2489,11 @@ android_glMaterialxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2554,7 +2526,7 @@ android_glMaterialxv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -2612,7 +2584,7 @@ android_glMaterialxv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glMaterialxv(
@@ -2645,11 +2617,11 @@ android_glMultMatrixf___3FI
GLfloat *m = (GLfloat *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -2694,11 +2666,11 @@ android_glMultMatrixx___3II
GLfixed *m = (GLfixed *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -3079,11 +3051,11 @@ android_glTexEnvfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3110,7 +3082,7 @@ android_glTexEnvfv__II_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -3162,7 +3134,7 @@ android_glTexEnvfv__IILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glTexEnvfv(
@@ -3197,11 +3169,11 @@ android_glTexEnvxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3228,7 +3200,7 @@ android_glTexEnvxv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -3280,7 +3252,7 @@ android_glTexEnvxv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glTexEnvxv(
diff --git a/core/jni/android_opengl_GLES10Ext.cpp b/core/jni/android_opengl_GLES10Ext.cpp
index f17ef21..1154cef 100644
--- a/core/jni/android_opengl_GLES10Ext.cpp
+++ b/core/jni/android_opengl_GLES10Ext.cpp
@@ -2,21 +2,23 @@
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
// This source file is automatically generated
+#include "jni.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
@@ -28,10 +30,6 @@ static int initialized = 0;
static jclass nioAccessClass;
static jclass bufferClass;
-static jclass OOMEClass;
-static jclass UOEClass;
-static jclass IAEClass;
-static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
@@ -42,7 +40,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
static void
-nativeClassInitBuffer(JNIEnv *_env)
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -64,26 +62,6 @@ nativeClassInitBuffer(JNIEnv *_env)
}
-static void
-nativeClassInit(JNIEnv *_env, jclass glImplClass)
-{
- nativeClassInitBuffer(_env);
-
- jclass IAEClassLocal =
- _env->FindClass("java/lang/IllegalArgumentException");
- jclass OOMEClassLocal =
- _env->FindClass("java/lang/OutOfMemoryError");
- jclass UOEClassLocal =
- _env->FindClass("java/lang/UnsupportedOperationException");
- jclass AIOOBEClassLocal =
- _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
-
- IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
- OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
- UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
- AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
-}
-
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
@@ -104,13 +82,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -123,7 +101,6 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
}
// --------------------------------------------------------------------------
-
/* GLbitfield glQueryMatrixxOES ( GLfixed *mantissa, GLint *exponent ) */
static jint
android_glQueryMatrixxOES___3II_3II
@@ -139,18 +116,18 @@ android_glQueryMatrixxOES___3II_3II
if (!mantissa_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "mantissa == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "mantissa == null");
goto exit;
}
if (mantissaOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "mantissaOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "mantissaOffset < 0");
goto exit;
}
_mantissaRemaining = _env->GetArrayLength(mantissa_ref) - mantissaOffset;
if (_mantissaRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - mantissaOffset < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - mantissaOffset < 16");
goto exit;
}
mantissa_base = (GLfixed *)
@@ -159,18 +136,18 @@ android_glQueryMatrixxOES___3II_3II
if (!exponent_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "exponent == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "exponent == null");
goto exit;
}
if (exponentOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "exponentOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "exponentOffset < 0");
goto exit;
}
_exponentRemaining = _env->GetArrayLength(exponent_ref) - exponentOffset;
if (_exponentRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - exponentOffset < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - exponentOffset < 16");
goto exit;
}
exponent_base = (GLint *)
@@ -210,13 +187,13 @@ android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
mantissa = (GLfixed *)getPointer(_env, mantissa_buf, &_mantissaArray, &_mantissaRemaining);
if (_mantissaRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 16");
goto exit;
}
exponent = (GLint *)getPointer(_env, exponent_buf, &_exponentArray, &_exponentRemaining);
if (_exponentRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 16");
goto exit;
}
_returnValue = glQueryMatrixxOES(
diff --git a/core/jni/android_opengl_GLES11.cpp b/core/jni/android_opengl_GLES11.cpp
index 1c326ba..d038f20 100644
--- a/core/jni/android_opengl_GLES11.cpp
+++ b/core/jni/android_opengl_GLES11.cpp
@@ -2,21 +2,23 @@
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
// This source file is automatically generated
+#include "jni.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
@@ -35,10 +37,6 @@ static int initialized = 0;
static jclass nioAccessClass;
static jclass bufferClass;
-static jclass OOMEClass;
-static jclass UOEClass;
-static jclass IAEClass;
-static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
@@ -49,7 +47,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
static void
-nativeClassInitBuffer(JNIEnv *_env)
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -71,26 +69,6 @@ nativeClassInitBuffer(JNIEnv *_env)
}
-static void
-nativeClassInit(JNIEnv *_env, jclass glImplClass)
-{
- nativeClassInitBuffer(_env);
-
- jclass IAEClassLocal =
- _env->FindClass("java/lang/IllegalArgumentException");
- jclass OOMEClassLocal =
- _env->FindClass("java/lang/OutOfMemoryError");
- jclass UOEClassLocal =
- _env->FindClass("java/lang/UnsupportedOperationException");
- jclass AIOOBEClassLocal =
- _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
-
- IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
- OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
- UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
- AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
-}
-
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
@@ -111,13 +89,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -137,13 +115,13 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
buf += position << elementSizeShift;
} else {
- _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
+ jniThrowException(_env, "java/lang/IllegalArgumentException",
+ "Must use a native order direct Buffer");
}
return (void*) buf;
}
// --------------------------------------------------------------------------
-
/* void glBindBuffer ( GLenum target, GLuint buffer ) */
static void
android_glBindBuffer__II
@@ -165,7 +143,7 @@ android_glBufferData__IILjava_nio_Buffer_2I
if (data_buf) {
data = (GLvoid *)getPointer(_env, data_buf, &_array, &_remaining);
if (_remaining < size) {
- _env->ThrowNew(IAEClass, "remaining() < size");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < size");
goto exit;
}
}
@@ -192,7 +170,7 @@ android_glBufferSubData__IIILjava_nio_Buffer_2
data = (GLvoid *)getPointer(_env, data_buf, &_array, &_remaining);
if (_remaining < size) {
- _env->ThrowNew(IAEClass, "remaining() < size");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < size");
goto exit;
}
glBufferSubData(
@@ -217,11 +195,11 @@ android_glClipPlanef__I_3FI
GLfloat *equation = (GLfloat *) 0;
if (!equation_ref) {
- _env->ThrowNew(IAEClass, "equation == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "equation == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
@@ -268,11 +246,11 @@ android_glClipPlanex__I_3II
GLfixed *equation = (GLfixed *) 0;
if (!equation_ref) {
- _env->ThrowNew(IAEClass, "equation == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "equation == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
@@ -343,16 +321,16 @@ android_glDeleteBuffers__I_3II
GLuint *buffers = (GLuint *) 0;
if (!buffers_ref) {
- _env->ThrowNew(IAEClass, "buffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "buffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
buffers_base = (GLuint *)
@@ -381,7 +359,7 @@ android_glDeleteBuffers__ILjava_nio_IntBuffer_2
buffers = (GLuint *)getPointer(_env, buffers_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteBuffers(
@@ -418,18 +396,18 @@ android_glGenBuffers__I_3II
if (!buffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "buffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "buffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
buffers_base = (GLuint *)
@@ -460,7 +438,7 @@ android_glGenBuffers__ILjava_nio_IntBuffer_2
buffers = (GLuint *)getPointer(_env, buffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenBuffers(
@@ -485,12 +463,12 @@ android_glGetBooleanv__I_3ZI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -540,18 +518,18 @@ android_glGetBufferParameteriv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -583,7 +561,7 @@ android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetBufferParameteriv(
@@ -609,12 +587,12 @@ android_glGetClipPlanef__I_3FI
if (!eqn_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "eqn == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "eqn == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
@@ -664,12 +642,12 @@ android_glGetClipPlanex__I_3II
if (!eqn_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "eqn == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "eqn == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
@@ -719,12 +697,12 @@ android_glGetFixedv__I_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -774,12 +752,12 @@ android_glGetFloatv__I_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -829,12 +807,12 @@ android_glGetLightfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -882,7 +860,7 @@ android_glGetLightfv__II_3FI
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -956,7 +934,7 @@ android_glGetLightfv__IILjava_nio_FloatBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetLightfv(
@@ -982,12 +960,12 @@ android_glGetLightxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1035,7 +1013,7 @@ android_glGetLightxv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -1109,7 +1087,7 @@ android_glGetLightxv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetLightxv(
@@ -1135,12 +1113,12 @@ android_glGetMaterialfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1174,7 +1152,7 @@ android_glGetMaterialfv__II_3FI
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -1234,7 +1212,7 @@ android_glGetMaterialfv__IILjava_nio_FloatBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetMaterialfv(
@@ -1260,12 +1238,12 @@ android_glGetMaterialxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1299,7 +1277,7 @@ android_glGetMaterialxv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -1359,7 +1337,7 @@ android_glGetMaterialxv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetMaterialxv(
@@ -1385,12 +1363,12 @@ android_glGetTexEnvfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1418,7 +1396,7 @@ android_glGetTexEnvfv__II_3FI
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -1472,7 +1450,7 @@ android_glGetTexEnvfv__IILjava_nio_FloatBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetTexEnvfv(
@@ -1498,12 +1476,12 @@ android_glGetTexEnviv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1531,7 +1509,7 @@ android_glGetTexEnviv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -1585,7 +1563,7 @@ android_glGetTexEnviv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetTexEnviv(
@@ -1611,12 +1589,12 @@ android_glGetTexEnvxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1644,7 +1622,7 @@ android_glGetTexEnvxv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -1698,7 +1676,7 @@ android_glGetTexEnvxv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetTexEnvxv(
@@ -1724,18 +1702,18 @@ android_glGetTexParameterfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -1767,7 +1745,7 @@ android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameterfv(
@@ -1793,18 +1771,18 @@ android_glGetTexParameteriv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -1836,7 +1814,7 @@ android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameteriv(
@@ -1862,18 +1840,18 @@ android_glGetTexParameterxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfixed *)
@@ -1905,7 +1883,7 @@ android_glGetTexParameterxv__IILjava_nio_IntBuffer_2
params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameterxv(
@@ -1983,16 +1961,16 @@ android_glPointParameterfv__I_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -2021,7 +1999,7 @@ android_glPointParameterfv__ILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glPointParameterfv(
@@ -2054,16 +2032,16 @@ android_glPointParameterxv__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfixed *)
@@ -2092,7 +2070,7 @@ android_glPointParameterxv__ILjava_nio_IntBuffer_2
params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glPointParameterxv(
@@ -2160,11 +2138,11 @@ android_glTexEnviv__II_3II
GLint *params = (GLint *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2191,7 +2169,7 @@ android_glTexEnviv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -2243,7 +2221,7 @@ android_glTexEnviv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glTexEnviv(
@@ -2267,16 +2245,16 @@ android_glTexParameterfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -2306,7 +2284,7 @@ android_glTexParameterfv__IILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameterfv(
@@ -2341,16 +2319,16 @@ android_glTexParameteriv__II_3II
GLint *params = (GLint *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -2380,7 +2358,7 @@ android_glTexParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameteriv(
@@ -2404,16 +2382,16 @@ android_glTexParameterxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfixed *)
@@ -2443,7 +2421,7 @@ android_glTexParameterxv__IILjava_nio_IntBuffer_2
params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameterxv(
diff --git a/core/jni/android_opengl_GLES11Ext.cpp b/core/jni/android_opengl_GLES11Ext.cpp
index 1390506..d6dc0fe 100644
--- a/core/jni/android_opengl_GLES11Ext.cpp
+++ b/core/jni/android_opengl_GLES11Ext.cpp
@@ -2,21 +2,23 @@
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
// This source file is automatically generated
+#include "jni.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
@@ -37,10 +39,6 @@ static int initialized = 0;
static jclass nioAccessClass;
static jclass bufferClass;
-static jclass OOMEClass;
-static jclass UOEClass;
-static jclass IAEClass;
-static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
@@ -51,7 +49,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
static void
-nativeClassInitBuffer(JNIEnv *_env)
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -73,26 +71,6 @@ nativeClassInitBuffer(JNIEnv *_env)
}
-static void
-nativeClassInit(JNIEnv *_env, jclass glImplClass)
-{
- nativeClassInitBuffer(_env);
-
- jclass IAEClassLocal =
- _env->FindClass("java/lang/IllegalArgumentException");
- jclass OOMEClassLocal =
- _env->FindClass("java/lang/OutOfMemoryError");
- jclass UOEClassLocal =
- _env->FindClass("java/lang/UnsupportedOperationException");
- jclass AIOOBEClassLocal =
- _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
-
- IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
- OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
- UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
- AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
-}
-
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
@@ -113,13 +91,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -139,12 +117,12 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
buf += position << elementSizeShift;
} else {
- _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
+ jniThrowException(_env, "java/lang/IllegalArgumentException",
+ "Must use a native order direct Buffer");
}
return (void*) buf;
}
// --------------------------------------------------------------------------
-
/* void glBlendEquationSeparateOES ( GLenum modeRGB, GLenum modeAlpha ) */
static void
android_glBlendEquationSeparateOES__II
@@ -224,16 +202,16 @@ android_glDrawTexsvOES___3SI
GLshort *coords = (GLshort *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLshort *)
@@ -261,7 +239,7 @@ android_glDrawTexsvOES__Ljava_nio_ShortBuffer_2
coords = (GLshort *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexsvOES(
@@ -283,16 +261,16 @@ android_glDrawTexivOES___3II
GLint *coords = (GLint *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLint *)
@@ -320,7 +298,7 @@ android_glDrawTexivOES__Ljava_nio_IntBuffer_2
coords = (GLint *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexivOES(
@@ -342,16 +320,16 @@ android_glDrawTexxvOES___3II
GLfixed *coords = (GLfixed *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLfixed *)
@@ -379,7 +357,7 @@ android_glDrawTexxvOES__Ljava_nio_IntBuffer_2
coords = (GLfixed *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexxvOES(
@@ -414,16 +392,16 @@ android_glDrawTexfvOES___3FI
GLfloat *coords = (GLfloat *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLfloat *)
@@ -451,7 +429,7 @@ android_glDrawTexfvOES__Ljava_nio_FloatBuffer_2
coords = (GLfloat *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexfvOES(
@@ -542,11 +520,11 @@ android_glClipPlanexOES__I_3II
GLfixed *equation = (GLfixed *) 0;
if (!equation_ref) {
- _env->ThrowNew(IAEClass, "equation == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "equation == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
@@ -625,11 +603,11 @@ android_glFogxvOES__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -692,18 +670,18 @@ android_glGetClipPlanexOES__I_3II
if (!eqn_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "eqn == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "eqn == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
if (_remaining < 4) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 4");
goto exit;
}
eqn_base = (GLfixed *)
@@ -734,7 +712,7 @@ android_glGetClipPlanexOES__ILjava_nio_IntBuffer_2
eqn = (GLfixed *)getPointer(_env, eqn_buf, &_array, &_remaining);
if (_remaining < 4) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 4");
goto exit;
}
glGetClipPlanexOES(
@@ -759,12 +737,12 @@ android_glGetFixedvOES__I_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -814,12 +792,12 @@ android_glGetLightxvOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -871,12 +849,12 @@ android_glGetMaterialxvOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -928,12 +906,12 @@ android_glGetTexEnvxvOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -985,12 +963,12 @@ android_glGetTexParameterxvOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1050,11 +1028,11 @@ android_glLightModelxvOES__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1112,11 +1090,11 @@ android_glLightxvOES__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1174,11 +1152,11 @@ android_glLoadMatrixxOES___3II
GLfixed *m = (GLfixed *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -1234,11 +1212,11 @@ android_glMaterialxvOES__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1287,11 +1265,11 @@ android_glMultMatrixxOES___3II
GLfixed *m = (GLfixed *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -1384,11 +1362,11 @@ android_glPointParameterxvOES__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1498,11 +1476,11 @@ android_glTexEnvxvOES__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1562,11 +1540,11 @@ android_glTexParameterxvOES__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1647,16 +1625,16 @@ android_glDeleteRenderbuffersOES__I_3II
GLuint *renderbuffers = (GLuint *) 0;
if (!renderbuffers_ref) {
- _env->ThrowNew(IAEClass, "renderbuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "renderbuffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
renderbuffers_base = (GLuint *)
@@ -1685,7 +1663,7 @@ android_glDeleteRenderbuffersOES__ILjava_nio_IntBuffer_2
renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteRenderbuffersOES(
@@ -1710,18 +1688,18 @@ android_glGenRenderbuffersOES__I_3II
if (!renderbuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "renderbuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "renderbuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
renderbuffers_base = (GLuint *)
@@ -1752,7 +1730,7 @@ android_glGenRenderbuffersOES__ILjava_nio_IntBuffer_2
renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenRenderbuffersOES(
@@ -1789,18 +1767,18 @@ android_glGetRenderbufferParameterivOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -1832,7 +1810,7 @@ android_glGetRenderbufferParameterivOES__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetRenderbufferParameterivOES(
@@ -1877,16 +1855,16 @@ android_glDeleteFramebuffersOES__I_3II
GLuint *framebuffers = (GLuint *) 0;
if (!framebuffers_ref) {
- _env->ThrowNew(IAEClass, "framebuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "framebuffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(framebuffers_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
framebuffers_base = (GLuint *)
@@ -1915,7 +1893,7 @@ android_glDeleteFramebuffersOES__ILjava_nio_IntBuffer_2
framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteFramebuffersOES(
@@ -1940,18 +1918,18 @@ android_glGenFramebuffersOES__I_3II
if (!framebuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "framebuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "framebuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(framebuffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
framebuffers_base = (GLuint *)
@@ -1982,7 +1960,7 @@ android_glGenFramebuffersOES__ILjava_nio_IntBuffer_2
framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenFramebuffersOES(
@@ -2043,18 +2021,18 @@ android_glGetFramebufferAttachmentParameterivOES__III_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -2087,7 +2065,7 @@ android_glGetFramebufferAttachmentParameterivOES__IIILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetFramebufferAttachmentParameterivOES(
@@ -2221,11 +2199,11 @@ android_glClipPlanefOES__I_3FI
GLfloat *equation = (GLfloat *) 0;
if (!equation_ref) {
- _env->ThrowNew(IAEClass, "equation == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "equation == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
@@ -2274,18 +2252,18 @@ android_glGetClipPlanefOES__I_3FI
if (!eqn_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "eqn == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "eqn == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
if (_remaining < 4) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 4");
goto exit;
}
eqn_base = (GLfloat *)
@@ -2316,7 +2294,7 @@ android_glGetClipPlanefOES__ILjava_nio_FloatBuffer_2
eqn = (GLfloat *)getPointer(_env, eqn_buf, &_array, &_remaining);
if (_remaining < 4) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 4");
goto exit;
}
glGetClipPlanefOES(
@@ -2359,11 +2337,11 @@ android_glTexGenfvOES__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2423,11 +2401,11 @@ android_glTexGenivOES__II_3II
GLint *params = (GLint *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2487,11 +2465,11 @@ android_glTexGenxvOES__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2542,12 +2520,12 @@ android_glGetTexGenfvOES__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2599,12 +2577,12 @@ android_glGetTexGenivOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2656,12 +2634,12 @@ android_glGetTexGenxvOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
diff --git a/core/jni/android_opengl_GLES20.cpp b/core/jni/android_opengl_GLES20.cpp
index 7ac0f6e..a53e4d7 100644
--- a/core/jni/android_opengl_GLES20.cpp
+++ b/core/jni/android_opengl_GLES20.cpp
@@ -2,21 +2,23 @@
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
// This source file is automatically generated
+#include "jni.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
@@ -28,10 +30,6 @@ static int initialized = 0;
static jclass nioAccessClass;
static jclass bufferClass;
-static jclass OOMEClass;
-static jclass UOEClass;
-static jclass IAEClass;
-static jclass AIOOBEClass;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
static jmethodID getBaseArrayOffsetID;
@@ -42,7 +40,7 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
static void
-nativeClassInitBuffer(JNIEnv *_env)
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -64,26 +62,6 @@ nativeClassInitBuffer(JNIEnv *_env)
}
-static void
-nativeClassInit(JNIEnv *_env, jclass glImplClass)
-{
- nativeClassInitBuffer(_env);
-
- jclass IAEClassLocal =
- _env->FindClass("java/lang/IllegalArgumentException");
- jclass OOMEClassLocal =
- _env->FindClass("java/lang/OutOfMemoryError");
- jclass UOEClassLocal =
- _env->FindClass("java/lang/UnsupportedOperationException");
- jclass AIOOBEClassLocal =
- _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
-
- IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
- OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
- UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
- AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
-}
-
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
@@ -104,13 +82,13 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -130,7 +108,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
jint elementSizeShift = _env->GetIntField(buffer, elementSizeShiftID);
buf += position << elementSizeShift;
} else {
- _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
+ jniThrowException(_env, "java/lang/IllegalArgumentException",
+ "Must use a native order direct Buffer");
}
return (void*) buf;
}
@@ -148,7 +127,6 @@ static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
}
// --------------------------------------------------------------------------
-
/* void glActiveTexture ( GLenum texture ) */
static void
android_glActiveTexture__I
@@ -175,7 +153,7 @@ android_glBindAttribLocation__IILjava_lang_String_2
const char* _nativename = 0;
if (!name) {
- _env->ThrowNew(IAEClass, "name == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "name == null");
goto exit;
}
_nativename = _env->GetStringUTFChars(name, 0);
@@ -297,7 +275,7 @@ android_glBufferData__IILjava_nio_Buffer_2I
if (data_buf) {
data = (GLvoid *)getPointer(_env, data_buf, &_array, &_remaining);
if (_remaining < size) {
- _env->ThrowNew(IAEClass, "remaining() < size");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < size");
goto exit;
}
}
@@ -324,7 +302,7 @@ android_glBufferSubData__IIILjava_nio_Buffer_2
data = (GLvoid *)getPointer(_env, data_buf, &_array, &_remaining);
if (_remaining < size) {
- _env->ThrowNew(IAEClass, "remaining() < size");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < size");
goto exit;
}
glBufferSubData(
@@ -530,16 +508,16 @@ android_glDeleteBuffers__I_3II
GLuint *buffers = (GLuint *) 0;
if (!buffers_ref) {
- _env->ThrowNew(IAEClass, "buffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "buffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
buffers_base = (GLuint *)
@@ -568,7 +546,7 @@ android_glDeleteBuffers__ILjava_nio_IntBuffer_2
buffers = (GLuint *)getPointer(_env, buffers_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteBuffers(
@@ -591,11 +569,11 @@ android_glDeleteFramebuffers__I_3II
GLuint *framebuffers = (GLuint *) 0;
if (!framebuffers_ref) {
- _env->ThrowNew(IAEClass, "framebuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "framebuffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(framebuffers_ref) - offset;
@@ -651,11 +629,11 @@ android_glDeleteRenderbuffers__I_3II
GLuint *renderbuffers = (GLuint *) 0;
if (!renderbuffers_ref) {
- _env->ThrowNew(IAEClass, "renderbuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "renderbuffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
@@ -711,16 +689,16 @@ android_glDeleteTextures__I_3II
GLuint *textures = (GLuint *) 0;
if (!textures_ref) {
- _env->ThrowNew(IAEClass, "textures == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "textures == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(textures_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
textures_base = (GLuint *)
@@ -749,7 +727,7 @@ android_glDeleteTextures__ILjava_nio_IntBuffer_2
textures = (GLuint *)getPointer(_env, textures_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteTextures(
@@ -852,7 +830,7 @@ android_glDrawElements__IIILjava_nio_Buffer_2
indices = (GLvoid *)getPointer(_env, indices_buf, &_array, &_remaining);
if (_remaining < count) {
- _env->ThrowNew(AIOOBEClass, "remaining() < count");
+ jniThrowException(_env, "java/lang/ArrayIndexOutOfBoundsException", "remaining() < count");
goto exit;
}
glDrawElements(
@@ -945,18 +923,18 @@ android_glGenBuffers__I_3II
if (!buffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "buffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "buffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
buffers_base = (GLuint *)
@@ -987,7 +965,7 @@ android_glGenBuffers__ILjava_nio_IntBuffer_2
buffers = (GLuint *)getPointer(_env, buffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenBuffers(
@@ -1021,12 +999,12 @@ android_glGenFramebuffers__I_3II
if (!framebuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "framebuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "framebuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(framebuffers_ref) - offset;
@@ -1076,12 +1054,12 @@ android_glGenRenderbuffers__I_3II
if (!renderbuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "renderbuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "renderbuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
@@ -1131,18 +1109,18 @@ android_glGenTextures__I_3II
if (!textures_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "textures == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "textures == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(textures_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
textures_base = (GLuint *)
@@ -1173,7 +1151,7 @@ android_glGenTextures__ILjava_nio_IntBuffer_2
textures = (GLuint *)getPointer(_env, textures_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenTextures(
@@ -1207,12 +1185,12 @@ android_glGetActiveAttrib__III_3II_3II_3II_3BI
if (!length_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length == null");
goto exit;
}
if (lengthOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "lengthOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "lengthOffset < 0");
goto exit;
}
_lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
@@ -1222,12 +1200,12 @@ android_glGetActiveAttrib__III_3II_3II_3II_3BI
if (!size_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "size == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "size == null");
goto exit;
}
if (sizeOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "sizeOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "sizeOffset < 0");
goto exit;
}
_sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
@@ -1237,12 +1215,12 @@ android_glGetActiveAttrib__III_3II_3II_3II_3BI
if (!type_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "type == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "type == null");
goto exit;
}
if (typeOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "typeOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "typeOffset < 0");
goto exit;
}
_typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
@@ -1252,12 +1230,12 @@ android_glGetActiveAttrib__III_3II_3II_3II_3BI
if (!name_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "name == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "name == null");
goto exit;
}
if (nameOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "nameOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "nameOffset < 0");
goto exit;
}
_nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
@@ -1352,12 +1330,12 @@ android_glGetActiveUniform__III_3II_3II_3II_3BI
if (!length_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length == null");
goto exit;
}
if (lengthOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "lengthOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "lengthOffset < 0");
goto exit;
}
_lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
@@ -1367,12 +1345,12 @@ android_glGetActiveUniform__III_3II_3II_3II_3BI
if (!size_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "size == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "size == null");
goto exit;
}
if (sizeOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "sizeOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "sizeOffset < 0");
goto exit;
}
_sizeRemaining = _env->GetArrayLength(size_ref) - sizeOffset;
@@ -1382,12 +1360,12 @@ android_glGetActiveUniform__III_3II_3II_3II_3BI
if (!type_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "type == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "type == null");
goto exit;
}
if (typeOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "typeOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "typeOffset < 0");
goto exit;
}
_typeRemaining = _env->GetArrayLength(type_ref) - typeOffset;
@@ -1397,12 +1375,12 @@ android_glGetActiveUniform__III_3II_3II_3II_3BI
if (!name_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "name == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "name == null");
goto exit;
}
if (nameOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "nameOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "nameOffset < 0");
goto exit;
}
_nameRemaining = _env->GetArrayLength(name_ref) - nameOffset;
@@ -1491,12 +1469,12 @@ android_glGetAttachedShaders__II_3II_3II
if (!count_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "count == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "count == null");
goto exit;
}
if (countOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "countOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "countOffset < 0");
goto exit;
}
_countRemaining = _env->GetArrayLength(count_ref) - countOffset;
@@ -1506,12 +1484,12 @@ android_glGetAttachedShaders__II_3II_3II
if (!shaders_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "shaders == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "shaders == null");
goto exit;
}
if (shadersOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "shadersOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "shadersOffset < 0");
goto exit;
}
_shadersRemaining = _env->GetArrayLength(shaders_ref) - shadersOffset;
@@ -1573,7 +1551,7 @@ android_glGetAttribLocation__ILjava_lang_String_2
const char* _nativename = 0;
if (!name) {
- _env->ThrowNew(IAEClass, "name == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "name == null");
goto exit;
}
_nativename = _env->GetStringUTFChars(name, 0);
@@ -1602,12 +1580,12 @@ android_glGetBooleanv__I_3ZI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1657,18 +1635,18 @@ android_glGetBufferParameteriv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -1700,7 +1678,7 @@ android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetBufferParameteriv(
@@ -1735,12 +1713,12 @@ android_glGetFloatv__I_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1790,12 +1768,12 @@ android_glGetFramebufferAttachmentParameteriv__III_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1849,12 +1827,12 @@ android_glGetIntegerv__I_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2191,7 +2169,7 @@ android_glGetIntegerv__I_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -2553,7 +2531,7 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetIntegerv(
@@ -2578,12 +2556,12 @@ android_glGetProgramiv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2624,32 +2602,24 @@ android_glGetProgramiv__IILjava_nio_IntBuffer_2
}
}
-#include <string.h>
+#include <stdlib.h>
/* void glGetProgramInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */
-static
-jstring
-android_glGetProgramInfoLog (JNIEnv *_env, jobject _this, jint shader) {
+static jstring android_glGetProgramInfoLog(JNIEnv *_env, jobject, jint shader) {
GLint infoLen = 0;
- jstring _result = 0;
- char* buf = 0;
glGetProgramiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
- if (infoLen) {
- char* buf = (char*) malloc(infoLen);
- if (buf == 0) {
- _env->ThrowNew(IAEClass, "out of memory");
- goto exit;
- }
- glGetProgramInfoLog(shader, infoLen, NULL, buf);
- _result = _env->NewStringUTF(buf);
- } else {
- _result = _env->NewStringUTF("");
+ if (!infoLen) {
+ return _env->NewStringUTF("");
}
-exit:
- if (buf) {
- free(buf);
+ char* buf = (char*) malloc(infoLen);
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
}
- return _result;
+ glGetProgramInfoLog(shader, infoLen, NULL, buf);
+ jstring result = _env->NewStringUTF(buf);
+ free(buf);
+ return result;
}
/* void glGetRenderbufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
static void
@@ -2662,12 +2632,12 @@ android_glGetRenderbufferParameteriv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2719,12 +2689,12 @@ android_glGetShaderiv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2765,32 +2735,24 @@ android_glGetShaderiv__IILjava_nio_IntBuffer_2
}
}
-#include <string.h>
+#include <stdlib.h>
/* void glGetShaderInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */
-static
-jstring
-android_glGetShaderInfoLog (JNIEnv *_env, jobject _this, jint shader) {
+static jstring android_glGetShaderInfoLog(JNIEnv *_env, jobject, jint shader) {
GLint infoLen = 0;
- jstring _result = 0;
- char* buf = 0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
- if (infoLen) {
- char* buf = (char*) malloc(infoLen);
- if (buf == 0) {
- _env->ThrowNew(IAEClass, "out of memory");
- goto exit;
- }
- glGetShaderInfoLog(shader, infoLen, NULL, buf);
- _result = _env->NewStringUTF(buf);
- } else {
- _result = _env->NewStringUTF("");
+ if (!infoLen) {
+ return _env->NewStringUTF("");
}
-exit:
- if (buf) {
- free(buf);
+ char* buf = (char*) malloc(infoLen);
+ if (buf == NULL) {
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory");
+ return NULL;
}
- return _result;
+ glGetShaderInfoLog(shader, infoLen, NULL, buf);
+ jstring result = _env->NewStringUTF(buf);
+ free(buf);
+ return result;
}
/* void glGetShaderPrecisionFormat ( GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision ) */
static void
@@ -2806,12 +2768,12 @@ android_glGetShaderPrecisionFormat__II_3II_3II
if (!range_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "range == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "range == null");
goto exit;
}
if (rangeOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "rangeOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "rangeOffset < 0");
goto exit;
}
_rangeRemaining = _env->GetArrayLength(range_ref) - rangeOffset;
@@ -2821,12 +2783,12 @@ android_glGetShaderPrecisionFormat__II_3II_3II
if (!precision_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "precision == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "precision == null");
goto exit;
}
if (precisionOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "precisionOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "precisionOffset < 0");
goto exit;
}
_precisionRemaining = _env->GetArrayLength(precision_ref) - precisionOffset;
@@ -2894,12 +2856,12 @@ android_glGetShaderSource__II_3II_3BI
if (!length_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length == null");
goto exit;
}
if (lengthOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "lengthOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "lengthOffset < 0");
goto exit;
}
_lengthRemaining = _env->GetArrayLength(length_ref) - lengthOffset;
@@ -2909,12 +2871,12 @@ android_glGetShaderSource__II_3II_3BI
if (!source_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "source == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "source == null");
goto exit;
}
if (sourceOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "sourceOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "sourceOffset < 0");
goto exit;
}
_sourceRemaining = _env->GetArrayLength(source_ref) - sourceOffset;
@@ -2961,16 +2923,10 @@ android_glGetShaderSource__IILjava_nio_IntBuffer_2B
}
}
-#include <string.h>
-
/* const GLubyte * glGetString ( GLenum name ) */
-static
-jstring
-android_glGetString
- (JNIEnv *_env, jobject _this, jint name) {
- const char * chars = (const char *)glGetString((GLenum)name);
- jstring output = _env->NewStringUTF(chars);
- return output;
+static jstring android_glGetString(JNIEnv* _env, jobject, jint name) {
+ const char* chars = (const char*) glGetString((GLenum) name);
+ return _env->NewStringUTF(chars);
}
/* void glGetTexParameterfv ( GLenum target, GLenum pname, GLfloat *params ) */
static void
@@ -2983,18 +2939,18 @@ android_glGetTexParameterfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -3026,7 +2982,7 @@ android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameterfv(
@@ -3052,18 +3008,18 @@ android_glGetTexParameteriv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -3095,7 +3051,7 @@ android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameteriv(
@@ -3121,12 +3077,12 @@ android_glGetUniformfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3178,12 +3134,12 @@ android_glGetUniformiv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3232,7 +3188,7 @@ android_glGetUniformLocation__ILjava_lang_String_2
const char* _nativename = 0;
if (!name) {
- _env->ThrowNew(IAEClass, "name == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "name == null");
goto exit;
}
_nativename = _env->GetStringUTFChars(name, 0);
@@ -3261,12 +3217,12 @@ android_glGetVertexAttribfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3318,12 +3274,12 @@ android_glGetVertexAttribiv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3566,11 +3522,11 @@ android_glShaderBinary__I_3IIILjava_nio_Buffer_2I
GLvoid *binary = (GLvoid *) 0;
if (!shaders_ref) {
- _env->ThrowNew(IAEClass, "shaders == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "shaders == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_shadersRemaining = _env->GetArrayLength(shaders_ref) - offset;
@@ -3633,7 +3589,7 @@ android_glShaderSource
(JNIEnv *_env, jobject _this, jint shader, jstring string) {
if (!string) {
- _env->ThrowNew(IAEClass, "string == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "string == null");
return;
}
@@ -3754,16 +3710,16 @@ android_glTexParameterfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -3793,7 +3749,7 @@ android_glTexParameterfv__IILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameterfv(
@@ -3828,16 +3784,16 @@ android_glTexParameteriv__II_3II
GLint *params = (GLint *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -3867,7 +3823,7 @@ android_glTexParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameteriv(
@@ -3928,11 +3884,11 @@ android_glUniform1fv__II_3FI
GLfloat *v = (GLfloat *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -3991,11 +3947,11 @@ android_glUniform1iv__II_3II
GLint *v = (GLint *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4055,11 +4011,11 @@ android_glUniform2fv__II_3FI
GLfloat *v = (GLfloat *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4119,11 +4075,11 @@ android_glUniform2iv__II_3II
GLint *v = (GLint *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4184,11 +4140,11 @@ android_glUniform3fv__II_3FI
GLfloat *v = (GLfloat *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4249,11 +4205,11 @@ android_glUniform3iv__II_3II
GLint *v = (GLint *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4315,11 +4271,11 @@ android_glUniform4fv__II_3FI
GLfloat *v = (GLfloat *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4381,11 +4337,11 @@ android_glUniform4iv__II_3II
GLint *v = (GLint *) 0;
if (!v_ref) {
- _env->ThrowNew(IAEClass, "v == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "v == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(v_ref) - offset;
@@ -4434,11 +4390,11 @@ android_glUniformMatrix2fv__IIZ_3FI
GLfloat *value = (GLfloat *) 0;
if (!value_ref) {
- _env->ThrowNew(IAEClass, "value == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "value == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
@@ -4489,11 +4445,11 @@ android_glUniformMatrix3fv__IIZ_3FI
GLfloat *value = (GLfloat *) 0;
if (!value_ref) {
- _env->ThrowNew(IAEClass, "value == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "value == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
@@ -4544,11 +4500,11 @@ android_glUniformMatrix4fv__IIZ_3FI
GLfloat *value = (GLfloat *) 0;
if (!value_ref) {
- _env->ThrowNew(IAEClass, "value == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "value == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(value_ref) - offset;
@@ -4627,11 +4583,11 @@ android_glVertexAttrib1fv__I_3FI
GLfloat *values = (GLfloat *) 0;
if (!values_ref) {
- _env->ThrowNew(IAEClass, "values == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "values == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(values_ref) - offset;
@@ -4689,11 +4645,11 @@ android_glVertexAttrib2fv__I_3FI
GLfloat *values = (GLfloat *) 0;
if (!values_ref) {
- _env->ThrowNew(IAEClass, "values == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "values == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(values_ref) - offset;
@@ -4752,11 +4708,11 @@ android_glVertexAttrib3fv__I_3FI
GLfloat *values = (GLfloat *) 0;
if (!values_ref) {
- _env->ThrowNew(IAEClass, "values == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "values == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(values_ref) - offset;
@@ -4816,11 +4772,11 @@ android_glVertexAttrib4fv__I_3FI
GLfloat *values = (GLfloat *) 0;
if (!values_ref) {
- _env->ThrowNew(IAEClass, "values == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "values == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(values_ref) - offset;
diff --git a/core/jni/android_os_FileUtils.cpp b/core/jni/android_os_FileUtils.cpp
index 2b4a955..89dce89 100644
--- a/core/jni/android_os_FileUtils.cpp
+++ b/core/jni/android_os_FileUtils.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, 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
+** 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
+** 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
+** 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.
*/
@@ -145,7 +145,7 @@ jint android_os_FileUtils_getFatVolumeId(JNIEnv* env, jobject clazz, jstring pat
jboolean android_os_FileUtils_getFileStatus(JNIEnv* env, jobject clazz, jstring path, jobject fileStatus) {
const char* pathStr = env->GetStringUTFChars(path, NULL);
jboolean ret = false;
-
+
struct stat s;
int res = stat(pathStr, &s);
if (res == 0) {
@@ -165,9 +165,9 @@ jboolean android_os_FileUtils_getFileStatus(JNIEnv* env, jobject clazz, jstring
env->SetLongField(fileStatus, gFileStatusCtimeFieldID, s.st_ctime);
}
}
-
+
env->ReleaseStringUTFChars(path, pathStr);
-
+
return ret;
}
@@ -183,11 +183,6 @@ static const char* const kFileUtilsPathName = "android/os/FileUtils";
int register_android_os_FileUtils(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass(kFileUtilsPathName);
- LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.FileUtils");
-
jclass fileStatusClass = env->FindClass("android/os/FileUtils$FileStatus");
LOG_FATAL_IF(fileStatusClass == NULL, "Unable to find class android.os.FileUtils$FileStatus");
diff --git a/core/jni/android_os_MemoryFile.cpp b/core/jni/android_os_MemoryFile.cpp
index ee8d836..7134191 100644
--- a/core/jni/android_os_MemoryFile.cpp
+++ b/core/jni/android_os_MemoryFile.cpp
@@ -148,17 +148,10 @@ static const JNINativeMethod methods[] = {
(void*)android_os_MemoryFile_get_size}
};
-static const char* const kClassPathName = "android/os/MemoryFile";
-
int register_android_os_MemoryFile(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass(kClassPathName);
- LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.FileUtils");
-
return AndroidRuntime::registerNativeMethods(
- env, kClassPathName,
+ env, "android/os/MemoryFile",
methods, NELEM(methods));
}
diff --git a/core/jni/android_os_ParcelFileDescriptor.cpp b/core/jni/android_os_ParcelFileDescriptor.cpp
index 1f737f9..4ec131c 100644
--- a/core/jni/android_os_ParcelFileDescriptor.cpp
+++ b/core/jni/android_os_ParcelFileDescriptor.cpp
@@ -29,43 +29,11 @@
namespace android
{
-static struct file_descriptor_offsets_t
-{
- jclass mClass;
- jmethodID mConstructor;
- jfieldID mDescriptor;
-} gFileDescriptorOffsets;
-
-static struct socket_offsets_t
-{
- jfieldID mSocketImpl;
-} gSocketOffsets;
-
-static struct socket_impl_offsets_t
-{
- jfieldID mFileDescriptor;
-} gSocketImplOffsets;
-
static struct parcel_file_descriptor_offsets_t
{
- jclass mClass;
jfieldID mFileDescriptor;
} gParcelFileDescriptorOffsets;
-static jobject android_os_ParcelFileDescriptor_getFileDescriptorFromSocket(JNIEnv* env,
- jobject clazz, jobject object)
-{
- jobject socketImpl = env->GetObjectField(object, gSocketOffsets.mSocketImpl);
- jobject fileDescriptor = env->GetObjectField(socketImpl, gSocketImplOffsets.mFileDescriptor);
- jint fd = env->GetIntField(fileDescriptor, gFileDescriptorOffsets.mDescriptor);
- jobject fileDescriptorClone = env->NewObject(gFileDescriptorOffsets.mClass,
- gFileDescriptorOffsets.mConstructor);
- if (fileDescriptorClone != NULL) {
- env->SetIntField(fileDescriptorClone, gFileDescriptorOffsets.mDescriptor, dup(fd));
- }
- return fileDescriptorClone;
-}
-
static int android_os_ParcelFileDescriptor_createPipeNative(JNIEnv* env,
jobject clazz, jobjectArray outFds)
{
@@ -75,11 +43,7 @@ static int android_os_ParcelFileDescriptor_createPipeNative(JNIEnv* env,
}
for (int i=0; i<2; i++) {
- jobject fdObj = env->NewObject(gFileDescriptorOffsets.mClass,
- gFileDescriptorOffsets.mConstructor);
- if (fdObj != NULL) {
- env->SetIntField(fdObj, gFileDescriptorOffsets.mDescriptor, fds[i]);
- }
+ jobject fdObj = jniCreateFileDescriptor(env, fds[i]);
env->SetObjectArrayElement(outFds, i, fdObj);
}
@@ -90,7 +54,7 @@ static jint getFd(JNIEnv* env, jobject clazz)
{
jobject descriptor = env->GetObjectField(clazz, gParcelFileDescriptorOffsets.mFileDescriptor);
if (descriptor == NULL) return -1;
- return env->GetIntField(descriptor, gFileDescriptorOffsets.mDescriptor);
+ return jniGetFDFromFileDescriptor(env, descriptor);
}
static jlong android_os_ParcelFileDescriptor_getStatSize(JNIEnv* env,
@@ -101,16 +65,16 @@ static jlong android_os_ParcelFileDescriptor_getStatSize(JNIEnv* env,
jniThrowException(env, "java/lang/IllegalArgumentException", "bad file descriptor");
return -1;
}
-
+
struct stat st;
if (fstat(fd, &st) != 0) {
return -1;
}
-
+
if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
return st.st_size;
}
-
+
return -1;
}
@@ -122,7 +86,7 @@ static jlong android_os_ParcelFileDescriptor_seekTo(JNIEnv* env,
jniThrowException(env, "java/lang/IllegalArgumentException", "bad file descriptor");
return -1;
}
-
+
return lseek(fd, pos, SEEK_SET);
}
@@ -138,8 +102,6 @@ static jlong android_os_ParcelFileDescriptor_getFdNative(JNIEnv* env, jobject cl
}
static const JNINativeMethod gParcelFileDescriptorMethods[] = {
- {"getFileDescriptorFromSocket", "(Ljava/net/Socket;)Ljava/io/FileDescriptor;",
- (void*)android_os_ParcelFileDescriptor_getFileDescriptorFromSocket},
{"createPipeNative", "([Ljava/io/FileDescriptor;)I",
(void*)android_os_ParcelFileDescriptor_createPipeNative},
{"getStatSize", "()J",
@@ -154,31 +116,8 @@ const char* const kParcelFileDescriptorPathName = "android/os/ParcelFileDescript
int register_android_os_ParcelFileDescriptor(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass("java/net/Socket");
- LOG_FATAL_IF(clazz == NULL, "Unable to find class java.net.Socket");
- gSocketOffsets.mSocketImpl = env->GetFieldID(clazz, "impl", "Ljava/net/SocketImpl;");
- LOG_FATAL_IF(gSocketOffsets.mSocketImpl == NULL,
- "Unable to find impl field in java.net.Socket");
-
- clazz = env->FindClass("java/net/SocketImpl");
- LOG_FATAL_IF(clazz == NULL, "Unable to find class java.net.SocketImpl");
- gSocketImplOffsets.mFileDescriptor = env->GetFieldID(clazz, "fd", "Ljava/io/FileDescriptor;");
- LOG_FATAL_IF(gSocketImplOffsets.mFileDescriptor == NULL,
- "Unable to find fd field in java.net.SocketImpl");
-
- clazz = env->FindClass("java/io/FileDescriptor");
- LOG_FATAL_IF(clazz == NULL, "Unable to find class java.io.FileDescriptor");
- gFileDescriptorOffsets.mClass = (jclass) env->NewGlobalRef(clazz);
- gFileDescriptorOffsets.mConstructor = env->GetMethodID(clazz, "<init>", "()V");
- gFileDescriptorOffsets.mDescriptor = env->GetFieldID(clazz, "descriptor", "I");
- LOG_FATAL_IF(gFileDescriptorOffsets.mDescriptor == NULL,
- "Unable to find descriptor field in java.io.FileDescriptor");
-
- clazz = env->FindClass(kParcelFileDescriptorPathName);
+ jclass clazz = env->FindClass(kParcelFileDescriptorPathName);
LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.ParcelFileDescriptor");
- gParcelFileDescriptorOffsets.mClass = (jclass) env->NewGlobalRef(clazz);
gParcelFileDescriptorOffsets.mFileDescriptor = env->GetFieldID(clazz, "mFileDescriptor", "Ljava/io/FileDescriptor;");
LOG_FATAL_IF(gParcelFileDescriptorOffsets.mFileDescriptor == NULL,
"Unable to find mFileDescriptor field in android.os.ParcelFileDescriptor");
diff --git a/core/jni/android_pim_EventRecurrence.cpp b/core/jni/android_pim_EventRecurrence.cpp
index 9056c90..44e898d 100644
--- a/core/jni/android_pim_EventRecurrence.cpp
+++ b/core/jni/android_pim_EventRecurrence.cpp
@@ -28,7 +28,6 @@ struct cached_array_fields_t
jfieldID count;
};
-static jclass clazz;
static jfieldID freq_field;
static jfieldID until_field;
static jfieldID count_field;
@@ -87,8 +86,7 @@ EventRecurrence_parse(JNIEnv* env, jobject This, jstring jstr)
jniThrowNullPointerException(env, "EventRecurrence.parse str parameter null");
return ;
}
- jboolean isCopy;
- const jchar* jchars = env->GetStringChars(jstr, &isCopy);
+ const jchar* jchars = env->GetStringChars(jstr, NULL);
jsize len = env->GetStringLength(jstr);
String16 str(jchars, len);
env->ReleaseStringChars(jstr, jchars);
@@ -156,7 +154,7 @@ static const char*const CLASS_NAME = "android/pim/EventRecurrence";
int register_android_pim_EventRecurrence(JNIEnv* env)
{
- clazz = env->FindClass(CLASS_NAME);
+ jclass clazz = env->FindClass(CLASS_NAME);
if (clazz == NULL) {
LOGE("Field lookup unable to find class '%s'\n", CLASS_NAME);
return -1;
diff --git a/core/jni/android_text_AndroidBidi.cpp b/core/jni/android_text_AndroidBidi.cpp
index 53028c3..d50a69f 100644
--- a/core/jni/android_text_AndroidBidi.cpp
+++ b/core/jni/android_text_AndroidBidi.cpp
@@ -2,16 +2,16 @@
**
** Copyright 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
+** 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
+** 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
+** 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.
*/
@@ -24,8 +24,8 @@
#include "unicode/ubidi.h"
namespace android {
-
-static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
+
+static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
jbyteArray infoArray, int n, jboolean haveInfo)
{
// Parameters are checked on java side
@@ -63,9 +63,6 @@ static JNINativeMethod gMethods[] = {
int register_android_text_AndroidBidi(JNIEnv* env)
{
- jclass clazz = env->FindClass("android/text/AndroidBidi");
- LOG_ASSERT(clazz, "Cannot find android/text/AndroidBidi");
-
return AndroidRuntime::registerNativeMethods(env, "android/text/AndroidBidi",
gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_text_AndroidCharacter.cpp b/core/jni/android_text_AndroidCharacter.cpp
index 0d0f5fa..dacbe41 100644
--- a/core/jni/android_text_AndroidCharacter.cpp
+++ b/core/jni/android_text_AndroidCharacter.cpp
@@ -191,9 +191,6 @@ static JNINativeMethod gMethods[] = {
int register_android_text_AndroidCharacter(JNIEnv* env)
{
- jclass clazz = env->FindClass("android/text/AndroidCharacter");
- LOG_ASSERT(clazz, "Cannot find android/text/AndroidCharacter");
-
return AndroidRuntime::registerNativeMethods(env, "android/text/AndroidCharacter",
gMethods, NELEM(gMethods));
}
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 8ea7e90..b0e92e4 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -169,7 +169,7 @@ static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outO
env->ReleasePrimitiveArrayCritical(outOffsets, offsets, 0);
- jobject fileDesc = newFileDescriptor(env, fd);
+ jobject fileDesc = jniCreateFileDescriptor(env, fd);
if (fileDesc == NULL) {
close(fd);
return NULL;
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 8618b79..0681195 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -131,13 +131,6 @@ static struct log_offsets_t
jmethodID mLogE;
} gLogOffsets;
-static struct file_descriptor_offsets_t
-{
- jclass mClass;
- jmethodID mConstructor;
- jfieldID mDescriptor;
-} gFileDescriptorOffsets;
-
static struct parcel_file_descriptor_offsets_t
{
jclass mClass;
@@ -591,17 +584,6 @@ Parcel* parcelForJavaObject(JNIEnv* env, jobject obj)
return NULL;
}
-jobject newFileDescriptor(JNIEnv* env, int fd)
-{
- jobject object = env->NewObject(
- gFileDescriptorOffsets.mClass, gFileDescriptorOffsets.mConstructor);
- if (object != NULL) {
- //LOGI("Created new FileDescriptor %p with fd %d\n", object, fd);
- env->SetIntField(object, gFileDescriptorOffsets.mDescriptor, fd);
- }
- return object;
-}
-
jobject newParcelFileDescriptor(JNIEnv* env, jobject fileDesc)
{
return env->NewObject(
@@ -1358,8 +1340,8 @@ static void android_os_Parcel_writeFileDescriptor(JNIEnv* env, jobject clazz, jo
{
Parcel* parcel = parcelForJavaObject(env, clazz);
if (parcel != NULL) {
- const status_t err = parcel->writeDupFileDescriptor(
- env->GetIntField(object, gFileDescriptorOffsets.mDescriptor));
+ const status_t err =
+ parcel->writeDupFileDescriptor(jniGetFDFromFileDescriptor(env, object));
if (err != NO_ERROR) {
jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
}
@@ -1459,13 +1441,7 @@ static jobject android_os_Parcel_readFileDescriptor(JNIEnv* env, jobject clazz)
if (fd < 0) return NULL;
fd = dup(fd);
if (fd < 0) return NULL;
- jobject object = env->NewObject(
- gFileDescriptorOffsets.mClass, gFileDescriptorOffsets.mConstructor);
- if (object != NULL) {
- //LOGI("Created new FileDescriptor %p with fd %d\n", object, fd);
- env->SetIntField(object, gFileDescriptorOffsets.mDescriptor, fd);
- }
- return object;
+ return jniCreateFileDescriptor(env, fd);
}
return NULL;
}
@@ -1512,7 +1488,7 @@ static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jobject clazz,
jniThrowException(env, "java/io/FileNotFoundException", strerror(errno));
return NULL;
}
- jobject object = newFileDescriptor(env, fd);
+ jobject object = jniCreateFileDescriptor(env, fd);
if (object == NULL) {
close(fd);
}
@@ -1525,7 +1501,7 @@ static jobject android_os_Parcel_dupFileDescriptor(JNIEnv* env, jobject clazz, j
jniThrowNullPointerException(env, NULL);
return NULL;
}
- int origfd = env->GetIntField(orig, gFileDescriptorOffsets.mDescriptor);
+ int origfd = jniGetFDFromFileDescriptor(env, orig);
if (origfd < 0) {
jniThrowException(env, "java/lang/IllegalArgumentException", "bad FileDescriptor");
return NULL;
@@ -1536,7 +1512,7 @@ static jobject android_os_Parcel_dupFileDescriptor(JNIEnv* env, jobject clazz, j
jniThrowIOException(env, errno);
return NULL;
}
- jobject object = newFileDescriptor(env, fd);
+ jobject object = jniCreateFileDescriptor(env, fd);
if (object == NULL) {
close(fd);
}
@@ -1549,9 +1525,9 @@ static void android_os_Parcel_closeFileDescriptor(JNIEnv* env, jobject clazz, jo
jniThrowNullPointerException(env, NULL);
return;
}
- int fd = env->GetIntField(object, gFileDescriptorOffsets.mDescriptor);
+ int fd = jniGetFDFromFileDescriptor(env, object);
if (fd >= 0) {
- env->SetIntField(object, gFileDescriptorOffsets.mDescriptor, -1);
+ jniSetFileDescriptorOfFD(env, object, -1);
//LOGI("Closing ParcelFileDescriptor %d\n", fd);
close(fd);
}
@@ -1563,9 +1539,9 @@ static void android_os_Parcel_clearFileDescriptor(JNIEnv* env, jobject clazz, jo
jniThrowNullPointerException(env, NULL);
return;
}
- int fd = env->GetIntField(object, gFileDescriptorOffsets.mDescriptor);
+ int fd = jniGetFDFromFileDescriptor(env, object);
if (fd >= 0) {
- env->SetIntField(object, gFileDescriptorOffsets.mDescriptor, -1);
+ jniSetFileDescriptorOfFD(env, object, -1);
}
}
@@ -1794,15 +1770,6 @@ static int int_register_android_os_Parcel(JNIEnv* env)
clazz, "e", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I");
assert(gLogOffsets.mLogE);
- clazz = env->FindClass("java/io/FileDescriptor");
- LOG_FATAL_IF(clazz == NULL, "Unable to find class java.io.FileDescriptor");
- gFileDescriptorOffsets.mClass = (jclass) env->NewGlobalRef(clazz);
- gFileDescriptorOffsets.mConstructor
- = env->GetMethodID(clazz, "<init>", "()V");
- gFileDescriptorOffsets.mDescriptor = env->GetFieldID(clazz, "descriptor", "I");
- LOG_FATAL_IF(gFileDescriptorOffsets.mDescriptor == NULL,
- "Unable to find descriptor field in java.io.FileDescriptor");
-
clazz = env->FindClass("android/os/ParcelFileDescriptor");
LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.ParcelFileDescriptor");
gParcelFileDescriptorOffsets.mClass = (jclass) env->NewGlobalRef(clazz);
@@ -1842,13 +1809,3 @@ int register_android_os_Binder(JNIEnv* env)
return -1;
return 0;
}
-
-namespace android {
-
-// Returns the Unix file descriptor for a ParcelFileDescriptor object
-int getParcelFileDescriptorFD(JNIEnv* env, jobject object)
-{
- return env->GetIntField(object, gFileDescriptorOffsets.mDescriptor);
-}
-
-}
diff --git a/core/jni/android_util_Binder.h b/core/jni/android_util_Binder.h
index 495e76a..0122691 100644
--- a/core/jni/android_util_Binder.h
+++ b/core/jni/android_util_Binder.h
@@ -2,16 +2,16 @@
**
** Copyright 2006, 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
+** 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
+** 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
+** 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.
*/
@@ -29,7 +29,6 @@ extern sp<IBinder> ibinderForJavaObject(JNIEnv* env, jobject obj);
// Note: does not type checking; must guarantee jobject is a Java Parcel
extern Parcel* parcelForJavaObject(JNIEnv* env, jobject obj);
-extern jobject newFileDescriptor(JNIEnv* env, int fd);
extern jobject newParcelFileDescriptor(JNIEnv* env, jobject fileDesc);
}
diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp
index 91d37d3..5d51110 100644
--- a/core/jni/android_util_EventLog.cpp
+++ b/core/jni/android_util_EventLog.cpp
@@ -35,9 +35,6 @@ static jmethodID gEventInitID;
static jclass gIntegerClass;
static jfieldID gIntegerValueID;
-static jclass gListClass;
-static jfieldID gListItemsID;
-
static jclass gLongClass;
static jfieldID gLongValueID;
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 0068de7..e5c2848 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -103,17 +103,6 @@ static void signalExceptionForGroupError(JNIEnv* env, jobject obj, int err)
}
}
-
-static void fakeProcessEntry(void* arg)
-{
- String8* cls = (String8*)arg;
-
- AndroidRuntime* jr = AndroidRuntime::getRuntime();
- jr->callMain(cls->string(), 0, NULL);
-
- delete cls;
-}
-
jint android_os_Process_myPid(JNIEnv* env, jobject clazz)
{
return getpid();
@@ -915,11 +904,6 @@ const char* const kProcessPathName = "android/os/Process";
int register_android_os_Process(JNIEnv* env)
{
- jclass clazz;
-
- clazz = env->FindClass(kProcessPathName);
- LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.Process");
-
return AndroidRuntime::registerNativeMethods(
env, kProcessPathName,
methods, NELEM(methods));
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index f31bba9..314c2ee 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -595,13 +595,11 @@ static jboolean android_view_GLES20Canvas_isAvailable(JNIEnv* env, jobject clazz
// Logging
// ----------------------------------------------------------------------------
-jfieldID gFileDescriptorField;
-
static void
android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor)
{
#ifdef USE_OPENGL_RENDERER
- int fd = env->GetIntField(javaFileDescriptor, gFileDescriptorField);
+ int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
android::uirenderer::DisplayList::outputLogBuffer(fd);
#endif // USE_OPENGL_RENDERER
}
@@ -736,12 +734,6 @@ const char* const kActivityThreadPathName = "android/app/ActivityThread";
int register_android_app_ActivityThread(JNIEnv* env)
{
- jclass fileDescriptorClass = env->FindClass("java/io/FileDescriptor");
- LOG_FATAL_IF(clazz == NULL, "Unable to find class java.io.FileDescriptor");
- gFileDescriptorField = env->GetFieldID(fileDescriptorClass, "descriptor", "I");
- LOG_FATAL_IF(gFileDescriptorField == NULL,
- "Unable to find descriptor field in java.io.FileDescriptor");
-
return AndroidRuntime::registerNativeMethods(
env, kActivityThreadPathName,
gActivityThreadMethods, NELEM(gActivityThreadMethods));
diff --git a/core/jni/com_android_internal_graphics_NativeUtils.cpp b/core/jni/com_android_internal_graphics_NativeUtils.cpp
index 319946f..9cc43606 100644
--- a/core/jni/com_android_internal_graphics_NativeUtils.cpp
+++ b/core/jni/com_android_internal_graphics_NativeUtils.cpp
@@ -29,11 +29,6 @@
namespace android
{
-static jclass class_fileDescriptor;
-static jfieldID field_fileDescriptor_descriptor;
-static jmethodID method_fileDescriptor_init;
-
-
static jboolean scrollRect(JNIEnv* env, jobject graphics2D, jobject canvas, jobject rect, int dx, int dy) {
if (canvas == NULL) {
jniThrowNullPointerException(env, NULL);
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 61efcf2..5f2065a 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -29,9 +29,6 @@
namespace android {
-static jclass gDisplay_class;
-static jclass gContext_class;
-static jclass gSurface_class;
static jclass gConfig_class;
static jmethodID gConfig_ctorID;
@@ -44,21 +41,6 @@ static jfieldID gConfig_EGLConfigFieldID;
static jfieldID gSurface_SurfaceFieldID;
static jfieldID gBitmap_NativeBitmapFieldID;
-static __attribute__((noinline))
-bool hasException(JNIEnv *env) {
- if (env->ExceptionCheck() != 0) {
- env->ExceptionDescribe();
- return true;
- }
- return false;
-}
-
-static __attribute__((noinline))
-jclass make_globalref(JNIEnv* env, const char classname[]) {
- jclass c = env->FindClass(classname);
- return (jclass)env->NewGlobalRef(c);
-}
-
static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_DISPLAY;
return (EGLDisplay)env->GetIntField(o, gDisplay_EGLDisplayFieldID);
@@ -77,18 +59,20 @@ static inline EGLConfig getConfig(JNIEnv* env, jobject o) {
}
static void nativeClassInit(JNIEnv *_env, jclass eglImplClass)
{
- gDisplay_class = make_globalref(_env, "com/google/android/gles_jni/EGLDisplayImpl");
- gContext_class = make_globalref(_env, "com/google/android/gles_jni/EGLContextImpl");
- gSurface_class = make_globalref(_env, "com/google/android/gles_jni/EGLSurfaceImpl");
- gConfig_class = make_globalref(_env, "com/google/android/gles_jni/EGLConfigImpl");
-
- gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V");
-
- gDisplay_EGLDisplayFieldID = _env->GetFieldID(gDisplay_class, "mEGLDisplay", "I");
- gContext_EGLContextFieldID = _env->GetFieldID(gContext_class, "mEGLContext", "I");
- gSurface_EGLSurfaceFieldID = _env->GetFieldID(gSurface_class, "mEGLSurface", "I");
- gSurface_NativePixelRefFieldID = _env->GetFieldID(gSurface_class, "mNativePixelRef", "I");
- gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I");
+ jclass config_class = _env->FindClass("com/google/android/gles_jni/EGLConfigImpl");
+ gConfig_class = (jclass) _env->NewGlobalRef(config_class);
+ gConfig_ctorID = _env->GetMethodID(gConfig_class, "<init>", "(I)V");
+ gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I");
+
+ jclass display_class = _env->FindClass("com/google/android/gles_jni/EGLDisplayImpl");
+ gDisplay_EGLDisplayFieldID = _env->GetFieldID(display_class, "mEGLDisplay", "I");
+
+ jclass context_class = _env->FindClass("com/google/android/gles_jni/EGLContextImpl");
+ gContext_EGLContextFieldID = _env->GetFieldID(context_class, "mEGLContext", "I");
+
+ jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
+ gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "I");
+ gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "I");
jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I");
diff --git a/core/jni/com_google_android_gles_jni_GLImpl.cpp b/core/jni/com_google_android_gles_jni_GLImpl.cpp
index bf613e1..8777131 100644
--- a/core/jni/com_google_android_gles_jni_GLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_GLImpl.cpp
@@ -2,21 +2,23 @@
**
** Copyright 2006, 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
+** 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
+** 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
+** 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.
*/
// This source file is automatically generated
+#include "jni.h"
+#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
@@ -64,10 +66,6 @@ static int initialized = 0;
static jclass nioAccessClass;
static jclass bufferClass;
-static jclass OOMEClass;
-static jclass UOEClass;
-static jclass IAEClass;
-static jclass AIOOBEClass;
static jclass G11ImplClass;
static jmethodID getBasePointerID;
static jmethodID getBaseArrayID;
@@ -85,7 +83,7 @@ static jfieldID have_OES_texture_cube_mapID;
/* Cache method IDs each time the class is loaded. */
static void
-nativeClassInitBuffer(JNIEnv *_env)
+nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
@@ -115,26 +113,6 @@ nativeClassInitBuffer(JNIEnv *_env)
_env->GetFieldID(bufferClass, "_elementSizeShift", "I");
}
-static void
-nativeClassInit(JNIEnv *_env, jclass glImplClass)
-{
- nativeClassInitBuffer(_env);
-
- jclass IAEClassLocal =
- _env->FindClass("java/lang/IllegalArgumentException");
- jclass OOMEClassLocal =
- _env->FindClass("java/lang/OutOfMemoryError");
- jclass UOEClassLocal =
- _env->FindClass("java/lang/UnsupportedOperationException");
- jclass AIOOBEClassLocal =
- _env->FindClass("java/lang/ArrayIndexOutOfBoundsException");
-
- IAEClass = (jclass) _env->NewGlobalRef(IAEClassLocal);
- OOMEClass = (jclass) _env->NewGlobalRef(OOMEClassLocal);
- UOEClass = (jclass) _env->NewGlobalRef(UOEClassLocal);
- AIOOBEClass = (jclass) _env->NewGlobalRef(AIOOBEClassLocal);
-}
-
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
{
@@ -155,7 +133,7 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
*array = NULL;
return (void *) (jint) pointer;
}
-
+
*array = (jarray) _env->CallStaticObjectMethod(nioAccessClass,
getBaseArrayID, buffer);
if (*array == NULL) {
@@ -164,7 +142,7 @@ getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining)
offset = _env->CallStaticIntMethod(nioAccessClass,
getBaseArrayOffsetID, buffer);
data = _env->GetPrimitiveArrayCritical(*array, (jboolean *) 0);
-
+
return (void *) ((char *) data + offset);
}
@@ -208,7 +186,8 @@ getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
releasePointer(_env, array, buf, 0);
}
} else {
- _env->ThrowNew(IAEClass, "Must use a native order direct Buffer");
+ jniThrowException(_env, "java/lang/IllegalArgumentException",
+ "Must use a native order direct Buffer");
}
}
return buf;
@@ -251,7 +230,7 @@ nextExtension(const GLubyte* pExtensions) {
}
}
}
-
+
static bool
checkForExtension(const GLubyte* pExtensions, const GLubyte* pExtension) {
for (;*pExtensions != '\0'; pExtensions = nextExtension(pExtensions)) {
@@ -280,7 +259,6 @@ supportsExtension(JNIEnv *_env, jobject impl, jfieldID fieldId) {
}
// --------------------------------------------------------------------------
-
/* void glActiveTexture ( GLenum texture ) */
static void
android_glActiveTexture__I
@@ -557,16 +535,16 @@ android_glDeleteTextures__I_3II
GLuint *textures = (GLuint *) 0;
if (!textures_ref) {
- _env->ThrowNew(IAEClass, "textures == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "textures == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(textures_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
textures_base = (GLuint *)
@@ -595,7 +573,7 @@ android_glDeleteTextures__ILjava_nio_IntBuffer_2
textures = (GLuint *)getPointer(_env, textures_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteTextures(
@@ -686,7 +664,7 @@ android_glDrawElements__IIILjava_nio_Buffer_2
indices = (GLvoid *)getPointer(_env, indices_buf, &_array, &_remaining);
if (_remaining < count) {
- _env->ThrowNew(AIOOBEClass, "remaining() < count");
+ jniThrowException(_env, "java/lang/ArrayIndexOutOfBoundsException", "remaining() < count");
goto exit;
}
glDrawElements(
@@ -753,11 +731,11 @@ android_glFogfv__I_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -787,7 +765,7 @@ android_glFogfv__I_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -841,7 +819,7 @@ android_glFogfv__ILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glFogfv(
@@ -874,11 +852,11 @@ android_glFogxv__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -908,7 +886,7 @@ android_glFogxv__I_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -962,7 +940,7 @@ android_glFogxv__ILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glFogxv(
@@ -1024,18 +1002,18 @@ android_glGenTextures__I_3II
if (!textures_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "textures == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "textures == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(textures_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
textures_base = (GLuint *)
@@ -1066,7 +1044,7 @@ android_glGenTextures__ILjava_nio_IntBuffer_2
textures = (GLuint *)getPointer(_env, textures_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenTextures(
@@ -1100,12 +1078,12 @@ android_glGetIntegerv__I_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1442,7 +1420,7 @@ android_glGetIntegerv__I_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -1804,7 +1782,7 @@ android_glGetIntegerv__ILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetIntegerv(
@@ -1818,16 +1796,10 @@ exit:
}
}
-#include <string.h>
-
/* const GLubyte * glGetString ( GLenum name ) */
-static
-jstring
-android_glGetString
- (JNIEnv *_env, jobject _this, jint name) {
- const char * chars = (const char *)glGetString((GLenum)name);
- jstring output = _env->NewStringUTF(chars);
- return output;
+static jstring android_glGetString(JNIEnv *_env, jobject, jint name) {
+ const char* chars = (const char*) glGetString((GLenum) name);
+ return _env->NewStringUTF(chars);
}
/* void glHint ( GLenum target, GLenum mode ) */
static void
@@ -1858,11 +1830,11 @@ android_glLightModelfv__I_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1883,7 +1855,7 @@ android_glLightModelfv__I_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -1928,7 +1900,7 @@ android_glLightModelfv__ILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightModelfv(
@@ -1961,11 +1933,11 @@ android_glLightModelxv__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -1986,7 +1958,7 @@ android_glLightModelxv__I_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -2031,7 +2003,7 @@ android_glLightModelxv__ILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightModelxv(
@@ -2065,11 +2037,11 @@ android_glLightfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2116,7 +2088,7 @@ android_glLightfv__II_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -2188,7 +2160,7 @@ android_glLightfv__IILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightfv(
@@ -2223,11 +2195,11 @@ android_glLightxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2274,7 +2246,7 @@ android_glLightxv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -2346,7 +2318,7 @@ android_glLightxv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glLightxv(
@@ -2395,11 +2367,11 @@ android_glLoadMatrixf___3FI
GLfloat *m = (GLfloat *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -2444,11 +2416,11 @@ android_glLoadMatrixx___3II
GLfixed *m = (GLfixed *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -2513,11 +2485,11 @@ android_glMaterialfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2550,7 +2522,7 @@ android_glMaterialfv__II_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -2608,7 +2580,7 @@ android_glMaterialfv__IILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glMaterialfv(
@@ -2643,11 +2615,11 @@ android_glMaterialxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -2680,7 +2652,7 @@ android_glMaterialxv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -2738,7 +2710,7 @@ android_glMaterialxv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glMaterialxv(
@@ -2771,11 +2743,11 @@ android_glMultMatrixf___3FI
GLfloat *m = (GLfloat *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -2820,11 +2792,11 @@ android_glMultMatrixx___3II
GLfixed *m = (GLfixed *) 0;
if (!m_ref) {
- _env->ThrowNew(IAEClass, "m == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "m == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(m_ref) - offset;
@@ -3205,11 +3177,11 @@ android_glTexEnvfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3236,7 +3208,7 @@ android_glTexEnvfv__II_3FI
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -3288,7 +3260,7 @@ android_glTexEnvfv__IILjava_nio_FloatBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glTexEnvfv(
@@ -3323,11 +3295,11 @@ android_glTexEnvxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -3354,7 +3326,7 @@ android_glTexEnvxv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -3406,7 +3378,7 @@ android_glTexEnvxv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glTexEnvxv(
@@ -3569,18 +3541,18 @@ android_glQueryMatrixxOES___3II_3II
if (!mantissa_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "mantissa == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "mantissa == null");
goto exit;
}
if (mantissaOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "mantissaOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "mantissaOffset < 0");
goto exit;
}
_mantissaRemaining = _env->GetArrayLength(mantissa_ref) - mantissaOffset;
if (_mantissaRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - mantissaOffset < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - mantissaOffset < 16");
goto exit;
}
mantissa_base = (GLfixed *)
@@ -3589,18 +3561,18 @@ android_glQueryMatrixxOES___3II_3II
if (!exponent_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "exponent == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "exponent == null");
goto exit;
}
if (exponentOffset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "exponentOffset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "exponentOffset < 0");
goto exit;
}
_exponentRemaining = _env->GetArrayLength(exponent_ref) - exponentOffset;
if (_exponentRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - exponentOffset < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - exponentOffset < 16");
goto exit;
}
exponent_base = (GLint *)
@@ -3640,13 +3612,13 @@ android_glQueryMatrixxOES__Ljava_nio_IntBuffer_2Ljava_nio_IntBuffer_2
mantissa = (GLfixed *)getPointer(_env, mantissa_buf, &_mantissaArray, &_mantissaRemaining);
if (_mantissaRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 16");
goto exit;
}
exponent = (GLint *)getPointer(_env, exponent_buf, &_exponentArray, &_exponentRemaining);
if (_exponentRemaining < 16) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 16");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 16");
goto exit;
}
_returnValue = glQueryMatrixxOES(
@@ -3685,7 +3657,7 @@ android_glBufferData__IILjava_nio_Buffer_2I
if (data_buf) {
data = (GLvoid *)getPointer(_env, data_buf, &_array, &_remaining);
if (_remaining < size) {
- _env->ThrowNew(IAEClass, "remaining() < size");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < size");
goto exit;
}
}
@@ -3712,7 +3684,7 @@ android_glBufferSubData__IIILjava_nio_Buffer_2
data = (GLvoid *)getPointer(_env, data_buf, &_array, &_remaining);
if (_remaining < size) {
- _env->ThrowNew(IAEClass, "remaining() < size");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < size");
goto exit;
}
glBufferSubData(
@@ -3737,16 +3709,16 @@ android_glClipPlanef__I_3FI
GLfloat *equation = (GLfloat *) 0;
if (!equation_ref) {
- _env->ThrowNew(IAEClass, "equation == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "equation == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
if (_remaining < 4) {
- _env->ThrowNew(IAEClass, "length - offset < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 4");
goto exit;
}
equation_base = (GLfloat *)
@@ -3775,7 +3747,7 @@ android_glClipPlanef__ILjava_nio_FloatBuffer_2
equation = (GLfloat *)getPointer(_env, equation_buf, &_array, &_remaining);
if (_remaining < 4) {
- _env->ThrowNew(IAEClass, "remaining() < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 4");
goto exit;
}
glClipPlanef(
@@ -3798,16 +3770,16 @@ android_glClipPlanex__I_3II
GLfixed *equation = (GLfixed *) 0;
if (!equation_ref) {
- _env->ThrowNew(IAEClass, "equation == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "equation == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
if (_remaining < 4) {
- _env->ThrowNew(IAEClass, "length - offset < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 4");
goto exit;
}
equation_base = (GLfixed *)
@@ -3836,7 +3808,7 @@ android_glClipPlanex__ILjava_nio_IntBuffer_2
equation = (GLfixed *)getPointer(_env, equation_buf, &_array, &_remaining);
if (_remaining < 4) {
- _env->ThrowNew(IAEClass, "remaining() < 4");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 4");
goto exit;
}
glClipPlanex(
@@ -3883,16 +3855,16 @@ android_glDeleteBuffers__I_3II
GLuint *buffers = (GLuint *) 0;
if (!buffers_ref) {
- _env->ThrowNew(IAEClass, "buffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "buffers == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
buffers_base = (GLuint *)
@@ -3921,7 +3893,7 @@ android_glDeleteBuffers__ILjava_nio_IntBuffer_2
buffers = (GLuint *)getPointer(_env, buffers_buf, &_array, &_remaining);
if (_remaining < n) {
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteBuffers(
@@ -3958,18 +3930,18 @@ android_glGenBuffers__I_3II
if (!buffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "buffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "buffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
buffers_base = (GLuint *)
@@ -4000,7 +3972,7 @@ android_glGenBuffers__ILjava_nio_IntBuffer_2
buffers = (GLuint *)getPointer(_env, buffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenBuffers(
@@ -4025,12 +3997,12 @@ android_glGetBooleanv__I_3ZI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4073,7 +4045,7 @@ android_glGetBooleanv__ILjava_nio_IntBuffer_2
static void
android_glGetBufferParameteriv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetBufferParameteriv");
}
@@ -4081,7 +4053,7 @@ android_glGetBufferParameteriv__II_3II
static void
android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetBufferParameteriv");
}
@@ -4096,12 +4068,12 @@ android_glGetClipPlanef__I_3FI
if (!eqn_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "eqn == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "eqn == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
@@ -4151,12 +4123,12 @@ android_glGetClipPlanex__I_3II
if (!eqn_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "eqn == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "eqn == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
@@ -4206,12 +4178,12 @@ android_glGetFixedv__I_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4261,12 +4233,12 @@ android_glGetFloatv__I_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4316,12 +4288,12 @@ android_glGetLightfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4369,7 +4341,7 @@ android_glGetLightfv__II_3FI
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -4443,7 +4415,7 @@ android_glGetLightfv__IILjava_nio_FloatBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetLightfv(
@@ -4469,12 +4441,12 @@ android_glGetLightxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4522,7 +4494,7 @@ android_glGetLightxv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -4596,7 +4568,7 @@ android_glGetLightxv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetLightxv(
@@ -4622,12 +4594,12 @@ android_glGetMaterialfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4661,7 +4633,7 @@ android_glGetMaterialfv__II_3FI
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfloat *)
@@ -4721,7 +4693,7 @@ android_glGetMaterialfv__IILjava_nio_FloatBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetMaterialfv(
@@ -4747,12 +4719,12 @@ android_glGetMaterialxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4786,7 +4758,7 @@ android_glGetMaterialxv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -4846,7 +4818,7 @@ android_glGetMaterialxv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetMaterialxv(
@@ -4872,12 +4844,12 @@ android_glGetTexEnviv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -4905,7 +4877,7 @@ android_glGetTexEnviv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -4959,7 +4931,7 @@ android_glGetTexEnviv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetTexEnviv(
@@ -4985,12 +4957,12 @@ android_glGetTexEnvxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -5018,7 +4990,7 @@ android_glGetTexEnvxv__II_3II
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLfixed *)
@@ -5072,7 +5044,7 @@ android_glGetTexEnvxv__IILjava_nio_IntBuffer_2
}
if (_remaining < _needed) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glGetTexEnvxv(
@@ -5098,18 +5070,18 @@ android_glGetTexParameterfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -5141,7 +5113,7 @@ android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameterfv(
@@ -5167,18 +5139,18 @@ android_glGetTexParameteriv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -5210,7 +5182,7 @@ android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameteriv(
@@ -5236,18 +5208,18 @@ android_glGetTexParameterxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfixed *)
@@ -5279,7 +5251,7 @@ android_glGetTexParameterxv__IILjava_nio_IntBuffer_2
params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glGetTexParameterxv(
@@ -5357,16 +5329,16 @@ android_glPointParameterfv__I_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -5395,7 +5367,7 @@ android_glPointParameterfv__ILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glPointParameterfv(
@@ -5428,16 +5400,16 @@ android_glPointParameterxv__I_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfixed *)
@@ -5466,7 +5438,7 @@ android_glPointParameterxv__ILjava_nio_IntBuffer_2
params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glPointParameterxv(
@@ -5534,11 +5506,11 @@ android_glTexEnviv__II_3II
GLint *params = (GLint *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -5565,7 +5537,7 @@ android_glTexEnviv__II_3II
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "length - offset < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < needed");
goto exit;
}
params_base = (GLint *)
@@ -5617,7 +5589,7 @@ android_glTexEnviv__IILjava_nio_IntBuffer_2
break;
}
if (_remaining < _needed) {
- _env->ThrowNew(IAEClass, "remaining() < needed");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < needed");
goto exit;
}
glTexEnviv(
@@ -5641,16 +5613,16 @@ android_glTexParameterfv__II_3FI
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfloat *)
@@ -5680,7 +5652,7 @@ android_glTexParameterfv__IILjava_nio_FloatBuffer_2
params = (GLfloat *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameterfv(
@@ -5715,16 +5687,16 @@ android_glTexParameteriv__II_3II
GLint *params = (GLint *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLint *)
@@ -5754,7 +5726,7 @@ android_glTexParameteriv__IILjava_nio_IntBuffer_2
params = (GLint *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameteriv(
@@ -5778,16 +5750,16 @@ android_glTexParameterxv__II_3II
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "length - offset < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 1");
goto exit;
}
params_base = (GLfixed *)
@@ -5817,7 +5789,7 @@ android_glTexParameterxv__IILjava_nio_IntBuffer_2
params = (GLfixed *)getPointer(_env, params_buf, &_array, &_remaining);
if (_remaining < 1) {
- _env->ThrowNew(IAEClass, "remaining() < 1");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 1");
goto exit;
}
glTexParameterxv(
@@ -5875,16 +5847,16 @@ android_glDrawTexfvOES___3FI
GLfloat *coords = (GLfloat *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLfloat *)
@@ -5912,7 +5884,7 @@ android_glDrawTexfvOES__Ljava_nio_FloatBuffer_2
coords = (GLfloat *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexfvOES(
@@ -5947,16 +5919,16 @@ android_glDrawTexivOES___3II
GLint *coords = (GLint *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLint *)
@@ -5984,7 +5956,7 @@ android_glDrawTexivOES__Ljava_nio_IntBuffer_2
coords = (GLint *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexivOES(
@@ -6019,16 +5991,16 @@ android_glDrawTexsvOES___3SI
GLshort *coords = (GLshort *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLshort *)
@@ -6056,7 +6028,7 @@ android_glDrawTexsvOES__Ljava_nio_ShortBuffer_2
coords = (GLshort *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexsvOES(
@@ -6091,16 +6063,16 @@ android_glDrawTexxvOES___3II
GLfixed *coords = (GLfixed *) 0;
if (!coords_ref) {
- _env->ThrowNew(IAEClass, "coords == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "coords == null");
goto exit;
}
if (offset < 0) {
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(coords_ref) - offset;
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "length - offset < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < 5");
goto exit;
}
coords_base = (GLfixed *)
@@ -6128,7 +6100,7 @@ android_glDrawTexxvOES__Ljava_nio_IntBuffer_2
coords = (GLfixed *)getPointer(_env, coords_buf, &_array, &_remaining);
if (_remaining < 5) {
- _env->ThrowNew(IAEClass, "remaining() < 5");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < 5");
goto exit;
}
glDrawTexxvOES(
@@ -6223,7 +6195,7 @@ static void
android_glBindFramebufferOES__II
(JNIEnv *_env, jobject _this, jint target, jint framebuffer) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glBindFramebufferOES");
return;
}
@@ -6238,7 +6210,7 @@ static void
android_glBindRenderbufferOES__II
(JNIEnv *_env, jobject _this, jint target, jint renderbuffer) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glBindRenderbufferOES");
return;
}
@@ -6253,7 +6225,7 @@ static void
android_glBlendEquation__I
(JNIEnv *_env, jobject _this, jint mode) {
if (! supportsExtension(_env, _this, have_OES_blend_subtractID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glBlendEquation");
return;
}
@@ -6267,7 +6239,7 @@ static void
android_glBlendEquationSeparate__II
(JNIEnv *_env, jobject _this, jint modeRGB, jint modeAlpha) {
if (! supportsExtension(_env, _this, have_OES_blend_equation_separateID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glBlendEquationSeparate");
return;
}
@@ -6282,7 +6254,7 @@ static void
android_glBlendFuncSeparate__IIII
(JNIEnv *_env, jobject _this, jint srcRGB, jint dstRGB, jint srcAlpha, jint dstAlpha) {
if (! supportsExtension(_env, _this, have_OES_blend_equation_separateID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glBlendFuncSeparate");
return;
}
@@ -6299,7 +6271,7 @@ static jint
android_glCheckFramebufferStatusOES__I
(JNIEnv *_env, jobject _this, jint target) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glCheckFramebufferStatusOES");
return 0;
}
@@ -6315,7 +6287,7 @@ static void
android_glDeleteFramebuffersOES__I_3II
(JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glDeleteFramebuffersOES");
return;
}
@@ -6326,18 +6298,18 @@ android_glDeleteFramebuffersOES__I_3II
if (!framebuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "framebuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "framebuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(framebuffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
framebuffers_base = (GLuint *)
@@ -6361,7 +6333,7 @@ static void
android_glDeleteFramebuffersOES__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glDeleteFramebuffersOES");
return;
}
@@ -6373,7 +6345,7 @@ android_glDeleteFramebuffersOES__ILjava_nio_IntBuffer_2
framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteFramebuffersOES(
@@ -6392,7 +6364,7 @@ static void
android_glDeleteRenderbuffersOES__I_3II
(JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glDeleteRenderbuffersOES");
return;
}
@@ -6403,18 +6375,18 @@ android_glDeleteRenderbuffersOES__I_3II
if (!renderbuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "renderbuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "renderbuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
renderbuffers_base = (GLuint *)
@@ -6438,7 +6410,7 @@ static void
android_glDeleteRenderbuffersOES__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glDeleteRenderbuffersOES");
return;
}
@@ -6450,7 +6422,7 @@ android_glDeleteRenderbuffersOES__ILjava_nio_IntBuffer_2
renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glDeleteRenderbuffersOES(
@@ -6469,7 +6441,7 @@ static void
android_glFramebufferRenderbufferOES__IIII
(JNIEnv *_env, jobject _this, jint target, jint attachment, jint renderbuffertarget, jint renderbuffer) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glFramebufferRenderbufferOES");
return;
}
@@ -6486,7 +6458,7 @@ static void
android_glFramebufferTexture2DOES__IIIII
(JNIEnv *_env, jobject _this, jint target, jint attachment, jint textarget, jint texture, jint level) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glFramebufferTexture2DOES");
return;
}
@@ -6504,7 +6476,7 @@ static void
android_glGenerateMipmapOES__I
(JNIEnv *_env, jobject _this, jint target) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGenerateMipmapOES");
return;
}
@@ -6518,7 +6490,7 @@ static void
android_glGenFramebuffersOES__I_3II
(JNIEnv *_env, jobject _this, jint n, jintArray framebuffers_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGenFramebuffersOES");
return;
}
@@ -6529,18 +6501,18 @@ android_glGenFramebuffersOES__I_3II
if (!framebuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "framebuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "framebuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(framebuffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
framebuffers_base = (GLuint *)
@@ -6564,7 +6536,7 @@ static void
android_glGenFramebuffersOES__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint n, jobject framebuffers_buf) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGenFramebuffersOES");
return;
}
@@ -6576,7 +6548,7 @@ android_glGenFramebuffersOES__ILjava_nio_IntBuffer_2
framebuffers = (GLuint *)getPointer(_env, framebuffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenFramebuffersOES(
@@ -6595,7 +6567,7 @@ static void
android_glGenRenderbuffersOES__I_3II
(JNIEnv *_env, jobject _this, jint n, jintArray renderbuffers_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGenRenderbuffersOES");
return;
}
@@ -6606,18 +6578,18 @@ android_glGenRenderbuffersOES__I_3II
if (!renderbuffers_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "renderbuffers == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "renderbuffers == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(renderbuffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "length - offset < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "length - offset < n");
goto exit;
}
renderbuffers_base = (GLuint *)
@@ -6641,7 +6613,7 @@ static void
android_glGenRenderbuffersOES__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint n, jobject renderbuffers_buf) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGenRenderbuffersOES");
return;
}
@@ -6653,7 +6625,7 @@ android_glGenRenderbuffersOES__ILjava_nio_IntBuffer_2
renderbuffers = (GLuint *)getPointer(_env, renderbuffers_buf, &_array, &_remaining);
if (_remaining < n) {
_exception = 1;
- _env->ThrowNew(IAEClass, "remaining() < n");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "remaining() < n");
goto exit;
}
glGenRenderbuffersOES(
@@ -6672,7 +6644,7 @@ static void
android_glGetFramebufferAttachmentParameterivOES__III_3II
(JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jintArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetFramebufferAttachmentParameterivOES");
return;
}
@@ -6683,12 +6655,12 @@ android_glGetFramebufferAttachmentParameterivOES__III_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -6715,7 +6687,7 @@ static void
android_glGetFramebufferAttachmentParameterivOES__IIILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint attachment, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetFramebufferAttachmentParameterivOES");
return;
}
@@ -6741,7 +6713,7 @@ static void
android_glGetRenderbufferParameterivOES__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetRenderbufferParameterivOES");
return;
}
@@ -6752,12 +6724,12 @@ android_glGetRenderbufferParameterivOES__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -6783,7 +6755,7 @@ static void
android_glGetRenderbufferParameterivOES__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetRenderbufferParameterivOES");
return;
}
@@ -6808,7 +6780,7 @@ static void
android_glGetTexGenfv__II_3FI
(JNIEnv *_env, jobject _this, jint coord, jint pname, jfloatArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetTexGenfv");
return;
}
@@ -6819,12 +6791,12 @@ android_glGetTexGenfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -6850,7 +6822,7 @@ static void
android_glGetTexGenfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint coord, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetTexGenfv");
return;
}
@@ -6875,7 +6847,7 @@ static void
android_glGetTexGeniv__II_3II
(JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetTexGeniv");
return;
}
@@ -6886,12 +6858,12 @@ android_glGetTexGeniv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -6917,7 +6889,7 @@ static void
android_glGetTexGeniv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint coord, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetTexGeniv");
return;
}
@@ -6942,7 +6914,7 @@ static void
android_glGetTexGenxv__II_3II
(JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetTexGenxv");
return;
}
@@ -6953,12 +6925,12 @@ android_glGetTexGenxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -6984,7 +6956,7 @@ static void
android_glGetTexGenxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint coord, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glGetTexGenxv");
return;
}
@@ -7009,7 +6981,7 @@ static jboolean
android_glIsFramebufferOES__I
(JNIEnv *_env, jobject _this, jint framebuffer) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glIsFramebufferOES");
return JNI_FALSE;
}
@@ -7025,7 +6997,7 @@ static jboolean
android_glIsRenderbufferOES__I
(JNIEnv *_env, jobject _this, jint renderbuffer) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glIsRenderbufferOES");
return JNI_FALSE;
}
@@ -7041,7 +7013,7 @@ static void
android_glRenderbufferStorageOES__IIII
(JNIEnv *_env, jobject _this, jint target, jint internalformat, jint width, jint height) {
if (! supportsExtension(_env, _this, have_OES_framebuffer_objectID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glRenderbufferStorageOES");
return;
}
@@ -7058,7 +7030,7 @@ static void
android_glTexGenf__IIF
(JNIEnv *_env, jobject _this, jint coord, jint pname, jfloat param) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGenf");
return;
}
@@ -7074,7 +7046,7 @@ static void
android_glTexGenfv__II_3FI
(JNIEnv *_env, jobject _this, jint coord, jint pname, jfloatArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGenfv");
return;
}
@@ -7085,12 +7057,12 @@ android_glTexGenfv__II_3FI
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -7116,7 +7088,7 @@ static void
android_glTexGenfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint coord, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGenfv");
return;
}
@@ -7141,7 +7113,7 @@ static void
android_glTexGeni__III
(JNIEnv *_env, jobject _this, jint coord, jint pname, jint param) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGeni");
return;
}
@@ -7157,7 +7129,7 @@ static void
android_glTexGeniv__II_3II
(JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGeniv");
return;
}
@@ -7168,12 +7140,12 @@ android_glTexGeniv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -7199,7 +7171,7 @@ static void
android_glTexGeniv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint coord, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGeniv");
return;
}
@@ -7224,7 +7196,7 @@ static void
android_glTexGenx__III
(JNIEnv *_env, jobject _this, jint coord, jint pname, jint param) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGenx");
return;
}
@@ -7240,7 +7212,7 @@ static void
android_glTexGenxv__II_3II
(JNIEnv *_env, jobject _this, jint coord, jint pname, jintArray params_ref, jint offset) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGenxv");
return;
}
@@ -7251,12 +7223,12 @@ android_glTexGenxv__II_3II
if (!params_ref) {
_exception = 1;
- _env->ThrowNew(IAEClass, "params == null");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "params == null");
goto exit;
}
if (offset < 0) {
_exception = 1;
- _env->ThrowNew(IAEClass, "offset < 0");
+ jniThrowException(_env, "java/lang/IllegalArgumentException", "offset < 0");
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
@@ -7282,7 +7254,7 @@ static void
android_glTexGenxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint coord, jint pname, jobject params_buf) {
if (! supportsExtension(_env, _this, have_OES_texture_cube_mapID)) {
- _env->ThrowNew(UOEClass,
+ jniThrowException(_env, "java/lang/UnsupportedOperationException",
"glTexGenxv");
return;
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 2a4d1b2..7f18121 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -607,6 +607,13 @@
android:label="@string/permlab_reorderTasks"
android:description="@string/permdesc_reorderTasks" />
+ <!-- Allows an application to change to remove/kill tasks -->
+ <permission android:name="android.permission.REMOVE_TASKS"
+ android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
+ android:protectionLevel="signature"
+ android:label="@string/permlab_removeTasks"
+ android:description="@string/permdesc_removeTasks" />
+
<!-- Allows an application to modify the current configuration, such
as locale. -->
<permission android:name="android.permission.CHANGE_CONFIGURATION"
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 80beaa5..9b04f78 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1169,6 +1169,10 @@
component specific values). -->
<attr name="enabled" />
<attr name="exported" />
+ <!-- If set to true, this service with be automatically stopped
+ when the user remove a task rooted in an activity owned by
+ the application. The default is false. -->
+ <attr name="stopWithTask" format="boolean" />
</declare-styleable>
<!-- The <code>receiver</code> tag declares an
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index d5c374d..778d934 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1656,6 +1656,7 @@
<public type="attr" name="state_hovered" />
<public type="attr" name="state_drag_can_accept" />
<public type="attr" name="state_drag_hovered" />
+ <public type="attr" name="stopWithTask" />
<public type="style" name="Theme.Holo.Light.NoActionBar" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 8ef9a3b..bc419ec 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -506,6 +506,13 @@
tasks to the foreground and background. Malicious applications can force
themselves to the front without your control.</string>
+ <!-- Title of an application permission, allowing an application to remove/kill tasks -->
+ <string name="permlab_removeTasks">stop running applications</string>
+ <!-- Description of an application permission, allowing an application to remove/kill tasks -->
+ <string name="permdesc_removeTasks">Allows an application to remove
+ tasks and kill their applications. Malicious applications can disrupt
+ the behavior of other applications.</string>
+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_setDebugApp">enable application debugging</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java
index 3667c7b..d22356d 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/AccessPointParserHelper.java
@@ -182,6 +182,7 @@ public class AccessPointParserHelper {
}
config.proxySettings = ProxySettings.NONE;
networks.add(config);
+ mLinkProperties = null;
}
}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
index e138200..adf1883 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
@@ -242,10 +242,10 @@ public class ConnectivityManagerTestActivity extends Activity {
initializeNetworkStates();
- if (mWifiManager.isWifiEnabled()) {
- log("Clear Wifi before we start the test.");
- removeConfiguredNetworksAndDisableWifi();
- }
+ mWifiManager.setWifiEnabled(true);
+ log("Clear Wifi before we start the test.");
+ sleep(SHORT_TIMEOUT);
+ removeConfiguredNetworksAndDisableWifi();
mWifiRegexs = mCM.getTetherableWifiRegexs();
}
@@ -633,13 +633,13 @@ public class ConnectivityManagerTestActivity extends Activity {
* Disconnect from the current AP and remove configured networks.
*/
public boolean disconnectAP() {
- if (mWifiManager.isWifiEnabled()) {
- // remove saved networks
- List<WifiConfiguration> wifiConfigList = mWifiManager.getConfiguredNetworks();
- for (WifiConfiguration wifiConfig: wifiConfigList) {
- log("remove wifi configuration: " + wifiConfig.toString());
- mWifiManager.forgetNetwork(wifiConfig.networkId);
- }
+ // remove saved networks
+ List<WifiConfiguration> wifiConfigList = mWifiManager.getConfiguredNetworks();
+ log("size of wifiConfigList: " + wifiConfigList.size());
+ for (WifiConfiguration wifiConfig: wifiConfigList) {
+ log("remove wifi configuration: " + wifiConfig.networkId);
+ int netId = wifiConfig.networkId;
+ mWifiManager.forgetNetwork(netId);
}
return true;
}
@@ -655,20 +655,23 @@ public class ConnectivityManagerTestActivity extends Activity {
* Remove configured networks and disable wifi
*/
public boolean removeConfiguredNetworksAndDisableWifi() {
- if (!disconnectAP()) {
- return false;
- }
- // Disable Wifi
- if (!mWifiManager.setWifiEnabled(false)) {
- return false;
- }
- // Wait for the actions to be completed
- try {
- Thread.sleep(SHORT_TIMEOUT);
- } catch (InterruptedException e) {}
+ if (!disconnectAP()) {
+ return false;
+ }
+ sleep(SHORT_TIMEOUT);
+ if (!mWifiManager.setWifiEnabled(false)) {
+ return false;
+ }
+ sleep(SHORT_TIMEOUT);
return true;
}
+ private void sleep(long sleeptime) {
+ try {
+ Thread.sleep(sleeptime);
+ } catch (InterruptedException e) {}
+ }
+
/**
* Set airplane mode
*/
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
index fe79e6c..22b1759 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
@@ -72,10 +72,8 @@ public class WifiConnectionTest
@Override
public void setUp() throws Exception {
super.setUp();
- log("before we launch the test activity, we preserve all the configured networks.");
mRunner = ((ConnectivityManagerTestRunner)getInstrumentation());
mWifiManager = (WifiManager) mRunner.getContext().getSystemService(Context.WIFI_SERVICE);
- enabledNetworks = getEnabledNetworks(mWifiManager.getConfiguredNetworks());
mAct = getActivity();
mWifiManager.asyncConnect(mAct, new WifiServiceHandler());
@@ -123,42 +121,9 @@ public class WifiConnectionTest
public void tearDown() throws Exception {
log("tearDown()");
mAct.removeConfiguredNetworksAndDisableWifi();
- reEnableNetworks(enabledNetworks);
super.tearDown();
}
- private Set<WifiConfiguration> getEnabledNetworks(List<WifiConfiguration> configuredNetworks) {
- Set<WifiConfiguration> networks = new HashSet<WifiConfiguration>();
- for (WifiConfiguration wifiConfig : configuredNetworks) {
- if (wifiConfig.status == Status.ENABLED || wifiConfig.status == Status.CURRENT) {
- networks.add(wifiConfig);
- log("remembering enabled network " + wifiConfig.SSID +
- " status is " + wifiConfig.status);
- }
- }
- return networks;
- }
-
- private void reEnableNetworks(Set<WifiConfiguration> enabledNetworks) {
- if (!mWifiManager.isWifiEnabled()) {
- log("reEnableNetworks: enable Wifi");
- mWifiManager.setWifiEnabled(true);
- sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT,
- "interruped while waiting for wifi to be enabled");
- }
-
- for (WifiConfiguration config : enabledNetworks) {
- if (DEBUG) {
- log("recover wifi configuration: " + config.toString());
- }
- config.SSID = "\"" + config.SSID + "\"";
- config.networkId = -1;
- mWifiManager.connectNetwork(config);
- sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT,
- "interruped while connecting to " + config.SSID);
- }
- }
-
/**
* Connect to the provided Wi-Fi network
* @param config is the network configuration
diff --git a/core/tests/overlaytests/Android.mk b/core/tests/overlaytests/Android.mk
new file mode 100644
index 0000000..bf69442
--- /dev/null
+++ b/core/tests/overlaytests/Android.mk
@@ -0,0 +1,4 @@
+# Dummy makefile to halt recursive directory traversal.
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
diff --git a/core/tests/overlaytests/OverlayTest/Android.mk b/core/tests/overlaytests/OverlayTest/Android.mk
new file mode 100644
index 0000000..f7f67f6
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_PACKAGE_NAME := OverlayTest
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/OverlayTest/AndroidManifest.xml b/core/tests/overlaytests/OverlayTest/AndroidManifest.xml
new file mode 100644
index 0000000..9edba12
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/AndroidManifest.xml
@@ -0,0 +1,10 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest">
+ <uses-permission android:name="android.permission.RUN_INSTRUMENTATION"/>
+ <application>
+ <uses-library android:name="android.test.runner"/>
+ </application>
+ <instrumentation android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.android.overlaytest"
+ android:label="Runtime resource overlay tests"/>
+</manifest>
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java
new file mode 100644
index 0000000..85b49ce
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/OverlayBaseTest.java
@@ -0,0 +1,118 @@
+package com.android.overlaytest;
+
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.test.AndroidTestCase;
+import java.io.InputStream;
+import java.util.Locale;
+
+public abstract class OverlayBaseTest extends AndroidTestCase {
+ private Resources mResources;
+ protected boolean mWithOverlay; // will be set by subclasses
+
+ protected void setUp() {
+ mResources = getContext().getResources();
+ }
+
+ private int calculateRawResourceChecksum(int resId) throws Throwable {
+ InputStream input = null;
+ try {
+ input = mResources.openRawResource(resId);
+ int ch, checksum = 0;
+ while ((ch = input.read()) != -1) {
+ checksum = (checksum + ch) % 0xffddbb00;
+ }
+ return checksum;
+ } finally {
+ input.close();
+ }
+ }
+
+ private void setLocale(String code) {
+ Locale locale = new Locale(code);
+ Locale.setDefault(locale);
+ Configuration config = new Configuration();
+ config.locale = locale;
+ mResources.updateConfiguration(config, mResources.getDisplayMetrics());
+ }
+
+ private void assertResource(int resId, boolean ewo, boolean ew) throws Throwable {
+ boolean expected = mWithOverlay ? ew : ewo;
+ boolean actual = mResources.getBoolean(resId);
+ assertEquals(expected, actual);
+ }
+
+ private void assertResource(int resId, String ewo, String ew) throws Throwable {
+ String expected = mWithOverlay ? ew : ewo;
+ String actual = mResources.getString(resId);
+ assertEquals(expected, actual);
+ }
+
+ private void assertResource(int resId, int[] ewo, int[] ew) throws Throwable {
+ int[] expected = mWithOverlay ? ew : ewo;
+ int[] actual = mResources.getIntArray(resId);
+ assertEquals("length:", expected.length, actual.length);
+ for (int i = 0; i < actual.length; ++i) {
+ assertEquals("index " + i + ":", actual[i], expected[i]);
+ }
+ }
+
+ public void testBooleanOverlay() throws Throwable {
+ // config_automatic_brightness_available has overlay (default config)
+ final int resId = com.android.internal.R.bool.config_automatic_brightness_available;
+ assertResource(resId, false, true);
+ }
+
+ public void testBoolean() throws Throwable {
+ // config_bypass_keyguard_if_slider_open has no overlay
+ final int resId = com.android.internal.R.bool.config_bypass_keyguard_if_slider_open;
+ assertResource(resId, true, true);
+ }
+
+ public void testStringOverlay() throws Throwable {
+ // phoneTypeCar has an overlay (default config), which shouldn't shadow
+ // the Swedish translation
+ final int resId = com.android.internal.R.string.phoneTypeCar;
+ setLocale("sv_SE");
+ assertResource(resId, "Bil", "Bil");
+ }
+
+ public void testStringSwedishOverlay() throws Throwable {
+ // phoneTypeWork has overlay (no default config, only for lang=sv)
+ final int resId = com.android.internal.R.string.phoneTypeWork;
+ setLocale("en_US");
+ assertResource(resId, "Work", "Work");
+ setLocale("sv_SE");
+ assertResource(resId, "Arbete", "Jobb");
+ }
+
+ public void testString() throws Throwable {
+ // phoneTypeHome has no overlay
+ final int resId = com.android.internal.R.string.phoneTypeHome;
+ setLocale("en_US");
+ assertResource(resId, "Home", "Home");
+ setLocale("sv_SE");
+ assertResource(resId, "Hem", "Hem");
+ }
+
+ public void testIntegerArrayOverlay() throws Throwable {
+ // config_scrollBarrierVibePattern has overlay (default config)
+ final int resId = com.android.internal.R.array.config_scrollBarrierVibePattern;
+ assertResource(resId, new int[]{0, 15, 10, 10}, new int[]{100, 200, 300});
+ }
+
+ public void testIntegerArray() throws Throwable {
+ // config_virtualKeyVibePattern has no overlay
+ final int resId = com.android.internal.R.array.config_virtualKeyVibePattern;
+ final int[] expected = {0, 10, 20, 30};
+ assertResource(resId, expected, expected);
+ }
+
+ public void testAsset() throws Throwable {
+ // drawable/default_background.jpg has overlay (default config)
+ final int resId = com.android.internal.R.drawable.default_wallpaper;
+ int actual = calculateRawResourceChecksum(resId);
+ int expected = mWithOverlay ? 0x000051da : 0x0014ebce;
+ assertEquals(expected, actual);
+ }
+}
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
new file mode 100644
index 0000000..1292d03
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithOverlayTest.java
@@ -0,0 +1,7 @@
+package com.android.overlaytest;
+
+public class WithOverlayTest extends OverlayBaseTest {
+ public WithOverlayTest() {
+ mWithOverlay = true;
+ }
+}
diff --git a/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
new file mode 100644
index 0000000..630ff8f
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTest/src/com/android/overlaytest/WithoutOverlayTest.java
@@ -0,0 +1,7 @@
+package com.android.overlaytest;
+
+public class WithoutOverlayTest extends OverlayBaseTest {
+ public WithoutOverlayTest() {
+ mWithOverlay = false;
+ }
+}
diff --git a/core/tests/overlaytests/OverlayTestOverlay/Android.mk b/core/tests/overlaytests/OverlayTestOverlay/Android.mk
new file mode 100644
index 0000000..cf32c9f
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTestOverlay/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_PACKAGE_NAME := com.android.overlaytest.overlay
+
+LOCAL_AAPT_FLAGS := -o
+
+include $(BUILD_PACKAGE)
diff --git a/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml b/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml
new file mode 100644
index 0000000..bcbb0d1
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTestOverlay/AndroidManifest.xml
@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.overlaytest.overlay"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <overlay-package android:name="android"/>
+</manifest>
diff --git a/core/tests/overlaytests/OverlayTestOverlay/res/drawable/default_wallpaper.jpg b/core/tests/overlaytests/OverlayTestOverlay/res/drawable/default_wallpaper.jpg
new file mode 100644
index 0000000..0d944d0
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTestOverlay/res/drawable/default_wallpaper.jpg
Binary files differ
diff --git a/core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml b/core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml
new file mode 100644
index 0000000..bc52367
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTestOverlay/res/values-sv/config.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="phoneTypeWork">Jobb</string>
+</resources>
diff --git a/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml b/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml
new file mode 100644
index 0000000..794f475
--- /dev/null
+++ b/core/tests/overlaytests/OverlayTestOverlay/res/values/config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <bool name="config_automatic_brightness_available">true</bool>
+ <string name="phoneTypeCar">Automobile</string>
+ <integer-array name="config_scrollBarrierVibePattern">
+ <item>100</item>
+ <item>200</item>
+ <item>300</item>
+ </integer-array>
+ <!-- The following integer does not exist in the original package. Idmap
+ generation should therefore ignore it. -->
+ <integer name="integer_not_in_original_package">0</integer>
+</resources>
diff --git a/core/tests/overlaytests/README b/core/tests/overlaytests/README
new file mode 100644
index 0000000..4b3e6f2
--- /dev/null
+++ b/core/tests/overlaytests/README
@@ -0,0 +1,15 @@
+Unit tests for runtime resource overlay
+=======================================
+
+As of this writing, runtime resource overlay is only triggered for
+/system/framework/framework-res.apk. Because of this, installation of
+overlay packages require the Android platform be rebooted. However, the
+regular unit tests (triggered via development/testrunner/runtest.py)
+cannot handle reboots. As a workaround, this directory contains a shell
+script which will trigger the tests in a non-standard way.
+
+Once runtime resource overlay may be applied to applications, the tests
+in this directory should be moved to core/tests/coretests. Also, by
+applying runtime resource overlay to a dedicated test application, the
+test cases would not need to assume default values for non-overlaid
+resources.
diff --git a/core/tests/overlaytests/runtests.sh b/core/tests/overlaytests/runtests.sh
new file mode 100755
index 0000000..0ad9efb
--- /dev/null
+++ b/core/tests/overlaytests/runtests.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+adb="adb"
+if [[ $# -gt 0 ]]; then
+ adb="adb $*" # for setting -e, -d or -s <serial>
+fi
+
+function atexit()
+{
+ local retval=$?
+
+ if [[ $retval -eq 0 ]]; then
+ rm $log
+ else
+ echo "There were errors, please check log at $log"
+ fi
+}
+
+log=$(mktemp)
+trap "atexit" EXIT
+failures=0
+
+function compile_module()
+{
+ local android_mk="$1"
+
+ echo "Compiling .${android_mk:${#PWD}}"
+ ONE_SHOT_MAKEFILE="$android_mk" make -C "../../../../../" files | tee -a $log
+ if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+ exit 1
+ fi
+}
+
+function wait_for_boot_completed()
+{
+ echo "Rebooting device"
+ $adb wait-for-device logcat -c
+ $adb wait-for-device logcat | grep -m 1 -e 'PowerManagerService.*bootCompleted' >/dev/null
+}
+
+function disable_overlay()
+{
+ echo "Disabling overlay"
+ $adb shell rm /vendor/overlay/framework/framework-res.apk
+ $adb shell rm /data/resource-cache/vendor@overlay@framework@framework-res.apk@idmap
+}
+
+function enable_overlay()
+{
+ echo "Enabling overlay"
+ $adb shell ln -s /data/app/com.android.overlaytest.overlay.apk /vendor/overlay/framework/framework-res.apk
+}
+
+function instrument()
+{
+ local class="$1"
+
+ echo "Instrumenting $class"
+ $adb shell am instrument -w -e class $class com.android.overlaytest/android.test.InstrumentationTestRunner | tee -a $log
+}
+
+function sync()
+{
+ echo "Syncing to device"
+ $adb remount | tee -a $log
+ $adb sync data | tee -a $log
+}
+
+# build and sync
+compile_module "$PWD/OverlayTest/Android.mk"
+compile_module "$PWD/OverlayTestOverlay/Android.mk"
+sync
+
+# instrument test (without overlay)
+$adb shell stop
+disable_overlay
+$adb shell start
+wait_for_boot_completed
+instrument "com.android.overlaytest.WithoutOverlayTest"
+
+# instrument test (with overlay)
+$adb shell stop
+enable_overlay
+$adb shell start
+wait_for_boot_completed
+instrument "com.android.overlaytest.WithOverlayTest"
+
+# cleanup
+exit $(grep -c -e '^FAILURES' $log)