diff options
170 files changed, 5468 insertions, 2960 deletions
diff --git a/api/current.txt b/api/current.txt index e946c06..4d3f8c6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -87,6 +87,7 @@ package android { field public static final java.lang.String RECEIVE_SMS = "android.permission.RECEIVE_SMS"; field public static final java.lang.String RECEIVE_WAP_PUSH = "android.permission.RECEIVE_WAP_PUSH"; field public static final java.lang.String RECORD_AUDIO = "android.permission.RECORD_AUDIO"; + field public static final java.lang.String REMOVE_TASKS = "android.permission.REMOVE_TASKS"; field public static final java.lang.String REORDER_TASKS = "android.permission.REORDER_TASKS"; field public static final deprecated java.lang.String RESTART_PACKAGES = "android.permission.RESTART_PACKAGES"; field public static final java.lang.String SEND_SMS = "android.permission.SEND_SMS"; @@ -855,6 +856,7 @@ package android { field public static final int state_window_focused = 16842909; // 0x101009d field public static final int staticWallpaperPreview = 16843569; // 0x1010331 field public static final int stepSize = 16843078; // 0x1010146 + field public static final int stopWithTask = 16843623; // 0x1010367 field public static final int streamType = 16843273; // 0x1010209 field public static final int stretchColumns = 16843081; // 0x1010149 field public static final int stretchMode = 16843030; // 0x1010116 @@ -929,9 +931,9 @@ package android { field public static final int textEditPasteWindowLayout = 16843540; // 0x1010314 field public static final int textEditSideNoPasteWindowLayout = 16843615; // 0x101035f field public static final int textEditSidePasteWindowLayout = 16843614; // 0x101035e - field public static final int textEditSuggestionItemLayout = 16843626; // 0x101036a - field public static final int textEditSuggestionsBottomWindowLayout = 16843624; // 0x1010368 - field public static final int textEditSuggestionsTopWindowLayout = 16843625; // 0x1010369 + field public static final int textEditSuggestionItemLayout = 16843627; // 0x101036b + field public static final int textEditSuggestionsBottomWindowLayout = 16843625; // 0x1010369 + field public static final int textEditSuggestionsTopWindowLayout = 16843626; // 0x101036a field public static final int textFilterEnabled = 16843007; // 0x10100ff field public static final int textIsSelectable = 16843542; // 0x1010316 field public static final int textOff = 16843045; // 0x1010125 @@ -943,7 +945,7 @@ package android { field public static final int textSelectHandleWindowStyle = 16843464; // 0x10102c8 field public static final int textSize = 16842901; // 0x1010095 field public static final int textStyle = 16842903; // 0x1010097 - field public static final int textSuggestionsWindowStyle = 16843623; // 0x1010367 + field public static final int textSuggestionsWindowStyle = 16843624; // 0x1010368 field public static final int textViewStyle = 16842884; // 0x1010084 field public static final int theme = 16842752; // 0x1010000 field public static final int thickness = 16843360; // 0x1010260 @@ -3384,6 +3386,7 @@ package android.app { method public void onRebind(android.content.Intent); method public deprecated void onStart(android.content.Intent, int); method public int onStartCommand(android.content.Intent, int, int); + method public void onTaskRemoved(android.content.Intent); method public boolean onUnbind(android.content.Intent); method public final void startForeground(int, android.app.Notification); method public final void stopForeground(boolean); @@ -5840,6 +5843,8 @@ package android.content.pm { method public int describeContents(); method public void dump(android.util.Printer, java.lang.String); field public static final android.os.Parcelable.Creator CREATOR; + field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1 + field public int flags; field public java.lang.String permission; } diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 1b4ef0d..fca6868 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -16,6 +16,9 @@ package android.app; +import com.android.internal.app.IUsageStats; +import com.android.internal.os.PkgUsageStats; + import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -26,17 +29,15 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.os.Debug; -import android.os.RemoteException; import android.os.Handler; import android.os.Parcel; import android.os.Parcelable; +import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; -import com.android.internal.app.IUsageStats; -import com.android.internal.os.PkgUsageStats; import java.util.ArrayList; import java.util.HashMap; @@ -204,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. * @@ -240,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. @@ -395,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; @@ -404,9 +447,6 @@ public class ActivityManager { /** @hide */ public IThumbnailRetriever retriever; - /** @hide Magic for ActivityManagerService. Not marshalled */ - public ArrayList<Bitmap> otherThumbnails; - public TaskThumbnails() { } @@ -676,7 +716,7 @@ public class ActivityManager { public List<RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException { try { - return (List<RunningServiceInfo>)ActivityManagerNative.getDefault() + return ActivityManagerNative.getDefault() .getServices(maxNum, 0); } catch (RemoteException e) { // System dead, we will be dead too soon! @@ -1331,4 +1371,17 @@ public class ActivityManager { return new HashMap<String, Integer>(); } } + + /** + * @param userid the user's id. Zero indicates the default user + * @hide + */ + public boolean switchUser(int userid) { + try { + return ActivityManagerNative.getDefault().switchUser(userid); + } catch (RemoteException e) { + return false; + } + } + } diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 5fbc70f..4b09b34c 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1397,6 +1397,37 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } + case SWITCH_USER_TRANSACTION: { + data.enforceInterface(IActivityManager.descriptor); + int userid = data.readInt(); + boolean result = switchUser(userid); + reply.writeNoException(); + 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; + } + } return super.onTransact(code, data, reply, flags); @@ -3141,5 +3172,46 @@ class ActivityManagerProxy implements IActivityManager return result; } + public boolean switchUser(int userid) throws RemoteException { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeInterfaceToken(IActivityManager.descriptor); + data.writeInt(userid); + mRemote.transact(SWITCH_USER_TRANSACTION, data, reply, 0); + reply.readException(); + boolean result = reply.readInt() != 0; + reply.recycle(); + 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/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 50e56c7..ef8ba8e 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -33,13 +33,13 @@ import android.content.pm.IPackageMoveObserver; import android.content.pm.IPackageStatsObserver; import android.content.pm.InstrumentationInfo; import android.content.pm.PackageInfo; -import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager; import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.content.pm.UserInfo; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; @@ -1106,6 +1106,56 @@ final class ApplicationPackageManager extends PackageManager { return PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; } + // Multi-user support + + /** + * @hide + */ + @Override + public UserInfo createUser(String name, int flags) { + // TODO + return null; + } + + /** + * @hide + */ + @Override + public List<UserInfo> getUsers() { + // TODO: + // Dummy code, always returns just the primary user + ArrayList<UserInfo> users = new ArrayList<UserInfo>(); + UserInfo primary = new UserInfo(0, "Root!", + UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY); + users.add(primary); + return users; + } + + /** + * @hide + */ + @Override + public boolean removeUser(int id) { + // TODO: + return false; + } + + /** + * @hide + */ + @Override + public void updateUserName(int id, String name) { + // TODO: + } + + /** + * @hide + */ + @Override + public void updateUserFlags(int id, int flags) { + // TODO: + } + private final ContextImpl mContext; private final IPackageManager mPM; 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 cd26a62..bec697a 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -342,6 +342,13 @@ public interface IActivityManager extends IInterface { public int startActivitiesInPackage(int uid, Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException; + // 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 */ @@ -557,4 +564,7 @@ public interface IActivityManager extends IInterface { int START_ACTIVITIES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+120; 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/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 80bed0d..99c4c7f 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -150,21 +150,21 @@ public abstract class PackageManager { * {@link PackageInfo#permissions}. */ public static final int GET_PERMISSIONS = 0x00001000; - + /** * Flag parameter to retrieve all applications(even uninstalled ones) with data directories. - * This state could have resulted if applications have been deleted with flag + * This state could have resulted if applications have been deleted with flag * DONT_DELETE_DATA * with a possibility of being replaced or reinstalled in future */ public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; - + /** * {@link PackageInfo} flag: return information about * hardware preferences in * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and * requested features in {@link PackageInfo#reqFeatures - * PackageInfo.reqFeatures}. + * PackageInfo.reqFeatures}. */ public static final int GET_CONFIGURATIONS = 0x00004000; @@ -244,7 +244,7 @@ public abstract class PackageManager { public static final int INSTALL_REPLACE_EXISTING = 0x00000002; /** - * Flag parameter for {@link #installPackage} to indicate that you want to + * Flag parameter for {@link #installPackage} to indicate that you want to * allow test packages (those that have set android:testOnly in their * manifest) to be installed. * @hide @@ -555,7 +555,7 @@ public abstract class PackageManager { * Return code for when package deletion succeeds. This is passed to the * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system * succeeded in deleting the package. - * + * * @hide */ public static final int DELETE_SUCCEEDED = 1; @@ -564,7 +564,7 @@ public abstract class PackageManager { * Deletion failed return code: this is passed to the * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system * failed to delete the package for an unspecified reason. - * + * * @hide */ public static final int DELETE_FAILED_INTERNAL_ERROR = -1; @@ -574,7 +574,7 @@ public abstract class PackageManager { * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system * failed to delete the package because it is the active DevicePolicy * manager. - * + * * @hide */ public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; @@ -583,7 +583,7 @@ public abstract class PackageManager { * Return code that is passed to the {@link IPackageMoveObserver} by * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the * package has been successfully moved by the system. - * + * * @hide */ public static final int MOVE_SUCCEEDED = 1; @@ -641,7 +641,7 @@ public abstract class PackageManager { * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the * specified package already has an operation pending in the * {@link PackageHandler} queue. - * + * * @hide */ public static final int MOVE_FAILED_OPERATION_PENDING = -7; @@ -789,7 +789,7 @@ public abstract class PackageManager { */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; - + /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device has a telephony radio with data @@ -797,14 +797,14 @@ public abstract class PackageManager { */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; - + /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device has a CDMA telephony stack. */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; - + /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device has a GSM telephony stack. @@ -847,8 +847,8 @@ public abstract class PackageManager { */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; - - + + /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device's touch screen supports @@ -856,7 +856,7 @@ public abstract class PackageManager { */ @SdkConstant(SdkConstantType.FEATURE) public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; - + /** * Feature for {@link #getSystemAvailableFeatures} and * {@link #hasSystemFeature}: The device's touch screen is capable of @@ -932,11 +932,11 @@ public abstract class PackageManager { * @return Returns a PackageInfo object containing information about the package. * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not * found in the list of installed applications, the package information is - * retrieved from the list of uninstalled applications(which includes + * retrieved from the list of uninstalled applications(which includes * installed applications as well as applications * with data directory ie applications which had been * deleted with DONT_DELTE_DATA flag set). - * + * * @see #GET_ACTIVITIES * @see #GET_GIDS * @see #GET_CONFIGURATIONS @@ -947,7 +947,7 @@ public abstract class PackageManager { * @see #GET_SERVICES * @see #GET_SIGNATURES * @see #GET_UNINSTALLED_PACKAGES - * + * */ public abstract PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException; @@ -960,7 +960,7 @@ public abstract class PackageManager { * the canonical name for each package. */ public abstract String[] currentToCanonicalPackageNames(String[] names); - + /** * Map from a packages canonical name to the current name in use on the device. * @param names Array of new names to be mapped. @@ -968,7 +968,7 @@ public abstract class PackageManager { * the current name for each package. */ public abstract String[] canonicalToCurrentPackageNames(String[] names); - + /** * Return a "good" intent to launch a front-door activity in a package, * for use for example to implement an "open" button when browsing through @@ -976,12 +976,12 @@ public abstract class PackageManager { * activity in the category {@link Intent#CATEGORY_INFO}, next for a * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return * null if neither are found. - * + * * <p>Throws {@link NameNotFoundException} if a package with the given * name can not be found on the system. * * @param packageName The name of the package to inspect. - * + * * @return Returns either a fully-qualified Intent that can be used to * launch the main activity in the package, or null if the package does * not contain such an activity. @@ -1077,16 +1077,16 @@ public abstract class PackageManager { * * @param packageName The full name (i.e. com.google.apps.contacts) of an * application. - * @param flags Additional option flags. Use any combination of + * @param flags Additional option flags. Use any combination of * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. * - * @return {@link ApplicationInfo} Returns ApplicationInfo object containing + * @return {@link ApplicationInfo} Returns ApplicationInfo object containing * information about the package. * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not - * found in the list of installed applications, - * the application information is retrieved from the - * list of uninstalled applications(which includes + * found in the list of installed applications, + * the application information is retrieved from the + * list of uninstalled applications(which includes * installed applications as well as applications * with data directory ie applications which had been * deleted with DONT_DELTE_DATA flag set). @@ -1108,7 +1108,7 @@ public abstract class PackageManager { * @param component The full component name (i.e. * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity * class. - * @param flags Additional option flags. Use any combination of + * @param flags Additional option flags. Use any combination of * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, * to modify the data (in ApplicationInfo) returned. * @@ -1131,7 +1131,7 @@ public abstract class PackageManager { * @param component The full component name (i.e. * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver * class. - * @param flags Additional option flags. Use any combination of + * @param flags Additional option flags. Use any combination of * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, * to modify the data returned. * @@ -1154,12 +1154,12 @@ public abstract class PackageManager { * @param component The full component name (i.e. * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service * class. - * @param flags Additional option flags. Use any combination of + * @param flags Additional option flags. Use any combination of * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, * to modify the data returned. * * @return ServiceInfo containing information about the service. - * + * * @see #GET_META_DATA * @see #GET_SHARED_LIBRARY_FILES */ @@ -1206,7 +1206,7 @@ public abstract class PackageManager { * * @return A List of PackageInfo objects, one for each package that is * installed on the device. In the unlikely case of there being no - * installed packages, an empty list is returned. + * installed packages, an empty list is returned. * If flag GET_UNINSTALLED_PACKAGES is set, a list of all * applications including those deleted with DONT_DELETE_DATA * (partially installed apps with data directory) will be returned. @@ -1221,7 +1221,7 @@ public abstract class PackageManager { * @see #GET_SERVICES * @see #GET_SIGNATURES * @see #GET_UNINSTALLED_PACKAGES - * + * */ public abstract List<PackageInfo> getInstalledPackages(int flags); @@ -1283,7 +1283,7 @@ public abstract class PackageManager { * the device is rebooted before it is written. */ public abstract boolean addPermissionAsync(PermissionInfo info); - + /** * Removes a permission that was previously added with * {@link #addPermission(PermissionInfo)}. The same ownership rules apply @@ -1370,7 +1370,7 @@ public abstract class PackageManager { * user id is not currently assigned. */ public abstract String getNameForUid(int uid); - + /** * Return the user id associated with a shared user name. Multiple * applications can specify a shared user name in their manifest and thus @@ -1391,38 +1391,38 @@ public abstract class PackageManager { * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all * applications including those deleted with DONT_DELETE_DATA(partially * installed apps with data directory) will be returned. - * - * @param flags Additional option flags. Use any combination of + * + * @param flags Additional option flags. Use any combination of * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned. * * @return A List of ApplicationInfo objects, one for each application that * is installed on the device. In the unlikely case of there being - * no installed applications, an empty list is returned. + * no installed applications, an empty list is returned. * If flag GET_UNINSTALLED_PACKAGES is set, a list of all * applications including those deleted with DONT_DELETE_DATA * (partially installed apps with data directory) will be returned. - * + * * @see #GET_META_DATA * @see #GET_SHARED_LIBRARY_FILES * @see #GET_UNINSTALLED_PACKAGES */ public abstract List<ApplicationInfo> getInstalledApplications(int flags); - + /** * Get a list of shared libraries that are available on the * system. - * + * * @return An array of shared library names that are * available on the system, or null if none are installed. - * + * */ public abstract String[] getSystemSharedLibraryNames(); /** * Get a list of features that are available on the * system. - * + * * @return An array of FeatureInfo classes describing the features * that are available on the system, or null if there are none(!!). */ @@ -1431,7 +1431,7 @@ public abstract class PackageManager { /** * Check whether the given feature name is one of the available * features as returned by {@link #getSystemAvailableFeatures()}. - * + * * @return Returns true if the devices supports the feature, else * false. */ @@ -1448,7 +1448,7 @@ public abstract class PackageManager { * that {@link android.content.Context#startActivity(Intent)} and * {@link android.content.Intent#resolveActivity(PackageManager) * Intent.resolveActivity(PackageManager)} do.</p> - * + * * @param intent An intent containing all of the desired specification * (action, data, type, category, and/or component). * @param flags Additional option flags. The most important is @@ -1747,7 +1747,7 @@ public abstract class PackageManager { * * @return Returns the image of the logo or null if the activity has no * logo specified. - * + * * @throws NameNotFoundException Thrown if the resources for the given * activity could not be loaded. * @@ -1768,7 +1768,7 @@ public abstract class PackageManager { * * @return Returns the image of the logo, or null if the activity has no * logo specified. - * + * * @throws NameNotFoundException Thrown if the resources for application * matching the given intent could not be loaded. * @@ -1801,7 +1801,7 @@ public abstract class PackageManager { * * @return Returns the image of the logo, or null if no application logo * has been specified. - * + * * @throws NameNotFoundException Thrown if the resources for the given * application could not be loaded. * @@ -1935,7 +1935,7 @@ public abstract class PackageManager { * @see #GET_RECEIVERS * @see #GET_SERVICES * @see #GET_SIGNATURES - * + * */ public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { PackageParser packageParser = new PackageParser(archiveFilePath); @@ -1952,7 +1952,7 @@ public abstract class PackageManager { /** * @hide - * + * * Install a package. Since this may take a little while, the result will * be posted back to the given observer. An installation will fail if the calling context * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the @@ -2012,11 +2012,11 @@ public abstract class PackageManager { /** * Retrieve the package name of the application that installed a package. This identifies * which market the package came from. - * + * * @param packageName The name of the package to query */ public abstract String getInstallerPackageName(String packageName); - + /** * Attempts to clear the user data directory of an application. * Since this may take a little while, the result will @@ -2071,7 +2071,7 @@ public abstract class PackageManager { * of bytes if possible. * @param observer call back used to notify when * the operation is completed - * + * * @hide */ public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); @@ -2096,7 +2096,7 @@ public abstract class PackageManager { * @param pi IntentSender call back used to * notify when the operation is completed.May be null * to indicate that no call back is desired. - * + * * @hide */ public abstract void freeStorage(long freeStorageSize, IntentSender pi); @@ -2172,7 +2172,7 @@ public abstract class PackageManager { * @deprecated This is a protected API that should not have been available * to third party applications. It is the platform's responsibility for * assigning preferred activities and this can not be directly modified. - * + * * Add a new preferred activity mapping to the system. This will be used * to automatically select the given activity component when * {@link Context#startActivity(Intent) Context.startActivity()} finds @@ -2195,7 +2195,7 @@ public abstract class PackageManager { * @deprecated This is a protected API that should not have been available * to third party applications. It is the platform's responsibility for * assigning preferred activities and this can not be directly modified. - * + * * Replaces an existing preferred activity mapping to the system, and if that were not present * adds a new preferred activity. This will be used * to automatically select the given activity component when @@ -2304,7 +2304,7 @@ public abstract class PackageManager { */ public abstract void setApplicationEnabledSetting(String packageName, int newState, int flags); - + /** * Return the the enabled setting for an application. This returns * the last value set by @@ -2345,4 +2345,46 @@ public abstract class PackageManager { */ public abstract void movePackage( String packageName, IPackageMoveObserver observer, int flags); + + /** + * Creates a user with the specified name and options. + * + * @param name the user's name + * @param flags flags that identify the type of user and other properties. + * @see UserInfo + * + * @return the UserInfo object for the created user, or null if the user could not be created. + * @hide + */ + public abstract UserInfo createUser(String name, int flags); + + /** + * @return the list of users that were created + * @hide + */ + public abstract List<UserInfo> getUsers(); + + /** + * @param id the ID of the user, where 0 is the primary user. + * @hide + */ + public abstract boolean removeUser(int id); + + /** + * Updates the user's name. + * + * @param id the user's id + * @param name the new name for the user + * @hide + */ + public abstract void updateUserName(int id, String name); + + /** + * Changes the user's properties specified by the flags. + * + * @param id the user's id + * @param flags the new flags for the user + * @hide + */ + public abstract void updateUserFlags(int id, int flags); } 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/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java new file mode 100644 index 0000000..3704d3a --- /dev/null +++ b/core/java/android/content/pm/UserInfo.java @@ -0,0 +1,106 @@ +/* + * 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.content.pm; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Per-user information. + * @hide + */ +public class UserInfo implements Parcelable { + /** + * Primary user. Only one user can have this flag set. Meaning of this + * flag TBD. + */ + public static final int FLAG_PRIMARY = 0x00000001; + + /** + * User with administrative privileges. Such a user can create and + * delete users. + */ + public static final int FLAG_ADMIN = 0x00000002; + + /** + * Indicates a guest user that may be transient. + */ + public static final int FLAG_GUEST = 0x00000004; + + public int id; + public String name; + public int flags; + + public UserInfo(int id, String name, int flags) { + this.id = id; + this.name = name; + this.flags = flags; + } + + public boolean isPrimary() { + return (flags & FLAG_PRIMARY) == FLAG_PRIMARY; + } + + public boolean isAdmin() { + return (flags & FLAG_ADMIN) == FLAG_ADMIN; + } + + public boolean isGuest() { + return (flags & FLAG_GUEST) == FLAG_GUEST; + } + + public UserInfo() { + } + + public UserInfo(UserInfo orig) { + name = orig.name; + id = orig.id; + flags = orig.flags; + } + + @Override + public String toString() { + return "UserInfo{" + + id + ":" + name + ":" + Integer.toHexString(flags) + "}"; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int parcelableFlags) { + dest.writeInt(id); + dest.writeString(name); + dest.writeInt(flags); + } + + public static final Parcelable.Creator<UserInfo> CREATOR + = new Parcelable.Creator<UserInfo>() { + public UserInfo createFromParcel(Parcel source) { + return new UserInfo(source); + } + public UserInfo[] newArray(int size) { + return new UserInfo[size]; + } + }; + + private UserInfo(Parcel source) { + id = source.readInt(); + name = source.readString(); + flags = source.readInt(); + } +} diff --git a/core/java/android/nfc/ApduList.aidl b/core/java/android/nfc/ApduList.aidl new file mode 100644 index 0000000..f6236b2 --- /dev/null +++ b/core/java/android/nfc/ApduList.aidl @@ -0,0 +1,19 @@ +/* + * 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.nfc; + +parcelable ApduList;
\ No newline at end of file diff --git a/core/java/android/nfc/ApduList.java b/core/java/android/nfc/ApduList.java new file mode 100644 index 0000000..85b0547 --- /dev/null +++ b/core/java/android/nfc/ApduList.java @@ -0,0 +1,68 @@ +package android.nfc; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.ArrayList; +import java.util.List; + +/** + * @hide + */ +public class ApduList implements Parcelable { + + private ArrayList<byte[]> commands = new ArrayList<byte[]>(); + + public ApduList() { + } + + public void add(byte[] command) { + commands.add(command); + } + + public List<byte[]> get() { + return commands; + } + + public static final Parcelable.Creator<ApduList> CREATOR = + new Parcelable.Creator<ApduList>() { + @Override + public ApduList createFromParcel(Parcel in) { + return new ApduList(in); + } + + @Override + public ApduList[] newArray(int size) { + return new ApduList[size]; + } + }; + + private ApduList(Parcel in) { + int count = in.readInt(); + + for (int i = 0 ; i < count ; i++) { + + int length = in.readInt(); + byte[] cmd = new byte[length]; + in.readByteArray(cmd); + commands.add(cmd); + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(commands.size()); + + for (byte[] cmd : commands) { + dest.writeInt(cmd.length); + dest.writeByteArray(cmd); + } + } +} + + diff --git a/core/java/android/nfc/INfcAdapterExtras.aidl b/core/java/android/nfc/INfcAdapterExtras.aidl index ab5c1a6..8677a50 100755 --- a/core/java/android/nfc/INfcAdapterExtras.aidl +++ b/core/java/android/nfc/INfcAdapterExtras.aidl @@ -16,8 +16,10 @@ package android.nfc; +import android.nfc.ApduList; import android.os.Bundle; + /** * {@hide} */ @@ -26,5 +28,7 @@ interface INfcAdapterExtras { Bundle close(); Bundle transceive(in byte[] data_in); int getCardEmulationRoute(); - void setCardEmulationRoute(int route); + void setCardEmulationRoute(int route); + void registerTearDownApdus(String packageName, in ApduList apdu); + void unregisterTearDownApdus(String packageName); } diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 7151ac2..f85df6c 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -101,7 +101,7 @@ public class Process { * Defines the UID/GID for the NFC service process. * @hide */ - public static final int NFC_UID = 1023; + public static final int NFC_UID = 1025; /** * Defines the GID for the group that allows write access to the internal media storage. 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/provider/Settings.java b/core/java/android/provider/Settings.java index ccab8e5..a675618 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3707,6 +3707,13 @@ public final class Settings { "inet_condition_debounce_down_delay"; /** + * URL to open browser on to allow user to manage a prepay account + * @hide + */ + public static final String SETUP_PREPAID_DATA_SERVICE_URL = + "setup_prepaid_data_service_url"; + + /** * @hide */ public static final String[] SETTINGS_TO_BACKUP = { 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/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/com/android/internal/util/HierarchicalStateMachine.java b/core/java/com/android/internal/util/HierarchicalStateMachine.java index f43f459..f6aa184 100644 --- a/core/java/com/android/internal/util/HierarchicalStateMachine.java +++ b/core/java/com/android/internal/util/HierarchicalStateMachine.java @@ -24,6 +24,7 @@ import android.util.Log; import java.util.ArrayList; import java.util.HashMap; +import java.util.Vector; /** * {@hide} @@ -433,6 +434,180 @@ public class HierarchicalStateMachine { */ public static final boolean NOT_HANDLED = false; + /** + * {@hide} + * + * The information maintained for a processed message. + */ + public static class ProcessedMessageInfo { + private int what; + private HierarchicalState state; + private HierarchicalState orgState; + + /** + * Constructor + * @param message + * @param state that handled the message + * @param orgState is the first state the received the message but + * did not processes the message. + */ + ProcessedMessageInfo(Message message, HierarchicalState state, HierarchicalState orgState) { + update(message, state, orgState); + } + + /** + * Update the information in the record. + * @param state that handled the message + * @param orgState is the first state the received the message but + * did not processes the message. + */ + public void update(Message message, HierarchicalState state, HierarchicalState orgState) { + this.what = message.what; + this.state = state; + this.orgState = orgState; + } + + /** + * @return the command that was executing + */ + public int getWhat() { + return what; + } + + /** + * @return the state that handled this message + */ + public HierarchicalState getState() { + return state; + } + + /** + * @return the original state that received the message. + */ + public HierarchicalState getOriginalState() { + return orgState; + } + + /** + * @return as string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("what="); + sb.append(what); + sb.append(" state="); + sb.append(cn(state)); + sb.append(" orgState="); + sb.append(cn(orgState)); + return sb.toString(); + } + + /** + * @return an objects class name + */ + private String cn(Object n) { + if (n == null) { + return "null"; + } else { + String name = n.getClass().getName(); + int lastDollar = name.lastIndexOf('$'); + return name.substring(lastDollar + 1); + } + } + } + + /** + * A list of messages recently processed by the state machine. + * + * The class maintains a list of messages that have been most + * recently processed. The list is finite and may be set in the + * constructor or by calling setSize. The public interface also + * includes size which returns the number of recent messages, + * count which is the number of message processed since the + * the last setSize, get which returns a processed message and + * add which adds a processed messaged. + */ + private static class ProcessedMessages { + + private static final int DEFAULT_SIZE = 20; + + private Vector<ProcessedMessageInfo> mMessages = new Vector<ProcessedMessageInfo>(); + private int mMaxSize = DEFAULT_SIZE; + private int mOldestIndex = 0; + private int mCount = 0; + + /** + * Constructor + */ + ProcessedMessages() { + } + + /** + * Set size of messages to maintain and clears all current messages. + * + * @param maxSize number of messages to maintain at anyone time. + */ + void setSize(int maxSize) { + mMaxSize = maxSize; + mCount = 0; + mMessages.clear(); + } + + /** + * @return the number of recent messages. + */ + int size() { + return mMessages.size(); + } + + /** + * @return the total number of messages processed since size was set. + */ + int count() { + return mCount; + } + + /** + * @return the information on a particular record. 0 is the oldest + * record and size()-1 is the newest record. If the index is to + * large null is returned. + */ + ProcessedMessageInfo get(int index) { + int nextIndex = mOldestIndex + index; + if (nextIndex >= mMaxSize) { + nextIndex -= mMaxSize; + } + if (nextIndex >= size()) { + return null; + } else { + return mMessages.get(nextIndex); + } + } + + /** + * Add a processed message. + * + * @param message + * @param state that handled the message + * @param orgState is the first state the received the message but + * did not processes the message. + */ + void add(Message message, HierarchicalState state, HierarchicalState orgState) { + mCount += 1; + if (mMessages.size() < mMaxSize) { + mMessages.add(new ProcessedMessageInfo(message, state, orgState)); + } else { + ProcessedMessageInfo pmi = mMessages.get(mOldestIndex); + mOldestIndex += 1; + if (mOldestIndex >= mMaxSize) { + mOldestIndex = 0; + } + pmi.update(message, state, orgState); + } + } + } + private static class HsmHandler extends Handler { /** The debug flag */ @@ -441,9 +616,6 @@ public class HierarchicalStateMachine { /** The quit object */ private static final Object mQuitObj = new Object(); - /** The initialization message */ - private static final Message mInitMsg = null; - /** The current message */ private Message mMsg; @@ -615,8 +787,9 @@ public class HierarchicalStateMachine { */ mHsm.quitting(); if (mHsm.mHsmThread != null) { - // If we made the thread then quit looper + // If we made the thread then quit looper which stops the thread. getLooper().quit(); + mHsm.mHsmThread = null; } } else if (destState == mHaltingState) { /** @@ -963,8 +1136,8 @@ public class HierarchicalStateMachine { return mProcessedMessages.count(); } - /** @see HierarchicalStateMachine#getProcessedMessage(int) */ - private final ProcessedMessages.Info getProcessedMessage(int index) { + /** @see HierarchicalStateMachine#getProcessedMessageInfo(int) */ + private final ProcessedMessageInfo getProcessedMessageInfo(int index) { return mProcessedMessages.get(index); } @@ -1090,9 +1263,7 @@ public class HierarchicalStateMachine { * @param msg that couldn't be handled. */ protected void unhandledMessage(Message msg) { - if (false) { - Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what); - } + if (mHsmHandler.mDbg) Log.e(TAG, mName + " - unhandledMessage: msg.what=" + msg.what); } /** @@ -1103,16 +1274,18 @@ public class HierarchicalStateMachine { } /** - * Called after the message that called transitionToHalting - * is called and should be overridden by StateMachine's that - * call transitionToHalting. + * This will be called once after handling a message that called + * transitionToHalting. All subsequent messages will invoke + * {@link HierarchicalStateMachine#haltedProcessMessage(Message)} */ protected void halting() { } /** - * Called after the quitting message was NOT handled and - * just before the quit actually occurs. + * This will be called once after a quit message that was NOT handled by + * the derived HSM. The HSM will stop and any subsequent messages will be + * ignored. In addition, if this HSM created the thread, the thread will + * be stopped after this method returns. */ protected void quitting() { } @@ -1148,10 +1321,10 @@ public class HierarchicalStateMachine { } /** - * @return a processed message + * @return a processed message information */ - public final ProcessedMessages.Info getProcessedMessage(int index) { - return mHsmHandler.getProcessedMessage(index); + public final ProcessedMessageInfo getProcessedMessageInfo(int index) { + return mHsmHandler.getProcessedMessageInfo(index); } /** diff --git a/core/java/com/android/internal/util/ProcessedMessages.java b/core/java/com/android/internal/util/ProcessedMessages.java deleted file mode 100644 index 244474e..0000000 --- a/core/java/com/android/internal/util/ProcessedMessages.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.internal.util; - -import android.os.Message; - -import java.util.Vector; - -/** - * {@hide} - * - * A list of messages recently processed by the state machine. - * - * The class maintains a list of messages that have been most - * recently processed. The list is finite and may be set in the - * constructor or by calling setSize. The public interface also - * includes size which returns the number of recent messages, - * count which is the number of message processed since the - * the last setSize, get which returns a processed message and - * add which adds a processed messaged. - */ -public class ProcessedMessages { - - public static final int DEFAULT_SIZE = 20; - - /** - * The information maintained for a processed message. - */ - public class Info { - private int what; - private HierarchicalState state; - private HierarchicalState orgState; - - /** - * Constructor - * @param message - * @param state that handled the message - * @param orgState is the first state the received the message but - * did not processes the message. - */ - Info(Message message, HierarchicalState state, HierarchicalState orgState) { - update(message, state, orgState); - } - - /** - * Update the information in the record. - * @param state that handled the message - * @param orgState is the first state the received the message but - * did not processes the message. - */ - public void update(Message message, HierarchicalState state, HierarchicalState orgState) { - this.what = message.what; - this.state = state; - this.orgState = orgState; - } - - /** - * @return the command that was executing - */ - public int getWhat() { - return what; - } - - /** - * @return the state that handled this message - */ - public HierarchicalState getState() { - return state; - } - - /** - * @return the original state that received the message. - */ - public HierarchicalState getOriginalState() { - return orgState; - } - - /** - * @return as string - */ - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("what="); - sb.append(what); - sb.append(" state="); - sb.append(cn(state)); - sb.append(" orgState="); - sb.append(cn(orgState)); - return sb.toString(); - } - - /** - * @return an objects class name - */ - private String cn(Object n) { - if (n == null) { - return "null"; - } else { - String name = n.getClass().getName(); - int lastDollar = name.lastIndexOf('$'); - return name.substring(lastDollar + 1); - } - } - } - - private Vector<Info> mMessages = new Vector<Info>(); - private int mMaxSize = DEFAULT_SIZE; - private int mOldestIndex = 0; - private int mCount = 0; - - /** - * Constructor - */ - ProcessedMessages() { - } - - ProcessedMessages(int maxSize) { - setSize(maxSize); - } - - /** - * Set size of messages to maintain and clears all current messages. - * - * @param maxSize number of messages to maintain at anyone time. - */ - void setSize(int maxSize) { - mMaxSize = maxSize; - mCount = 0; - mMessages.clear(); - } - - /** - * @return the number of recent messages. - */ - int size() { - return mMessages.size(); - } - - /** - * @return the total number of messages processed since size was set. - */ - int count() { - return mCount; - } - - /** - * @return the information on a particular record. 0 is the oldest - * record and size()-1 is the newest record. If the index is to - * large null is returned. - */ - Info get(int index) { - int nextIndex = mOldestIndex + index; - if (nextIndex >= mMaxSize) { - nextIndex -= mMaxSize; - } - if (nextIndex >= size()) { - return null; - } else { - return mMessages.get(nextIndex); - } - } - - /** - * Add a processed message. - * - * @param message - * @param state that handled the message - * @param orgState is the first state the received the message but - * did not processes the message. - */ - void add(Message message, HierarchicalState state, HierarchicalState orgState) { - mCount += 1; - if (mMessages.size() < mMaxSize) { - mMessages.add(new Info(message, state, orgState)); - } else { - Info info = mMessages.get(mOldestIndex); - mOldestIndex += 1; - if (mOldestIndex >= mMaxSize) { - mOldestIndex = 0; - } - info.update(message, state, orgState); - } - } -} 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/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/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..56859b8 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; 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_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp index 494dc27..2abb9ea 100644 --- a/core/jni/android_net_wifi_Wifi.cpp +++ b/core/jni/android_net_wifi_Wifi.cpp @@ -651,9 +651,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..bfa80e1 100644 --- a/core/jni/android_os_ParcelFileDescriptor.cpp +++ b/core/jni/android_os_ParcelFileDescriptor.cpp @@ -29,13 +29,6 @@ namespace android { -static struct file_descriptor_offsets_t -{ - jclass mClass; - jmethodID mConstructor; - jfieldID mDescriptor; -} gFileDescriptorOffsets; - static struct socket_offsets_t { jfieldID mSocketImpl; @@ -57,13 +50,8 @@ static jobject android_os_ParcelFileDescriptor_getFileDescriptorFromSocket(JNIEn { 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; + jint fd = jniGetFDFromFileDescriptor(env, fileDescriptor); + return jniCreateFileDescriptor(env, dup(fd)); } static int android_os_ParcelFileDescriptor_createPipeNative(JNIEnv* env, @@ -75,11 +63,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 +74,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 +85,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 +106,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); } @@ -168,14 +152,6 @@ int register_android_os_ParcelFileDescriptor(JNIEnv* env) 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); LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.ParcelFileDescriptor"); gParcelFileDescriptorOffsets.mClass = (jclass) env->NewGlobalRef(clazz); 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..34f0fdc 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -915,11 +915,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-de/strings.xml b/core/res/res/values-de/strings.xml index db3e9d9..c97eec3 100644 --- a/core/res/res/values-de/strings.xml +++ b/core/res/res/values-de/strings.xml @@ -151,7 +151,7 @@ <string name="global_actions_toggle_airplane_mode" msgid="5884330306926307456">"Flugmodus"</string> <string name="global_actions_airplane_mode_on_status" msgid="2719557982608919750">"Flugmodus ist AN."</string> <string name="global_actions_airplane_mode_off_status" msgid="5075070442854490296">"Flugmodus ist AUS."</string> - <string name="status_bar_notification_info_overflow" msgid="5833510281787786290">"100 +"</string> + <string name="status_bar_notification_info_overflow" msgid="5833510281787786290">"Mehr als 100"</string> <string name="safeMode" msgid="2788228061547930246">"Abgesicherter Modus"</string> <string name="android_system_label" msgid="6577375335728551336">"Android-System"</string> <string name="permgrouplab_costMoney" msgid="5429808217861460401">"Kostenpflichtige Dienste"</string> @@ -465,7 +465,7 @@ <string name="permdesc_sdcardWrite" product="nosdcard" msgid="6594393334785738252">"Ermöglicht der Anwendung Schreiben in USB-Speicher"</string> <string name="permdesc_sdcardWrite" product="default" msgid="6643963204976471878">"Ermöglicht einer Anwendung, auf die SD-Karte zu schreiben"</string> <string name="permlab_mediaStorageWrite" product="default" msgid="6859839199706879015">"Intern. Mediensp. änd./löschen"</string> - <string name="permdesc_mediaStorageWrite" product="default" msgid="8232008512478316233">"Ermöglicht es einer Anwendung, den Inhalt des internen Medienspeichers zu ändern"</string> + <string name="permdesc_mediaStorageWrite" product="default" msgid="8232008512478316233">"Ermöglicht einer Anwendung, den Inhalt des internen Medienspeichers zu ändern"</string> <string name="permlab_cache_filesystem" msgid="5656487264819669824">"Zugriff auf das Cache-Dateisystem"</string> <string name="permdesc_cache_filesystem" msgid="1624734528435659906">"Gewährt einer Anwendung Lese- und Schreibzugriff auf das Cache-Dateisystem."</string> <string name="permlab_use_sip" msgid="5986952362795870502">"Internetanrufe tätigen/annehmen"</string> 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/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java b/core/tests/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java index 36666c4..b6f8be5 100644 --- a/core/tests/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java +++ b/core/tests/coretests/src/com/android/internal/util/HierarchicalStateMachineTest.java @@ -24,7 +24,7 @@ import android.os.SystemClock; import com.android.internal.util.HierarchicalState; import com.android.internal.util.HierarchicalStateMachine; -import com.android.internal.util.ProcessedMessages; +import com.android.internal.util.HierarchicalStateMachine.ProcessedMessageInfo; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.SmallTest; @@ -125,21 +125,21 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(smQuitTest.getProcessedMessagesCount() == 9); - ProcessedMessages.Info pmi; + ProcessedMessageInfo pmi; // The first two message didn't quit and were handled by mS1 - pmi = smQuitTest.getProcessedMessage(6); + pmi = smQuitTest.getProcessedMessageInfo(6); assertEquals(HierarchicalStateMachine.HSM_QUIT_CMD, pmi.getWhat()); assertEquals(smQuitTest.mS1, pmi.getState()); assertEquals(smQuitTest.mS1, pmi.getOriginalState()); - pmi = smQuitTest.getProcessedMessage(7); + pmi = smQuitTest.getProcessedMessageInfo(7); assertEquals(HierarchicalStateMachine.HSM_QUIT_CMD, pmi.getWhat()); assertEquals(smQuitTest.mS1, pmi.getState()); assertEquals(smQuitTest.mS1, pmi.getOriginalState()); // The last message was never handled so the states are null - pmi = smQuitTest.getProcessedMessage(8); + pmi = smQuitTest.getProcessedMessageInfo(8); assertEquals(HierarchicalStateMachine.HSM_QUIT_CMD, pmi.getWhat()); assertEquals(null, pmi.getState()); assertEquals(null, pmi.getOriginalState()); @@ -285,10 +285,10 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(smEnterExitTranstionToTest.getProcessedMessagesCount() == 1); - ProcessedMessages.Info pmi; + ProcessedMessageInfo pmi; // Message should be handled by mS2. - pmi = smEnterExitTranstionToTest.getProcessedMessage(0); + pmi = smEnterExitTranstionToTest.getProcessedMessageInfo(0); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(smEnterExitTranstionToTest.mS2, pmi.getState()); assertEquals(smEnterExitTranstionToTest.mS2, pmi.getOriginalState()); @@ -369,18 +369,18 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(sm0.getProcessedMessagesCount() == 6); assertTrue(sm0.getProcessedMessagesSize() == 3); - ProcessedMessages.Info pmi; - pmi = sm0.getProcessedMessage(0); + ProcessedMessageInfo pmi; + pmi = sm0.getProcessedMessageInfo(0); assertEquals(TEST_CMD_4, pmi.getWhat()); assertEquals(sm0.mS1, pmi.getState()); assertEquals(sm0.mS1, pmi.getOriginalState()); - pmi = sm0.getProcessedMessage(1); + pmi = sm0.getProcessedMessageInfo(1); assertEquals(TEST_CMD_5, pmi.getWhat()); assertEquals(sm0.mS1, pmi.getState()); assertEquals(sm0.mS1, pmi.getOriginalState()); - pmi = sm0.getProcessedMessage(2); + pmi = sm0.getProcessedMessageInfo(2); assertEquals(TEST_CMD_6, pmi.getWhat()); assertEquals(sm0.mS1, pmi.getState()); assertEquals(sm0.mS1, pmi.getOriginalState()); @@ -469,13 +469,13 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(sm1.getProcessedMessagesSize() == 2); - ProcessedMessages.Info pmi; - pmi = sm1.getProcessedMessage(0); + ProcessedMessageInfo pmi; + pmi = sm1.getProcessedMessageInfo(0); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(sm1.mS1, pmi.getState()); assertEquals(sm1.mS1, pmi.getOriginalState()); - pmi = sm1.getProcessedMessage(1); + pmi = sm1.getProcessedMessageInfo(1); assertEquals(TEST_CMD_2, pmi.getWhat()); assertEquals(sm1.mS1, pmi.getState()); assertEquals(sm1.mS1, pmi.getOriginalState()); @@ -571,20 +571,20 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(sm2.getProcessedMessagesSize() == 4); - ProcessedMessages.Info pmi; - pmi = sm2.getProcessedMessage(0); + ProcessedMessageInfo pmi; + pmi = sm2.getProcessedMessageInfo(0); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(sm2.mS1, pmi.getState()); - pmi = sm2.getProcessedMessage(1); + pmi = sm2.getProcessedMessageInfo(1); assertEquals(TEST_CMD_2, pmi.getWhat()); assertEquals(sm2.mS1, pmi.getState()); - pmi = sm2.getProcessedMessage(2); + pmi = sm2.getProcessedMessageInfo(2); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(sm2.mS2, pmi.getState()); - pmi = sm2.getProcessedMessage(3); + pmi = sm2.getProcessedMessageInfo(3); assertEquals(TEST_CMD_2, pmi.getWhat()); assertEquals(sm2.mS2, pmi.getState()); @@ -663,13 +663,13 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(sm3.getProcessedMessagesSize() == 2); - ProcessedMessages.Info pmi; - pmi = sm3.getProcessedMessage(0); + ProcessedMessageInfo pmi; + pmi = sm3.getProcessedMessageInfo(0); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(sm3.mParentState, pmi.getState()); assertEquals(sm3.mChildState, pmi.getOriginalState()); - pmi = sm3.getProcessedMessage(1); + pmi = sm3.getProcessedMessageInfo(1); assertEquals(TEST_CMD_2, pmi.getWhat()); assertEquals(sm3.mParentState, pmi.getState()); assertEquals(sm3.mChildState, pmi.getOriginalState()); @@ -757,13 +757,13 @@ public class HierarchicalStateMachineTest extends TestCase { assertTrue(sm4.getProcessedMessagesSize() == 2); - ProcessedMessages.Info pmi; - pmi = sm4.getProcessedMessage(0); + ProcessedMessageInfo pmi; + pmi = sm4.getProcessedMessageInfo(0); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(sm4.mChildState1, pmi.getState()); assertEquals(sm4.mChildState1, pmi.getOriginalState()); - pmi = sm4.getProcessedMessage(1); + pmi = sm4.getProcessedMessageInfo(1); assertEquals(TEST_CMD_2, pmi.getWhat()); assertEquals(sm4.mParentState, pmi.getState()); assertEquals(sm4.mChildState2, pmi.getOriginalState()); @@ -1050,33 +1050,33 @@ public class HierarchicalStateMachineTest extends TestCase { assertEquals(1, sm5.mChildState5EnterCount); assertEquals(1, sm5.mChildState5ExitCount); - ProcessedMessages.Info pmi; - pmi = sm5.getProcessedMessage(0); + ProcessedMessageInfo pmi; + pmi = sm5.getProcessedMessageInfo(0); assertEquals(TEST_CMD_1, pmi.getWhat()); assertEquals(sm5.mChildState1, pmi.getState()); assertEquals(sm5.mChildState1, pmi.getOriginalState()); - pmi = sm5.getProcessedMessage(1); + pmi = sm5.getProcessedMessageInfo(1); assertEquals(TEST_CMD_2, pmi.getWhat()); assertEquals(sm5.mChildState2, pmi.getState()); assertEquals(sm5.mChildState2, pmi.getOriginalState()); - pmi = sm5.getProcessedMessage(2); + pmi = sm5.getProcessedMessageInfo(2); assertEquals(TEST_CMD_3, pmi.getWhat()); assertEquals(sm5.mChildState5, pmi.getState()); assertEquals(sm5.mChildState5, pmi.getOriginalState()); - pmi = sm5.getProcessedMessage(3); + pmi = sm5.getProcessedMessageInfo(3); assertEquals(TEST_CMD_4, pmi.getWhat()); assertEquals(sm5.mChildState3, pmi.getState()); assertEquals(sm5.mChildState3, pmi.getOriginalState()); - pmi = sm5.getProcessedMessage(4); + pmi = sm5.getProcessedMessageInfo(4); assertEquals(TEST_CMD_5, pmi.getWhat()); assertEquals(sm5.mChildState4, pmi.getState()); assertEquals(sm5.mChildState4, pmi.getOriginalState()); - pmi = sm5.getProcessedMessage(5); + pmi = sm5.getProcessedMessageInfo(5); assertEquals(TEST_CMD_6, pmi.getWhat()); assertEquals(sm5.mParentState2, pmi.getState()); assertEquals(sm5.mParentState2, pmi.getOriginalState()); @@ -1434,7 +1434,7 @@ public class HierarchicalStateMachineTest extends TestCase { for (StateMachineSharedThread sm : sms) { assertTrue(sm.getProcessedMessagesCount() == 4); for (int i = 0; i < sm.getProcessedMessagesCount(); i++) { - ProcessedMessages.Info pmi = sm.getProcessedMessage(i); + ProcessedMessageInfo pmi = sm.getProcessedMessageInfo(i); assertEquals(i+1, pmi.getWhat()); assertEquals(sm.mS1, pmi.getState()); assertEquals(sm.mS1, pmi.getOriginalState()); @@ -1464,37 +1464,37 @@ public class HierarchicalStateMachineTest extends TestCase { } assertEquals(7, sm.getProcessedMessagesCount()); - ProcessedMessages.Info pmi = sm.getProcessedMessage(0); + ProcessedMessageInfo pmi = sm.getProcessedMessageInfo(0); assertEquals(Hsm1.CMD_1, pmi.getWhat()); assertEquals(sm.mS1, pmi.getState()); assertEquals(sm.mS1, pmi.getOriginalState()); - pmi = sm.getProcessedMessage(1); + pmi = sm.getProcessedMessageInfo(1); assertEquals(Hsm1.CMD_2, pmi.getWhat()); assertEquals(sm.mP1, pmi.getState()); assertEquals(sm.mS1, pmi.getOriginalState()); - pmi = sm.getProcessedMessage(2); + pmi = sm.getProcessedMessageInfo(2); assertEquals(Hsm1.CMD_2, pmi.getWhat()); assertEquals(sm.mS2, pmi.getState()); assertEquals(sm.mS2, pmi.getOriginalState()); - pmi = sm.getProcessedMessage(3); + pmi = sm.getProcessedMessageInfo(3); assertEquals(Hsm1.CMD_3, pmi.getWhat()); assertEquals(sm.mS2, pmi.getState()); assertEquals(sm.mS2, pmi.getOriginalState()); - pmi = sm.getProcessedMessage(4); + pmi = sm.getProcessedMessageInfo(4); assertEquals(Hsm1.CMD_3, pmi.getWhat()); assertEquals(sm.mP2, pmi.getState()); assertEquals(sm.mP2, pmi.getOriginalState()); - pmi = sm.getProcessedMessage(5); + pmi = sm.getProcessedMessageInfo(5); assertEquals(Hsm1.CMD_4, pmi.getWhat()); assertEquals(sm.mP2, pmi.getState()); assertEquals(sm.mP2, pmi.getOriginalState()); - pmi = sm.getProcessedMessage(6); + pmi = sm.getProcessedMessageInfo(6); assertEquals(Hsm1.CMD_5, pmi.getWhat()); assertEquals(sm.mP2, pmi.getState()); assertEquals(sm.mP2, pmi.getOriginalState()); 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 Binary files differnew file mode 100644 index 0000000..0d944d0 --- /dev/null +++ b/core/tests/overlaytests/OverlayTestOverlay/res/drawable/default_wallpaper.jpg 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) diff --git a/docs/html/guide/developing/tools/logcat.jd b/docs/html/guide/developing/tools/logcat.jd index d4ee68a..546e3ea 100644 --- a/docs/html/guide/developing/tools/logcat.jd +++ b/docs/html/guide/developing/tools/logcat.jd @@ -2,7 +2,6 @@ page.title=logcat parent.title=Tools parent.link=index.html @jd:body -<div></div> <p>The Android logging system provides a mechanism for collecting and viewing system debug output. Logs from various applications and portions of the system are collected in a series of @@ -23,7 +22,7 @@ For more <p>You can run <code>logcat</code> as an adb command or directly in a shell prompt of your emulator or connected device. To view log output using adb, navigate to your SDK - <code>platform-tools/</code> directory and execute:/p> + <code>platform-tools/</code> directory and execute:</p> <pre> $ adb logcat </pre> diff --git a/docs/html/guide/market/billing/billing_admin.jd b/docs/html/guide/market/billing/billing_admin.jd index 723113d..939bbaa 100755 --- a/docs/html/guide/market/billing/billing_admin.jd +++ b/docs/html/guide/market/billing/billing_admin.jd @@ -97,7 +97,7 @@ file</a>.</p> <img src="{@docRoot}images/billing_list_form.png" height="840" id="figure3" /> <p class="img-caption"> - f<strong>Figure 3.</strong> The Create New In-app Product page lets you add items to an + <strong>Figure 3.</strong> The Create New In-app Product page lets you add items to an application's product list. </p> diff --git a/docs/html/guide/market/billing/billing_integrate.jd b/docs/html/guide/market/billing/billing_integrate.jd index f57ebe3..59344ba 100755 --- a/docs/html/guide/market/billing/billing_integrate.jd +++ b/docs/html/guide/market/billing/billing_integrate.jd @@ -163,11 +163,11 @@ Selected</strong> to begin the download.</p> <p>When the download is complete, the Android SDK and AVD Manager saves the component into the following directory:</p> -<p><code><sdk>/google-market_billing/</code></p> +<p><code><sdk>/extras/google/market_billing/</code></p> <p>If you want to see an end-to-end demonstration of in-app billing before you integrate in-app billing into your own application, you can build and run the sample application. Building and -running the sample application involves three tasks:<p> +running the sample application involves three tasks:</p> <ul> <li>Configuring and building the sample application.</li> @@ -501,7 +501,7 @@ protected Bundle makeRequestBundle(String method) { <p>To use this helper method, you pass in a <code>String</code> that corresponds to one of the five types of billing requests. The method returns a Bundle that has the three required keys defined. The -following sections show you how to use this helper method when you send a billing request.<p> +following sections show you how to use this helper method when you send a billing request.</p> <p class="caution"><strong>Important</strong>: You must make all in-app billing requests from your application's main thread.</p> diff --git a/docs/html/guide/practices/design/accessibility.jd b/docs/html/guide/practices/design/accessibility.jd index a2b314e..a66a974 100644 --- a/docs/html/guide/practices/design/accessibility.jd +++ b/docs/html/guide/practices/design/accessibility.jd @@ -60,8 +60,9 @@ access-related problems:</p> <li>Make all of your user interface controls accessible with a trackball or directional controller (d-pad).</li> <li>Label your {@link android.widget.ImageButton}, {@link android.widget.EditText}, and other input -widgets using the <a href="{@docRoot}reference/android/view/View#attr_android:contentDescription" ->{@code android:contentDescription}</a> attribute.</li> +widgets using the <a +href="{@docRoot}reference/android/view/View.html#attr_android:contentDescription">{@code +android:contentDescription}</a> attribute.</li> </ul> @@ -100,8 +101,9 @@ request that a widget be given focus. Such methods include:</p> </ul> <p>When working with a view that is not focusable by default, you can make it focusable from the XML -layout file by setting the <a href="{@docRoot}reference/android/view/View#attr_android:focusable" ->{@code android:focusable}</a> attribute to {@code "true"}.</p> +layout file by setting the <a +href="{@docRoot}reference/android/view/View.html#attr_android:focusable">{@code +android:focusable}</a> attribute to {@code "true"}.</p> @@ -181,13 +183,13 @@ a label near it that indicates its purpose. When a visually impaired user acces application, these visual cues are often useless.</p> <p>To provide textual information about these widgets (as an alternative to the visual cues), you -should use the <a href="{@docRoot}reference/android/view/View#attr_android:contentDescription" +should use the <a href="{@docRoot}reference/android/view/View.html#attr_android:contentDescription" >{@code android:contentDescription}</a> attribute. The text you provide in this attribute is not visible on the screen, but if a user has enabled accessibility speech tools then the description in this attribute is read aloud to the user.</p> <p>You should set the <a -href="{@docRoot}reference/android/view/View#attr_android:contentDescription" >{@code +href="{@docRoot}reference/android/view/View.html#attr_android:contentDescription" >{@code android:contentDescription}</a> attribute on every {@link android.widget.ImageButton}, {@link android.widget.EditText}, {@link android.widget.CheckBox}, and on any other input widgets that might benefit users with extra information.</p> diff --git a/docs/html/guide/publishing/licensing.jd b/docs/html/guide/publishing/licensing.jd index 4184ecb..a9b182e 100644 --- a/docs/html/guide/publishing/licensing.jd +++ b/docs/html/guide/publishing/licensing.jd @@ -368,7 +368,7 @@ to set up your development environment for licensing. </p> <ol> <li><a href="#download-sdk">Downloading the latest SDK</a>, if you haven't already done so </li> -<li><a href="#runtime-setup">Setting up the runtime environment</a> for development</a></li> +<li><a href="#runtime-setup">Setting up the runtime environment</a> for development</li> <li><a href="#download-lvl">Downloading the Market Licensing component</a> into your SDK </li> <li><a href="#lvl-setup">Setting up the Licensing Verification Library</a></li> <li><a href="#add-library">Including the LVL library project in your application</a></li> @@ -582,9 +582,9 @@ Licensing package contains the LVL and the LVL sample application. </div> <p>When the download is complete, the Android SDK and AVD Manager installs both the LVL library project and the example application into these directories: </p> -<p style="margin-left:2em"><code><<em>sdk</em>>/market_licensing/library/</code> +<p style="margin-left:2em"><code><<em>sdk</em>>/extras/google/market_licensing/library/</code> (the LVL library project)<br /> -<code><<em>sdk</em>>/market_licensing/sample/</code> (the example +<code><<em>sdk</em>>/extras/google/market_licensing/sample/</code> (the example application)</p> <p>If you aren't familiar with how to download components into your SDK, see the @@ -1530,7 +1530,7 @@ Make sure that you sign in to the account from which the application you are licensing is published (or will be published). </li> <li>In the account home page, locate the "Edit profile" link and click it. </li> <li>In the Edit Profile page, locate the "Licensing" pane, shown below. Your -public key for licensing is given in the "Public key" text box. </p> +public key for licensing is given in the "Public key" text box. </li> </ol> <p>To add the public key to your application, simply copy/paste the key string diff --git a/docs/html/guide/topics/fundamentals/tasks-and-back-stack.jd b/docs/html/guide/topics/fundamentals/tasks-and-back-stack.jd index bd542bd..f22e5b2 100644 --- a/docs/html/guide/topics/fundamentals/tasks-and-back-stack.jd +++ b/docs/html/guide/topics/fundamentals/tasks-and-back-stack.jd @@ -11,7 +11,7 @@ parent.link=activities.html <li>A task contains a collection of activities in the order in which the user interacts with them</li> <li>Tasks can move to the background and retain the state of each activity in order for the user -to perform other tasks without loosing their work</li> +to perform other tasks without losing their work</li> </ul> <h2>In this document</h2> @@ -181,7 +181,7 @@ system memory. When this happens, information about the activity state is lost. system still knows that the activity has a place in the back stack, but when the activity is brought to the top of the stack the system must recreate it (rather than resume it). In order to -avoid loosing the user's work, you should proactively retain it by implementing the {@link +avoid losing the user's work, you should proactively retain it by implementing the {@link android.app.Activity#onSaveInstanceState onSaveInstanceState()} callback methods in your activity.</p> @@ -201,7 +201,7 @@ the normal behavior. Perhaps you want an activity in your application to begin a started (instead of being placed within the current task); or, when you start an activity, you want to bring forward an existing instance of it (instead of creating a new instance on top of the back stack); or, you want your back stack to be cleared of all -activitiesstart an activity except for the root activity when the user leaves the task.</p> +activities except for the root activity when the user leaves the task.</p> <p>You can do these things and more, with attributes in the <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code @@ -566,4 +566,4 @@ activate other application components and publish the intents to which your comp respond, continue with the <b><a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a></b> document.</p> --->
\ No newline at end of file +--> diff --git a/include/android_runtime/AndroidRuntime.h b/include/android_runtime/AndroidRuntime.h index 22c9b72..de2d50b 100644 --- a/include/android_runtime/AndroidRuntime.h +++ b/include/android_runtime/AndroidRuntime.h @@ -56,7 +56,7 @@ public: status_t callMain(const char* className, int argc, const char* const argv[]); /** - * Find a class, with the input either of the form + * Find a class, with the input either of the form * "package/class" or "package.class". */ static jclass findClass(JNIEnv* env, const char* className); @@ -67,7 +67,7 @@ public: void start(); // start in android.util.RuntimeInit static AndroidRuntime* getRuntime(); - + /** * This gets called after the JavaVM has initialized. Override it * with the system's native entry point. @@ -112,7 +112,7 @@ private: * Thread creation helpers. */ static int javaCreateThreadEtc( - android_thread_func_t entryFunction, + android_thread_func_t entryFunction, void* userData, const char* threadName, int32_t threadPriority, @@ -121,9 +121,6 @@ private: static int javaThreadShell(void* args); }; -// Returns the Unix file descriptor for a ParcelFileDescriptor object -extern int getParcelFileDescriptorFD(JNIEnv* env, jobject object); - extern CursorWindow * get_window_from_object(JNIEnv * env, jobject javaWindow); } diff --git a/include/utils/AssetManager.h b/include/utils/AssetManager.h index 9e2bf37..a8c7ddb 100644 --- a/include/utils/AssetManager.h +++ b/include/utils/AssetManager.h @@ -222,6 +222,7 @@ private: { String8 path; FileType type; + String8 idmap; }; Asset* openInPathLocked(const char* fileName, AccessMode mode, @@ -262,6 +263,16 @@ private: void setLocaleLocked(const char* locale); void updateResourceParamsLocked() const; + bool createIdmapFileLocked(const String8& originalPath, const String8& overlayPath, + const String8& idmapPath); + + bool isIdmapStaleLocked(const String8& originalPath, const String8& overlayPath, + const String8& idmapPath); + + Asset* openIdmapLocked(const struct asset_path& ap) const; + + bool getZipEntryCrcLocked(const String8& zipPath, const char* entryFilename, uint32_t* pCrc); + class SharedZip : public RefBase { public: static sp<SharedZip> get(const String8& path); diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h index 35792dc..173412e 100644 --- a/include/utils/ResourceTypes.h +++ b/include/utils/ResourceTypes.h @@ -1798,9 +1798,9 @@ public: ~ResTable(); status_t add(const void* data, size_t size, void* cookie, - bool copyData=false); + bool copyData=false, const void* idmap = NULL); status_t add(Asset* asset, void* cookie, - bool copyData=false); + bool copyData=false, const void* idmap = NULL); status_t add(ResTable* src); status_t getError() const; @@ -2046,6 +2046,24 @@ public: void getLocales(Vector<String8>* locales) const; + // Generate an idmap. + // + // Return value: on success: NO_ERROR; caller is responsible for free-ing + // outData (using free(3)). On failure, any status_t value other than + // NO_ERROR; the caller should not free outData. + status_t createIdmap(const ResTable& overlay, uint32_t originalCrc, uint32_t overlayCrc, + void** outData, size_t* outSize) const; + + enum { + IDMAP_HEADER_SIZE_BYTES = 3 * sizeof(uint32_t), + }; + // Retrieve idmap meta-data. + // + // This function only requires the idmap header (the first + // IDMAP_HEADER_SIZE_BYTES) bytes of an idmap file. + static bool getIdmapInfo(const void* idmap, size_t size, + uint32_t* pOriginalCrc, uint32_t* pOverlayCrc); + #ifndef HAVE_ANDROID_OS void print(bool inclValues) const; static String8 normalizeForOutput(const char* input); @@ -2059,7 +2077,7 @@ private: struct bag_set; status_t add(const void* data, size_t size, void* cookie, - Asset* asset, bool copyData); + Asset* asset, bool copyData, const Asset* idmap); ssize_t getResourcePackageIndex(uint32_t resID) const; ssize_t getEntry( @@ -2068,7 +2086,7 @@ private: const ResTable_type** outType, const ResTable_entry** outEntry, const Type** outTypeClass) const; status_t parsePackage( - const ResTable_package* const pkg, const Header* const header); + const ResTable_package* const pkg, const Header* const header, uint32_t idmap_id); void print_value(const Package* pkg, const Res_value& value) const; diff --git a/libs/usb/src/com/android/future/usb/UsbManager.java b/libs/usb/src/com/android/future/usb/UsbManager.java index d424b63..91d8e8a 100644 --- a/libs/usb/src/com/android/future/usb/UsbManager.java +++ b/libs/usb/src/com/android/future/usb/UsbManager.java @@ -28,7 +28,7 @@ import android.os.ServiceManager; import android.util.Log; /** - * This class allows you to access the state of USB, both in host and device mode. + * This is a wrapper class for the USB Manager to support USB accessories. * * <p>You can obtain an instance of this class by calling {@link #getInstance} * @@ -141,7 +141,7 @@ public class UsbManager { /** * Returns true if the caller has permission to access the accessory. * Permission might have been granted temporarily via - * {@link #requestPermission(android.hardware.usb.UsbAccessory} or + * {@link #requestPermission} or * by the user choosing the caller as the default application for the accessory. * * @param accessory to check permissions for diff --git a/libs/utils/AssetManager.cpp b/libs/utils/AssetManager.cpp index 6e57d93..e41dd39 100644 --- a/libs/utils/AssetManager.cpp +++ b/libs/utils/AssetManager.cpp @@ -37,6 +37,19 @@ #include <errno.h> #include <assert.h> #include <strings.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <unistd.h> + +#ifndef TEMP_FAILURE_RETRY +/* Used to retry syscalls that can return EINTR. */ +#define TEMP_FAILURE_RETRY(exp) ({ \ + typeof (exp) _rc; \ + do { \ + _rc = (exp); \ + } while (_rc == -1 && errno == EINTR); \ + _rc; }) +#endif using namespace android; @@ -49,6 +62,7 @@ static const char* kDefaultVendor = "default"; static const char* kAssetsRoot = "assets"; static const char* kAppZipName = NULL; //"classes.jar"; static const char* kSystemAssets = "framework/framework-res.apk"; +static const char* kIdmapCacheDir = "resource-cache"; static const char* kExcludeExtension = ".EXCLUDE"; @@ -56,6 +70,35 @@ static Asset* const kExcludedAsset = (Asset*) 0xd000000d; static volatile int32_t gCount = 0; +namespace { + // Transform string /a/b/c.apk to /data/resource-cache/a@b@c.apk@idmap + String8 idmapPathForPackagePath(const String8& pkgPath) + { + const char* root = getenv("ANDROID_DATA"); + LOG_ALWAYS_FATAL_IF(root == NULL, "ANDROID_DATA not set"); + String8 path(root); + path.appendPath(kIdmapCacheDir); + + char buf[256]; // 256 chars should be enough for anyone... + strncpy(buf, pkgPath.string(), 255); + buf[255] = '\0'; + char* filename = buf; + while (*filename && *filename == '/') { + ++filename; + } + char* p = filename; + while (*p) { + if (*p == '/') { + *p = '@'; + } + ++p; + } + path.appendPath(filename); + path.append("@idmap"); + + return path; + } +} /* * =========================================================================== @@ -123,7 +166,7 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie) return true; } } - + LOGV("In %p Asset %s path: %s", this, ap.type == kFileTypeDirectory ? "dir" : "zip", ap.path.string()); @@ -134,9 +177,181 @@ bool AssetManager::addAssetPath(const String8& path, void** cookie) *cookie = (void*)mAssetPaths.size(); } + // add overlay packages for /system/framework; apps are handled by the + // (Java) package manager + if (strncmp(path.string(), "/system/framework/", 18) == 0) { + // When there is an environment variable for /vendor, this + // should be changed to something similar to how ANDROID_ROOT + // and ANDROID_DATA are used in this file. + String8 overlayPath("/vendor/overlay/framework/"); + overlayPath.append(path.getPathLeaf()); + if (TEMP_FAILURE_RETRY(access(overlayPath.string(), R_OK)) == 0) { + asset_path oap; + oap.path = overlayPath; + oap.type = ::getFileType(overlayPath.string()); + bool addOverlay = (oap.type == kFileTypeRegular); // only .apks supported as overlay + if (addOverlay) { + oap.idmap = idmapPathForPackagePath(overlayPath); + + if (isIdmapStaleLocked(ap.path, oap.path, oap.idmap)) { + addOverlay = createIdmapFileLocked(ap.path, oap.path, oap.idmap); + } + } + if (addOverlay) { + mAssetPaths.add(oap); + } else { + LOGW("failed to add overlay package %s\n", overlayPath.string()); + } + } + } + + return true; +} + +bool AssetManager::isIdmapStaleLocked(const String8& originalPath, const String8& overlayPath, + const String8& idmapPath) +{ + struct stat st; + if (TEMP_FAILURE_RETRY(stat(idmapPath.string(), &st)) == -1) { + if (errno == ENOENT) { + return true; // non-existing idmap is always stale + } else { + LOGW("failed to stat file %s: %s\n", idmapPath.string(), strerror(errno)); + return false; + } + } + if (st.st_size < ResTable::IDMAP_HEADER_SIZE_BYTES) { + LOGW("file %s has unexpectedly small size=%zd\n", idmapPath.string(), (size_t)st.st_size); + return false; + } + int fd = TEMP_FAILURE_RETRY(::open(idmapPath.string(), O_RDONLY)); + if (fd == -1) { + LOGW("failed to open file %s: %s\n", idmapPath.string(), strerror(errno)); + return false; + } + char buf[ResTable::IDMAP_HEADER_SIZE_BYTES]; + ssize_t bytesLeft = ResTable::IDMAP_HEADER_SIZE_BYTES; + for (;;) { + ssize_t r = TEMP_FAILURE_RETRY(read(fd, buf + ResTable::IDMAP_HEADER_SIZE_BYTES - bytesLeft, + bytesLeft)); + if (r < 0) { + TEMP_FAILURE_RETRY(close(fd)); + return false; + } + bytesLeft -= r; + if (bytesLeft == 0) { + break; + } + } + TEMP_FAILURE_RETRY(close(fd)); + + uint32_t cachedOriginalCrc, cachedOverlayCrc; + if (!ResTable::getIdmapInfo(buf, ResTable::IDMAP_HEADER_SIZE_BYTES, + &cachedOriginalCrc, &cachedOverlayCrc)) { + return false; + } + + uint32_t actualOriginalCrc, actualOverlayCrc; + if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &actualOriginalCrc)) { + return false; + } + if (!getZipEntryCrcLocked(overlayPath, "resources.arsc", &actualOverlayCrc)) { + return false; + } + return cachedOriginalCrc != actualOriginalCrc || cachedOverlayCrc != actualOverlayCrc; +} + +bool AssetManager::getZipEntryCrcLocked(const String8& zipPath, const char* entryFilename, + uint32_t* pCrc) +{ + asset_path ap; + ap.path = zipPath; + const ZipFileRO* zip = getZipFileLocked(ap); + if (zip == NULL) { + return false; + } + const ZipEntryRO entry = zip->findEntryByName(entryFilename); + if (entry == NULL) { + return false; + } + if (!zip->getEntryInfo(entry, NULL, NULL, NULL, NULL, NULL, (long*)pCrc)) { + return false; + } return true; } +bool AssetManager::createIdmapFileLocked(const String8& originalPath, const String8& overlayPath, + const String8& idmapPath) +{ + LOGD("%s: originalPath=%s overlayPath=%s idmapPath=%s\n", + __FUNCTION__, originalPath.string(), overlayPath.string(), idmapPath.string()); + ResTable tables[2]; + const String8* paths[2] = { &originalPath, &overlayPath }; + uint32_t originalCrc, overlayCrc; + bool retval = false; + ssize_t offset = 0; + int fd = 0; + uint32_t* data = NULL; + size_t size; + + for (int i = 0; i < 2; ++i) { + asset_path ap; + ap.type = kFileTypeRegular; + ap.path = *paths[i]; + Asset* ass = openNonAssetInPathLocked("resources.arsc", Asset::ACCESS_BUFFER, ap); + if (ass == NULL) { + LOGW("failed to find resources.arsc in %s\n", ap.path.string()); + goto error; + } + tables[i].add(ass, (void*)1, false); + } + + if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &originalCrc)) { + LOGW("failed to retrieve crc for resources.arsc in %s\n", originalPath.string()); + goto error; + } + if (!getZipEntryCrcLocked(overlayPath, "resources.arsc", &overlayCrc)) { + LOGW("failed to retrieve crc for resources.arsc in %s\n", overlayPath.string()); + goto error; + } + + if (tables[0].createIdmap(tables[1], originalCrc, overlayCrc, + (void**)&data, &size) != NO_ERROR) { + LOGW("failed to generate idmap data for file %s\n", idmapPath.string()); + goto error; + } + + // This should be abstracted (eg replaced by a stand-alone + // application like dexopt, triggered by something equivalent to + // installd). + fd = TEMP_FAILURE_RETRY(::open(idmapPath.string(), O_WRONLY | O_CREAT | O_TRUNC, 0644)); + if (fd == -1) { + LOGW("failed to write idmap file %s (open: %s)\n", idmapPath.string(), strerror(errno)); + goto error_free; + } + for (;;) { + ssize_t written = TEMP_FAILURE_RETRY(write(fd, data + offset, size)); + if (written < 0) { + LOGW("failed to write idmap file %s (write: %s)\n", idmapPath.string(), + strerror(errno)); + goto error_close; + } + size -= (size_t)written; + offset += written; + if (size == 0) { + break; + } + } + + retval = true; +error_close: + TEMP_FAILURE_RETRY(close(fd)); +error_free: + free(data); +error: + return retval; +} + bool AssetManager::addDefaultAssets() { const char* root = getenv("ANDROID_ROOT"); @@ -405,6 +620,7 @@ const ResTable* AssetManager::getResTable(bool required) const ResTable* sharedRes = NULL; bool shared = true; const asset_path& ap = mAssetPaths.itemAt(i); + Asset* idmap = openIdmapLocked(ap); LOGV("Looking for resource asset in '%s'\n", ap.path.string()); if (ap.type != kFileTypeDirectory) { if (i == 0) { @@ -434,7 +650,7 @@ const ResTable* AssetManager::getResTable(bool required) const // can quickly copy it out for others. LOGV("Creating shared resources for %s", ap.path.string()); sharedRes = new ResTable(); - sharedRes->add(ass, (void*)(i+1), false); + sharedRes->add(ass, (void*)(i+1), false, idmap); sharedRes = const_cast<AssetManager*>(this)-> mZipSet.setZipResourceTable(ap.path, sharedRes); } @@ -458,7 +674,7 @@ const ResTable* AssetManager::getResTable(bool required) const rt->add(sharedRes); } else { LOGV("Parsing resources for %s", ap.path.string()); - rt->add(ass, (void*)(i+1), !shared); + rt->add(ass, (void*)(i+1), !shared, idmap); } if (!shared) { @@ -499,6 +715,21 @@ void AssetManager::updateResourceParamsLocked() const res->setParameters(mConfig); } +Asset* AssetManager::openIdmapLocked(const struct asset_path& ap) const +{ + Asset* ass = NULL; + if (ap.idmap.size() != 0) { + ass = const_cast<AssetManager*>(this)-> + openAssetFromFileLocked(ap.idmap, Asset::ACCESS_BUFFER); + if (ass) { + LOGV("loading idmap %s\n", ap.idmap.string()); + } else { + LOGW("failed to load idmap %s\n", ap.idmap.string()); + } + } + return ass; +} + const ResTable& AssetManager::getResources(bool required) const { const ResTable* rt = getResTable(required); diff --git a/libs/utils/README b/libs/utils/README index 36a706d..01741e0 100644 --- a/libs/utils/README +++ b/libs/utils/README @@ -1,4 +1,6 @@ Android Utility Function Library +================================ + If you need a feature that is native to Linux but not present on other platforms, construct a platform-dependent implementation that shares @@ -12,3 +14,276 @@ The ultimate goal is *not* to create a super-duper platform abstraction layer. The goal is to provide an optimized solution for Linux with reasonable implementations for other platforms. + + +Resource overlay +================ + + +Introduction +------------ + +Overlay packages are special .apk files which provide no code but +additional resource values (and possibly new configurations) for +resources in other packages. When an application requests resources, +the system will return values from either the application's original +package or any associated overlay package. Any redirection is completely +transparent to the calling application. + +Resource values have the following precedence table, listed in +descending precedence. + + * overlay package, matching config (eg res/values-en-land) + + * original package, matching config + + * overlay package, no config (eg res/values) + + * original package, no config + +During compilation, overlay packages are differentiated from regular +packages by passing the -o flag to aapt. + + +Background +---------- + +This section provides generic background material on resources in +Android. + + +How resources are bundled in .apk files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Android .apk files are .zip files, usually housing .dex code, +certificates and resources, though packages containing resources but +no code are possible. Resources can be divided into the following +categories; a `configuration' indicates a set of phone language, display +density, network operator, etc. + + * assets: uncompressed, raw files packaged as part of an .apk and + explicitly referenced by filename. These files are + independent of configuration. + + * res/drawable: bitmap or xml graphics. Each file may have different + values depending on configuration. + + * res/values: integers, strings, etc. Each resource may have different + values depending on configuration. + +Resource meta information and information proper is stored in a binary +format in a named file resources.arsc, bundled as part of the .apk. + +Resource IDs and lookup +~~~~~~~~~~~~~~~~~~~~~~~ +During compilation, the aapt tool gathers application resources and +generates a resources.arsc file. Each resource name is assigned an +integer ID 0xppttiii (translated to a symbolic name via R.java), where + + * pp: corresponds to the package namespace (details below). + + * tt: corresponds to the resource type (string, int, etc). Every + resource of the same type within the same package has the same + tt value, but depending on available types, the actual numerical + value may be different between packages. + + * iiii: sequential number, assigned in the order resources are found. + +Resource values are specified paired with a set of configuration +constraints (the default being the empty set), eg res/values-sv-port +which imposes restrictions on language (Swedish) and display orientation +(portrait). During lookup, every constraint set is matched against the +current configuration, and the value corresponding to the best matching +constraint set is returned (ResourceTypes.{h,cpp}). + +Parsing of resources.arsc is handled by ResourceTypes.cpp; this utility +is governed by AssetManager.cpp, which tracks loaded resources per +process. + +Assets are looked up by path and filename in AssetManager.cpp. The path +to resources in res/drawable are located by ResourceTypes.cpp and then +handled like assets by AssetManager.cpp. Other resources are handled +solely by ResourceTypes.cpp. + +Package ID as namespace +~~~~~~~~~~~~~~~~~~~~~~~ +The pp part of a resource ID defines a namespace. Android currently +defines two namespaces: + + * 0x01: system resources (pre-installed in framework-res.apk) + + * 0x7f: application resources (bundled in the application .apk) + +ResourceTypes.cpp supports package IDs between 0x01 and 0x7f +(inclusive); values outside this range are invalid. + +Each running (Dalvik) process is assigned a unique instance of +AssetManager, which in turn keeps a forest structure of loaded +resource.arsc files. Normally, this forest is structured as follows, +where mPackageMap is the internal vector employed in ResourceTypes.cpp. + +mPackageMap[0x00] -> system package +mPackageMap[0x01] -> NULL +mPackageMap[0x02] -> NULL +... +mPackageMap[0x7f - 2] -> NULL +mPackageMap[0x7f - 1] -> application package + + + +The resource overlay extension +------------------------------ + +The resource overlay mechanism aims to (partly) shadow and extend +existing resources with new values for defined and new configurations. +Technically, this is achieved by adding resource-only packages (called +overlay packages) to existing resource namespaces, like so: + +mPackageMap[0x00] -> system package -> system overlay package +mPackageMap[0x01] -> NULL +mPackageMap[0x02] -> NULL +... +mPackageMap[0x7f - 2] -> NULL +mPackageMap[0x7f - 1] -> application package -> overlay 1 -> overlay 2 + +The use of overlay resources is completely transparent to +applications; no additional resource identifiers are introduced, only +configuration/value pairs. Any number of overlay packages may be loaded +at a time; overlay packages are agnostic to what they target -- both +system and application resources are fair game. + +The package targeted by an overlay package is called the target or +original package. + +Resource overlay operates on symbolic resources names. Hence, to +override the string/str1 resources in a package, the overlay package +would include a resource also named string/str1. The end user does not +have to worry about the numeric resources IDs assigned by aapt, as this +is resolved automatically by the system. + +As of this writing, the use of resource overlay has not been fully +explored. Until it has, only OEMs are trusted to use resource overlay. +For this reason, overlay packages must reside in /system/overlay. + + +Resource ID mapping +~~~~~~~~~~~~~~~~~~~ +Resource identifiers must be coherent within the same namespace (ie +PackageGroup in ResourceTypes.cpp). Calling applications will refer to +resources using the IDs defined in the original package, but there is no +guarantee aapt has assigned the same ID to the corresponding resource in +an overlay package. To translate between the two, a resource ID mapping +{original ID -> overlay ID} is created during package installation +(PackageManagerService.java) and used during resource lookup. The +mapping is stored in /data/resource-cache, with a @idmap file name +suffix. + +The idmap file format is documented in a separate section, below. + + +Package management +~~~~~~~~~~~~~~~~~~ +Packages are managed by the PackageManagerService. Addition and removal +of packages are monitored via the inotify framework, exposed via +android.os.FileObserver. + +During initialization of a Dalvik process, ActivityThread.java requests +the process' AssetManager (by proxy, via AssetManager.java and JNI) +to load a list of packages. This list includes overlay packages, if +present. + +When a target package or a corresponding overlay package is installed, +the target package's process is stopped and a new idmap is generated. +This is similar to how applications are stopped when their packages are +upgraded. + + +Creating overlay packages +------------------------- + +Overlay packages should contain no code, define (some) resources with +the same type and name as in the original package, and be compiled with +the -o flag passed to aapt. + +The aapt -o flag instructs aapt to create an overlay package. +Technically, this means the package will be assigned package id 0x00. + +There are no restrictions on overlay packages names, though the naming +convention <original.package.name>.overlay.<name> is recommended. + + +Example overlay package +~~~~~~~~~~~~~~~~~~~~~~~ + +To overlay the resource bool/b in package com.foo.bar, to be applied +when the display is in landscape mode, create a new package with +no source code and a single .xml file under res/values-land, with +an entry for bool/b. Compile with aapt -o and place the results in +/system/overlay by adding the following to Android.mk: + +LOCAL_AAPT_FLAGS := -o com.foo.bar +LOCAL_MODULE_PATH := $(TARGET_OUT)/overlay + + +The ID map (idmap) file format +------------------------------ + +The idmap format is designed for lookup performance. However, leading +and trailing undefined overlay values are discarded to reduce the memory +footprint. + + +idmap grammar +~~~~~~~~~~~~~ +All atoms (names in square brackets) are uint32_t integers. The +idmap-magic constant spells "idmp" in ASCII. Offsets are given relative +to the data_header, not to the beginning of the file. + +map := header data +header := idmap-magic <crc32-original-pkg> <crc32-overlay-pkg> +idmap-magic := <0x706d6469> +data := data_header type_block+ +data_header := <m> header_block{m} +header_block := <0> | <type_block_offset> +type_block := <n> <id_offset> entry{n} +entry := <resource_id_in_target_package> + + +idmap example +~~~~~~~~~~~~~ +Given a pair of target and overlay packages with CRC sums 0x216a8fe2 +and 0x6b9beaec, each defining the following resources + +Name Target package Overlay package +string/str0 0x7f010000 - +string/str1 0x7f010001 0x7f010000 +string/str2 0x7f010002 - +string/str3 0x7f010003 0x7f010001 +string/str4 0x7f010004 - +bool/bool0 0x7f020000 - +integer/int0 0x7f030000 0x7f020000 +integer/int1 0x7f030001 - + +the corresponding resource map is + +0x706d6469 0x216a8fe2 0x6b9beaec 0x00000003 \ +0x00000004 0x00000000 0x00000009 0x00000003 \ +0x00000001 0x7f010000 0x00000000 0x7f010001 \ +0x00000001 0x00000000 0x7f020000 + +or, formatted differently + +0x706d6469 # magic: all idmap files begin with this constant +0x216a8fe2 # CRC32 of the resources.arsc file in the original package +0x6b9beaec # CRC32 of the resources.arsc file in the overlay package +0x00000003 # header; three types (string, bool, integer) in the target package +0x00000004 # header_block for type 0 (string) is located at offset 4 +0x00000000 # no bool type exists in overlay package -> no header_block +0x00000009 # header_block for type 2 (integer) is located at offset 9 +0x00000003 # header_block for string; overlay IDs span 3 elements +0x00000001 # the first string in target package is entry 1 == offset +0x7f010000 # target 0x7f01001 -> overlay 0x7f010000 +0x00000000 # str2 not defined in overlay package +0x7f010001 # target 0x7f010003 -> overlay 0x7f010001 +0x00000001 # header_block for integer; overlay IDs span 1 element +0x00000000 # offset == 0 +0x7f020000 # target 0x7f030000 -> overlay 0x7f020000 diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index ac9cdf9..784c9d2 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -63,6 +63,10 @@ namespace android { #endif #endif +#define IDMAP_MAGIC 0x706d6469 +// size measured in sizeof(uint32_t) +#define IDMAP_HEADER_SIZE (ResTable::IDMAP_HEADER_SIZE_BYTES / sizeof(uint32_t)) + static void printToLogFunc(void* cookie, const char* txt) { LOGV("%s", txt); @@ -214,6 +218,81 @@ static void deserializeInternal(const void* inData, Res_png_9patch* outData) { outData->colors = (uint32_t*) data; } +static bool assertIdmapHeader(const uint32_t* map, size_t sizeBytes) +{ + if (sizeBytes < ResTable::IDMAP_HEADER_SIZE_BYTES) { + LOGW("idmap assertion failed: size=%d bytes\n", sizeBytes); + return false; + } + if (*map != htodl(IDMAP_MAGIC)) { // htodl: map data expected to be in correct endianess + LOGW("idmap assertion failed: invalid magic found (is 0x%08x, expected 0x%08x)\n", + *map, htodl(IDMAP_MAGIC)); + return false; + } + return true; +} + +static status_t idmapLookup(const uint32_t* map, size_t sizeBytes, uint32_t key, uint32_t* outValue) +{ + // see README for details on the format of map + if (!assertIdmapHeader(map, sizeBytes)) { + return UNKNOWN_ERROR; + } + map = map + IDMAP_HEADER_SIZE; // skip ahead to data segment + // size of data block, in uint32_t + const size_t size = (sizeBytes - ResTable::IDMAP_HEADER_SIZE_BYTES) / sizeof(uint32_t); + const uint32_t type = Res_GETTYPE(key) + 1; // add one, idmap stores "public" type id + const uint32_t entry = Res_GETENTRY(key); + const uint32_t typeCount = *map; + + if (type > typeCount) { + LOGW("Resource ID map: type=%d exceeds number of types=%d\n", type, typeCount); + return UNKNOWN_ERROR; + } + if (typeCount > size) { + LOGW("Resource ID map: number of types=%d exceeds size of map=%d\n", typeCount, size); + return UNKNOWN_ERROR; + } + const uint32_t typeOffset = map[type]; + if (typeOffset == 0) { + *outValue = 0; + return NO_ERROR; + } + if (typeOffset + 1 > size) { + LOGW("Resource ID map: type offset=%d exceeds reasonable value, size of map=%d\n", + typeOffset, size); + return UNKNOWN_ERROR; + } + const uint32_t entryCount = map[typeOffset]; + const uint32_t entryOffset = map[typeOffset + 1]; + if (entryCount == 0 || entry < entryOffset || entry - entryOffset > entryCount - 1) { + *outValue = 0; + return NO_ERROR; + } + const uint32_t index = typeOffset + 2 + entry - entryOffset; + if (index > size) { + LOGW("Resource ID map: entry index=%d exceeds size of map=%d\n", index, size); + *outValue = 0; + return NO_ERROR; + } + *outValue = map[index]; + + return NO_ERROR; +} + +static status_t getIdmapPackageId(const uint32_t* map, size_t mapSize, uint32_t *outId) +{ + if (!assertIdmapHeader(map, mapSize)) { + return UNKNOWN_ERROR; + } + const uint32_t* p = map + IDMAP_HEADER_SIZE + 1; + while (*p == 0) { + ++p; + } + *outId = (map[*p + IDMAP_HEADER_SIZE + 2] >> 24) & 0x000000ff; + return NO_ERROR; +} + Res_png_9patch* Res_png_9patch::deserialize(const void* inData) { if (sizeof(void*) != sizeof(int32_t)) { @@ -1290,7 +1369,13 @@ status_t ResXMLTree::validateNode(const ResXMLTree_node* node) const struct ResTable::Header { - Header(ResTable* _owner) : owner(_owner), ownedData(NULL), header(NULL) { } + Header(ResTable* _owner) : owner(_owner), ownedData(NULL), header(NULL), + resourceIDMap(NULL), resourceIDMapSize(0) { } + + ~Header() + { + free(resourceIDMap); + } ResTable* const owner; void* ownedData; @@ -1301,6 +1386,8 @@ struct ResTable::Header void* cookie; ResStringPool values; + uint32_t* resourceIDMap; + size_t resourceIDMapSize; }; struct ResTable::Type @@ -1716,12 +1803,13 @@ inline ssize_t ResTable::getResourcePackageIndex(uint32_t resID) const return ((ssize_t)mPackageMap[Res_GETPACKAGE(resID)+1])-1; } -status_t ResTable::add(const void* data, size_t size, void* cookie, bool copyData) +status_t ResTable::add(const void* data, size_t size, void* cookie, bool copyData, + const void* idmap) { - return add(data, size, cookie, NULL, copyData); + return add(data, size, cookie, NULL, copyData, reinterpret_cast<const Asset*>(idmap)); } -status_t ResTable::add(Asset* asset, void* cookie, bool copyData) +status_t ResTable::add(Asset* asset, void* cookie, bool copyData, const void* idmap) { const void* data = asset->getBuffer(true); if (data == NULL) { @@ -1729,7 +1817,7 @@ status_t ResTable::add(Asset* asset, void* cookie, bool copyData) return UNKNOWN_ERROR; } size_t size = (size_t)asset->getLength(); - return add(data, size, cookie, asset, copyData); + return add(data, size, cookie, asset, copyData, reinterpret_cast<const Asset*>(idmap)); } status_t ResTable::add(ResTable* src) @@ -1757,19 +1845,30 @@ status_t ResTable::add(ResTable* src) } status_t ResTable::add(const void* data, size_t size, void* cookie, - Asset* asset, bool copyData) + Asset* asset, bool copyData, const Asset* idmap) { if (!data) return NO_ERROR; Header* header = new Header(this); header->index = mHeaders.size(); header->cookie = cookie; + if (idmap != NULL) { + const size_t idmap_size = idmap->getLength(); + const void* idmap_data = const_cast<Asset*>(idmap)->getBuffer(true); + header->resourceIDMap = (uint32_t*)malloc(idmap_size); + if (header->resourceIDMap == NULL) { + delete header; + return (mError = NO_MEMORY); + } + memcpy((void*)header->resourceIDMap, idmap_data, idmap_size); + header->resourceIDMapSize = idmap_size; + } mHeaders.add(header); const bool notDeviceEndian = htods(0xf0) != 0xf0; LOAD_TABLE_NOISY( - LOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d\n", - data, size, cookie, asset, copyData)); + LOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d " + "idmap=%p\n", data, size, cookie, asset, copyData, idmap)); if (copyData || notDeviceEndian) { header->ownedData = malloc(size); @@ -1836,7 +1935,16 @@ status_t ResTable::add(const void* data, size_t size, void* cookie, dtohl(header->header->packageCount)); return (mError=BAD_TYPE); } - if (parsePackage((ResTable_package*)chunk, header) != NO_ERROR) { + uint32_t idmap_id = 0; + if (idmap != NULL) { + uint32_t tmp; + if (getIdmapPackageId(header->resourceIDMap, + header->resourceIDMapSize, + &tmp) == NO_ERROR) { + idmap_id = tmp; + } + } + if (parsePackage((ResTable_package*)chunk, header, idmap_id) != NO_ERROR) { return mError; } curPackage++; @@ -1858,6 +1966,7 @@ status_t ResTable::add(const void* data, size_t size, void* cookie, if (mError != NO_ERROR) { LOGW("No string values found in resource table!"); } + TABLE_NOISY(LOGV("Returning from add with mError=%d\n", mError)); return mError; } @@ -2002,17 +2111,38 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag size_t ip = grp->packages.size(); while (ip > 0) { ip--; + int T = t; + int E = e; const Package* const package = grp->packages[ip]; + if (package->header->resourceIDMap) { + uint32_t overlayResID = 0x0; + status_t retval = idmapLookup(package->header->resourceIDMap, + package->header->resourceIDMapSize, + resID, &overlayResID); + if (retval == NO_ERROR && overlayResID != 0x0) { + // for this loop iteration, this is the type and entry we really want + LOGV("resource map 0x%08x -> 0x%08x\n", resID, overlayResID); + T = Res_GETTYPE(overlayResID); + E = Res_GETENTRY(overlayResID); + } else { + // resource not present in overlay package, continue with the next package + continue; + } + } const ResTable_type* type; const ResTable_entry* entry; const Type* typeClass; - ssize_t offset = getEntry(package, t, e, desiredConfig, &type, &entry, &typeClass); + ssize_t offset = getEntry(package, T, E, desiredConfig, &type, &entry, &typeClass); if (offset <= 0) { - if (offset < 0) { + // No {entry, appropriate config} pair found in package. If this + // package is an overlay package (ip != 0), this simply means the + // overlay package did not specify a default. + // Non-overlay packages are still required to provide a default. + if (offset < 0 && ip == 0) { LOGW("Failure getting entry for 0x%08x (t=%d e=%d) in package %zd (error %d)\n", - resID, t, e, ip, (int)offset); + resID, T, E, ip, (int)offset); rc = offset; goto out; } @@ -2044,13 +2174,16 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag if (outSpecFlags != NULL) { if (typeClass->typeSpecFlags != NULL) { - *outSpecFlags |= dtohl(typeClass->typeSpecFlags[e]); + *outSpecFlags |= dtohl(typeClass->typeSpecFlags[E]); } else { *outSpecFlags = -1; } } - - if (bestPackage != NULL && bestItem.isMoreSpecificThan(thisConfig)) { + + if (bestPackage != NULL && + (bestItem.isMoreSpecificThan(thisConfig) || bestItem.diff(thisConfig) == 0)) { + // Discard thisConfig not only if bestItem is more specific, but also if the two configs + // are identical (diff == 0), or overlay packages will not take effect. continue; } @@ -2250,21 +2383,45 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, TABLE_NOISY(LOGI("Building bag: %p\n", (void*)resID)); + ResTable_config bestConfig; + memset(&bestConfig, 0, sizeof(bestConfig)); + // Now collect all bag attributes from all packages. size_t ip = grp->packages.size(); while (ip > 0) { ip--; + int T = t; + int E = e; const Package* const package = grp->packages[ip]; + if (package->header->resourceIDMap) { + uint32_t overlayResID = 0x0; + status_t retval = idmapLookup(package->header->resourceIDMap, + package->header->resourceIDMapSize, + resID, &overlayResID); + if (retval == NO_ERROR && overlayResID != 0x0) { + // for this loop iteration, this is the type and entry we really want + LOGV("resource map 0x%08x -> 0x%08x\n", resID, overlayResID); + T = Res_GETTYPE(overlayResID); + E = Res_GETENTRY(overlayResID); + } else { + // resource not present in overlay package, continue with the next package + continue; + } + } const ResTable_type* type; const ResTable_entry* entry; const Type* typeClass; - LOGV("Getting entry pkg=%p, t=%d, e=%d\n", package, t, e); - ssize_t offset = getEntry(package, t, e, &mParams, &type, &entry, &typeClass); + LOGV("Getting entry pkg=%p, t=%d, e=%d\n", package, T, E); + ssize_t offset = getEntry(package, T, E, &mParams, &type, &entry, &typeClass); LOGV("Resulting offset=%d\n", offset); if (offset <= 0) { - if (offset < 0) { + // No {entry, appropriate config} pair found in package. If this + // package is an overlay package (ip != 0), this simply means the + // overlay package did not specify a default. + // Non-overlay packages are still required to provide a default. + if (offset < 0 && ip == 0) { if (set) free(set); return offset; } @@ -2277,6 +2434,15 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, continue; } + if (set != NULL && !type->config.isBetterThan(bestConfig, NULL)) { + continue; + } + bestConfig = type->config; + if (set) { + free(set); + set = NULL; + } + const uint16_t entrySize = dtohs(entry->size); const uint32_t parent = entrySize >= sizeof(ResTable_map_entry) ? dtohl(((const ResTable_map_entry*)entry)->parent.ident) : 0; @@ -2288,43 +2454,41 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, TABLE_NOISY(LOGI("Found map: size=%p parent=%p count=%d\n", entrySize, parent, count)); - if (set == NULL) { - // If this map inherits from another, we need to start - // with its parent's values. Otherwise start out empty. - TABLE_NOISY(printf("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", - entrySize, parent)); - if (parent) { - const bag_entry* parentBag; - uint32_t parentTypeSpecFlags = 0; - const ssize_t NP = getBagLocked(parent, &parentBag, &parentTypeSpecFlags); - const size_t NT = ((NP >= 0) ? NP : 0) + N; - set = (bag_set*)malloc(sizeof(bag_set)+sizeof(bag_entry)*NT); - if (set == NULL) { - return NO_MEMORY; - } - if (NP > 0) { - memcpy(set+1, parentBag, NP*sizeof(bag_entry)); - set->numAttrs = NP; - TABLE_NOISY(LOGI("Initialized new bag with %d inherited attributes.\n", NP)); - } else { - TABLE_NOISY(LOGI("Initialized new bag with no inherited attributes.\n")); - set->numAttrs = 0; - } - set->availAttrs = NT; - set->typeSpecFlags = parentTypeSpecFlags; + // If this map inherits from another, we need to start + // with its parent's values. Otherwise start out empty. + TABLE_NOISY(printf("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", + entrySize, parent)); + if (parent) { + const bag_entry* parentBag; + uint32_t parentTypeSpecFlags = 0; + const ssize_t NP = getBagLocked(parent, &parentBag, &parentTypeSpecFlags); + const size_t NT = ((NP >= 0) ? NP : 0) + N; + set = (bag_set*)malloc(sizeof(bag_set)+sizeof(bag_entry)*NT); + if (set == NULL) { + return NO_MEMORY; + } + if (NP > 0) { + memcpy(set+1, parentBag, NP*sizeof(bag_entry)); + set->numAttrs = NP; + TABLE_NOISY(LOGI("Initialized new bag with %d inherited attributes.\n", NP)); } else { - set = (bag_set*)malloc(sizeof(bag_set)+sizeof(bag_entry)*N); - if (set == NULL) { - return NO_MEMORY; - } + TABLE_NOISY(LOGI("Initialized new bag with no inherited attributes.\n")); set->numAttrs = 0; - set->availAttrs = N; - set->typeSpecFlags = 0; } + set->availAttrs = NT; + set->typeSpecFlags = parentTypeSpecFlags; + } else { + set = (bag_set*)malloc(sizeof(bag_set)+sizeof(bag_entry)*N); + if (set == NULL) { + return NO_MEMORY; + } + set->numAttrs = 0; + set->availAttrs = N; + set->typeSpecFlags = 0; } if (typeClass->typeSpecFlags != NULL) { - set->typeSpecFlags |= dtohl(typeClass->typeSpecFlags[e]); + set->typeSpecFlags |= dtohl(typeClass->typeSpecFlags[E]); } else { set->typeSpecFlags = -1; } @@ -3870,7 +4034,7 @@ ssize_t ResTable::getEntry( } status_t ResTable::parsePackage(const ResTable_package* const pkg, - const Header* const header) + const Header* const header, uint32_t idmap_id) { const uint8_t* base = (const uint8_t*)pkg; status_t err = validate_chunk(&pkg->header, sizeof(*pkg), @@ -3904,8 +4068,12 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, Package* package = NULL; PackageGroup* group = NULL; - uint32_t id = dtohl(pkg->id); - if (id != 0 && id < 256) { + uint32_t id = idmap_id != 0 ? idmap_id : dtohl(pkg->id); + // If at this point id == 0, pkg is an overlay package without a + // corresponding idmap. During regular usage, overlay packages are + // always loaded alongside their idmaps, but during idmap creation + // the package is temporarily loaded by itself. + if (id < 256) { package = new Package(this, header, pkg); if (package == NULL) { @@ -3958,7 +4126,7 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, return (mError=err); } } else { - LOG_ALWAYS_FATAL("Skins not supported!"); + LOG_ALWAYS_FATAL("Package id out of range"); return NO_ERROR; } @@ -4112,6 +4280,136 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, return NO_ERROR; } +status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, uint32_t overlayCrc, + void** outData, size_t* outSize) const +{ + // see README for details on the format of map + if (mPackageGroups.size() == 0) { + return UNKNOWN_ERROR; + } + if (mPackageGroups[0]->packages.size() == 0) { + return UNKNOWN_ERROR; + } + + Vector<Vector<uint32_t> > map; + const PackageGroup* pg = mPackageGroups[0]; + const Package* pkg = pg->packages[0]; + size_t typeCount = pkg->types.size(); + // starting size is header + first item (number of types in map) + *outSize = (IDMAP_HEADER_SIZE + 1) * sizeof(uint32_t); + const String16 overlayPackage(overlay.mPackageGroups[0]->packages[0]->package->name); + const uint32_t pkg_id = pkg->package->id << 24; + + for (size_t typeIndex = 0; typeIndex < typeCount; ++typeIndex) { + ssize_t offset = -1; + const Type* typeConfigs = pkg->getType(typeIndex); + ssize_t mapIndex = map.add(); + if (mapIndex < 0) { + return NO_MEMORY; + } + Vector<uint32_t>& vector = map.editItemAt(mapIndex); + for (size_t entryIndex = 0; entryIndex < typeConfigs->entryCount; ++entryIndex) { + uint32_t resID = (0xff000000 & ((pkg->package->id)<<24)) + | (0x00ff0000 & ((typeIndex+1)<<16)) + | (0x0000ffff & (entryIndex)); + resource_name resName; + if (!this->getResourceName(resID, &resName)) { + return UNKNOWN_ERROR; + } + + const String16 overlayType(resName.type, resName.typeLen); + const String16 overlayName(resName.name, resName.nameLen); + uint32_t overlayResID = overlay.identifierForName(overlayName.string(), + overlayName.size(), + overlayType.string(), + overlayType.size(), + overlayPackage.string(), + overlayPackage.size()); + if (overlayResID != 0) { + // overlay package has package ID == 0, use original package's ID instead + overlayResID |= pkg_id; + } + vector.push(overlayResID); + if (overlayResID != 0 && offset == -1) { + offset = Res_GETENTRY(resID); + } +#if 0 + if (overlayResID != 0) { + LOGD("%s/%s 0x%08x -> 0x%08x\n", + String8(String16(resName.type)).string(), + String8(String16(resName.name)).string(), + resID, overlayResID); + } +#endif + } + + if (offset != -1) { + // shave off leading and trailing entries which lack overlay values + vector.removeItemsAt(0, offset); + vector.insertAt((uint32_t)offset, 0, 1); + while (vector.top() == 0) { + vector.pop(); + } + // reserve space for number and offset of entries, and the actual entries + *outSize += (2 + vector.size()) * sizeof(uint32_t); + } else { + // no entries of current type defined in overlay package + vector.clear(); + // reserve space for type offset + *outSize += 1 * sizeof(uint32_t); + } + } + + if ((*outData = malloc(*outSize)) == NULL) { + return NO_MEMORY; + } + uint32_t* data = (uint32_t*)*outData; + *data++ = htodl(IDMAP_MAGIC); + *data++ = htodl(originalCrc); + *data++ = htodl(overlayCrc); + const size_t mapSize = map.size(); + *data++ = htodl(mapSize); + size_t offset = mapSize; + for (size_t i = 0; i < mapSize; ++i) { + const Vector<uint32_t>& vector = map.itemAt(i); + const size_t N = vector.size(); + if (N == 0) { + *data++ = htodl(0); + } else { + offset++; + *data++ = htodl(offset); + offset += N; + } + } + for (size_t i = 0; i < mapSize; ++i) { + const Vector<uint32_t>& vector = map.itemAt(i); + const size_t N = vector.size(); + if (N == 0) { + continue; + } + *data++ = htodl(N - 1); // do not count the offset (which is vector's first element) + for (size_t j = 0; j < N; ++j) { + const uint32_t& overlayResID = vector.itemAt(j); + *data++ = htodl(overlayResID); + } + } + + return NO_ERROR; +} + +bool ResTable::getIdmapInfo(const void* idmap, size_t sizeBytes, + uint32_t* pOriginalCrc, uint32_t* pOverlayCrc) +{ + const uint32_t* map = (const uint32_t*)idmap; + if (!assertIdmapHeader(map, sizeBytes)) { + return false; + } + *pOriginalCrc = map[1]; + *pOverlayCrc = map[2]; + return true; +} + + #ifndef HAVE_ANDROID_OS #define CHAR16_TO_CSTR(c16, len) (String8(String16(c16,len)).string()) diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index a219623..2ba9b3f 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -241,7 +241,7 @@ static void android_media_MediaMetadataRetriever_setDataSourceFD(JNIEnv *env, jo jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } - int fd = getParcelFileDescriptorFD(env, fileDescriptor); + int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (offset < 0 || length < 0 || fd < 0) { if (offset < 0) { LOGE("negative offset (%lld)", offset); diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index ecbd288..aa0adf3 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -325,7 +325,7 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } - int fd = getParcelFileDescriptorFD(env, fileDescriptor); + int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); LOGV("setDataSourceFD: fd %d", fd); process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." ); } diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index a8a46c1..2c24695 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -253,7 +253,7 @@ android_media_MediaRecorder_setOutputFileFD(JNIEnv *env, jobject thiz, jobject f jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } - int fd = getParcelFileDescriptorFD(env, fileDescriptor); + int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); sp<MediaRecorder> mr = getMediaRecorder(env, thiz); status_t opStatus = mr->setOutputFile(fd, offset, length); process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); @@ -267,7 +267,7 @@ android_media_MediaRecorder_setOutputFileAuxFD(JNIEnv *env, jobject thiz, jobjec jniThrowException(env, "java/lang/IllegalArgumentException", NULL); return; } - int fd = getParcelFileDescriptorFD(env, fileDescriptor); + int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); sp<MediaRecorder> mr = getMediaRecorder(env, thiz); status_t opStatus = mr->setOutputFileAuxiliary(fd); process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); @@ -404,38 +404,32 @@ android_media_MediaRecorder_native_init(JNIEnv *env) clazz = env->FindClass("android/media/MediaRecorder"); if (clazz == NULL) { - jniThrowException(env, "java/lang/RuntimeException", "Can't find android/media/MediaRecorder"); return; } fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); if (fields.context == NULL) { - jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaRecorder.mNativeContext"); return; } fields.surface = env->GetFieldID(clazz, "mSurface", "Landroid/view/Surface;"); if (fields.surface == NULL) { - jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaRecorder.mSurface"); return; } jclass surface = env->FindClass("android/view/Surface"); if (surface == NULL) { - jniThrowException(env, "java/lang/RuntimeException", "Can't find android/view/Surface"); return; } fields.surface_native = env->GetFieldID(surface, ANDROID_VIEW_SURFACE_JNI_ID, "I"); if (fields.surface_native == NULL) { - jniThrowException(env, "java/lang/RuntimeException", "Can't find Surface.mSurface"); return; } fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative", "(Ljava/lang/Object;IIILjava/lang/Object;)V"); if (fields.post_event == NULL) { - jniThrowException(env, "java/lang/RuntimeException", "MediaRecorder.postEventFromNative"); return; } } diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 06058dc..a3dd136 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -303,7 +303,7 @@ android_media_MediaScanner_extractAlbumArt( return NULL; } - int fd = getParcelFileDescriptorFD(env, fileDescriptor); + int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); char* data = mp->extractAlbumArt(fd); if (!data) { return NULL; @@ -335,15 +335,11 @@ android_media_MediaScanner_native_init(JNIEnv *env) LOGV("native_init"); jclass clazz = env->FindClass(kClassMediaScanner); if (clazz == NULL) { - const char* err = "Can't find android/media/MediaScanner"; - jniThrowException(env, kRunTimeException, err); return; } fields.context = env->GetFieldID(clazz, "mNativeContext", "I"); if (fields.context == NULL) { - const char* err = "Can't find MediaScanner.mNativeContext"; - jniThrowException(env, kRunTimeException, err); return; } } @@ -426,5 +422,3 @@ int register_android_media_MediaScanner(JNIEnv *env) return AndroidRuntime::registerNativeMethods(env, kClassMediaScanner, gMethods, NELEM(gMethods)); } - - diff --git a/media/jni/soundpool/android_media_SoundPool.cpp b/media/jni/soundpool/android_media_SoundPool.cpp index 447f931..03d3388 100644 --- a/media/jni/soundpool/android_media_SoundPool.cpp +++ b/media/jni/soundpool/android_media_SoundPool.cpp @@ -60,7 +60,7 @@ android_media_SoundPool_load_FD(JNIEnv *env, jobject thiz, jobject fileDescripto LOGV("android_media_SoundPool_load_FD"); SoundPool *ap = MusterSoundPool(env, thiz); if (ap == NULL) return 0; - return ap->load(getParcelFileDescriptorFD(env, fileDescriptor), + return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor), int64_t(offset), int64_t(length), int(priority)); } diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index f31c2ac..9bd329d 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#undef DEBUG_HDCP +#define DEBUG_HDCP //#define LOG_NDEBUG 0 #define LOG_TAG "AwesomePlayer" @@ -184,7 +184,8 @@ AwesomePlayer::AwesomePlayer() mFlags(0), mExtractorFlags(0), mVideoBuffer(NULL), - mDecryptHandle(NULL) { + mDecryptHandle(NULL), + mLastVideoTimeUs(-1) { CHECK_EQ(mClient.connect(), (status_t)OK); DataSource::RegisterDefaultSniffers(); @@ -470,28 +471,13 @@ void AwesomePlayer::reset_l() { mVideoRenderer.clear(); - if (mVideoBuffer) { - mVideoBuffer->release(); - mVideoBuffer = NULL; - } - if (mRTSPController != NULL) { mRTSPController->disconnect(); mRTSPController.clear(); } if (mVideoSource != NULL) { - mVideoSource->stop(); - - // The following hack is necessary to ensure that the OMX - // component is completely released by the time we may try - // to instantiate it again. - wp<MediaSource> tmp = mVideoSource; - mVideoSource.clear(); - while (tmp.promote() != NULL) { - usleep(1000); - } - IPCThreadState::self()->flushCommands(); + shutdownVideoDecoder_l(); } mDurationUs = -1; @@ -510,6 +496,7 @@ void AwesomePlayer::reset_l() { mFileSource.clear(); mBitrate = -1; + mLastVideoTimeUs = -1; } void AwesomePlayer::notifyListener_l(int msg, int ext1, int ext2) { @@ -1012,7 +999,7 @@ void AwesomePlayer::setSurface(const sp<Surface> &surface) { Mutex::Autolock autoLock(mLock); mSurface = surface; - mNativeWindow = surface; + setNativeWindow_l(surface); } void AwesomePlayer::setSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) { @@ -1020,9 +1007,57 @@ void AwesomePlayer::setSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) mSurface.clear(); if (surfaceTexture != NULL) { - mNativeWindow = new SurfaceTextureClient(surfaceTexture); + setNativeWindow_l(new SurfaceTextureClient(surfaceTexture)); } +} +void AwesomePlayer::shutdownVideoDecoder_l() { + if (mVideoBuffer) { + mVideoBuffer->release(); + mVideoBuffer = NULL; + } + + mVideoSource->stop(); + + // The following hack is necessary to ensure that the OMX + // component is completely released by the time we may try + // to instantiate it again. + wp<MediaSource> tmp = mVideoSource; + mVideoSource.clear(); + while (tmp.promote() != NULL) { + usleep(1000); + } + IPCThreadState::self()->flushCommands(); +} + +void AwesomePlayer::setNativeWindow_l(const sp<ANativeWindow> &native) { + mNativeWindow = native; + + if (mVideoSource == NULL) { + return; + } + + LOGI("attempting to reconfigure to use new surface"); + + bool wasPlaying = (mFlags & PLAYING) != 0; + + pause_l(); + mVideoRenderer.clear(); + + shutdownVideoDecoder_l(); + + CHECK_EQ(initVideoDecoder(), (status_t)OK); + + if (mLastVideoTimeUs >= 0) { + mSeeking = SEEK; + mSeekNotificationSent = true; + mSeekTimeUs = mLastVideoTimeUs; + mFlags &= ~(AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS); + } + + if (wasPlaying) { + play_l(); + } } void AwesomePlayer::setAudioSink( @@ -1412,6 +1447,8 @@ void AwesomePlayer::onVideoEvent() { int64_t timeUs; CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs)); + mLastVideoTimeUs = timeUs; + if (mSeeking == SEEK_VIDEO_ONLY) { if (mSeekTimeUs > timeUs) { LOGI("XXX mSeekTimeUs = %lld us, timeUs = %lld us", diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp index 03ce202..4bdfc6f 100644 --- a/media/libstagefright/MP3Extractor.cpp +++ b/media/libstagefright/MP3Extractor.cpp @@ -48,7 +48,7 @@ static const uint32_t kMask = 0xfffe0c00; bool MP3Extractor::get_mp3_frame_size( uint32_t header, size_t *frame_size, int *out_sampling_rate, int *out_channels, - int *out_bitrate) { + int *out_bitrate, int *out_num_samples) { *frame_size = 0; if (out_sampling_rate) { @@ -63,6 +63,10 @@ bool MP3Extractor::get_mp3_frame_size( *out_bitrate = 0; } + if (out_num_samples) { + *out_num_samples = 1152; + } + if ((header & 0xffe00000) != 0xffe00000) { return false; } @@ -127,6 +131,10 @@ bool MP3Extractor::get_mp3_frame_size( } *frame_size = (12000 * bitrate / sampling_rate + padding) * 4; + + if (out_num_samples) { + *out_num_samples = 384; + } } else { // layer II or III @@ -150,10 +158,17 @@ bool MP3Extractor::get_mp3_frame_size( bitrate = (layer == 2 /* L2 */) ? kBitrateV1L2[bitrate_index - 1] : kBitrateV1L3[bitrate_index - 1]; + + if (out_num_samples) { + *out_num_samples = 1152; + } } else { // V2 (or 2.5) bitrate = kBitrateV2[bitrate_index - 1]; + if (out_num_samples) { + *out_num_samples = 576; + } } if (out_bitrate) { @@ -374,6 +389,9 @@ private: sp<MP3Seeker> mSeeker; MediaBufferGroup *mGroup; + int64_t mBasisTimeUs; + int64_t mSamplesRead; + MP3Source(const MP3Source &); MP3Source &operator=(const MP3Source &); }; @@ -489,7 +507,9 @@ MP3Source::MP3Source( mCurrentTimeUs(0), mStarted(false), mSeeker(seeker), - mGroup(NULL) { + mGroup(NULL), + mBasisTimeUs(0), + mSamplesRead(0) { } MP3Source::~MP3Source() { @@ -509,6 +529,9 @@ status_t MP3Source::start(MetaData *) { mCurrentPos = mFirstFramePos; mCurrentTimeUs = 0; + mBasisTimeUs = mCurrentTimeUs; + mSamplesRead = 0; + mStarted = true; return OK; @@ -552,6 +575,9 @@ status_t MP3Source::read( } else { mCurrentTimeUs = actualSeekTimeUs; } + + mBasisTimeUs = mCurrentTimeUs; + mSamplesRead = 0; } MediaBuffer *buffer; @@ -562,6 +588,8 @@ status_t MP3Source::read( size_t frame_size; int bitrate; + int num_samples; + int sample_rate; for (;;) { ssize_t n = mDataSource->readAt(mCurrentPos, buffer->data(), 4); if (n < 4) { @@ -575,7 +603,7 @@ status_t MP3Source::read( if ((header & kMask) == (mFixedHeader & kMask) && MP3Extractor::get_mp3_frame_size( - header, &frame_size, NULL, NULL, &bitrate)) { + header, &frame_size, &sample_rate, NULL, &bitrate, &num_samples)) { break; } @@ -613,7 +641,9 @@ status_t MP3Source::read( buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1); mCurrentPos += frame_size; - mCurrentTimeUs += frame_size * 8000ll / bitrate; + + mSamplesRead += num_samples; + mCurrentTimeUs = mBasisTimeUs + ((mSamplesRead * 1000000) / sample_rate); *out = buffer; diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp index 4095fbf..7621f2c 100644 --- a/media/libstagefright/StagefrightMetadataRetriever.cpp +++ b/media/libstagefright/StagefrightMetadataRetriever.cpp @@ -146,7 +146,8 @@ static VideoFrame *extractVideoFrameWithCodecFlags( int64_t thumbNailTime; if (frameTimeUs < 0) { - if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime)) { + if (!trackMeta->findInt64(kKeyThumbnailTime, &thumbNailTime) + || thumbNailTime < 0) { thumbNailTime = 0; } options.setSeekTo(thumbNailTime, mode); diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index 7fd7724..8c61064 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -218,6 +218,8 @@ private: DrmManagerClient *mDrmManagerClient; sp<DecryptHandle> mDecryptHandle; + int64_t mLastVideoTimeUs; + status_t setDataSource_l( const char *uri, const KeyedVector<String8, String8> *headers = NULL); @@ -267,6 +269,9 @@ private: status_t startAudioPlayer_l(); + void shutdownVideoDecoder_l(); + void setNativeWindow_l(const sp<ANativeWindow> &native); + AwesomePlayer(const AwesomePlayer &); AwesomePlayer &operator=(const AwesomePlayer &); }; diff --git a/media/libstagefright/include/MP3Extractor.h b/media/libstagefright/include/MP3Extractor.h index ef71b8f..cf1146b 100644 --- a/media/libstagefright/include/MP3Extractor.h +++ b/media/libstagefright/include/MP3Extractor.h @@ -42,7 +42,7 @@ public: static bool get_mp3_frame_size( uint32_t header, size_t *frame_size, int *out_sampling_rate = NULL, int *out_channels = NULL, - int *out_bitrate = NULL); + int *out_bitrate = NULL, int *out_num_samples = NULL); private: status_t mInitCheck; diff --git a/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java b/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java index ed1af49..9bd8f36 100644 --- a/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java +++ b/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java @@ -18,6 +18,7 @@ package com.android.nfc_extras; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.nfc.ApduList; import android.nfc.INfcAdapterExtras; import android.nfc.NfcAdapter; import android.os.RemoteException; @@ -184,4 +185,20 @@ public final class NfcAdapterExtras { public NfcExecutionEnvironment getEmbeddedExecutionEnvironment() { return sEmbeddedEe; } + + public void registerTearDownApdus(String packageName, ApduList apdus) { + try { + sService.registerTearDownApdus(packageName, apdus); + } catch (RemoteException e) { + Log.e(TAG, "", e); + } + } + + public void unregisterTearDownApdus(String packageName) { + try { + sService.unregisterTearDownApdus(packageName); + } catch (RemoteException e) { + Log.e(TAG, "", e); + } + } } diff --git a/opengl/java/android/opengl/GLES10.java b/opengl/java/android/opengl/GLES10.java index 7c0f949..790acbd 100644 --- a/opengl/java/android/opengl/GLES10.java +++ b/opengl/java/android/opengl/GLES10.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** 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 +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES10Ext.java b/opengl/java/android/opengl/GLES10Ext.java index 116ab9d..81fc59e 100644 --- a/opengl/java/android/opengl/GLES10Ext.java +++ b/opengl/java/android/opengl/GLES10Ext.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** 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 +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES11.java b/opengl/java/android/opengl/GLES11.java index b24c043..1ca179b 100644 --- a/opengl/java/android/opengl/GLES11.java +++ b/opengl/java/android/opengl/GLES11.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** 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 +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES11Ext.java b/opengl/java/android/opengl/GLES11Ext.java index a9a7a22..25d5467 100644 --- a/opengl/java/android/opengl/GLES11Ext.java +++ b/opengl/java/android/opengl/GLES11Ext.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** 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 +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/android/opengl/GLES20.java b/opengl/java/android/opengl/GLES20.java index 700164b..635f811 100644 --- a/opengl/java/android/opengl/GLES20.java +++ b/opengl/java/android/opengl/GLES20.java @@ -1,18 +1,19 @@ /* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +** +** 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 +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/com/google/android/gles_jni/GLImpl.java b/opengl/java/com/google/android/gles_jni/GLImpl.java index 50f6760..090c0cb 100644 --- a/opengl/java/com/google/android/gles_jni/GLImpl.java +++ b/opengl/java/com/google/android/gles_jni/GLImpl.java @@ -1,18 +1,19 @@ -/* - * 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. - */ +/* //device/java/android/com/google/android/gles_jni/GLImpl.java +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL.java b/opengl/java/javax/microedition/khronos/opengles/GL.java index d5b60c6..3b78f3d 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL.java @@ -1,18 +1,19 @@ -/* - * 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. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL.java +** +** 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. +*/ package javax.microedition.khronos.opengles; diff --git a/opengl/java/javax/microedition/khronos/opengles/GL10.java b/opengl/java/javax/microedition/khronos/opengles/GL10.java index f48ecde..4fcfb52 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL10.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL10.java @@ -1,18 +1,19 @@ -/* - * 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. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL10.java +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java b/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java index f3252ab..562b20a 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL10Ext.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2007 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. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL10Ext.java +** +** Copyright 2007, 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. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL11.java b/opengl/java/javax/microedition/khronos/opengles/GL11.java index 943a5be..3ba110c 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL11.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL11.java @@ -1,18 +1,19 @@ -/* - * 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. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL11.java +** +** 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. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java b/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java index 842db7a..459a1ab 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL11Ext.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2007 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. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL11Ext.java +** +** Copyright 2007, 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. +*/ // This source file is automatically generated diff --git a/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java b/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java index 97d5fd8..933c91e 100644 --- a/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java +++ b/opengl/java/javax/microedition/khronos/opengles/GL11ExtensionPack.java @@ -1,18 +1,19 @@ -/* - * Copyright (C) 2007 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. - */ +/* //device/java/android/javax/microedition/khronos/opengles/GL11ExtensionPack.java +** +** Copyright 2007, 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. +*/ // This source file is automatically generated diff --git a/opengl/tools/glgen/gen b/opengl/tools/glgen/gen index 6c1a231..31f4190 100755 --- a/opengl/tools/glgen/gen +++ b/opengl/tools/glgen/gen @@ -21,7 +21,7 @@ mkdir -p out/android/util echo "package android.graphics;" > out/android/graphics/Canvas.java echo "public interface Canvas {}" >> out/android/graphics/Canvas.java -echo "package android.app; import android.content.pm.IPackageManager; public class ActivityThread { public static final ActivityThread currentActivityThread() { return null; } public static final String currentPackageName(){ return null; } public static IPackageManager getPackageManager() { return null;} }" > out/android/app/ActivityThread.java +echo "package android.app; import android.content.pm.IPackageManager; public class AppGlobals { public static IPackageManager getPackageManager() { return null;} }" > out/android/app/AppGlobals.java # echo "package android.content; import android.content.pm.PackageManager; public interface Context { public PackageManager getPackageManager(); }" > out/android/content/Context.java echo "package android.content.pm; public class ApplicationInfo {public int targetSdkVersion;}" > out/android/content/pm/ApplicationInfo.java echo "package android.content.pm; public interface IPackageManager {ApplicationInfo getApplicationInfo(java.lang.String packageName, int flags) throws android.os.RemoteException;}" > out/android/content/pm/IPackageManager.java diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java index 9d8c5a0..9fa2b74 100644 --- a/opengl/tools/glgen/src/JniCodeEmitter.java +++ b/opengl/tools/glgen/src/JniCodeEmitter.java @@ -58,7 +58,7 @@ public class JniCodeEmitter { } else if (baseType.equals("void")) { // nothing. } else { - throw new RuntimeException("Uknown primitive basetype " + baseType); + throw new RuntimeException("Unknown primitive basetype " + baseType); } return jniName; } @@ -200,15 +200,9 @@ public class JniCodeEmitter { if (emitExceptionCheck) { out.println(iii + indent + "_exception = 1;"); } - out.println(iii + indent + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - "IAEClass, " + - "\"" + - (isBuffer ? - "remaining()" : "length - " + offset) + - " < needed\");"); + out.println(iii + indent + "jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", " + + "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < needed\");"); out.println(iii + indent + "goto exit;"); needsExit = true; out.println(iii + "}"); @@ -302,7 +296,7 @@ public class JniCodeEmitter { } return false; } - + String isRequiresFunc(CFunc cfunc) { String[] checks = mChecker.getChecks(cfunc.getName()); int index = 1; @@ -329,109 +323,94 @@ public class JniCodeEmitter { } return null; } - + void emitNativeBoundsChecks(CFunc cfunc, String cname, PrintStream out, boolean isBuffer, boolean emitExceptionCheck, String offset, String remaining, String iii) { - String[] checks = mChecker.getChecks(cfunc.getName()); - - boolean lastWasIfcheck = false; - - int index = 1; - if (checks != null) { - while (index < checks.length) { - if (checks[index].startsWith("check")) { - if (lastWasIfcheck) { - printIfcheckPostamble(out, isBuffer, emitExceptionCheck, - offset, remaining, iii); - } - lastWasIfcheck = false; - if (cname != null && !cname.equals(checks[index + 1])) { - index += 3; - continue; - } - out.println(iii + "if (" + remaining + " < " + - checks[index + 2] + - ") {"); - if (emitExceptionCheck) { - out.println(iii + indent + "_exception = 1;"); - } - String exceptionClassName = "IAEClass"; + String[] checks = mChecker.getChecks(cfunc.getName()); + + boolean lastWasIfcheck = false; + + int index = 1; + if (checks != null) { + while (index < checks.length) { + if (checks[index].startsWith("check")) { + if (lastWasIfcheck) { + printIfcheckPostamble(out, isBuffer, emitExceptionCheck, + offset, remaining, iii); + } + lastWasIfcheck = false; + if (cname != null && !cname.equals(checks[index + 1])) { + index += 3; + continue; + } + out.println(iii + "if (" + remaining + " < " + checks[index + 2] + ") {"); + if (emitExceptionCheck) { + out.println(iii + indent + "_exception = 1;"); + } + String exceptionClassName = "java/lang/IllegalArgumentException"; // If the "check" keyword was of the form // "check_<class name>", use the class name in the // exception to be thrown int underscore = checks[index].indexOf('_'); if (underscore >= 0) { - exceptionClassName = checks[index].substring(underscore + 1) + "Class"; - } - out.println(iii + indent + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - exceptionClassName + ", " + - "\"" + - (isBuffer ? - "remaining()" : "length - " + offset) + - " < " + checks[index + 2] + - "\");"); - - out.println(iii + indent + "goto exit;"); - needsExit = true; - out.println(iii + "}"); - - index += 3; - } else if (checks[index].equals("ifcheck")) { - String[] matches = checks[index + 4].split(","); - - if (!lastWasIfcheck) { - out.println(iii + "int _needed;"); - out.println(iii + - "switch (" + - checks[index + 3] + - ") {"); - } - - for (int i = 0; i < matches.length; i++) { - out.println("#if defined(" + matches[i] + ")"); - out.println(iii + - " case " + - matches[i] + - ":"); - out.println("#endif // defined(" + matches[i] + ")"); - } - out.println(iii + - " _needed = " + - checks[index + 2] + - ";"); - out.println(iii + - " break;"); - - lastWasIfcheck = true; - index += 5; - } else if (checks[index].equals("return")) { - // ignore - index += 2; - } else if (checks[index].equals("unsupported")) { - // ignore - index += 1; - } else if (checks[index].equals("requires")) { - // ignore - index += 2; - } else if (checks[index].equals("nullAllowed")) { - // ignore - index += 1; + String abbr = checks[index].substring(underscore + 1); + if (abbr.equals("AIOOBE")) { + exceptionClassName = "java/lang/ArrayIndexOutOfBoundsException"; } else { - System.out.println("Error: unknown keyword \"" + - checks[index] + "\""); - System.exit(0); + throw new RuntimeException("unknown exception abbreviation: " + abbr); } } - } + out.println(iii + indent + "jniThrowException(_env, " + + "\"" + exceptionClassName + "\", " + + "\"" + (isBuffer ? "remaining()" : "length - " + offset) + " < " + checks[index + 2] + "\");"); + + out.println(iii + indent + "goto exit;"); + needsExit = true; + out.println(iii + "}"); + + index += 3; + } else if (checks[index].equals("ifcheck")) { + String[] matches = checks[index + 4].split(","); + + if (!lastWasIfcheck) { + out.println(iii + "int _needed;"); + out.println(iii + "switch (" + checks[index + 3] + ") {"); + } + + for (int i = 0; i < matches.length; i++) { + out.println("#if defined(" + matches[i] + ")"); + out.println(iii + " case " + matches[i] + ":"); + out.println("#endif // defined(" + matches[i] + ")"); + } + out.println(iii + " _needed = " + checks[index + 2] + ";"); + out.println(iii + " break;"); - if (lastWasIfcheck) { - printIfcheckPostamble(out, isBuffer, emitExceptionCheck, iii); + lastWasIfcheck = true; + index += 5; + } else if (checks[index].equals("return")) { + // ignore + index += 2; + } else if (checks[index].equals("unsupported")) { + // ignore + index += 1; + } else if (checks[index].equals("requires")) { + // ignore + index += 2; + } else if (checks[index].equals("nullAllowed")) { + // ignore + index += 1; + } else { + System.out.println("Error: unknown keyword \"" + checks[index] + "\""); + System.exit(0); } } + } + + if (lastWasIfcheck) { + printIfcheckPostamble(out, isBuffer, emitExceptionCheck, iii); + } + } boolean hasNonConstArg(JFunc jfunc, CFunc cfunc, List<Integer> nonPrimitiveArgs) { if (nonPrimitiveArgs.size() > 0) { @@ -817,7 +796,7 @@ public class JniCodeEmitter { boolean isUnsupported = isUnsupportedFunc(cfunc); if (isUnsupported) { out.println(indent + - "_env->ThrowNew(UOEClass,"); + "jniThrowException(_env, \"java/lang/UnsupportedOperationException\","); out.println(indent + " \"" + cfunc.getName() + "\");"); if (!isVoid) { @@ -828,13 +807,13 @@ public class JniCodeEmitter { out.println(); return; } - + String requiresExtension = isRequiresFunc(cfunc); if (requiresExtension != null) { out.println(indent + "if (! supportsExtension(_env, _this, have_" + requiresExtension + "ID)) {"); out.println(indent + indent + - "_env->ThrowNew(UOEClass,"); + "jniThrowException(_env, \"java/lang/UnsupportedOperationException\","); out.println(indent + indent + " \"" + cfunc.getName() + "\");"); if (isVoid) { @@ -945,7 +924,8 @@ public class JniCodeEmitter { CType type = cfunc.getArgType(jfunc.getArgCIndex(idx)); String decl = type.getDeclaration(); out.println(indent + "if (!" + cname + ") {"); - out.println(indent + " _env->ThrowNew(IAEClass, \"" + cname + " == null\");"); + out.println(indent + " jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", \"" + cname + " == null\");"); out.println(indent + " goto exit;"); needsExit = true; out.println(indent + "}"); @@ -978,13 +958,9 @@ public class JniCodeEmitter { if (emitExceptionCheck) { out.println(indent + indent + "_exception = 1;"); } - out.println(indent + " " + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - "IAEClass, " + - "\"" + cname + - " == null\");"); + out.println(indent + " jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", " + + "\"" + cname + " == null\");"); out.println(indent + " goto exit;"); needsExit = true; out.println(indent + "}"); @@ -993,12 +969,8 @@ public class JniCodeEmitter { if (emitExceptionCheck) { out.println(indent + indent + "_exception = 1;"); } - out.println(indent + " " + - (mUseCPlusPlus ? "_env" : "(*_env)") + - "->ThrowNew(" + - (mUseCPlusPlus ? "" : "_env, ") + - "IAEClass, " + - "\"" + offset + " < 0\");"); + out.println(indent + " jniThrowException(_env, " + + "\"java/lang/IllegalArgumentException\", \"" + offset + " < 0\");"); out.println(indent + " goto exit;"); needsExit = true; out.println(indent + "}"); diff --git a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp index 294d1ce..5d418d7 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES10ExtcHeader.cpp @@ -1,21 +1,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> @@ -27,10 +29,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; @@ -41,7 +39,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); @@ -63,26 +61,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) { @@ -103,13 +81,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); } @@ -122,4 +100,3 @@ releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit) } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp index e1c09f4..35a3c33 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES10cHeader.cpp @@ -1,21 +1,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> @@ -40,10 +42,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; @@ -54,7 +52,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); @@ -75,26 +73,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) { @@ -115,13 +93,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); } @@ -140,7 +118,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; } @@ -153,4 +132,3 @@ getNumCompressedTextureFormats() { } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp index 2548b32..9b29a44 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES11ExtcHeader.cpp @@ -1,21 +1,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> @@ -36,10 +38,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; @@ -50,7 +48,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); @@ -72,26 +70,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) { @@ -112,13 +90,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); } @@ -138,9 +116,9 @@ 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; } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp index 4c297f7..823079f 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES11cHeader.cpp @@ -1,21 +1,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> @@ -34,10 +36,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; @@ -48,7 +46,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); @@ -70,26 +68,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) { @@ -110,13 +88,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); } @@ -136,10 +114,10 @@ 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; } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp index e451e9a..13a2577 100644 --- a/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp +++ b/opengl/tools/glgen/stubs/gles11/GLES20cHeader.cpp @@ -1,21 +1,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> @@ -27,10 +29,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; @@ -41,7 +39,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); @@ -63,26 +61,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) { @@ -103,13 +81,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); } @@ -129,7 +107,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; } @@ -147,4 +126,3 @@ static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type, } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp b/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp index d92f515..ce6ab24 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.cpp @@ -1,27 +1,19 @@ -#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; -}
\ No newline at end of file + glGetProgramInfoLog(shader, infoLen, NULL, buf); + jstring result = _env->NewStringUTF(buf); + free(buf); + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp b/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp index 5441d66..dd656b6 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.cpp @@ -1,27 +1,19 @@ -#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; -}
\ No newline at end of file + glGetShaderInfoLog(shader, infoLen, NULL, buf); + jstring result = _env->NewStringUTF(buf); + free(buf); + return result; +} diff --git a/opengl/tools/glgen/stubs/gles11/glGetString.cpp b/opengl/tools/glgen/stubs/gles11/glGetString.cpp index a400859..239fe4a 100644 --- a/opengl/tools/glgen/stubs/gles11/glGetString.cpp +++ b/opengl/tools/glgen/stubs/gles11/glGetString.cpp @@ -1,11 +1,5 @@ -#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);
}
diff --git a/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp b/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp index c274108..125fd0f 100644 --- a/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp +++ b/opengl/tools/glgen/stubs/gles11/glShaderSource.cpp @@ -6,7 +6,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; } diff --git a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp index c2464b0..f7315ee 100644 --- a/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp +++ b/opengl/tools/glgen/stubs/jsr239/GLCHeader.cpp @@ -1,21 +1,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> @@ -63,10 +65,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; @@ -84,7 +82,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); @@ -114,26 +112,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) { @@ -154,7 +132,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) { @@ -163,7 +141,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); } @@ -207,7 +185,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; @@ -250,7 +229,7 @@ nextExtension(const GLubyte* pExtensions) { } } } - + static bool checkForExtension(const GLubyte* pExtensions, const GLubyte* pExtension) { for (;*pExtensions != '\0'; pExtensions = nextExtension(pExtensions)) { @@ -279,4 +258,3 @@ supportsExtension(JNIEnv *_env, jobject impl, jfieldID fieldId) { } // -------------------------------------------------------------------------- - diff --git a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl index 3727106..cd730aa 100644 --- a/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl +++ b/opengl/tools/glgen/stubs/jsr239/GLImplHeader.java-impl @@ -18,7 +18,7 @@ package com.google.android.gles_jni; -import android.app.ActivityThread; +import android.app.AppGlobals; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.os.Build; @@ -64,7 +64,7 @@ public class GLImpl implements GL10, GL10Ext, GL11, GL11Ext, GL11ExtensionPack { private static boolean allowIndirectBuffers(String appName) { boolean result = false; int version = 0; - IPackageManager pm = ActivityThread.getPackageManager(); + IPackageManager pm = AppGlobals.getPackageManager(); try { ApplicationInfo applicationInfo = pm.getApplicationInfo(appName, 0); if (applicationInfo != null) { diff --git a/opengl/tools/glgen/stubs/jsr239/glGetString.cpp b/opengl/tools/glgen/stubs/jsr239/glGetString.cpp index a400859..cd6e3f3 100644 --- a/opengl/tools/glgen/stubs/jsr239/glGetString.cpp +++ b/opengl/tools/glgen/stubs/jsr239/glGetString.cpp @@ -1,11 +1,5 @@ -#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);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java b/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java index 8c6eefb..7d4629e 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java @@ -410,7 +410,7 @@ public class RecentApplicationsActivity extends Activity { void updateRunningTasks() { mRunningTaskList = mActivityManager.getRunningTasks(MAX_TASKS, - ActivityManager.TASKS_GET_THUMBNAILS, mThumbnailReceiver); + 0, mThumbnailReceiver); if (DBG) Log.v(TAG, "Portrait: " + mPortraitMode); for (RunningTaskInfo r : mRunningTaskList) { if (r.thumbnail != null) { @@ -441,8 +441,7 @@ public class RecentApplicationsActivity extends Activity { final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = - am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE - | ActivityManager.TASKS_GET_THUMBNAILS); + am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE); ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) .resolveActivityInfo(pm, 0); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java index a39bef8..cfb4975 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java @@ -429,8 +429,7 @@ public class RecentAppsPanel extends RelativeLayout implements StatusBarPanel, O mContext.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = - am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE - | ActivityManager.TASKS_GET_THUMBNAILS); + am.getRecentTasks(MAX_TASKS, ActivityManager.RECENT_IGNORE_UNAVAILABLE); ActivityInfo homeInfo = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) .resolveActivityInfo(pm, 0); diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp index 5c3b43fc..dca795c 100644 --- a/services/audioflinger/AudioResampler.cpp +++ b/services/audioflinger/AudioResampler.cpp @@ -26,11 +26,15 @@ #include "AudioResamplerSinc.h" #include "AudioResamplerCubic.h" +#ifdef __arm__ +#include <machine/cpu-features.h> +#endif + namespace android { -#ifdef __ARM_ARCH_5E__ // optimized asm option +#ifdef __ARM_HAVE_HALFWORD_MULTIPLY // optimized asm option #define ASM_ARM_RESAMP1 // enable asm optimisation for ResamplerOrder1 -#endif // __ARM_ARCH_5E__ +#endif // __ARM_HAVE_HALFWORD_MULTIPLY // ---------------------------------------------------------------------------- class AudioResamplerOrder1 : public AudioResampler { diff --git a/services/input/Android.mk b/services/input/Android.mk index 96431bc..f9f8623f 100644 --- a/services/input/Android.mk +++ b/services/input/Android.mk @@ -22,7 +22,9 @@ LOCAL_SRC_FILES:= \ InputManager.cpp \ InputReader.cpp \ InputWindow.cpp \ - PointerController.cpp + PointerController.cpp \ + SpotController.cpp \ + SpriteController.cpp LOCAL_SHARED_LIBRARIES := \ libcutils \ diff --git a/services/input/InputReader.h b/services/input/InputReader.h index cf9b13d..9ed1391 100644 --- a/services/input/InputReader.h +++ b/services/input/InputReader.h @@ -20,6 +20,7 @@ #include "EventHub.h" #include "InputDispatcher.h" #include "PointerController.h" +#include "SpotController.h" #include <ui/Input.h> #include <ui/DisplayInfo.h> @@ -89,6 +90,9 @@ public: /* Gets a pointer controller associated with the specified cursor device (ie. a mouse). */ virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId) = 0; + + /* Gets a spot controller associated with the specified touch pad device. */ + virtual sp<SpotControllerInterface> obtainSpotController(int32_t deviceId) = 0; }; diff --git a/services/input/PointerController.cpp b/services/input/PointerController.cpp index a4ee295..15effb7 100644 --- a/services/input/PointerController.cpp +++ b/services/input/PointerController.cpp @@ -49,8 +49,11 @@ static const nsecs_t FADE_FRAME_INTERVAL = 1000000000LL / 60; static const float FADE_DECAY_PER_FRAME = float(FADE_FRAME_INTERVAL) / FADE_DURATION; -PointerController::PointerController(const sp<Looper>& looper, int32_t pointerLayer) : - mLooper(looper), mPointerLayer(pointerLayer) { +PointerController::PointerController(const sp<Looper>& looper, + const sp<SpriteController>& spriteController) : + mLooper(looper), mSpriteController(spriteController) { + mHandler = new WeakMessageHandler(this); + AutoMutex _l(mLock); mLocked.displayWidth = -1; @@ -61,34 +64,20 @@ PointerController::PointerController(const sp<Looper>& looper, int32_t pointerLa mLocked.pointerY = 0; mLocked.buttonState = 0; - mLocked.iconBitmap = NULL; - mLocked.iconHotSpotX = 0; - mLocked.iconHotSpotY = 0; - mLocked.fadeAlpha = 1; mLocked.inactivityFadeDelay = INACTIVITY_FADE_DELAY_NORMAL; - mLocked.wantVisible = false; mLocked.visible = false; - mLocked.drawn = false; - mHandler = new WeakMessageHandler(this); + mLocked.sprite = mSpriteController->createSprite(); } PointerController::~PointerController() { mLooper->removeMessages(mHandler); - if (mSurfaceControl != NULL) { - mSurfaceControl->clear(); - mSurfaceControl.clear(); - } - - if (mSurfaceComposerClient != NULL) { - mSurfaceComposerClient->dispose(); - mSurfaceComposerClient.clear(); - } + AutoMutex _l(mLock); - delete mLocked.iconBitmap; + mLocked.sprite.clear(); } bool PointerController::getBounds(float* outMinX, float* outMinY, @@ -214,75 +203,11 @@ void PointerController::setInactivityFadeDelay(InactivityFadeDelay inactivityFad } void PointerController::updateLocked() { - bool wantVisibleAndHavePointerIcon = mLocked.wantVisible && mLocked.iconBitmap; - - if (wantVisibleAndHavePointerIcon) { - // Want the pointer to be visible. - // Ensure the surface is created and drawn. - if (!createSurfaceIfNeededLocked() || !drawPointerIfNeededLocked()) { - return; - } - } else { - // Don't want the pointer to be visible. - // If it is not visible then we are done. - if (mSurfaceControl == NULL || !mLocked.visible) { - return; - } - } - - status_t status = mSurfaceComposerClient->openTransaction(); - if (status) { - LOGE("Error opening surface transaction to update pointer surface."); - return; - } - - if (wantVisibleAndHavePointerIcon) { - status = mSurfaceControl->setPosition( - mLocked.pointerX - mLocked.iconHotSpotX, - mLocked.pointerY - mLocked.iconHotSpotY); - if (status) { - LOGE("Error %d moving pointer surface.", status); - goto CloseTransaction; - } - - status = mSurfaceControl->setAlpha(mLocked.fadeAlpha); - if (status) { - LOGE("Error %d setting pointer surface alpha.", status); - goto CloseTransaction; - } - - if (!mLocked.visible) { - status = mSurfaceControl->setLayer(mPointerLayer); - if (status) { - LOGE("Error %d setting pointer surface layer.", status); - goto CloseTransaction; - } - - status = mSurfaceControl->show(mPointerLayer); - if (status) { - LOGE("Error %d showing pointer surface.", status); - goto CloseTransaction; - } - - mLocked.visible = true; - } - } else { - if (mLocked.visible) { - status = mSurfaceControl->hide(); - if (status) { - LOGE("Error %d hiding pointer surface.", status); - goto CloseTransaction; - } - - mLocked.visible = false; - } - } - -CloseTransaction: - status = mSurfaceComposerClient->closeTransaction(); - if (status) { - LOGE("Error closing surface transaction to update pointer surface."); - } + mLocked.sprite->openTransaction(); + mLocked.sprite->setPosition(mLocked.pointerX, mLocked.pointerY); + mLocked.sprite->setAlpha(mLocked.fadeAlpha); + mLocked.sprite->setVisible(mLocked.visible); + mLocked.sprite->closeTransaction(); } void PointerController::setDisplaySize(int32_t width, int32_t height) { @@ -339,7 +264,7 @@ void PointerController::setDisplayOrientation(int32_t orientation) { case DISPLAY_ORIENTATION_90: temp = x; x = y; - y = mLocked.displayWidth - x; + y = mLocked.displayWidth - temp; break; case DISPLAY_ORIENTATION_180: x = mLocked.displayWidth - x; @@ -365,106 +290,7 @@ void PointerController::setDisplayOrientation(int32_t orientation) { void PointerController::setPointerIcon(const SkBitmap* bitmap, float hotSpotX, float hotSpotY) { AutoMutex _l(mLock); - if (mLocked.iconBitmap) { - delete mLocked.iconBitmap; - mLocked.iconBitmap = NULL; - } - - if (bitmap) { - mLocked.iconBitmap = new SkBitmap(); - bitmap->copyTo(mLocked.iconBitmap, SkBitmap::kARGB_8888_Config); - } - - mLocked.iconHotSpotX = hotSpotX; - mLocked.iconHotSpotY = hotSpotY; - mLocked.drawn = false; -} - -bool PointerController::createSurfaceIfNeededLocked() { - if (!mLocked.iconBitmap) { - // If we don't have a pointer icon, then no point allocating a surface now. - return false; - } - - if (mSurfaceComposerClient == NULL) { - mSurfaceComposerClient = new SurfaceComposerClient(); - } - - if (mSurfaceControl == NULL) { - mSurfaceControl = mSurfaceComposerClient->createSurface(getpid(), - String8("Pointer Icon"), 0, - mLocked.iconBitmap->width(), mLocked.iconBitmap->height(), - PIXEL_FORMAT_RGBA_8888); - if (mSurfaceControl == NULL) { - LOGE("Error creating pointer surface."); - return false; - } - } - return true; -} - -bool PointerController::drawPointerIfNeededLocked() { - if (!mLocked.drawn) { - if (!mLocked.iconBitmap) { - return false; - } - - if (!resizeSurfaceLocked(mLocked.iconBitmap->width(), mLocked.iconBitmap->height())) { - return false; - } - - sp<Surface> surface = mSurfaceControl->getSurface(); - - Surface::SurfaceInfo surfaceInfo; - status_t status = surface->lock(&surfaceInfo); - if (status) { - LOGE("Error %d locking pointer surface before drawing.", status); - return false; - } - - SkBitmap surfaceBitmap; - ssize_t bpr = surfaceInfo.s * bytesPerPixel(surfaceInfo.format); - surfaceBitmap.setConfig(SkBitmap::kARGB_8888_Config, surfaceInfo.w, surfaceInfo.h, bpr); - surfaceBitmap.setPixels(surfaceInfo.bits); - - SkCanvas surfaceCanvas; - surfaceCanvas.setBitmapDevice(surfaceBitmap); - - SkPaint paint; - paint.setXfermodeMode(SkXfermode::kSrc_Mode); - surfaceCanvas.drawBitmap(*mLocked.iconBitmap, 0, 0, &paint); - - status = surface->unlockAndPost(); - if (status) { - LOGE("Error %d unlocking pointer surface after drawing.", status); - return false; - } - } - - mLocked.drawn = true; - return true; -} - -bool PointerController::resizeSurfaceLocked(int32_t width, int32_t height) { - status_t status = mSurfaceComposerClient->openTransaction(); - if (status) { - LOGE("Error opening surface transaction to resize pointer surface."); - return false; - } - - status = mSurfaceControl->setSize(width, height); - if (status) { - LOGE("Error %d setting pointer surface size.", status); - return false; - } - - status = mSurfaceComposerClient->closeTransaction(); - if (status) { - LOGE("Error closing surface transaction to resize pointer surface."); - return false; - } - - return true; + mLocked.sprite->setBitmap(bitmap, hotSpotX, hotSpotY); } void PointerController::handleMessage(const Message& message) { @@ -481,7 +307,7 @@ bool PointerController::unfadeBeforeUpdateLocked() { sendFadeStepMessageDelayedLocked(getInactivityFadeDelayTimeLocked()); if (isFadingLocked()) { - mLocked.wantVisible = true; + mLocked.visible = true; mLocked.fadeAlpha = 1; return true; // update required to effect the unfade } @@ -501,11 +327,11 @@ void PointerController::startInactivityFadeDelayLocked() { } void PointerController::fadeStepLocked() { - if (mLocked.wantVisible) { + if (mLocked.visible) { mLocked.fadeAlpha -= FADE_DECAY_PER_FRAME; if (mLocked.fadeAlpha < 0) { mLocked.fadeAlpha = 0; - mLocked.wantVisible = false; + mLocked.visible = false; } else { sendFadeStepMessageDelayedLocked(FADE_FRAME_INTERVAL); } @@ -514,7 +340,7 @@ void PointerController::fadeStepLocked() { } bool PointerController::isFadingLocked() { - return !mLocked.wantVisible || mLocked.fadeAlpha != 1; + return !mLocked.visible || mLocked.fadeAlpha != 1; } nsecs_t PointerController::getInactivityFadeDelayTimeLocked() { diff --git a/services/input/PointerController.h b/services/input/PointerController.h index e1dab5c..d467a5a 100644 --- a/services/input/PointerController.h +++ b/services/input/PointerController.h @@ -17,16 +17,14 @@ #ifndef _UI_POINTER_CONTROLLER_H #define _UI_POINTER_CONTROLLER_H +#include "SpriteController.h" + #include <ui/DisplayInfo.h> #include <ui/Input.h> #include <utils/RefBase.h> #include <utils/Looper.h> #include <utils/String8.h> -#include <surfaceflinger/Surface.h> -#include <surfaceflinger/SurfaceComposerClient.h> -#include <surfaceflinger/ISurfaceComposer.h> - #include <SkBitmap.h> namespace android { @@ -86,7 +84,7 @@ public: INACTIVITY_FADE_DELAY_SHORT = 1, }; - PointerController(const sp<Looper>& looper, int32_t pointerLayer); + PointerController(const sp<Looper>& looper, const sp<SpriteController>& spriteController); virtual bool getBounds(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const; @@ -111,9 +109,8 @@ private: mutable Mutex mLock; sp<Looper> mLooper; - int32_t mPointerLayer; - sp<SurfaceComposerClient> mSurfaceComposerClient; - sp<SurfaceControl> mSurfaceControl; + sp<SpriteController> mSpriteController; + sp<WeakMessageHandler> mHandler; struct Locked { int32_t displayWidth; @@ -124,26 +121,17 @@ private: float pointerY; uint32_t buttonState; - SkBitmap* iconBitmap; - float iconHotSpotX; - float iconHotSpotY; - float fadeAlpha; InactivityFadeDelay inactivityFadeDelay; - bool wantVisible; bool visible; - bool drawn; - } mLocked; - sp<WeakMessageHandler> mHandler; + sp<Sprite> sprite; + } mLocked; bool getBoundsLocked(float* outMinX, float* outMinY, float* outMaxX, float* outMaxY) const; void setPositionLocked(float x, float y); void updateLocked(); - bool createSurfaceIfNeededLocked(); - bool drawPointerIfNeededLocked(); - bool resizeSurfaceLocked(int32_t width, int32_t height); void handleMessage(const Message& message); bool unfadeBeforeUpdateLocked(); diff --git a/services/input/SpotController.cpp b/services/input/SpotController.cpp new file mode 100644 index 0000000..dffad81 --- /dev/null +++ b/services/input/SpotController.cpp @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#define LOG_TAG "SpotController" + +//#define LOG_NDEBUG 0 + +// Log debug messages about spot updates +#define DEBUG_SPOT_UPDATES 0 + +#include "SpotController.h" + +#include <cutils/log.h> + +namespace android { + +// --- SpotController --- + +SpotController::SpotController(const sp<Looper>& looper, + const sp<SpriteController>& spriteController) : + mLooper(looper), mSpriteController(spriteController) { + mHandler = new WeakMessageHandler(this); +} + +SpotController::~SpotController() { + mLooper->removeMessages(mHandler); +} + +void SpotController:: handleMessage(const Message& message) { +} + +} // namespace android diff --git a/services/input/SpotController.h b/services/input/SpotController.h new file mode 100644 index 0000000..1d091d7 --- /dev/null +++ b/services/input/SpotController.h @@ -0,0 +1,71 @@ +/* + * 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. + */ + +#ifndef _UI_SPOT_CONTROLLER_H +#define _UI_SPOT_CONTROLLER_H + +#include "SpriteController.h" + +#include <utils/RefBase.h> +#include <utils/Looper.h> + +#include <SkBitmap.h> + +namespace android { + +/* + * Interface for displaying spots on screen that visually represent the positions + * of fingers on a touch pad. + * + * The spot controller is responsible for providing synchronization and for tracking + * display orientation changes if needed. + */ +class SpotControllerInterface : public virtual RefBase { +protected: + SpotControllerInterface() { } + virtual ~SpotControllerInterface() { } + +public: + +}; + + +/* + * Sprite-based spot controller implementation. + */ +class SpotController : public SpotControllerInterface, public MessageHandler { +protected: + virtual ~SpotController(); + +public: + SpotController(const sp<Looper>& looper, const sp<SpriteController>& spriteController); + +private: + mutable Mutex mLock; + + sp<Looper> mLooper; + sp<SpriteController> mSpriteController; + sp<WeakMessageHandler> mHandler; + + struct Locked { + } mLocked; + + void handleMessage(const Message& message); +}; + +} // namespace android + +#endif // _UI_SPOT_CONTROLLER_H diff --git a/services/input/SpriteController.cpp b/services/input/SpriteController.cpp new file mode 100644 index 0000000..c6d4390 --- /dev/null +++ b/services/input/SpriteController.cpp @@ -0,0 +1,472 @@ +/* + * 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. + */ + +#define LOG_TAG "Sprites" + +//#define LOG_NDEBUG 0 + +#include "SpriteController.h" + +#include <cutils/log.h> +#include <utils/String8.h> + +#include <SkBitmap.h> +#include <SkCanvas.h> +#include <SkColor.h> +#include <SkPaint.h> +#include <SkXfermode.h> + +namespace android { + +// --- SpriteController --- + +SpriteController::SpriteController(const sp<Looper>& looper, int32_t overlayLayer) : + mLooper(looper), mOverlayLayer(overlayLayer) { + mHandler = new WeakMessageHandler(this); +} + +SpriteController::~SpriteController() { + mLooper->removeMessages(mHandler); + + if (mSurfaceComposerClient != NULL) { + mSurfaceComposerClient->dispose(); + mSurfaceComposerClient.clear(); + } +} + +sp<Sprite> SpriteController::createSprite() { + return new SpriteImpl(this); +} + +void SpriteController::invalidateSpriteLocked(const sp<SpriteImpl>& sprite) { + bool wasEmpty = mInvalidatedSprites.isEmpty(); + mInvalidatedSprites.push(sprite); + if (wasEmpty) { + mLooper->sendMessage(mHandler, Message(MSG_UPDATE_SPRITES)); + } +} + +void SpriteController::disposeSurfaceLocked(const sp<SurfaceControl>& surfaceControl) { + bool wasEmpty = mDisposedSurfaces.isEmpty(); + mDisposedSurfaces.push(surfaceControl); + if (wasEmpty) { + mLooper->sendMessage(mHandler, Message(MSG_DISPOSE_SURFACES)); + } +} + +void SpriteController::handleMessage(const Message& message) { + switch (message.what) { + case MSG_UPDATE_SPRITES: + doUpdateSprites(); + break; + case MSG_DISPOSE_SURFACES: + doDisposeSurfaces(); + break; + } +} + +void SpriteController::doUpdateSprites() { + // Collect information about sprite updates. + // Each sprite update record includes a reference to its associated sprite so we can + // be certain the sprites will not be deleted while this function runs. Sprites + // may invalidate themselves again during this time but we will handle those changes + // in the next iteration. + Vector<SpriteUpdate> updates; + size_t numSprites; + { // acquire lock + AutoMutex _l(mLock); + + numSprites = mInvalidatedSprites.size(); + for (size_t i = 0; i < numSprites; i++) { + const sp<SpriteImpl>& sprite = mInvalidatedSprites.itemAt(i); + + updates.push(SpriteUpdate(sprite, sprite->getStateLocked())); + sprite->resetDirtyLocked(); + } + mInvalidatedSprites.clear(); + } // release lock + + // Create missing surfaces. + bool surfaceChanged = false; + for (size_t i = 0; i < numSprites; i++) { + SpriteUpdate& update = updates.editItemAt(i); + + if (update.state.surfaceControl == NULL && update.state.wantSurfaceVisible()) { + update.state.surfaceWidth = update.state.bitmap.width(); + update.state.surfaceHeight = update.state.bitmap.height(); + update.state.surfaceDrawn = false; + update.state.surfaceVisible = false; + update.state.surfaceControl = obtainSurface( + update.state.surfaceWidth, update.state.surfaceHeight); + if (update.state.surfaceControl != NULL) { + update.surfaceChanged = surfaceChanged = true; + } + } + } + + // Resize sprites if needed, inside a global transaction. + bool haveGlobalTransaction = false; + for (size_t i = 0; i < numSprites; i++) { + SpriteUpdate& update = updates.editItemAt(i); + + if (update.state.surfaceControl != NULL && update.state.wantSurfaceVisible()) { + int32_t desiredWidth = update.state.bitmap.width(); + int32_t desiredHeight = update.state.bitmap.height(); + if (update.state.surfaceWidth < desiredWidth + || update.state.surfaceHeight < desiredHeight) { + if (!haveGlobalTransaction) { + SurfaceComposerClient::openGlobalTransaction(); + haveGlobalTransaction = true; + } + + status_t status = update.state.surfaceControl->setSize(desiredWidth, desiredHeight); + if (status) { + LOGE("Error %d resizing sprite surface from %dx%d to %dx%d", + status, update.state.surfaceWidth, update.state.surfaceHeight, + desiredWidth, desiredHeight); + } else { + update.state.surfaceWidth = desiredWidth; + update.state.surfaceHeight = desiredHeight; + update.state.surfaceDrawn = false; + update.surfaceChanged = surfaceChanged = true; + + if (update.state.surfaceVisible) { + status = update.state.surfaceControl->hide(); + if (status) { + LOGE("Error %d hiding sprite surface after resize.", status); + } else { + update.state.surfaceVisible = false; + } + } + } + } + } + } + if (haveGlobalTransaction) { + SurfaceComposerClient::closeGlobalTransaction(); + } + + // Redraw sprites if needed. + for (size_t i = 0; i < numSprites; i++) { + SpriteUpdate& update = updates.editItemAt(i); + + if ((update.state.dirty & DIRTY_BITMAP) && update.state.surfaceDrawn) { + update.state.surfaceDrawn = false; + update.surfaceChanged = surfaceChanged = true; + } + + if (update.state.surfaceControl != NULL && !update.state.surfaceDrawn + && update.state.wantSurfaceVisible()) { + sp<Surface> surface = update.state.surfaceControl->getSurface(); + Surface::SurfaceInfo surfaceInfo; + status_t status = surface->lock(&surfaceInfo); + if (status) { + LOGE("Error %d locking sprite surface before drawing.", status); + } else { + SkBitmap surfaceBitmap; + ssize_t bpr = surfaceInfo.s * bytesPerPixel(surfaceInfo.format); + surfaceBitmap.setConfig(SkBitmap::kARGB_8888_Config, + surfaceInfo.w, surfaceInfo.h, bpr); + surfaceBitmap.setPixels(surfaceInfo.bits); + + SkCanvas surfaceCanvas; + surfaceCanvas.setBitmapDevice(surfaceBitmap); + + SkPaint paint; + paint.setXfermodeMode(SkXfermode::kSrc_Mode); + surfaceCanvas.drawBitmap(update.state.bitmap, 0, 0, &paint); + + if (surfaceInfo.w > uint32_t(update.state.bitmap.width())) { + paint.setColor(0); // transparent fill color + surfaceCanvas.drawRectCoords(update.state.bitmap.width(), 0, + surfaceInfo.w, update.state.bitmap.height(), paint); + } + if (surfaceInfo.h > uint32_t(update.state.bitmap.height())) { + paint.setColor(0); // transparent fill color + surfaceCanvas.drawRectCoords(0, update.state.bitmap.height(), + surfaceInfo.w, surfaceInfo.h, paint); + } + + status = surface->unlockAndPost(); + if (status) { + LOGE("Error %d unlocking and posting sprite surface after drawing.", status); + } else { + update.state.surfaceDrawn = true; + update.surfaceChanged = surfaceChanged = true; + } + } + } + } + + // Set sprite surface properties and make them visible. + bool haveTransaction = false; + for (size_t i = 0; i < numSprites; i++) { + SpriteUpdate& update = updates.editItemAt(i); + + bool wantSurfaceVisibleAndDrawn = update.state.wantSurfaceVisible() + && update.state.surfaceDrawn; + bool becomingVisible = wantSurfaceVisibleAndDrawn && !update.state.surfaceVisible; + bool becomingHidden = !wantSurfaceVisibleAndDrawn && update.state.surfaceVisible; + if (update.state.surfaceControl != NULL && (becomingVisible || becomingHidden + || (wantSurfaceVisibleAndDrawn && (update.state.dirty & (DIRTY_ALPHA + | DIRTY_POSITION | DIRTY_TRANSFORMATION_MATRIX | DIRTY_LAYER + | DIRTY_VISIBILITY | DIRTY_HOTSPOT))))) { + status_t status; + if (!haveTransaction) { + status = mSurfaceComposerClient->openTransaction(); + if (status) { + LOGE("Error %d opening transation to update sprite surface.", status); + break; + } + haveTransaction = true; + } + + if (wantSurfaceVisibleAndDrawn + && (becomingVisible || (update.state.dirty & DIRTY_ALPHA))) { + status = update.state.surfaceControl->setAlpha(update.state.alpha); + if (status) { + LOGE("Error %d setting sprite surface alpha.", status); + } + } + + if (wantSurfaceVisibleAndDrawn + && (becomingVisible || (update.state.dirty & (DIRTY_POSITION + | DIRTY_HOTSPOT)))) { + status = update.state.surfaceControl->setPosition( + update.state.positionX - update.state.hotSpotX, + update.state.positionY - update.state.hotSpotY); + if (status) { + LOGE("Error %d setting sprite surface position.", status); + } + } + + if (wantSurfaceVisibleAndDrawn + && (becomingVisible + || (update.state.dirty & DIRTY_TRANSFORMATION_MATRIX))) { + status = update.state.surfaceControl->setMatrix( + update.state.transformationMatrix.dsdx, + update.state.transformationMatrix.dtdx, + update.state.transformationMatrix.dsdy, + update.state.transformationMatrix.dtdy); + if (status) { + LOGE("Error %d setting sprite surface transformation matrix.", status); + } + } + + int32_t surfaceLayer = mOverlayLayer + update.state.layer; + if (wantSurfaceVisibleAndDrawn + && (becomingVisible || (update.state.dirty & DIRTY_LAYER))) { + status = update.state.surfaceControl->setLayer(surfaceLayer); + if (status) { + LOGE("Error %d setting sprite surface layer.", status); + } + } + + if (becomingVisible) { + status = update.state.surfaceControl->show(surfaceLayer); + if (status) { + LOGE("Error %d showing sprite surface.", status); + } else { + update.state.surfaceVisible = true; + update.surfaceChanged = surfaceChanged = true; + } + } else if (becomingHidden) { + status = update.state.surfaceControl->hide(); + if (status) { + LOGE("Error %d hiding sprite surface.", status); + } else { + update.state.surfaceVisible = false; + update.surfaceChanged = surfaceChanged = true; + } + } + } + } + + if (haveTransaction) { + status_t status = mSurfaceComposerClient->closeTransaction(); + if (status) { + LOGE("Error %d closing transaction to update sprite surface.", status); + } + } + + // If any surfaces were changed, write back the new surface properties to the sprites. + if (surfaceChanged) { // acquire lock + AutoMutex _l(mLock); + + for (size_t i = 0; i < numSprites; i++) { + const SpriteUpdate& update = updates.itemAt(i); + + if (update.surfaceChanged) { + update.sprite->setSurfaceLocked(update.state.surfaceControl, + update.state.surfaceWidth, update.state.surfaceHeight, + update.state.surfaceDrawn, update.state.surfaceVisible); + } + } + } // release lock + + // Clear the sprite update vector outside the lock. It is very important that + // we do not clear sprite references inside the lock since we could be releasing + // the last remaining reference to the sprite here which would result in the + // sprite being deleted and the lock being reacquired by the sprite destructor + // while already held. + updates.clear(); +} + +void SpriteController::doDisposeSurfaces() { + // Collect disposed surfaces. + Vector<sp<SurfaceControl> > disposedSurfaces; + { // acquire lock + disposedSurfaces = mDisposedSurfaces; + mDisposedSurfaces.clear(); + } // release lock + + // Release the last reference to each surface outside of the lock. + // We don't want the surfaces to be deleted while we are holding our lock. + disposedSurfaces.clear(); +} + +void SpriteController::ensureSurfaceComposerClient() { + if (mSurfaceComposerClient == NULL) { + mSurfaceComposerClient = new SurfaceComposerClient(); + } +} + +sp<SurfaceControl> SpriteController::obtainSurface(int32_t width, int32_t height) { + ensureSurfaceComposerClient(); + + sp<SurfaceControl> surfaceControl = mSurfaceComposerClient->createSurface( + getpid(), String8("Sprite"), 0, width, height, PIXEL_FORMAT_RGBA_8888); + if (surfaceControl == NULL) { + LOGE("Error creating sprite surface."); + return NULL; + } + return surfaceControl; +} + + +// --- SpriteController::SpriteImpl --- + +SpriteController::SpriteImpl::SpriteImpl(const sp<SpriteController> controller) : + mController(controller), mTransactionNestingCount(0) { +} + +SpriteController::SpriteImpl::~SpriteImpl() { + AutoMutex _m(mController->mLock); + + // Let the controller take care of deleting the last reference to sprite + // surfaces so that we do not block the caller on an IPC here. + if (mState.surfaceControl != NULL) { + mController->disposeSurfaceLocked(mState.surfaceControl); + mState.surfaceControl.clear(); + } +} + +void SpriteController::SpriteImpl::setBitmap(const SkBitmap* bitmap, + float hotSpotX, float hotSpotY) { + AutoMutex _l(mController->mLock); + + if (bitmap) { + bitmap->copyTo(&mState.bitmap, SkBitmap::kARGB_8888_Config); + } else { + mState.bitmap.reset(); + } + + uint32_t dirty = DIRTY_BITMAP; + if (mState.hotSpotX != hotSpotX || mState.hotSpotY != hotSpotY) { + mState.hotSpotX = hotSpotX; + mState.hotSpotY = hotSpotY; + dirty |= DIRTY_HOTSPOT; + } + + invalidateLocked(dirty); +} + +void SpriteController::SpriteImpl::setVisible(bool visible) { + AutoMutex _l(mController->mLock); + + if (mState.visible != visible) { + mState.visible = visible; + invalidateLocked(DIRTY_VISIBILITY); + } +} + +void SpriteController::SpriteImpl::setPosition(float x, float y) { + AutoMutex _l(mController->mLock); + + if (mState.positionX != x || mState.positionY != y) { + mState.positionX = x; + mState.positionY = y; + invalidateLocked(DIRTY_POSITION); + } +} + +void SpriteController::SpriteImpl::setLayer(int32_t layer) { + AutoMutex _l(mController->mLock); + + if (mState.layer != layer) { + mState.layer = layer; + invalidateLocked(DIRTY_LAYER); + } +} + +void SpriteController::SpriteImpl::setAlpha(float alpha) { + AutoMutex _l(mController->mLock); + + if (mState.alpha != alpha) { + mState.alpha = alpha; + invalidateLocked(DIRTY_ALPHA); + } +} + +void SpriteController::SpriteImpl::setTransformationMatrix( + const SpriteTransformationMatrix& matrix) { + AutoMutex _l(mController->mLock); + + if (mState.transformationMatrix != matrix) { + mState.transformationMatrix = matrix; + invalidateLocked(DIRTY_TRANSFORMATION_MATRIX); + } +} + +void SpriteController::SpriteImpl::openTransaction() { + AutoMutex _l(mController->mLock); + + mTransactionNestingCount += 1; +} + +void SpriteController::SpriteImpl::closeTransaction() { + AutoMutex _l(mController->mLock); + + LOG_ALWAYS_FATAL_IF(mTransactionNestingCount == 0, + "Sprite closeTransaction() called but there is no open sprite transaction"); + + mTransactionNestingCount -= 1; + if (mTransactionNestingCount == 0 && mState.dirty) { + mController->invalidateSpriteLocked(this); + } +} + +void SpriteController::SpriteImpl::invalidateLocked(uint32_t dirty) { + if (mTransactionNestingCount > 0) { + bool wasDirty = mState.dirty; + mState.dirty |= dirty; + if (!wasDirty) { + mController->invalidateSpriteLocked(this); + } + } +} + +} // namespace android diff --git a/services/input/SpriteController.h b/services/input/SpriteController.h new file mode 100644 index 0000000..27afb5e --- /dev/null +++ b/services/input/SpriteController.h @@ -0,0 +1,251 @@ +/* + * 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. + */ + +#ifndef _UI_SPRITES_H +#define _UI_SPRITES_H + +#include <utils/RefBase.h> +#include <utils/Looper.h> + +#include <surfaceflinger/Surface.h> +#include <surfaceflinger/SurfaceComposerClient.h> +#include <surfaceflinger/ISurfaceComposer.h> + +#include <SkBitmap.h> + +namespace android { + +/* + * Transformation matrix for a sprite. + */ +struct SpriteTransformationMatrix { + inline SpriteTransformationMatrix() : dsdx(1.0f), dtdx(0.0f), dsdy(0.0f), dtdy(1.0f) { } + + float dsdx; + float dtdx; + float dsdy; + float dtdy; + + inline bool operator== (const SpriteTransformationMatrix& other) { + return dsdx == other.dsdx + && dtdx == other.dtdx + && dsdy == other.dsdy + && dtdy == other.dtdy; + } + + inline bool operator!= (const SpriteTransformationMatrix& other) { + return !(*this == other); + } +}; + +/* + * A sprite is a simple graphical object that is displayed on-screen above other layers. + * The basic sprite class is an interface. + * The implementation is provided by the sprite controller. + */ +class Sprite : public RefBase { +protected: + Sprite() { } + virtual ~Sprite() { } + +public: + /* Sets the bitmap that is drawn by the sprite. + * The sprite retains a copy of the bitmap for subsequent rendering. */ + virtual void setBitmap(const SkBitmap* bitmap, float hotSpotX, float hotSpotY) = 0; + + /* Sets whether the sprite is visible. */ + virtual void setVisible(bool visible) = 0; + + /* Sets the sprite position on screen, relative to the sprite's hot spot. */ + virtual void setPosition(float x, float y) = 0; + + /* Sets the layer of the sprite, relative to the system sprite overlay layer. + * Layer 0 is the overlay layer, > 0 appear above this layer. */ + virtual void setLayer(int32_t layer) = 0; + + /* Sets the sprite alpha blend ratio between 0.0 and 1.0. */ + virtual void setAlpha(float alpha) = 0; + + /* Sets the sprite transformation matrix. */ + virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix) = 0; + + /* Opens or closes a transaction to perform a batch of sprite updates as part of + * a single operation such as setPosition and setAlpha. It is not necessary to + * open a transaction when updating a single property. + * Calls to openTransaction() nest and must be matched by an equal number + * of calls to closeTransaction(). */ + virtual void openTransaction() = 0; + virtual void closeTransaction() = 0; +}; + +/* + * Displays sprites on the screen. + * + * This interface is used by PointerController and SpotController to draw pointers or + * spot representations of fingers. It is not intended for general purpose use + * by other components. + * + * All sprite position updates and rendering is performed asynchronously. + * + * Clients are responsible for animating sprites by periodically updating their properties. + */ +class SpriteController : public MessageHandler { +protected: + virtual ~SpriteController(); + +public: + SpriteController(const sp<Looper>& looper, int32_t overlayLayer); + + /* Creates a new sprite, initially invisible. */ + sp<Sprite> createSprite(); + +private: + enum { + MSG_UPDATE_SPRITES, + MSG_DISPOSE_SURFACES, + }; + + enum { + DIRTY_BITMAP = 1 << 0, + DIRTY_ALPHA = 1 << 1, + DIRTY_POSITION = 1 << 2, + DIRTY_TRANSFORMATION_MATRIX = 1 << 3, + DIRTY_LAYER = 1 << 4, + DIRTY_VISIBILITY = 1 << 5, + DIRTY_HOTSPOT = 1 << 6, + }; + + /* Describes the state of a sprite. + * This structure is designed so that it can be copied during updates so that + * surfaces can be resized and redrawn without blocking the client by holding a lock + * on the sprites for a long time. + * Note that the SkBitmap holds a reference to a shared (and immutable) pixel ref. */ + struct SpriteState { + inline SpriteState() : + dirty(0), hotSpotX(0), hotSpotY(0), visible(false), + positionX(0), positionY(0), layer(0), alpha(1.0f), + surfaceWidth(0), surfaceHeight(0), surfaceDrawn(false), surfaceVisible(false) { + } + + uint32_t dirty; + + SkBitmap bitmap; + float hotSpotX; + float hotSpotY; + bool visible; + float positionX; + float positionY; + int32_t layer; + float alpha; + SpriteTransformationMatrix transformationMatrix; + + sp<SurfaceControl> surfaceControl; + int32_t surfaceWidth; + int32_t surfaceHeight; + bool surfaceDrawn; + bool surfaceVisible; + + inline bool wantSurfaceVisible() const { + return visible && alpha > 0.0f && !bitmap.isNull() && !bitmap.empty(); + } + }; + + /* Client interface for a sprite. + * Requests acquire a lock on the controller, update local state and request the + * controller to invalidate the sprite. + * The real heavy lifting of creating, resizing and redrawing surfaces happens + * asynchronously with no locks held except in short critical section to copy + * the sprite state before the work and update the sprite surface control afterwards. + */ + class SpriteImpl : public Sprite { + protected: + virtual ~SpriteImpl(); + + public: + SpriteImpl(const sp<SpriteController> controller); + + virtual void setBitmap(const SkBitmap* bitmap, float hotSpotX, float hotSpotY); + virtual void setVisible(bool visible); + virtual void setPosition(float x, float y); + virtual void setLayer(int32_t layer); + virtual void setAlpha(float alpha); + virtual void setTransformationMatrix(const SpriteTransformationMatrix& matrix); + virtual void openTransaction(); + virtual void closeTransaction(); + + inline const SpriteState& getStateLocked() const { + return mState; + } + + inline void resetDirtyLocked() { + mState.dirty = 0; + } + + inline void setSurfaceLocked(const sp<SurfaceControl>& surfaceControl, + int32_t width, int32_t height, bool drawn, bool visible) { + mState.surfaceControl = surfaceControl; + mState.surfaceWidth = width; + mState.surfaceHeight = height; + mState.surfaceDrawn = drawn; + mState.surfaceVisible = visible; + } + + private: + sp<SpriteController> mController; + + SpriteState mState; // guarded by mController->mLock + uint32_t mTransactionNestingCount; // guarded by mController->mLock + + void invalidateLocked(uint32_t dirty); + }; + + /* Stores temporary information collected during the sprite update cycle. */ + struct SpriteUpdate { + inline SpriteUpdate() : surfaceChanged(false) { } + inline SpriteUpdate(const sp<SpriteImpl> sprite, const SpriteState& state) : + sprite(sprite), state(state), surfaceChanged(false) { + } + + sp<SpriteImpl> sprite; + SpriteState state; + bool surfaceChanged; + }; + + mutable Mutex mLock; + + sp<Looper> mLooper; + const int32_t mOverlayLayer; + sp<WeakMessageHandler> mHandler; + + sp<SurfaceComposerClient> mSurfaceComposerClient; + + Vector<sp<SpriteImpl> > mInvalidatedSprites; // guarded by mLock + Vector<sp<SurfaceControl> > mDisposedSurfaces; // guarded by mLock + + void invalidateSpriteLocked(const sp<SpriteImpl>& sprite); + void disposeSurfaceLocked(const sp<SurfaceControl>& surfaceControl); + + void handleMessage(const Message& message); + void doUpdateSprites(); + void doDisposeSurfaces(); + + void ensureSurfaceComposerClient(); + sp<SurfaceControl> obtainSurface(int32_t width, int32_t height); +}; + +} // namespace android + +#endif // _UI_SPRITES_H diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp index 4c5f239..ba8ca9c 100644 --- a/services/input/tests/InputReader_test.cpp +++ b/services/input/tests/InputReader_test.cpp @@ -192,6 +192,10 @@ private: virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId) { return mPointerControllers.valueFor(deviceId); } + + virtual sp<SpotControllerInterface> obtainSpotController(int32_t device) { + return NULL; + } }; diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index f44b889..768d990 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -441,8 +441,7 @@ public final class ActivityManagerService extends ActivityManagerNative /** * List of intents that were used to start the most recent tasks. */ - final ArrayList<TaskRecord> mRecentTasks - = new ArrayList<TaskRecord>(); + final ArrayList<TaskRecord> mRecentTasks = new ArrayList<TaskRecord>(); /** * All of the applications we currently have running organized by name. @@ -450,8 +449,7 @@ public final class ActivityManagerService extends ActivityManagerNative * returned by the package manager), and the keys are ApplicationRecord * objects. */ - final ProcessMap<ProcessRecord> mProcessNames - = new ProcessMap<ProcessRecord>(); + final ProcessMap<ProcessRecord> mProcessNames = new ProcessMap<ProcessRecord>(); /** * The currently running heavy-weight process, if any. @@ -480,8 +478,7 @@ public final class ActivityManagerService extends ActivityManagerNative * <p>NOTE: This object is protected by its own lock, NOT the global * activity manager lock! */ - final SparseArray<ProcessRecord> mPidsSelfLocked - = new SparseArray<ProcessRecord>(); + final SparseArray<ProcessRecord> mPidsSelfLocked = new SparseArray<ProcessRecord>(); /** * All of the processes that have been forced to be foreground. The key @@ -2981,7 +2978,10 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (this) { if (!showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID) { - Process.killProcess(app.pid); + Slog.w(TAG, "Killing " + app + ": background ANR"); + EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + app.processName, app.setAdj, "background ANR"); + Process.killProcessQuiet(app.pid); return; } @@ -3446,7 +3446,9 @@ public final class ActivityManagerService extends ActivityManagerNative bringDownServiceLocked(sr, true); } } - Process.killProcess(pid); + EventLog.writeEvent(EventLogTags.AM_KILL, pid, + app.processName, app.setAdj, "start timeout"); + Process.killProcessQuiet(pid); if (mBackupTarget != null && mBackupTarget.app.pid == pid) { Slog.w(TAG, "Unattached app died before backup, skipping"); try { @@ -3492,7 +3494,7 @@ public final class ActivityManagerService extends ActivityManagerNative + " (IApplicationThread " + thread + "); dropping process"); EventLog.writeEvent(EventLogTags.AM_DROP_PROCESS, pid); if (pid > 0 && pid != MY_PID) { - Process.killProcess(pid); + Process.killProcessQuiet(pid); } else { try { thread.scheduleExit(); @@ -4832,11 +4834,6 @@ public final class ActivityManagerService extends ActivityManagerNative throw new SecurityException(msg); } - final boolean canReadFb = (flags&ActivityManager.TASKS_GET_THUMBNAILS) != 0 - && checkCallingPermission( - android.Manifest.permission.READ_FRAME_BUFFER) - == PackageManager.PERMISSION_GRANTED; - int pos = mMainStack.mHistory.size()-1; ActivityRecord next = pos >= 0 ? (ActivityRecord)mMainStack.mHistory.get(pos) : null; @@ -4876,13 +4873,6 @@ public final class ActivityManagerService extends ActivityManagerNative ci.id = curTask.taskId; ci.baseActivity = r.intent.getComponent(); ci.topActivity = top.intent.getComponent(); - if (canReadFb) { - if (top.state == ActivityState.RESUMED) { - ci.thumbnail = top.stack.screenshotActivities(top); - } else if (top.thumbHolder != null) { - ci.thumbnail = top.thumbHolder.lastThumbnail; - } - } if (top.thumbHolder != null) { ci.description = top.thumbHolder.lastDescription; } @@ -4955,8 +4945,6 @@ public final class ActivityManagerService extends ActivityManagerNative IPackageManager pm = AppGlobals.getPackageManager(); - ActivityRecord resumed = mMainStack.mResumedActivity; - final int N = mRecentTasks.size(); ArrayList<ActivityManager.RecentTaskInfo> res = new ArrayList<ActivityManager.RecentTaskInfo>( @@ -5002,74 +4990,121 @@ public final class ActivityManagerService extends ActivityManagerNative } } + private TaskRecord taskForIdLocked(int id) { + final int N = mRecentTasks.size(); + for (int i=0; i<N; i++) { + TaskRecord tr = mRecentTasks.get(i); + if (tr.taskId == id) { + return tr; + } + } + return null; + } + public ActivityManager.TaskThumbnails getTaskThumbnails(int id) { synchronized (this) { enforceCallingPermission(android.Manifest.permission.READ_FRAME_BUFFER, - "getTaskThumbnail()"); - ActivityRecord resumed = mMainStack.mResumedActivity; - final int N = mRecentTasks.size(); - for (int i=0; i<N; i++) { - TaskRecord tr = mRecentTasks.get(i); - if (tr.taskId == id) { - final ActivityManager.TaskThumbnails thumbs - = new ActivityManager.TaskThumbnails(); - if (resumed != null && resumed.thumbHolder == tr) { - thumbs.mainThumbnail = resumed.stack.screenshotActivities(resumed); - } else { - thumbs.mainThumbnail = tr.lastThumbnail; - } - // How many different sub-thumbnails? - final int NA = mMainStack.mHistory.size(); - int j = 0; - ThumbnailHolder holder = null; - while (j < NA) { - ActivityRecord ar = (ActivityRecord)mMainStack.mHistory.get(j); - j++; - if (ar.task == tr) { - holder = ar.thumbHolder; - break; - } - } - ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(); - thumbs.otherThumbnails = bitmaps; - ActivityRecord lastActivity = null; - while (j < NA) { - ActivityRecord ar = (ActivityRecord)mMainStack.mHistory.get(j); - j++; - if (ar.task != tr) { - break; - } - lastActivity = ar; - if (ar.thumbHolder != holder && holder != null) { - thumbs.numSubThumbbails++; - holder = ar.thumbHolder; - bitmaps.add(holder.lastThumbnail); - } - } - if (lastActivity != null && bitmaps.size() > 0) { - if (resumed == lastActivity) { - Bitmap bm = lastActivity.stack.screenshotActivities(lastActivity); - if (bm != null) { - bitmaps.remove(bitmaps.size()-1); - bitmaps.add(bm); - } - } + "getTaskThumbnails()"); + TaskRecord tr = taskForIdLocked(id); + if (tr != null) { + return mMainStack.getTaskThumbnailsLocked(tr); + } + } + return null; + } + + public boolean removeSubTask(int taskId, int subTaskIndex) { + synchronized (this) { + enforceCallingPermission(android.Manifest.permission.REMOVE_TASKS, + "removeSubTask()"); + long ident = Binder.clearCallingIdentity(); + try { + return mMainStack.removeTaskActivitiesLocked(taskId, subTaskIndex) != null; + } finally { + Binder.restoreCallingIdentity(ident); + } + } + } + + private void removeTaskProcessesLocked(ActivityRecord root) { + TaskRecord tr = root.task; + Intent baseIntent = new Intent( + tr.intent != null ? tr.intent : tr.affinityIntent); + ComponentName component = baseIntent.getComponent(); + if (component == null) { + Slog.w(TAG, "Now component for base intent of task: " + tr); + return; + } + + // Find any running services associated with this app. + ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>(); + for (ServiceRecord sr : mServices.values()) { + if (sr.packageName.equals(component.getPackageName())) { + services.add(sr); + } + } + + // Take care of any running services associated with the app. + for (int i=0; i<services.size(); i++) { + ServiceRecord sr = services.get(i); + if (sr.startRequested) { + if ((sr.serviceInfo.flags&ServiceInfo.FLAG_STOP_WITH_TASK) != 0) { + stopServiceLocked(sr); + } else { + sr.pendingStarts.add(new ServiceRecord.StartItem(sr, true, + sr.makeNextStartId(), baseIntent, -1)); + if (sr.app != null && sr.app.thread != null) { + sendServiceArgsLocked(sr, false); } - if (thumbs.numSubThumbbails > 0) { - thumbs.retriever = new IThumbnailRetriever.Stub() { - public Bitmap getThumbnail(int index) { - if (index < 0 || index >= thumbs.otherThumbnails.size()) { - return null; - } - return thumbs.otherThumbnails.get(index); - } - }; + } + } + } + + // Find any running processes associated with this app. + ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(); + SparseArray<ProcessRecord> appProcs + = mProcessNames.getMap().get(component.getPackageName()); + if (appProcs != null) { + for (int i=0; i<appProcs.size(); i++) { + procs.add(appProcs.valueAt(i)); + } + } + + // Kill the running processes. + for (int i=0; i<procs.size(); i++) { + ProcessRecord pr = procs.get(i); + if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) { + Slog.i(TAG, "Killing " + pr + ": remove task"); + EventLog.writeEvent(EventLogTags.AM_KILL, pr.pid, + pr.processName, pr.setAdj, "remove task"); + Process.killProcessQuiet(pr.pid); + } else { + pr.waitingToKill = "remove task"; + } + } + } + + public boolean removeTask(int taskId, int flags) { + synchronized (this) { + enforceCallingPermission(android.Manifest.permission.REMOVE_TASKS, + "removeTask()"); + long ident = Binder.clearCallingIdentity(); + try { + ActivityRecord r = mMainStack.removeTaskActivitiesLocked(taskId, -1); + if (r != null) { + mRecentTasks.remove(r.task); + + if ((flags&ActivityManager.REMOVE_TASK_KILL_PROCESS) != 0) { + removeTaskProcessesLocked(r); } - return thumbs; + + return true; } + } finally { + Binder.restoreCallingIdentity(ident); } } - return null; + return false; } private final int findAffinityTaskTopLocked(int startIndex, String affinity) { @@ -5123,21 +5158,18 @@ public final class ActivityManagerService extends ActivityManagerNative } final long origId = Binder.clearCallingIdentity(); try { - int N = mRecentTasks.size(); - for (int i=0; i<N; i++) { - TaskRecord tr = mRecentTasks.get(i); - if (tr.taskId == task) { - if ((flags&ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) { - mMainStack.mUserLeaving = true; - } - if ((flags&ActivityManager.MOVE_TASK_WITH_HOME) != 0) { - // Caller wants the home activity moved with it. To accomplish this, - // we'll just move the home task to the top first. - mMainStack.moveHomeToFrontLocked(); - } - mMainStack.moveTaskToFrontLocked(tr, null); - return; + TaskRecord tr = taskForIdLocked(task); + if (tr != null) { + if ((flags&ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) { + mMainStack.mUserLeaving = true; + } + if ((flags&ActivityManager.MOVE_TASK_WITH_HOME) != 0) { + // Caller wants the home activity moved with it. To accomplish this, + // we'll just move the home task to the top first. + mMainStack.moveHomeToFrontLocked(); } + mMainStack.moveTaskToFrontLocked(tr, null); + return; } for (int i=mMainStack.mHistory.size()-1; i>=0; i--) { ActivityRecord hr = (ActivityRecord)mMainStack.mHistory.get(i); @@ -6661,11 +6693,10 @@ public final class ActivityManagerService extends ActivityManagerNative } if (app.pid > 0 && app.pid != MY_PID) { handleAppCrashLocked(app); - Slog.i(ActivityManagerService.TAG, "Killing " - + app.processName + " (pid=" + app.pid + "): user's request"); + Slog.i(ActivityManagerService.TAG, "Killing " + app + ": user's request"); EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, app.processName, app.setAdj, "user's request after error"); - Process.killProcess(app.pid); + Process.killProcessQuiet(app.pid); } } } @@ -8946,7 +8977,7 @@ public final class ActivityManagerService extends ActivityManagerNative + " in dying process " + proc.processName); EventLog.writeEvent(EventLogTags.AM_KILL, capp.pid, capp.processName, capp.setAdj, "dying provider " + proc.processName); - Process.killProcess(capp.pid); + Process.killProcessQuiet(capp.pid); } } @@ -9453,7 +9484,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (si.doneExecutingCount > 0) { flags |= Service.START_FLAG_REDELIVERY; } - r.app.thread.scheduleServiceArgs(r, si.id, flags, si.intent); + r.app.thread.scheduleServiceArgs(r, si.taskRemoved, si.id, flags, si.intent); } catch (RemoteException e) { // Remote process gone... we'll let the normal cleanup take // care of this. @@ -9539,11 +9570,8 @@ public final class ActivityManagerService extends ActivityManagerNative // pending arguments, then fake up one so its onStartCommand() will // be called. if (r.startRequested && r.callStart && r.pendingStarts.size() == 0) { - r.lastStartId++; - if (r.lastStartId < 1) { - r.lastStartId = 1; - } - r.pendingStarts.add(new ServiceRecord.StartItem(r, r.lastStartId, null, -1)); + r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(), + null, -1)); } sendServiceArgsLocked(r, true); @@ -9897,11 +9925,7 @@ public final class ActivityManagerService extends ActivityManagerNative } r.startRequested = true; r.callStart = false; - r.lastStartId++; - if (r.lastStartId < 1) { - r.lastStartId = 1; - } - r.pendingStarts.add(new ServiceRecord.StartItem(r, r.lastStartId, + r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(), service, targetPermissionUid)); r.lastActivity = SystemClock.uptimeMillis(); synchronized (r.stats.getBatteryStats()) { @@ -9943,6 +9967,15 @@ public final class ActivityManagerService extends ActivityManagerNative } } + private void stopServiceLocked(ServiceRecord service) { + synchronized (service.stats.getBatteryStats()) { + service.stats.stopRunningLocked(); + } + service.startRequested = false; + service.callStart = false; + bringDownServiceLocked(service, false); + } + public int stopService(IApplicationThread caller, Intent service, String resolvedType) { // Refuse possible leaked file descriptors @@ -9966,14 +9999,12 @@ public final class ActivityManagerService extends ActivityManagerNative ServiceLookupResult r = findServiceLocked(service, resolvedType); if (r != null) { if (r.record != null) { - synchronized (r.record.stats.getBatteryStats()) { - r.record.stats.stopRunningLocked(); - } - r.record.startRequested = false; - r.record.callStart = false; final long origId = Binder.clearCallingIdentity(); - bringDownServiceLocked(r.record, false); - Binder.restoreCallingIdentity(origId); + try { + stopServiceLocked(r.record); + } finally { + Binder.restoreCallingIdentity(origId); + } return 1; } return -1; @@ -10035,7 +10066,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } - if (r.lastStartId != startId) { + if (r.getLastStartId() != startId) { return false; } @@ -10476,7 +10507,7 @@ public final class ActivityManagerService extends ActivityManagerNative case Service.START_NOT_STICKY: { // We are done with the associated start arguments. r.findDeliveredStart(startId, true); - if (r.lastStartId == startId) { + if (r.getLastStartId() == startId) { // There is no more work, and this service // doesn't want to hang around if killed. r.stopIfKilled = true; @@ -10496,6 +10527,12 @@ public final class ActivityManagerService extends ActivityManagerNative } break; } + case Service.START_TASK_REMOVED_COMPLETE: { + // Special processing for onTaskRemoved(). Don't + // impact normal onStartCommand() processing. + r.findDeliveredStart(startId, true); + break; + } default: throw new IllegalArgumentException( "Unknown service start result: " + res); @@ -12885,23 +12922,31 @@ public final class ActivityManagerService extends ActivityManagerNative if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v(TAG, "Setting process group of " + app.processName + " to " + app.curSchedGroup); - if (true) { - long oldId = Binder.clearCallingIdentity(); - try { - Process.setProcessGroup(app.pid, app.curSchedGroup); - } catch (Exception e) { - Slog.w(TAG, "Failed setting process group of " + app.pid - + " to " + app.curSchedGroup); - e.printStackTrace(); - } finally { - Binder.restoreCallingIdentity(oldId); - } - } - if (false) { - if (app.thread != null) { + if (app.waitingToKill != null && + app.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) { + Slog.i(TAG, "Killing " + app + ": " + app.waitingToKill); + EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + app.processName, app.setAdj, app.waitingToKill); + Process.killProcessQuiet(app.pid); + } else { + if (true) { + long oldId = Binder.clearCallingIdentity(); try { - app.thread.setSchedulingGroup(app.curSchedGroup); - } catch (RemoteException e) { + Process.setProcessGroup(app.pid, app.curSchedGroup); + } catch (Exception e) { + Slog.w(TAG, "Failed setting process group of " + app.pid + + " to " + app.curSchedGroup); + e.printStackTrace(); + } finally { + Binder.restoreCallingIdentity(oldId); + } + } + if (false) { + if (app.thread != null) { + try { + app.thread.setSchedulingGroup(app.curSchedGroup); + } catch (RemoteException e) { + } } } } @@ -13024,7 +13069,9 @@ public final class ActivityManagerService extends ActivityManagerNative + (app.thread != null ? app.thread.asBinder() : null) + ")\n"); if (app.pid > 0 && app.pid != MY_PID) { - Process.killProcess(app.pid); + EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + app.processName, app.setAdj, "empty"); + Process.killProcessQuiet(app.pid); } else { try { app.thread.scheduleExit(); @@ -13090,7 +13137,9 @@ public final class ActivityManagerService extends ActivityManagerNative + (app.thread != null ? app.thread.asBinder() : null) + ")\n"); if (app.pid > 0 && app.pid != MY_PID) { - Process.killProcess(app.pid); + EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + app.processName, app.setAdj, "empty"); + Process.killProcessQuiet(app.pid); } else { try { app.thread.scheduleExit(); @@ -13147,7 +13196,9 @@ public final class ActivityManagerService extends ActivityManagerNative + (app.thread != null ? app.thread.asBinder() : null) + ")\n"); if (app.pid > 0 && app.pid != MY_PID) { - Process.killProcess(app.pid); + EventLog.writeEvent(EventLogTags.AM_KILL, app.pid, + app.processName, app.setAdj, "old background"); + Process.killProcessQuiet(app.pid); } else { try { app.thread.scheduleExit(); @@ -13364,4 +13415,11 @@ public final class ActivityManagerService extends ActivityManagerNative } } } + + // Multi-user methods + + public boolean switchUser(int userid) { + // TODO + return true; + } } diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index e1d380b..9558895 100644 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -21,8 +21,10 @@ import com.android.internal.os.BatteryStatsImpl; import com.android.server.am.ActivityManagerService.PendingActivityLaunch; import android.app.Activity; +import android.app.ActivityManager; import android.app.AppGlobals; import android.app.IActivityManager; +import android.app.IThumbnailRetriever; import static android.app.IActivityManager.START_CLASS_NOT_FOUND; import static android.app.IActivityManager.START_DELIVERED_TO_TOP; import static android.app.IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT; @@ -69,7 +71,7 @@ import java.util.List; /** * State and management of a single stack of activities. */ -final public class ActivityStack { +final class ActivityStack { static final String TAG = ActivityManagerService.TAG; static final boolean localLOGV = ActivityManagerService.localLOGV; static final boolean DEBUG_SWITCH = ActivityManagerService.DEBUG_SWITCH; @@ -135,14 +137,14 @@ final public class ActivityStack { * The back history of all previous (and possibly still * running) activities. It contains HistoryRecord objects. */ - final ArrayList mHistory = new ArrayList(); + final ArrayList<ActivityRecord> mHistory = new ArrayList<ActivityRecord>(); /** * List of running activities, sorted by recent usage. * The first entry in the list is the least recently used. * It contains HistoryRecord objects. */ - final ArrayList mLRUActivities = new ArrayList(); + final ArrayList<ActivityRecord> mLRUActivities = new ArrayList<ActivityRecord>(); /** * List of activities that are waiting for a new activity @@ -346,7 +348,7 @@ final public class ActivityStack { final ActivityRecord topRunningActivityLocked(ActivityRecord notTop) { int i = mHistory.size()-1; while (i >= 0) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (!r.finishing && r != notTop) { return r; } @@ -358,7 +360,7 @@ final public class ActivityStack { final ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) { int i = mHistory.size()-1; while (i >= 0) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (!r.finishing && !r.delayedResume && r != notTop) { return r; } @@ -379,7 +381,7 @@ final public class ActivityStack { final ActivityRecord topRunningActivityLocked(IBinder token, int taskId) { int i = mHistory.size()-1; while (i >= 0) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); // Note: the taskId check depends on real taskId fields being non-zero if (!r.finishing && (token != r) && (taskId != r.task.taskId)) { return r; @@ -425,7 +427,7 @@ final public class ActivityStack { final int N = mHistory.size(); for (int i=(N-1); i>=0; i--) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (!r.finishing && r.task != cp && r.launchMode != ActivityInfo.LAUNCH_SINGLE_INSTANCE) { cp = r.task; @@ -469,7 +471,7 @@ final public class ActivityStack { final int N = mHistory.size(); for (int i=(N-1); i>=0; i--) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (!r.finishing) { if (r.intent.getComponent().equals(cls)) { //Slog.i(TAG, "Found matching class!"); @@ -504,6 +506,7 @@ final public class ActivityStack { } r.app = app; + app.waitingToKill = null; if (localLOGV) Slog.v(TAG, "Launching: " + r); @@ -678,7 +681,7 @@ final public class ActivityStack { } // Ensure activities are no longer sleeping. for (int i=mHistory.size()-1; i>=0; i--) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); r.setSleeping(false); } mGoingToSleepActivities.clear(); @@ -724,7 +727,7 @@ final public class ActivityStack { // Make sure any stopped but visible activities are now sleeping. // This ensures that the activity's onStop() is called. for (int i=mHistory.size()-1; i>=0; i--) { - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (r.state == ActivityState.STOPPING || r.state == ActivityState.STOPPED) { r.setSleeping(true); } @@ -862,7 +865,7 @@ final public class ActivityStack { synchronized (mService) { int index = indexOfTokenLocked(token); if (index >= 0) { - r = (ActivityRecord)mHistory.get(index); + r = mHistory.get(index); mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r); if (mPausingActivity == r) { r.state = ActivityState.PAUSED; @@ -1024,7 +1027,7 @@ final public class ActivityStack { ActivityRecord r; boolean behindFullscreen = false; for (; i>=0; i--) { - r = (ActivityRecord)mHistory.get(i); + r = mHistory.get(i); if (DEBUG_VISBILITY) Slog.v( TAG, "Make visible? " + r + " finishing=" + r.finishing + " state=" + r.state); @@ -1108,7 +1111,7 @@ final public class ActivityStack { // Now for any activities that aren't visible to the user, make // sure they no longer are keeping the screen frozen. while (i >= 0) { - r = (ActivityRecord)mHistory.get(i); + r = mHistory.get(i); if (DEBUG_VISBILITY) Slog.v( TAG, "Make invisible? " + r + " finishing=" + r.finishing + " state=" + r.state @@ -1499,7 +1502,7 @@ final public class ActivityStack { // If starting in an existing task, find where that is... boolean startIt = true; for (int i = NH-1; i >= 0; i--) { - ActivityRecord p = (ActivityRecord)mHistory.get(i); + ActivityRecord p = mHistory.get(i); if (p.finishing) { continue; } @@ -1646,7 +1649,7 @@ final public class ActivityStack { int replyChainEnd = -1; int lastReparentPos = -1; for (int i=mHistory.size()-1; i>=-1; i--) { - ActivityRecord below = i >= 0 ? (ActivityRecord)mHistory.get(i) : null; + ActivityRecord below = i >= 0 ? mHistory.get(i) : null; if (below != null && below.finishing) { continue; @@ -1700,7 +1703,7 @@ final public class ActivityStack { // bottom of the activity stack. This also keeps it // correctly ordered with any activities we previously // moved. - ActivityRecord p = (ActivityRecord)mHistory.get(0); + ActivityRecord p = mHistory.get(0); if (target.taskAffinity != null && target.taskAffinity.equals(p.task.affinity)) { // If the activity currently at the bottom has the @@ -1727,7 +1730,7 @@ final public class ActivityStack { int dstPos = 0; ThumbnailHolder curThumbHolder = target.thumbHolder; for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) { - p = (ActivityRecord)mHistory.get(srcPos); + p = mHistory.get(srcPos); if (p.finishing) { continue; } @@ -1764,7 +1767,7 @@ final public class ActivityStack { // like these are all in the reply chain. replyChainEnd = targetI+1; while (replyChainEnd < mHistory.size() && - ((ActivityRecord)mHistory.get( + (mHistory.get( replyChainEnd)).task == task) { replyChainEnd++; } @@ -1774,7 +1777,7 @@ final public class ActivityStack { } ActivityRecord p = null; for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) { - p = (ActivityRecord)mHistory.get(srcPos); + p = mHistory.get(srcPos); if (p.finishing) { continue; } @@ -1834,7 +1837,7 @@ final public class ActivityStack { } ActivityRecord p = null; for (int srcPos=targetI; srcPos<=replyChainEnd; srcPos++) { - p = (ActivityRecord)mHistory.get(srcPos); + p = mHistory.get(srcPos); if (p.finishing) { continue; } @@ -1852,7 +1855,7 @@ final public class ActivityStack { replyChainEnd = targetI; } for (int srcPos=replyChainEnd; srcPos>=targetI; srcPos--) { - ActivityRecord p = (ActivityRecord)mHistory.get(srcPos); + ActivityRecord p = mHistory.get(srcPos); if (p.finishing) { continue; } @@ -1881,7 +1884,7 @@ final public class ActivityStack { // below so it remains singleTop. if (target.info.launchMode == ActivityInfo.LAUNCH_SINGLE_TOP) { for (int j=lastReparentPos-1; j>=0; j--) { - ActivityRecord p = (ActivityRecord)mHistory.get(j); + ActivityRecord p = mHistory.get(j); if (p.finishing) { continue; } @@ -1922,7 +1925,7 @@ final public class ActivityStack { // First find the requested task. while (i > 0) { i--; - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (r.task.taskId == taskId) { i++; break; @@ -1932,7 +1935,7 @@ final public class ActivityStack { // Now clear it. while (i > 0) { i--; - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (r.finishing) { continue; } @@ -1944,7 +1947,7 @@ final public class ActivityStack { ActivityRecord ret = r; while (i < (mHistory.size()-1)) { i++; - r = (ActivityRecord)mHistory.get(i); + r = mHistory.get(i); if (r.task.taskId != taskId) { break; } @@ -1980,6 +1983,28 @@ final public class ActivityStack { } /** + * Completely remove all activities associated with an existing + * task starting at a specified index. + */ + private final void performClearTaskAtIndexLocked(int taskId, int i) { + while (i < (mHistory.size()-1)) { + ActivityRecord r = mHistory.get(i); + if (r.task.taskId != taskId) { + // Whoops hit the end. + return; + } + if (r.finishing) { + i++; + continue; + } + if (!finishActivityLocked(r, i, Activity.RESULT_CANCELED, + null, "clear")) { + i++; + } + } + } + + /** * Completely remove all activities associated with an existing task. */ private final void performClearTaskLocked(int taskId) { @@ -1988,37 +2013,23 @@ final public class ActivityStack { // First find the requested task. while (i > 0) { i--; - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (r.task.taskId == taskId) { i++; break; } } - // Now clear it. + // Now find the start and clear it. while (i > 0) { i--; - ActivityRecord r = (ActivityRecord)mHistory.get(i); + ActivityRecord r = mHistory.get(i); if (r.finishing) { continue; } if (r.task.taskId != taskId) { // We hit the bottom. Now finish it all... - while (i < (mHistory.size()-1)) { - i++; - r = (ActivityRecord)mHistory.get(i); - if (r.task.taskId != taskId) { - // Whoops hit the end. - return; - } - if (r.finishing) { - continue; - } - if (finishActivityLocked(r, i, Activity.RESULT_CANCELED, - null, "clear")) { - i--; - } - } + performClearTaskAtIndexLocked(taskId, i+1); return; } } @@ -2032,7 +2043,7 @@ final public class ActivityStack { int i = mHistory.size(); while (i > 0) { i--; - ActivityRecord candidate = (ActivityRecord)mHistory.get(i); + ActivityRecord candidate = mHistory.get(i); if (candidate.task.taskId != task) { break; } @@ -2049,9 +2060,9 @@ final public class ActivityStack { * brought to the front. */ private final ActivityRecord moveActivityToFrontLocked(int where) { - ActivityRecord newTop = (ActivityRecord)mHistory.remove(where); + ActivityRecord newTop = mHistory.remove(where); int top = mHistory.size(); - ActivityRecord oldTop = (ActivityRecord)mHistory.get(top-1); + ActivityRecord oldTop = mHistory.get(top-1); mHistory.add(top, newTop); oldTop.frontOfTask = false; newTop.frontOfTask = true; @@ -2094,7 +2105,7 @@ final public class ActivityStack { if (DEBUG_RESULTS) Slog.v( TAG, "Sending result to " + resultTo + " (index " + index + ")"); if (index >= 0) { - sourceRecord = (ActivityRecord)mHistory.get(index); + sourceRecord = mHistory.get(index); if (requestCode >= 0 && !sourceRecord.finishing) { resultRecord = sourceRecord; } @@ -2576,7 +2587,7 @@ final public class ActivityStack { // this case should never happen. final int N = mHistory.size(); ActivityRecord prev = - N > 0 ? (ActivityRecord)mHistory.get(N-1) : null; + N > 0 ? mHistory.get(N-1) : null; r.setTask(prev != null ? prev.task : new TaskRecord(mService.mCurTask, r.info, intent), null, true); @@ -3021,7 +3032,7 @@ final public class ActivityStack { // Get the activity record. int index = indexOfTokenLocked(token); if (index >= 0) { - ActivityRecord r = (ActivityRecord)mHistory.get(index); + ActivityRecord r = mHistory.get(index); if (fromTimeout) { reportActivityLaunchedLocked(fromTimeout, r, -1, -1); @@ -3153,12 +3164,12 @@ final public class ActivityStack { if (index < 0) { return false; } - ActivityRecord r = (ActivityRecord)mHistory.get(index); + ActivityRecord r = mHistory.get(index); // Is this the last activity left? boolean lastActivity = true; for (int i=mHistory.size()-1; i>=0; i--) { - ActivityRecord p = (ActivityRecord)mHistory.get(i); + ActivityRecord p = mHistory.get(i); if (!p.finishing && p != r) { lastActivity = false; break; @@ -3193,7 +3204,7 @@ final public class ActivityStack { System.identityHashCode(r), r.task.taskId, r.shortComponentName, reason); if (index < (mHistory.size()-1)) { - ActivityRecord next = (ActivityRecord)mHistory.get(index+1); + ActivityRecord next = mHistory.get(index+1); if (next.task == r.task) { if (r.frontOfTask) { // The next activity is now the front of the task. @@ -3249,7 +3260,7 @@ final public class ActivityStack { if (mResumedActivity == r) { boolean endTask = index <= 0 - || ((ActivityRecord)mHistory.get(index-1)).task != r.task; + || (mHistory.get(index-1)).task != r.task; if (DEBUG_TRANSITION) Slog.v(TAG, "Prepare close transition: finishing " + r); mService.mWindowManager.prepareAppTransition(endTask @@ -3391,6 +3402,7 @@ final public class ActivityStack { // Get rid of any pending idle timeouts. mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r); mHandler.removeMessages(IDLE_TIMEOUT_MSG, r); + mHandler.removeMessages(DESTROY_TIMEOUT_MSG, r); } private final void removeActivityFromHistoryLocked(ActivityRecord r) { @@ -3516,7 +3528,7 @@ final public class ActivityStack { int index = indexOfTokenLocked(token); if (index >= 0) { - ActivityRecord r = (ActivityRecord)mHistory.get(index); + ActivityRecord r = mHistory.get(index); if (r.state == ActivityState.DESTROYING) { final long origId = Binder.clearCallingIdentity(); removeActivityFromHistoryLocked(r); @@ -3558,7 +3570,7 @@ final public class ActivityStack { final void moveHomeToFrontLocked() { TaskRecord homeTask = null; for (int i=mHistory.size()-1; i>=0; i--) { - ActivityRecord hr = (ActivityRecord)mHistory.get(i); + ActivityRecord hr = mHistory.get(i); if (hr.isHomeActivity) { homeTask = hr.task; break; @@ -3576,7 +3588,7 @@ final public class ActivityStack { final int task = tr.taskId; int top = mHistory.size()-1; - if (top < 0 || ((ActivityRecord)mHistory.get(top)).task.taskId == task) { + if (top < 0 || (mHistory.get(top)).task.taskId == task) { // nothing to do! return; } @@ -3591,7 +3603,7 @@ final public class ActivityStack { // Shift all activities with this task up to the top // of the stack, keeping them in the same internal order. while (pos >= 0) { - ActivityRecord r = (ActivityRecord)mHistory.get(pos); + ActivityRecord r = mHistory.get(pos); if (localLOGV) Slog.v( TAG, "At " + pos + " ckp " + r.task + ": " + r); if (r.task.taskId == task) { @@ -3680,7 +3692,7 @@ final public class ActivityStack { // Shift all activities with this task down to the bottom // of the stack, keeping them in the same internal order. while (pos < N) { - ActivityRecord r = (ActivityRecord)mHistory.get(pos); + ActivityRecord r = mHistory.get(pos); if (localLOGV) Slog.v( TAG, "At " + pos + " ckp " + r.task + ": " + r); if (r.task.taskId == task) { @@ -3714,6 +3726,106 @@ final public class ActivityStack { return true; } + public ActivityManager.TaskThumbnails getTaskThumbnailsLocked(TaskRecord tr) { + TaskAccessInfo info = getTaskAccessInfoLocked(tr.taskId, true); + ActivityRecord resumed = mResumedActivity; + if (resumed != null && resumed.thumbHolder == tr) { + info.mainThumbnail = resumed.stack.screenshotActivities(resumed); + } else { + info.mainThumbnail = tr.lastThumbnail; + } + return info; + } + + public ActivityRecord removeTaskActivitiesLocked(int taskId, int subTaskIndex) { + TaskAccessInfo info = getTaskAccessInfoLocked(taskId, false); + if (info.root == null) { + Slog.w(TAG, "removeTaskLocked: unknown taskId " + taskId); + return null; + } + + if (subTaskIndex < 0) { + // Just remove the entire task. + performClearTaskAtIndexLocked(taskId, info.rootIndex); + return info.root; + } + + if (subTaskIndex >= info.subtasks.size()) { + Slog.w(TAG, "removeTaskLocked: unknown subTaskIndex " + subTaskIndex); + return null; + } + + // Remove all of this task's activies starting at the sub task. + TaskAccessInfo.SubTask subtask = info.subtasks.get(subTaskIndex); + performClearTaskAtIndexLocked(taskId, subtask.index); + return subtask.activity; + } + + public TaskAccessInfo getTaskAccessInfoLocked(int taskId, boolean inclThumbs) { + ActivityRecord resumed = mResumedActivity; + final TaskAccessInfo thumbs = new TaskAccessInfo(); + // How many different sub-thumbnails? + final int NA = mHistory.size(); + int j = 0; + ThumbnailHolder holder = null; + while (j < NA) { + ActivityRecord ar = mHistory.get(j); + if (!ar.finishing && ar.task.taskId == taskId) { + holder = ar.thumbHolder; + break; + } + j++; + } + + if (j >= NA) { + return thumbs; + } + + thumbs.root = mHistory.get(j); + thumbs.rootIndex = j; + + ArrayList<TaskAccessInfo.SubTask> subtasks = new ArrayList<TaskAccessInfo.SubTask>(); + thumbs.subtasks = subtasks; + ActivityRecord lastActivity = null; + while (j < NA) { + ActivityRecord ar = mHistory.get(j); + j++; + if (ar.finishing) { + continue; + } + if (ar.task.taskId != taskId) { + break; + } + lastActivity = ar; + if (ar.thumbHolder != holder && holder != null) { + thumbs.numSubThumbbails++; + holder = ar.thumbHolder; + TaskAccessInfo.SubTask sub = new TaskAccessInfo.SubTask(); + sub.thumbnail = holder.lastThumbnail; + sub.activity = ar; + sub.index = j-1; + subtasks.add(sub); + } + } + if (lastActivity != null && subtasks.size() > 0) { + if (resumed == lastActivity) { + TaskAccessInfo.SubTask sub = subtasks.get(subtasks.size()-1); + sub.thumbnail = lastActivity.stack.screenshotActivities(lastActivity); + } + } + if (thumbs.numSubThumbbails > 0) { + thumbs.retriever = new IThumbnailRetriever.Stub() { + public Bitmap getThumbnail(int index) { + if (index < 0 || index >= thumbs.subtasks.size()) { + return null; + } + return thumbs.subtasks.get(index).thumbnail; + } + }; + } + return thumbs; + } + private final void logStartActivity(int tag, ActivityRecord r, TaskRecord task) { EventLog.writeEvent(tag, diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java index 353ff6d..e39c239 100644 --- a/services/java/com/android/server/am/ProcessRecord.java +++ b/services/java/com/android/server/am/ProcessRecord.java @@ -65,6 +65,7 @@ class ProcessRecord { boolean foregroundServices; // Running any services that are foreground? boolean bad; // True if disabled in the bad process list boolean killedBackground; // True when proc has been killed due to too many bg + String waitingToKill; // Process is waiting to be killed when in the bg; reason IBinder forcingToForeground;// Token that is forcing this process to be foreground int adjSeq; // Sequence id for identifying oom_adj assignment cycles int lruSeq; // Sequence id for identifying LRU update cycles @@ -202,8 +203,9 @@ class ProcessRecord { pw.print(" lastLowMemory="); TimeUtils.formatDuration(lastLowMemory, now, pw); pw.print(" reportLowMemory="); pw.println(reportLowMemory); - if (killedBackground) { - pw.print(prefix); pw.print("killedBackground="); pw.println(killedBackground); + if (killedBackground || waitingToKill != null) { + pw.print(prefix); pw.print("killedBackground="); pw.print(killedBackground); + pw.print(" waitingToKill="); pw.println(waitingToKill); } if (debugging || crashing || crashDialog != null || notResponding || anrDialog != null || bad) { diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java index 1a617dd..da00c0c 100644 --- a/services/java/com/android/server/am/ServiceRecord.java +++ b/services/java/com/android/server/am/ServiceRecord.java @@ -84,7 +84,6 @@ class ServiceRecord extends Binder { boolean startRequested; // someone explicitly called start? boolean stopIfKilled; // last onStart() said to stop if service killed? boolean callStart; // last onStart() has asked to alway be called on restart. - int lastStartId; // identifier of most recent start request. int executeNesting; // number of outstanding operations keeping foreground. long executingStart; // start time of last execute request. int crashCount; // number of times proc has crashed with service running @@ -96,8 +95,11 @@ class ServiceRecord extends Binder { String stringName; // caching of toString + private int lastStartId; // identifier of most recent start request. + static class StartItem { final ServiceRecord sr; + final boolean taskRemoved; final int id; final Intent intent; final int targetPermissionUid; @@ -108,8 +110,10 @@ class ServiceRecord extends Binder { String stringName; // caching of toString - StartItem(ServiceRecord _sr, int _id, Intent _intent, int _targetPermissionUid) { + StartItem(ServiceRecord _sr, boolean _taskRemoved, int _id, Intent _intent, + int _targetPermissionUid) { sr = _sr; + taskRemoved = _taskRemoved; id = _id; intent = _intent; targetPermissionUid = _targetPermissionUid; @@ -321,6 +325,18 @@ class ServiceRecord extends Binder { return null; } + public int getLastStartId() { + return lastStartId; + } + + public int makeNextStartId() { + lastStartId++; + if (lastStartId < 1) { + lastStartId = 1; + } + return lastStartId; + } + public void postNotification() { final int appUid = appInfo.uid; final int appPid = app.pid; diff --git a/services/java/com/android/server/am/TaskAccessInfo.java b/services/java/com/android/server/am/TaskAccessInfo.java new file mode 100644 index 0000000..5618c1a --- /dev/null +++ b/services/java/com/android/server/am/TaskAccessInfo.java @@ -0,0 +1,35 @@ +/* + * 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 com.android.server.am; + +import java.util.ArrayList; + +import android.app.ActivityManager.TaskThumbnails; +import android.graphics.Bitmap; + +final class TaskAccessInfo extends TaskThumbnails { + final static class SubTask { + Bitmap thumbnail; + ActivityRecord activity; + int index; + } + + public ActivityRecord root; + public int rootIndex; + + public ArrayList<SubTask> subtasks; +} diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index 11dde75..16b55c3 100644 --- a/services/java/com/android/server/pm/Settings.java +++ b/services/java/com/android/server/pm/Settings.java @@ -1336,6 +1336,19 @@ final class Settings { } mPendingPackages.clear(); + /* + * Make sure all the updated system packages have their shared users + * associated with them. + */ + final Iterator<PackageSetting> disabledIt = mDisabledSysPackages.values().iterator(); + while (disabledIt.hasNext()) { + final PackageSetting disabledPs = disabledIt.next(); + final Object id = getUserIdLPr(disabledPs.userId); + if (id != null && id instanceof SharedUserSetting) { + disabledPs.sharedUser = (SharedUserSetting) id; + } + } + readStoppedLPw(); mReadMessages.append("Read completed successfully: " + mPackages.size() + " packages, " diff --git a/services/java/com/android/server/pm/UserDetails.java b/services/java/com/android/server/pm/UserDetails.java new file mode 100644 index 0000000..2aeed7c --- /dev/null +++ b/services/java/com/android/server/pm/UserDetails.java @@ -0,0 +1,305 @@ +/* + * 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 com.android.server.pm; + +import com.android.internal.util.FastXmlSerializer; + +import android.content.pm.UserInfo; +import android.os.Environment; +import android.os.FileUtils; +import android.util.Slog; +import android.util.SparseArray; +import android.util.Xml; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; +import org.xmlpull.v1.XmlSerializer; + +public class UserDetails { + private static final String TAG_NAME = "name"; + + private static final String ATTR_FLAGS = "flags"; + + private static final String ATTR_ID = "id"; + + private static final String TAG_USERS = "users"; + + private static final String TAG_USER = "user"; + + private static final String TAG = "UserDetails"; + + private static final String USER_INFO_DIR = "system/users"; + private static final String USER_LIST_FILENAME = "userlist.xml"; + + private SparseArray<UserInfo> mUsers; + + private final File mUsersDir; + private final File mUserListFile; + + /** + * Available for testing purposes. + */ + UserDetails(File dataDir) { + mUsersDir = new File(dataDir, USER_INFO_DIR); + mUsersDir.mkdirs(); + FileUtils.setPermissions(mUsersDir.toString(), + FileUtils.S_IRWXU|FileUtils.S_IRWXG + |FileUtils.S_IROTH|FileUtils.S_IXOTH, + -1, -1); + mUserListFile = new File(mUsersDir, USER_LIST_FILENAME); + readUserList(); + } + + public UserDetails() { + this(Environment.getDataDirectory()); + } + + public List<UserInfo> getUsers() { + ArrayList<UserInfo> users = new ArrayList<UserInfo>(mUsers.size()); + for (int i = 0; i < mUsers.size(); i++) { + users.add(mUsers.valueAt(i)); + } + return users; + } + + private void readUserList() { + mUsers = new SparseArray<UserInfo>(); + if (!mUserListFile.exists()) { + fallbackToSingleUser(); + return; + } + FileInputStream fis = null; + try { + fis = new FileInputStream(mUserListFile); + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(fis, null); + int type; + while ((type = parser.next()) != XmlPullParser.START_TAG + && type != XmlPullParser.END_DOCUMENT) { + ; + } + + if (type != XmlPullParser.START_TAG) { + Slog.e(TAG, "Unable to read user list"); + fallbackToSingleUser(); + return; + } + + while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) { + if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) { + String id = parser.getAttributeValue(null, ATTR_ID); + UserInfo user = readUser(Integer.parseInt(id)); + if (user != null) { + mUsers.put(user.id, user); + } + } + } + } catch (IOException ioe) { + fallbackToSingleUser(); + } catch (XmlPullParserException pe) { + fallbackToSingleUser(); + } + } + + private void fallbackToSingleUser() { + // Create the primary user + UserInfo primary = new UserInfo(0, "Primary", + UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY); + mUsers.put(0, primary); + + writeUserList(); + writeUser(primary); + } + + /* + * Writes the user file in this format: + * + * <user flags="20039023" id="0"> + * <name>Primary</name> + * </user> + */ + private void writeUser(UserInfo userInfo) { + try { + final File mUserFile = new File(mUsersDir, userInfo.id + ".xml"); + final FileOutputStream fos = new FileOutputStream(mUserFile); + final BufferedOutputStream bos = new BufferedOutputStream(fos); + + // XmlSerializer serializer = XmlUtils.serializerInstance(); + final XmlSerializer serializer = new FastXmlSerializer(); + serializer.setOutput(bos, "utf-8"); + serializer.startDocument(null, true); + serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + + serializer.startTag(null, TAG_USER); + serializer.attribute(null, ATTR_ID, Integer.toString(userInfo.id)); + serializer.attribute(null, ATTR_FLAGS, Integer.toString(userInfo.flags)); + + serializer.startTag(null, TAG_NAME); + serializer.text(userInfo.name); + serializer.endTag(null, TAG_NAME); + + serializer.endTag(null, TAG_USER); + + serializer.endDocument(); + } catch (IOException ioe) { + Slog.e(TAG, "Error writing user info " + userInfo.id + "\n" + ioe); + } + } + + /* + * Writes the user list file in this format: + * + * <users> + * <user id="0"></user> + * <user id="2"></user> + * </users> + */ + private void writeUserList() { + try { + final FileOutputStream fos = new FileOutputStream(mUserListFile); + final BufferedOutputStream bos = new BufferedOutputStream(fos); + + // XmlSerializer serializer = XmlUtils.serializerInstance(); + final XmlSerializer serializer = new FastXmlSerializer(); + serializer.setOutput(bos, "utf-8"); + serializer.startDocument(null, true); + serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + + serializer.startTag(null, TAG_USERS); + + for (int i = 0; i < mUsers.size(); i++) { + UserInfo user = mUsers.valueAt(i); + serializer.startTag(null, TAG_USER); + serializer.attribute(null, ATTR_ID, Integer.toString(user.id)); + serializer.endTag(null, TAG_USER); + Slog.e(TAG, "Wrote user " + user.id + " to userlist.xml"); + } + + serializer.endTag(null, TAG_USERS); + + serializer.endDocument(); + } catch (IOException ioe) { + Slog.e(TAG, "Error writing user list"); + } + } + + private UserInfo readUser(int id) { + int flags = 0; + String name = null; + + FileInputStream fis = null; + try { + File userFile = new File(mUsersDir, Integer.toString(id) + ".xml"); + fis = new FileInputStream(userFile); + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(fis, null); + int type; + while ((type = parser.next()) != XmlPullParser.START_TAG + && type != XmlPullParser.END_DOCUMENT) { + ; + } + + if (type != XmlPullParser.START_TAG) { + Slog.e(TAG, "Unable to read user " + id); + return null; + } + + if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) { + String storedId = parser.getAttributeValue(null, ATTR_ID); + if (Integer.parseInt(storedId) != id) { + Slog.e(TAG, "User id does not match the file name"); + return null; + } + String flagString = parser.getAttributeValue(null, ATTR_FLAGS); + flags = Integer.parseInt(flagString); + + while ((type = parser.next()) != XmlPullParser.START_TAG + && type != XmlPullParser.END_DOCUMENT) { + } + if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_NAME)) { + type = parser.next(); + if (type == XmlPullParser.TEXT) { + name = parser.getText(); + } + } + } + fis.close(); + + UserInfo userInfo = new UserInfo(id, name, flags); + return userInfo; + + } catch (IOException ioe) { + } catch (XmlPullParserException pe) { + } + return null; + } + + public UserInfo createUser(String name, int flags) { + int id = getNextAvailableId(); + UserInfo userInfo = new UserInfo(id, name, flags); + if (!createPackageFolders(id)) { + return null; + } + mUsers.put(id, userInfo); + writeUserList(); + writeUser(userInfo); + return userInfo; + } + + public void removeUser(int id) { + // Remove from the list + UserInfo userInfo = mUsers.get(id); + if (userInfo != null) { + // Remove this user from the list + mUsers.remove(id); + // Remove user file + File userFile = new File(mUsersDir, id + ".xml"); + userFile.delete(); + writeUserList(); + removePackageFolders(id); + } + } + + private int getNextAvailableId() { + int i = 0; + while (i < Integer.MAX_VALUE) { + if (mUsers.indexOfKey(i) < 0) { + break; + } + i++; + } + return i; + } + + private boolean createPackageFolders(int id) { + // TODO: Create data directories for all the packages for a new user, w/ specified user id. + return true; + } + + private boolean removePackageFolders(int id) { + // TODO: Remove all the data directories for the specified user. + return true; + } +} diff --git a/services/jni/com_android_server_AlarmManagerService.cpp b/services/jni/com_android_server_AlarmManagerService.cpp index aa8c9b3..c9a702a 100644 --- a/services/jni/com_android_server_AlarmManagerService.cpp +++ b/services/jni/com_android_server_AlarmManagerService.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. */ @@ -84,7 +84,7 @@ static void android_server_AlarmManagerService_set(JNIEnv* env, jobject obj, jin struct timespec ts; ts.tv_sec = seconds; ts.tv_nsec = nanoseconds; - + int result = ioctl(fd, ANDROID_ALARM_SET(type), &ts); if (result < 0) { @@ -97,18 +97,18 @@ static jint android_server_AlarmManagerService_waitForAlarm(JNIEnv* env, jobject { #ifdef HAVE_ANDROID_OS int result = 0; - + do { result = ioctl(fd, ANDROID_ALARM_WAIT); } while (result < 0 && errno == EINTR); - + if (result < 0) { LOGE("Unable to wait on alarm: %s\n", strerror(errno)); return 0; } - + return result; #endif } @@ -124,14 +124,6 @@ static JNINativeMethod sMethods[] = { int register_android_server_AlarmManagerService(JNIEnv* env) { - jclass clazz = env->FindClass("com/android/server/AlarmManagerService"); - - if (clazz == NULL) - { - LOGE("Can't find com/android/server/AlarmManagerService"); - return -1; - } - return jniRegisterNativeMethods(env, "com/android/server/AlarmManagerService", sMethods, NELEM(sMethods)); } diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp index ab2c125..aaa305e 100644 --- a/services/jni/com_android_server_InputManager.cpp +++ b/services/jni/com_android_server_InputManager.cpp @@ -36,6 +36,8 @@ #include <input/InputManager.h> #include <input/PointerController.h> +#include <input/SpotController.h> +#include <input/SpriteController.h> #include <android_os_MessageQueue.h> #include <android_view_KeyEvent.h> @@ -163,6 +165,7 @@ public: virtual nsecs_t getVirtualKeyQuietTime(); virtual void getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames); virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId); + virtual sp<SpotControllerInterface> obtainSpotController(int32_t deviceId); /* --- InputDispatcherPolicyInterface implementation --- */ @@ -213,12 +216,16 @@ private: // System UI visibility. int32_t systemUiVisibility; + // Sprite controller singleton, created on first use. + sp<SpriteController> spriteController; + // Pointer controller singleton, created and destroyed as needed. wp<PointerController> pointerController; } mLocked; void updateInactivityFadeDelayLocked(const sp<PointerController>& controller); void handleInterceptActions(jint wmActions, nsecs_t when, uint32_t& policyFlags); + void ensureSpriteControllerLocked(); // Power manager interactions. bool isScreenOn(); @@ -419,18 +426,15 @@ sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32 sp<PointerController> controller = mLocked.pointerController.promote(); if (controller == NULL) { - JNIEnv* env = jniEnv(); - jint layer = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getPointerLayer); - if (checkAndClearExceptionFromCallback(env, "getPointerLayer")) { - layer = -1; - } + ensureSpriteControllerLocked(); - controller = new PointerController(mLooper, layer); + controller = new PointerController(mLooper, mLocked.spriteController); mLocked.pointerController = controller; controller->setDisplaySize(mLocked.displayWidth, mLocked.displayHeight); controller->setDisplayOrientation(mLocked.displayOrientation); + JNIEnv* env = jniEnv(); jobject iconObj = env->CallObjectMethod(mCallbacksObj, gCallbacksClassInfo.getPointerIcon); if (!checkAndClearExceptionFromCallback(env, "getPointerIcon") && iconObj) { jfloat iconHotSpotX = env->GetFloatField(iconObj, gPointerIconClassInfo.hotSpotX); @@ -451,6 +455,24 @@ sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32 return controller; } +sp<SpotControllerInterface> NativeInputManager::obtainSpotController(int32_t deviceId) { + AutoMutex _l(mLock); + + ensureSpriteControllerLocked(); + return new SpotController(mLooper, mLocked.spriteController); +} + +void NativeInputManager::ensureSpriteControllerLocked() { + if (mLocked.spriteController == NULL) { + JNIEnv* env = jniEnv(); + jint layer = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getPointerLayer); + if (checkAndClearExceptionFromCallback(env, "getPointerLayer")) { + layer = -1; + } + mLocked.spriteController = new SpriteController(mLooper, layer); + } +} + void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode, int32_t switchValue, uint32_t policyFlags) { #if DEBUG_INPUT_DISPATCHER_POLICY diff --git a/services/jni/com_android_server_UsbService.cpp b/services/jni/com_android_server_UsbService.cpp index 00ee7e3..9cd04f6 100644 --- a/services/jni/com_android_server_UsbService.cpp +++ b/services/jni/com_android_server_UsbService.cpp @@ -37,13 +37,6 @@ namespace android { -static struct file_descriptor_offsets_t -{ - jclass mClass; - jmethodID mConstructor; - jfieldID mDescriptor; -} gFileDescriptorOffsets; - static struct parcel_file_descriptor_offsets_t { jclass mClass; @@ -167,11 +160,8 @@ static jobject android_server_UsbService_openDevice(JNIEnv *env, jobject thiz, j int newFD = dup(fd); usb_device_close(device); - jobject fileDescriptor = env->NewObject(gFileDescriptorOffsets.mClass, - gFileDescriptorOffsets.mConstructor); - if (fileDescriptor != NULL) { - env->SetIntField(fileDescriptor, gFileDescriptorOffsets.mDescriptor, newFD); - } else { + jobject fileDescriptor = jniCreateFileDescriptor(env, newFD); + if (fileDescriptor == NULL) { return NULL; } return env->NewObject(gParcelFileDescriptorOffsets.mClass, @@ -221,11 +211,8 @@ static jobject android_server_UsbService_openAccessory(JNIEnv *env, jobject thiz LOGE("could not open %s", DRIVER_NAME); return NULL; } - jobject fileDescriptor = env->NewObject(gFileDescriptorOffsets.mClass, - gFileDescriptorOffsets.mConstructor); - if (fileDescriptor != NULL) { - env->SetIntField(fileDescriptor, gFileDescriptorOffsets.mDescriptor, fd); - } else { + jobject fileDescriptor = jniCreateFileDescriptor(env, fd); + if (fileDescriptor == NULL) { return NULL; } return env->NewObject(gParcelFileDescriptorOffsets.mClass, @@ -260,14 +247,6 @@ int register_android_server_UsbService(JNIEnv *env) return -1; } - 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); diff --git a/services/tests/servicestests/AndroidManifest.xml b/services/tests/servicestests/AndroidManifest.xml index f115f42..2fcce78 100644 --- a/services/tests/servicestests/AndroidManifest.xml +++ b/services/tests/servicestests/AndroidManifest.xml @@ -15,7 +15,7 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.android.frameworks.servicestests"> + package="com.android.frameworks.servicestests"> <uses-permission android:name="android.permission.READ_LOGS" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> diff --git a/services/tests/servicestests/src/com/android/server/pm/UserDetailsTest.java b/services/tests/servicestests/src/com/android/server/pm/UserDetailsTest.java new file mode 100644 index 0000000..7b77aac --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/pm/UserDetailsTest.java @@ -0,0 +1,106 @@ +/* + * 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 com.android.server.pm; + +import com.android.server.pm.UserDetails; + +import android.content.pm.UserInfo; +import android.os.Debug; +import android.os.Environment; +import android.test.AndroidTestCase; + +import java.util.List; + +/** Test {@link UserDetails} functionality. */ +public class UserDetailsTest extends AndroidTestCase { + + UserDetails mDetails = null; + + @Override + public void setUp() throws Exception { + mDetails = new UserDetails(Environment.getExternalStorageDirectory()); + } + + @Override + public void tearDown() throws Exception { + List<UserInfo> users = mDetails.getUsers(); + // Remove all except the primary user + for (UserInfo user : users) { + if (!user.isPrimary()) { + mDetails.removeUser(user.id); + } + } + } + + public void testHasPrimary() throws Exception { + assertTrue(findUser(0)); + } + + public void testAddUser() throws Exception { + final UserDetails details = mDetails; + + UserInfo userInfo = details.createUser("Guest 1", UserInfo.FLAG_GUEST); + assertTrue(userInfo != null); + + List<UserInfo> list = details.getUsers(); + boolean found = false; + for (UserInfo user : list) { + if (user.id == userInfo.id && user.name.equals("Guest 1") + && user.isGuest() + && !user.isAdmin() + && !user.isPrimary()) { + found = true; + } + } + assertTrue(found); + } + + public void testAdd2Users() throws Exception { + final UserDetails details = mDetails; + + UserInfo user1 = details.createUser("Guest 1", UserInfo.FLAG_GUEST); + UserInfo user2 = details.createUser("User 2", UserInfo.FLAG_ADMIN); + + assertTrue(user1 != null); + assertTrue(user2 != null); + + assertTrue(findUser(0)); + assertTrue(findUser(user1.id)); + assertTrue(findUser(user2.id)); + } + + public void testRemoveUser() throws Exception { + final UserDetails details = mDetails; + + UserInfo userInfo = details.createUser("Guest 1", UserInfo.FLAG_GUEST); + + details.removeUser(userInfo.id); + + assertFalse(findUser(userInfo.id)); + } + + private boolean findUser(int id) { + List<UserInfo> list = mDetails.getUsers(); + + for (UserInfo user : list) { + if (user.id == id) { + return true; + } + } + return false; + } +} diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index 24c31c7..8c2851a 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -569,7 +569,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { if (defaultApnContext != null) { if (defaultApnContext.getState() == State.FAILED) { cleanUpConnection(false, defaultApnContext); - defaultApnContext.getDataConnection().resetRetryCount(); + if (defaultApnContext.getDataConnection() != null) { + defaultApnContext.getDataConnection().resetRetryCount(); + } } trySetupData(Phone.REASON_GPRS_ATTACHED, Phone.APN_TYPE_DEFAULT); } diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java index 0d20496..d84f1e5 100644 --- a/test-runner/src/android/test/mock/MockPackageManager.java +++ b/test-runner/src/android/test/mock/MockPackageManager.java @@ -23,32 +23,30 @@ import android.content.IntentSender; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.FeatureInfo; -import android.content.pm.IPackageDeleteObserver; import android.content.pm.IPackageDataObserver; +import android.content.pm.IPackageDeleteObserver; import android.content.pm.IPackageInstallObserver; import android.content.pm.IPackageMoveObserver; import android.content.pm.IPackageStatsObserver; import android.content.pm.InstrumentationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.content.pm.PackageParser; import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; -import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.UserInfo; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.os.RemoteException; import java.util.List; /** * A mock {@link android.content.pm.PackageManager} class. All methods are non-functional and throw - * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you + * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you * need. */ public class MockPackageManager extends PackageManager { @@ -63,12 +61,12 @@ public class MockPackageManager extends PackageManager { public String[] currentToCanonicalPackageNames(String[] names) { throw new UnsupportedOperationException(); } - + @Override public String[] canonicalToCurrentPackageNames(String[] names) { throw new UnsupportedOperationException(); } - + @Override public Intent getLaunchIntentForPackage(String packageName) { throw new UnsupportedOperationException(); @@ -101,7 +99,7 @@ public class MockPackageManager extends PackageManager { public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { throw new UnsupportedOperationException(); } - + @Override public ApplicationInfo getApplicationInfo(String packageName, int flags) throws NameNotFoundException { @@ -176,7 +174,7 @@ public class MockPackageManager extends PackageManager { public String getNameForUid(int uid) { throw new UnsupportedOperationException(); } - + /** * @hide - to match hiding in superclass */ @@ -273,7 +271,7 @@ public class MockPackageManager extends PackageManager { public Drawable getApplicationIcon(String packageName) throws NameNotFoundException { throw new UnsupportedOperationException(); } - + @Override public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException { throw new UnsupportedOperationException(); @@ -354,7 +352,7 @@ public class MockPackageManager extends PackageManager { public void movePackage(String packageName, IPackageMoveObserver observer, int flags) { throw new UnsupportedOperationException(); } - + @Override public String getInstallerPackageName(String packageName) { throw new UnsupportedOperationException(); @@ -368,7 +366,7 @@ public class MockPackageManager extends PackageManager { String packageName, IPackageDataObserver observer) { throw new UnsupportedOperationException(); } - + /** * @hide - to match hiding in superclass */ @@ -377,7 +375,7 @@ public class MockPackageManager extends PackageManager { String packageName, IPackageDataObserver observer) { throw new UnsupportedOperationException(); } - + /** * @hide - to match hiding in superclass */ @@ -435,7 +433,7 @@ public class MockPackageManager extends PackageManager { public void setApplicationEnabledSetting(String packageName, int newState, int flags) { throw new UnsupportedOperationException(); } - + @Override public int getApplicationEnabledSetting(String packageName) { throw new UnsupportedOperationException(); @@ -446,7 +444,7 @@ public class MockPackageManager extends PackageManager { int match, ComponentName[] set, ComponentName activity) { throw new UnsupportedOperationException(); } - + /** * @hide - to match hiding in superclass */ @@ -475,24 +473,64 @@ public class MockPackageManager extends PackageManager { List<ComponentName> outActivities, String packageName) { throw new UnsupportedOperationException(); } - + @Override public String[] getSystemSharedLibraryNames() { throw new UnsupportedOperationException(); } - + @Override public FeatureInfo[] getSystemAvailableFeatures() { throw new UnsupportedOperationException(); } - + @Override public boolean hasSystemFeature(String name) { throw new UnsupportedOperationException(); } - + @Override public boolean isSafeMode() { throw new UnsupportedOperationException(); } + + /** + * @hide + */ + @Override + public UserInfo createUser(String name, int flags) { + throw new UnsupportedOperationException(); + } + + /** + * @hide + */ + @Override + public List<UserInfo> getUsers() { + throw new UnsupportedOperationException(); + } + + /** + * @hide + */ + @Override + public boolean removeUser(int id) { + throw new UnsupportedOperationException(); + } + + /** + * @hide + */ + @Override + public void updateUserName(int id, String name) { + throw new UnsupportedOperationException(); + } + + /** + * @hide + */ + @Override + public void updateUserFlags(int id, int flags) { + throw new UnsupportedOperationException(); + } } diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml index 6fa27ed..de3b6d1 100644 --- a/tests/ActivityTests/AndroidManifest.xml +++ b/tests/ActivityTests/AndroidManifest.xml @@ -17,6 +17,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.test.activity"> <uses-permission android:name="android.permission.GET_TASKS" /> + <uses-permission android:name="android.permission.REORDER_TASKS" /> + <uses-permission android:name="android.permission.REMOVE_TASKS" /> <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> <application android:label="ActivityTest"> <activity android:name="ActivityTestMain"> diff --git a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java index 8c5c35a..583c13c 100644 --- a/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java +++ b/tests/ActivityTests/src/com/google/android/test/activity/ActivityTestMain.java @@ -23,6 +23,7 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityThread; import android.app.Application; +import android.content.ActivityNotFoundException; import android.os.Bundle; import android.graphics.BitmapFactory; import android.graphics.Bitmap; @@ -43,7 +44,11 @@ import android.util.DisplayMetrics; import android.util.Log; public class ActivityTestMain extends Activity { - private void addThumbnail(LinearLayout container, Bitmap bm) { + ActivityManager mAm; + + private void addThumbnail(LinearLayout container, Bitmap bm, + final ActivityManager.RecentTaskInfo task, + final ActivityManager.TaskThumbnails thumbs, final int subIndex) { ImageView iv = new ImageView(this); if (bm != null) { iv.setImageBitmap(bm); @@ -52,24 +57,72 @@ public class ActivityTestMain extends Activity { int w = getResources().getDimensionPixelSize(android.R.dimen.thumbnail_width); int h = getResources().getDimensionPixelSize(android.R.dimen.thumbnail_height); container.addView(iv, new LinearLayout.LayoutParams(w, h)); + + iv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (task.id >= 0 && thumbs != null) { + if (subIndex < (thumbs.numSubThumbbails-1)) { + mAm.removeSubTask(task.id, subIndex+1); + } + mAm.moveTaskToFront(task.id, ActivityManager.MOVE_TASK_WITH_HOME); + } else { + try { + startActivity(task.baseIntent); + } catch (ActivityNotFoundException e) { + Log.w("foo", "Unable to start task: " + e); + } + } + buildUi(); + } + }); + iv.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + if (task.id >= 0 && thumbs != null) { + if (subIndex < 0) { + mAm.removeTask(task.id, ActivityManager.REMOVE_TASK_KILL_PROCESS); + } else { + mAm.removeSubTask(task.id, subIndex); + } + buildUi(); + return true; + } + return false; + } + }); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE); + mAm = (ActivityManager)getSystemService(ACTIVITY_SERVICE); + } + + @Override + protected void onStart() { + super.onStart(); + buildUi(); + } + + private View scrollWrap(View view) { + ScrollView scroller = new ScrollView(this); + scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, + ScrollView.LayoutParams.MATCH_PARENT)); + return scroller; + } + private void buildUi() { LinearLayout top = new LinearLayout(this); top.setOrientation(LinearLayout.VERTICAL); - List<ActivityManager.RecentTaskInfo> recents = am.getRecentTasks(10, + List<ActivityManager.RecentTaskInfo> recents = mAm.getRecentTasks(10, ActivityManager.RECENT_WITH_EXCLUDED); if (recents != null) { for (int i=0; i<recents.size(); i++) { ActivityManager.RecentTaskInfo r = recents.get(i); - ActivityManager.TaskThumbnails tt = r != null - ? am.getTaskThumbnails(r.persistentId) : null; + ActivityManager.TaskThumbnails tt = mAm.getTaskThumbnails(r.persistentId); TextView tv = new TextView(this); tv.setText(r.baseIntent.getComponent().flattenToShortString()); top.addView(tv, new LinearLayout.LayoutParams( @@ -77,9 +130,9 @@ public class ActivityTestMain extends Activity { LinearLayout.LayoutParams.WRAP_CONTENT)); LinearLayout item = new LinearLayout(this); item.setOrientation(LinearLayout.HORIZONTAL); - addThumbnail(item, tt != null ? tt.mainThumbnail : null); + addThumbnail(item, tt != null ? tt.mainThumbnail : null, r, tt, -1); for (int j=0; j<tt.numSubThumbbails; j++) { - addThumbnail(item, tt.getSubThumbnail(j)); + addThumbnail(item, tt.getSubThumbnail(j), r, tt, j); } top.addView(item, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, @@ -89,11 +142,4 @@ public class ActivityTestMain extends Activity { setContentView(scrollWrap(top)); } - - private View scrollWrap(View view) { - ScrollView scroller = new ScrollView(this); - scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, - ScrollView.LayoutParams.MATCH_PARENT)); - return scroller; - } } diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h index 15570e4..fa84e93 100644 --- a/tools/aapt/Bundle.h +++ b/tools/aapt/Bundle.h @@ -40,6 +40,7 @@ public: mWantUTF16(false), mValues(false), mCompressionMethod(0), mOutputAPKFile(NULL), mManifestPackageNameOverride(NULL), mInstrumentationPackageNameOverride(NULL), + mIsOverlayPackage(false), mAutoAddOverlay(false), mAssetSourceDir(NULL), mProguardFile(NULL), mAndroidManifestFile(NULL), mPublicOutputFile(NULL), mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL), @@ -92,6 +93,8 @@ public: void setManifestPackageNameOverride(const char * val) { mManifestPackageNameOverride = val; } const char* getInstrumentationPackageNameOverride() const { return mInstrumentationPackageNameOverride; } void setInstrumentationPackageNameOverride(const char * val) { mInstrumentationPackageNameOverride = val; } + bool getIsOverlayPackage() const { return mIsOverlayPackage; } + void setIsOverlayPackage(bool val) { mIsOverlayPackage = val; } bool getAutoAddOverlay() { return mAutoAddOverlay; } void setAutoAddOverlay(bool val) { mAutoAddOverlay = val; } @@ -219,6 +222,7 @@ private: const char* mOutputAPKFile; const char* mManifestPackageNameOverride; const char* mInstrumentationPackageNameOverride; + bool mIsOverlayPackage; bool mAutoAddOverlay; const char* mAssetSourceDir; const char* mProguardFile; diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp index 266a02f..1e63131 100644 --- a/tools/aapt/Main.cpp +++ b/tools/aapt/Main.cpp @@ -68,6 +68,7 @@ void usage(void) " [-S resource-sources [-S resource-sources ...]] " " [-F apk-file] [-J R-file-dir] \\\n" " [--product product1,product2,...] \\\n" + " [-o] \\\n" " [raw-files-dir [raw-files-dir] ...]\n" "\n" " Package the android resources. It will read assets and resources that are\n" @@ -105,6 +106,7 @@ void usage(void) " -j specify a jar or zip file containing classes to include\n" " -k junk path of file(s) added\n" " -m make package directories under location specified by -J\n" + " -o create overlay package (ie only resources; expects <overlay-package> in manifest)\n" #if 0 " -p pseudolocalize the default configuration\n" #endif @@ -275,6 +277,9 @@ int main(int argc, char* const argv[]) case 'm': bundle.setMakePackageDirs(true); break; + case 'o': + bundle.setIsOverlayPackage(true); + break; #if 0 case 'p': bundle.setPseudolocalize(true); diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index 3dcc093..a88476e 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -3696,7 +3696,9 @@ sp<ResourceTable::Package> ResourceTable::getPackage(const String16& package) { sp<Package> p = mPackages.valueFor(package); if (p == NULL) { - if (mIsAppPackage) { + if (mBundle->getIsOverlayPackage()) { + p = new Package(package, 0x00); + } else if (mIsAppPackage) { if (mHaveAppPackage) { fprintf(stderr, "Adding multiple application package resources; only one is allowed.\n" "Use -x to create extended resources.\n"); |