diff options
32 files changed, 142 insertions, 92 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 13fda59240a6..2ed4b513f710 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -103,7 +103,7 @@ public class Am extends BaseCommand { "usage: am [subcommand] [options]\n" + "usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]\n" + " [--sampling INTERVAL] [-R COUNT] [-S] [--opengl-trace]\n" + - " [--user <USER_ID> | current] <INTENT>\n" + + " [--track-allocation] [--user <USER_ID> | current] <INTENT>\n" + " am startservice [--user <USER_ID> | current] <INTENT>\n" + " am stopservice [--user <USER_ID> | current] <INTENT>\n" + " am force-stop [--user <USER_ID> | all | current] <PACKAGE>\n" + @@ -159,6 +159,7 @@ public class Am extends BaseCommand { " the top activity will be finished.\n" + " -S: force stop the target app before starting the activity\n" + " --opengl-trace: enable tracing of OpenGL functions\n" + + " --track-allocation: enable tracking of object allocations\n" + " --user <USER_ID> | current: Specify which user to run as; if not\n" + " specified then run as the current user.\n" + "\n" + @@ -687,6 +688,8 @@ public class Am extends BaseCommand { mStopOption = true; } else if (opt.equals("--opengl-trace")) { mStartFlags |= ActivityManager.START_FLAG_OPENGL_TRACES; + } else if (opt.equals("--track-allocation")) { + mStartFlags |= ActivityManager.START_FLAG_TRACK_ALLOCATION; } else if (opt.equals("--user")) { mUserId = parseUserArg(nextArgRequired()); } else if (opt.equals("--receiver-permission")) { diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk index 7ce0846f2e7c..51bbb813df65 100644 --- a/cmds/app_process/Android.mk +++ b/cmds/app_process/Android.mk @@ -65,7 +65,7 @@ LOCAL_MULTILIB := both LOCAL_MODULE_STEM_32 := app_process32 LOCAL_MODULE_STEM_64 := app_process64 -LOCAL_ADDRESS_SANITIZER := true +LOCAL_SANITIZE := address LOCAL_CLANG := true LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan diff --git a/cmds/input/src/com/android/commands/input/Input.java b/cmds/input/src/com/android/commands/input/Input.java index 2a7c79bdfb5b..754d3f510bbd 100644 --- a/cmds/input/src/com/android/commands/input/Input.java +++ b/cmds/input/src/com/android/commands/input/Input.java @@ -234,6 +234,18 @@ public class Input { InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } + private int getInputDeviceId(int inputSource) { + final int DEFAULT_DEVICE_ID = 0; + int[] devIds = InputDevice.getDeviceIds(); + for (int devId : devIds) { + InputDevice inputDev = InputDevice.getDevice(devId); + if (inputDev.supportsSource(inputSource)) { + return devId; + } + } + return DEFAULT_DEVICE_ID; + } + /** * Builds a MotionEvent and injects it into the event stream. * @@ -249,11 +261,10 @@ public class Input { final int DEFAULT_META_STATE = 0; final float DEFAULT_PRECISION_X = 1.0f; final float DEFAULT_PRECISION_Y = 1.0f; - final int DEFAULT_DEVICE_ID = 0; final int DEFAULT_EDGE_FLAGS = 0; MotionEvent event = MotionEvent.obtain(when, when, action, x, y, pressure, DEFAULT_SIZE, - DEFAULT_META_STATE, DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y, DEFAULT_DEVICE_ID, - DEFAULT_EDGE_FLAGS); + DEFAULT_META_STATE, DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y, + getInputDeviceId(inputSource), DEFAULT_EDGE_FLAGS); event.setSource(inputSource); Log.i(TAG, "injectMotionEvent: " + event); InputManager.getInstance().injectInputEvent(event, diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 9ca206a42c00..ea1adc039889 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -210,6 +210,13 @@ public class ActivityManager { public static final int START_FLAG_OPENGL_TRACES = 1<<2; /** + * Flag for IActivityManaqer.startActivity: launch the app for + * allocation tracking. + * @hide + */ + public static final int START_FLAG_TRACK_ALLOCATION = 1<<3; + + /** * Result for IActivityManaqer.broadcastIntent: success! * @hide */ diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 828dc0af2026..2ad474a52b1e 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -132,6 +132,7 @@ import libcore.net.event.NetworkEventDispatcher; import dalvik.system.CloseGuard; import dalvik.system.VMDebug; import dalvik.system.VMRuntime; +import org.apache.harmony.dalvik.ddmc.DdmVmInternal; final class RemoteServiceException extends AndroidRuntimeException { public RemoteServiceException(String msg) { @@ -446,6 +447,7 @@ public final class ActivityThread { IUiAutomationConnection instrumentationUiAutomationConnection; int debugMode; boolean enableOpenGlTrace; + boolean trackAllocation; boolean restrictedBackupMode; boolean persistent; Configuration config; @@ -770,9 +772,9 @@ public final class ActivityThread { ProfilerInfo profilerInfo, Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher, IUiAutomationConnection instrumentationUiConnection, int debugMode, - boolean enableOpenGlTrace, boolean isRestrictedBackupMode, boolean persistent, - Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, - Bundle coreSettings) { + boolean enableOpenGlTrace, boolean trackAllocation, boolean isRestrictedBackupMode, + boolean persistent, Configuration config, CompatibilityInfo compatInfo, + Map<String, IBinder> services, Bundle coreSettings) { if (services != null) { // Setup the service cache in the ServiceManager @@ -828,6 +830,7 @@ public final class ActivityThread { data.instrumentationUiAutomationConnection = instrumentationUiConnection; data.debugMode = debugMode; data.enableOpenGlTrace = enableOpenGlTrace; + data.trackAllocation = trackAllocation; data.restrictedBackupMode = isRestrictedBackupMode; data.persistent = persistent; data.config = config; @@ -4426,6 +4429,10 @@ public final class ActivityThread { } private void handleBindApplication(AppBindData data) { + if (data.trackAllocation) { + DdmVmInternal.enableRecentAllocations(true); + } + mBoundApplication = data; mConfiguration = new Configuration(data.config); mCompatConfiguration = new Configuration(data.config); diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java index 9ea160680683..0a28690da8d2 100644 --- a/core/java/android/app/AlarmManager.java +++ b/core/java/android/app/AlarmManager.java @@ -817,7 +817,7 @@ public class AlarmManager { } /** - * Returns an intent intent that can be used to show or edit details of the alarm clock in + * Returns an intent that can be used to show or edit details of the alarm clock in * the application that scheduled it. * * <p class="note">Beware that any application can retrieve and send this intent, diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index e17808744408..b9ebd9fbaf9c 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -292,6 +292,7 @@ public abstract class ApplicationThreadNative extends Binder IUiAutomationConnection.Stub.asInterface(binder); int testMode = data.readInt(); boolean openGlTrace = data.readInt() != 0; + boolean trackAllocation = data.readInt() != 0; boolean restrictedBackupMode = (data.readInt() != 0); boolean persistent = (data.readInt() != 0); Configuration config = Configuration.CREATOR.createFromParcel(data); @@ -299,7 +300,7 @@ public abstract class ApplicationThreadNative extends Binder HashMap<String, IBinder> services = data.readHashMap(null); Bundle coreSettings = data.readBundle(); bindApplication(packageName, info, providers, testName, profilerInfo, testArgs, - testWatcher, uiAutomationConnection, testMode, openGlTrace, + testWatcher, uiAutomationConnection, testMode, openGlTrace, trackAllocation, restrictedBackupMode, persistent, config, compatInfo, services, coreSettings); return true; } @@ -987,13 +988,14 @@ class ApplicationThreadProxy implements IApplicationThread { data.recycle(); } + @Override public final void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo, Bundle testArgs, IInstrumentationWatcher testWatcher, IUiAutomationConnection uiAutomationConnection, int debugMode, - boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, - Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, - Bundle coreSettings) throws RemoteException { + boolean openGlTrace, boolean trackAllocation, boolean restrictedBackupMode, + boolean persistent, Configuration config, CompatibilityInfo compatInfo, + Map<String, IBinder> services, Bundle coreSettings) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeString(packageName); @@ -1016,6 +1018,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeStrongInterface(uiAutomationConnection); data.writeInt(debugMode); data.writeInt(openGlTrace ? 1 : 0); + data.writeInt(trackAllocation ? 1 : 0); data.writeInt(restrictedBackupMode ? 1 : 0); data.writeInt(persistent ? 1 : 0); config.writeToParcel(data, 0); diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java index 185578fa707c..e204d50d226a 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -95,8 +95,9 @@ public interface IApplicationThread extends IInterface { void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo, Bundle testArguments, IInstrumentationWatcher testWatcher, IUiAutomationConnection uiAutomationConnection, - int debugMode, boolean openGlTrace, boolean restrictedBackupMode, boolean persistent, - Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services, + int debugMode, boolean openGlTrace, boolean trackAllocation, + boolean restrictedBackupMode, boolean persistent, Configuration config, + CompatibilityInfo compatInfo, Map<String, IBinder> services, Bundle coreSettings) throws RemoteException; void scheduleExit() throws RemoteException; void scheduleSuicide() throws RemoteException; diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 63dd4926bc56..9dd5aa1c4178 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -19015,7 +19015,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Returns the suggested minimum width that the view should use. This - * returns the maximum of the view's minimum width) + * returns the maximum of the view's minimum width * and the background's minimum width * ({@link android.graphics.drawable.Drawable#getMinimumWidth()}). * <p> diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java index 1464bb5cff97..8f780526c50d 100644 --- a/core/java/android/view/accessibility/AccessibilityEvent.java +++ b/core/java/android/view/accessibility/AccessibilityEvent.java @@ -372,7 +372,6 @@ import java.util.List; * <li>{@link #getClassName()} - The class name of the source.</li> * <li>{@link #getPackageName()} - The package name of the source.</li> * <li>{@link #getEventTime()} - The event time.</li> - * <li>{@link #getText()} - The text of the source's sub-tree.</li> * <li>{@link #getParcelableData()} - The posted {@link android.app.Notification}.</li> * <li>{@link #getText()} - Text for providing more context.</li> * </ul> diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java index de8ccc100880..f2bb55a7db13 100644 --- a/core/java/android/webkit/WebViewClient.java +++ b/core/java/android/webkit/WebViewClient.java @@ -415,7 +415,7 @@ public class WebViewClient { * Notify the host application that the scale applied to the WebView has * changed. * - * @param view he WebView that is initiating the callback. + * @param view The WebView that is initiating the callback. * @param oldScale The old scale factor * @param newScale The new scale factor */ diff --git a/core/java/android/widget/Adapter.java b/core/java/android/widget/Adapter.java index 88b54bf14ebb..518718f9632a 100644 --- a/core/java/android/widget/Adapter.java +++ b/core/java/android/widget/Adapter.java @@ -130,8 +130,7 @@ public interface Adapter { * type of View for all items, this method should return 1. * </p> * <p> - * This method will only be called when when the adapter is set on the - * the {@link AdapterView}. + * This method will only be called when the adapter is set on the {@link AdapterView}. * </p> * * @return The number of types of Views that will be created by this adapter @@ -148,4 +147,3 @@ public interface Adapter { */ boolean isEmpty(); } - diff --git a/core/java/com/android/internal/app/ProcessStats.java b/core/java/com/android/internal/app/ProcessStats.java index 27aec4e6103a..17ca904d50b0 100644 --- a/core/java/com/android/internal/app/ProcessStats.java +++ b/core/java/com/android/internal/app/ProcessStats.java @@ -3366,10 +3366,11 @@ public final class ProcessStats implements Parcelable { + pkgList.keyAt(index) + "/" + proc.mUid + " for multi-proc " + proc.mName + " version " + proc.mVersion); } + String savedName = proc.mName; proc = pkg.mProcesses.get(proc.mName); if (proc == null) { throw new IllegalStateException("Didn't create per-package process " - + proc.mName + " in pkg " + pkg.mPackageName + "/" + pkg.mUid); + + savedName + " in pkg " + pkg.mPackageName + "/" + pkg.mUid); } holder.state = proc; } diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp index 0f5ba83fa19a..a14afa054c17 100644 --- a/core/jni/android_os_Parcel.cpp +++ b/core/jni/android_os_Parcel.cpp @@ -451,15 +451,11 @@ static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jclass clazz, jniThrowNullPointerException(env, NULL); return NULL; } - const jchar* str = env->GetStringCritical(name, 0); - if (str == NULL) { - // Whatever, whatever. - jniThrowException(env, "java/lang/IllegalStateException", NULL); + ScopedUtfChars name8(env, name); + if (name8.c_str() == NULL) { return NULL; } - String8 name8(reinterpret_cast<const char16_t*>(str), - env->GetStringLength(name)); - env->ReleaseStringCritical(name, str); + int flags=0; switch (mode&0x30000000) { case 0: @@ -482,7 +478,7 @@ static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jclass clazz, if (mode&0x00000001) realMode |= S_IROTH; if (mode&0x00000002) realMode |= S_IWOTH; - int fd = open(name8.string(), flags, realMode); + int fd = open(name8.c_str(), flags, realMode); if (fd < 0) { jniThrowException(env, "java/io/FileNotFoundException", strerror(errno)); return NULL; diff --git a/core/tests/overlaytests/testrunner.py b/core/tests/overlaytests/testrunner.py index 3703f4a4b7ca..2aa25adeda5d 100755 --- a/core/tests/overlaytests/testrunner.py +++ b/core/tests/overlaytests/testrunner.py @@ -301,7 +301,7 @@ class Md5Test: return self.path def execute(self): - returncode, stdout, stderr = _adb_shell('md5 %s' % self.path) + returncode, stdout, stderr = _adb_shell('md5sum %s' % self.path) if returncode != 0: return returncode, stdout, stderr actual_md5 = stdout.split()[0] diff --git a/data/keyboards/Android.mk b/data/keyboards/Android.mk index 898efe8f2dca..461683805058 100644 --- a/data/keyboards/Android.mk +++ b/data/keyboards/Android.mk @@ -32,7 +32,7 @@ $(LOCAL_BUILT_MODULE) : $(framework_keylayouts) $(framework_keycharmaps) $(frame $(hide) mkdir -p $(dir $@) && touch $@ # Run validatekeymaps uncondionally for platform build. -droidcore all_modules : $(LOCAL_BUILT_MODULE) +droidcore : $(LOCAL_BUILT_MODULE) # Reset temp vars. validatekeymaps := diff --git a/docs/html/guide/topics/renderscript/reference/overview.jd b/docs/html/guide/topics/renderscript/reference/overview.jd index f85b843b3a8f..169b32016f8c 100644 --- a/docs/html/guide/topics/renderscript/reference/overview.jd +++ b/docs/html/guide/topics/renderscript/reference/overview.jd @@ -43,7 +43,7 @@ E.g. <a href='rs_value_types.html#android_rs:float4'>float4</a>, <a href='rs_val </p> <p> To create vector literals, use the vector type followed by the values enclosed -between parentheses, e.g. <code>(float3)(1.0f, 2.0f, 3.0f)</code>. +between curly braces, e.g. <code>(float3){1.0f, 2.0f, 3.0f}</code>. </p> <p> Entries of a vector can be accessed using different naming styles. diff --git a/docs/html/tools/debugging/debugging-log.jd b/docs/html/tools/debugging/debugging-log.jd index d2baaf26ce84..e222b2a05cd4 100644 --- a/docs/html/tools/debugging/debugging-log.jd +++ b/docs/html/tools/debugging/debugging-log.jd @@ -284,22 +284,8 @@ adb logcat -b radio <h2 id="viewingStd">Viewing stdout and stderr</h2> <p>By default, the Android system sends <code>stdout</code> and <code>stderr</code> - (<code>System.out</code> and <code>System.err</code>) output to <code>/dev/null</code>. In - processes that run the Dalvik VM, you can have the system write a copy of the output to the log - file. In this case, the system writes the messages to the log using the log tags - <code>stdout</code> and <code>stderr</code>, both with priority <code>I</code>.</p> - - <p>To route the output in this way, you stop a running emulator/device instance and then use the - shell command <code>setprop</code> to enable the redirection of output. Here's how you do it:</p> - <pre> -$ adb shell stop -$ adb shell setprop log.redirect-stdio true -$ adb shell start -</pre> - - <p>The system retains this setting until you terminate the emulator/device instance. To use the - setting as a default on the emulator/device instance, you can add an entry to - <code>/data/local.prop</code> on the device.</p> + output to <code>/dev/null</code>. (The Java <code>System.out</code> and <code>System.err</code> + streams go to the log.) <h2 id="DebuggingWebPages">Debugging Web Apps</h2> <p> diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp index a6f6d8c4ff16..49fe8a261178 100644 --- a/libs/androidfw/ZipFileRO.cpp +++ b/libs/androidfw/ZipFileRO.cpp @@ -39,7 +39,7 @@ using namespace android; class _ZipEntryRO { public: ZipEntry entry; - ZipEntryName name; + ZipString name; void *cookie; _ZipEntryRO() : cookie(NULL) {} @@ -80,7 +80,7 @@ ZipEntryRO ZipFileRO::findEntryByName(const char* entryName) const { _ZipEntryRO* data = new _ZipEntryRO; - data->name = ZipEntryName(entryName); + data->name = ZipString(entryName); const int32_t error = FindEntry(mHandle, data->name, &(data->entry)); if (error) { @@ -133,8 +133,8 @@ bool ZipFileRO::startIteration(void** cookie) { bool ZipFileRO::startIteration(void** cookie, const char* prefix, const char* suffix) { _ZipEntryRO* ze = new _ZipEntryRO; - ZipEntryName pe(prefix ? prefix : ""); - ZipEntryName se(suffix ? suffix : ""); + ZipString pe(prefix ? prefix : ""); + ZipString se(suffix ? suffix : ""); int32_t error = StartIteration(mHandle, &(ze->cookie), prefix ? &pe : NULL, suffix ? &se : NULL); diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index a3ff080c53f0..7dd70d4d5527 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -64,9 +64,7 @@ public class MediaMetadataRetriever throw new IllegalArgumentException(); } - FileInputStream is = null; - try { - is = new FileInputStream(path); + try (FileInputStream is = new FileInputStream(path)) { FileDescriptor fd = is.getFD(); setDataSource(fd, 0, 0x7ffffffffffffffL); } catch (FileNotFoundException fileEx) { @@ -74,12 +72,6 @@ public class MediaMetadataRetriever } catch (IOException ioEx) { throw new IllegalArgumentException(); } - - try { - if (is != null) { - is.close(); - } - } catch (Exception e) {} } /** diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 6dd855d4dc41..430f6a8a6133 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -793,7 +793,7 @@ public class MediaPlayer implements SubtitleController.Listener * <li> {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING} * </ul> * - * @param mode target video scaling mode. Most be one of the supported + * @param mode target video scaling mode. Must be one of the supported * video scaling modes; otherwise, IllegalArgumentException will be thrown. * * @see MediaPlayer#VIDEO_SCALING_MODE_SCALE_TO_FIT diff --git a/packages/InputDevices/Android.mk b/packages/InputDevices/Android.mk index f537022c6129..e7190dc90843 100644 --- a/packages/InputDevices/Android.mk +++ b/packages/InputDevices/Android.mk @@ -42,7 +42,7 @@ $(LOCAL_BUILT_MODULE) : $(input_devices_keymaps) | $(validatekeymaps) $(hide) mkdir -p $(dir $@) && touch $@ # Run validatekeymaps unconditionally for platform build. -droidcore all_modules : $(LOCAL_BUILT_MODULE) +droidcore : $(LOCAL_BUILT_MODULE) # Reset temp vars. validatekeymaps := diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 6acd13731b27..35ea9a840442 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -236,7 +236,9 @@ public class ImageWallpaper extends WallpaperService { Log.d(TAG, "Visibility changed to visible=" + visible); } mVisible = visible; - drawFrame(); + if (visible) { + drawFrame(); + } } } diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index 0a5059390449..a4876b92fadf 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -1505,7 +1505,7 @@ public class Allocation extends BaseObj { } final byte[] data = fp.getData(); - int data_length = fp.getPos(); + int data_length = data.length; int eSize = mType.mElement.mElements[component_number].getBytesSize(); eSize *= mType.mElement.mArraySizes[component_number]; diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 8b1a0324956a..f8028eeccacf 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -88,6 +88,13 @@ public class RenderScript { */ public static final int CREATE_FLAG_LOW_POWER = 0x0004; + /** + * @hide + * Context creation flag which instructs the implementation to wait for + * a debugger to be attached before continuing execution. + */ + public static final int CREATE_FLAG_WAIT_FOR_ATTACH = 0x0008; + /* * Detect the bitness of the VM to allow FieldPacker to do the right thing. */ @@ -1356,7 +1363,7 @@ public class RenderScript { return null; } - if ((flags & ~(CREATE_FLAG_LOW_LATENCY | CREATE_FLAG_LOW_POWER)) != 0) { + if ((flags & ~(CREATE_FLAG_LOW_LATENCY | CREATE_FLAG_LOW_POWER | CREATE_FLAG_WAIT_FOR_ATTACH)) != 0) { throw new RSIllegalArgumentException("Invalid flags passed."); } diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlend.java b/rs/java/android/renderscript/ScriptIntrinsicBlend.java index 906e0f640a4f..dc1bec32f52d 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBlend.java +++ b/rs/java/android/renderscript/ScriptIntrinsicBlend.java @@ -402,6 +402,8 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { /** * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a} * + * <b>Note:</b> this is NOT the Porter/Duff XOR mode; this is a bitwise xor. + * * @param ain The source buffer * @param aout The destination buffer * @param opt LaunchOptions for clipping diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp index ffc4fd82ab5e..6a41699fc77e 100644 --- a/rs/jni/android_renderscript_RenderScript.cpp +++ b/rs/jni/android_renderscript_RenderScript.cpp @@ -1452,7 +1452,7 @@ nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong alloc, rsAllocationElementRead((RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, lod, ptr, sizeBytes, compIdx); - _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); + _env->ReleaseByteArrayElements(data, ptr, 0); } // Copies from the Allocation pointed to by _alloc into the Java object data. diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java index d58d3721d803..4288fa2668dc 100644 --- a/services/core/java/com/android/server/AlarmManagerService.java +++ b/services/core/java/com/android/server/AlarmManagerService.java @@ -516,10 +516,10 @@ class AlarmManagerService extends SystemService { public int compare(Batch b1, Batch b2) { long when1 = b1.start; long when2 = b2.start; - if (when1 - when2 > 0) { + if (when1 > when2) { return 1; } - if (when1 - when2 < 0) { + if (when1 < when2) { return -1; } return 0; @@ -1932,10 +1932,10 @@ class AlarmManagerService extends SystemService { public int compare(Alarm a1, Alarm a2) { long when1 = a1.whenElapsed; long when2 = a2.whenElapsed; - if (when1 - when2 > 0) { + if (when1 > when2) { return 1; } - if (when1 - when2 < 0) { + if (when1 < when2) { return -1; } return 0; diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 959fd37e6186..91b9ecbbbd34 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1205,6 +1205,7 @@ public final class ActivityManagerService extends ActivityManagerNative String mMemWatchDumpFile; int mMemWatchDumpPid; int mMemWatchDumpUid; + String mTrackAllocationApp = null; final long[] mTmpLong = new long[1]; @@ -6033,6 +6034,11 @@ public final class ActivityManagerService extends ActivityManagerNative enableOpenGlTrace = true; mOpenGlTraceApp = null; } + boolean enableTrackAllocation = false; + if (mTrackAllocationApp != null && mTrackAllocationApp.equals(processName)) { + enableTrackAllocation = true; + mTrackAllocationApp = null; + } // If the app is being launched for restore or full backup, set it up specially boolean isRestrictedBackupMode = false; @@ -6061,7 +6067,7 @@ public final class ActivityManagerService extends ActivityManagerNative thread.bindApplication(processName, appInfo, providers, app.instrumentationClass, profilerInfo, app.instrumentationArguments, app.instrumentationWatcher, app.instrumentationUiAutomationConnection, testMode, enableOpenGlTrace, - isRestrictedBackupMode || !normalMode, app.persistent, + enableTrackAllocation, isRestrictedBackupMode || !normalMode, app.persistent, new Configuration(mConfiguration), app.compat, getCommonServicesLocked(app.isolated), mCoreSettingsObserver.getCoreSettingsLocked()); @@ -10495,7 +10501,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (this) { boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0")); if (!isDebuggable) { - if ((app.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0) { + if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) { throw new SecurityException("Process not debuggable: " + app.packageName); } } @@ -10504,11 +10510,24 @@ public final class ActivityManagerService extends ActivityManagerNative } } + void setTrackAllocationApp(ApplicationInfo app, String processName) { + synchronized (this) { + boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0")); + if (!isDebuggable) { + if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) { + throw new SecurityException("Process not debuggable: " + app.packageName); + } + } + + mTrackAllocationApp = processName; + } + } + void setProfileApp(ApplicationInfo app, String processName, ProfilerInfo profilerInfo) { synchronized (this) { boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0")); if (!isDebuggable) { - if ((app.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0) { + if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) { throw new SecurityException("Process not debuggable: " + app.packageName); } } @@ -13531,6 +13550,15 @@ public final class ActivityManagerService extends ActivityManagerNative pw.println(" mOpenGlTraceApp=" + mOpenGlTraceApp); } } + if (mTrackAllocationApp != null) { + if (dumpPackage == null || dumpPackage.equals(mTrackAllocationApp)) { + if (needSep) { + pw.println(); + needSep = false; + } + pw.println(" mTrackAllocationApp=" + mTrackAllocationApp); + } + } if (mProfileApp != null || mProfileProc != null || mProfileFile != null || mProfileFd != null) { if (dumpPackage == null || dumpPackage.equals(mProfileApp)) { diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 4ce5c7ef7fca..f1c123e14ded 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -884,20 +884,20 @@ public final class ActivityStackSupervisor implements DisplayListener { aInfo.applicationInfo.packageName, aInfo.name)); // Don't debug things in the system process - if ((startFlags&ActivityManager.START_FLAG_DEBUG) != 0) { - if (!aInfo.processName.equals("system")) { + if (!aInfo.processName.equals("system")) { + if ((startFlags & ActivityManager.START_FLAG_DEBUG) != 0) { mService.setDebugApp(aInfo.processName, true, false); } - } - if ((startFlags&ActivityManager.START_FLAG_OPENGL_TRACES) != 0) { - if (!aInfo.processName.equals("system")) { + if ((startFlags & ActivityManager.START_FLAG_OPENGL_TRACES) != 0) { mService.setOpenGlTraceApp(aInfo.applicationInfo, aInfo.processName); } - } - if (profilerInfo != null) { - if (!aInfo.processName.equals("system")) { + if ((startFlags & ActivityManager.START_FLAG_TRACK_ALLOCATION) != 0) { + mService.setTrackAllocationApp(aInfo.applicationInfo, aInfo.processName); + } + + if (profilerInfo != null) { mService.setProfileApp(aInfo.applicationInfo, aInfo.processName, profilerInfo); } } diff --git a/services/core/java/com/android/server/job/JobServiceContext.java b/services/core/java/com/android/server/job/JobServiceContext.java index bb4e38849a56..d26319b5b0b9 100644 --- a/services/core/java/com/android/server/job/JobServiceContext.java +++ b/services/core/java/com/android/server/job/JobServiceContext.java @@ -73,7 +73,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne private static final long OP_TIMEOUT_MILLIS = 8 * 1000; private static final String[] VERB_STRINGS = { - "VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING" + "VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING", "VERB_FINISHED" }; // States that a job occupies while interacting with the client. @@ -81,6 +81,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne static final int VERB_STARTING = 1; static final int VERB_EXECUTING = 2; static final int VERB_STOPPING = 3; + static final int VERB_FINISHED = 4; // Messages that result from interactions with the client service. /** System timed out waiting for a response. */ @@ -172,6 +173,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne mRunningJob = null; mParams = null; mExecutionStartTimeElapsed = 0L; + mVerb = VERB_FINISHED; removeOpTimeOut(); return false; } @@ -307,8 +309,8 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne break; case MSG_CALLBACK: if (DEBUG) { - Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob + " v:" + - (mVerb >= 0 ? VERB_STRINGS[mVerb] : "[invalid]")); + Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob + + " v:" + VERB_STRINGS[mVerb]); } removeOpTimeOut(); @@ -524,8 +526,12 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne * we want to clean up internally. */ private void closeAndCleanupJobH(boolean reschedule) { - final JobStatus completedJob = mRunningJob; + final JobStatus completedJob; synchronized (mLock) { + if (mVerb == VERB_FINISHED) { + return; + } + completedJob = mRunningJob; try { mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getUid()); } catch (RemoteException e) { @@ -538,7 +544,7 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne mWakeLock = null; mRunningJob = null; mParams = null; - mVerb = -1; + mVerb = VERB_FINISHED; mCancelled.set(false); service = null; mAvailable = true; diff --git a/services/core/jni/com_android_server_PersistentDataBlockService.cpp b/services/core/jni/com_android_server_PersistentDataBlockService.cpp index e842eebdd2e0..4ccfa56cd30c 100644 --- a/services/core/jni/com_android_server_PersistentDataBlockService.cpp +++ b/services/core/jni/com_android_server_PersistentDataBlockService.cpp @@ -17,6 +17,7 @@ #include <android_runtime/AndroidRuntime.h> #include <JNIHelp.h> #include <jni.h> +#include <ScopedUtfChars.h> #include <utils/misc.h> #include <sys/ioctl.h> @@ -77,8 +78,8 @@ namespace android { static jlong com_android_server_PersistentDataBlockService_getBlockDeviceSize(JNIEnv *env, jclass, jstring jpath) { - const char *path = env->GetStringUTFChars(jpath, 0); - int fd = open(path, O_RDONLY); + ScopedUtfChars path(env, jpath); + int fd = open(path.c_str(), O_RDONLY); if (fd < 0) return 0; @@ -87,8 +88,8 @@ namespace android { } static int com_android_server_PersistentDataBlockService_wipe(JNIEnv *env, jclass, jstring jpath) { - const char *path = env->GetStringUTFChars(jpath, 0); - int fd = open(path, O_WRONLY); + ScopedUtfChars path(env, jpath); + int fd = open(path.c_str(), O_WRONLY); if (fd < 0) return 0; |