diff options
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 5 | ||||
-rw-r--r-- | core/java/android/app/ActivityManager.java | 7 | ||||
-rw-r--r-- | core/java/android/app/ActivityThread.java | 13 | ||||
-rw-r--r-- | core/java/android/app/ApplicationThreadNative.java | 11 | ||||
-rw-r--r-- | core/java/android/app/IApplicationThread.java | 5 | ||||
-rw-r--r-- | core/java/android/os/Debug.java | 21 | ||||
-rw-r--r-- | core/java/android/view/View.java | 2 | ||||
-rw-r--r-- | core/java/android/view/accessibility/AccessibilityEvent.java | 1 | ||||
-rw-r--r-- | core/java/android/webkit/WebViewClient.java | 2 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 20 | ||||
-rw-r--r-- | media/java/android/media/MediaMetadataRetriever.java | 10 | ||||
-rw-r--r-- | media/java/android/media/MediaPlayer.java | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 34 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityStackSupervisor.java | 16 |
14 files changed, 113 insertions, 36 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 2ea1d4d4f1d4..50cfe6f1ff8c 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" + @@ -149,6 +149,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" + @@ -583,6 +584,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/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index c6ffef64f7e8..ad22523c2d84 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -200,6 +200,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 e32254a91d1e..9449eff1f40b 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -133,6 +133,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) { @@ -443,6 +444,7 @@ public final class ActivityThread { IUiAutomationConnection instrumentationUiAutomationConnection; int debugMode; boolean enableOpenGlTrace; + boolean trackAllocation; boolean restrictedBackupMode; boolean persistent; Configuration config; @@ -756,9 +758,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 @@ -814,6 +816,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; @@ -4314,6 +4317,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/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index eb3ddb28c367..6c8b182feb8e 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -284,6 +284,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); @@ -291,7 +292,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; } @@ -961,13 +962,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); @@ -990,6 +992,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 8bf8cd733b0b..121d8ad58bf0 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -96,8 +96,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/os/Debug.java b/core/java/android/os/Debug.java index 2a60b4d9738f..a43526748e62 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -1090,13 +1090,30 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo * </tr> * <tr> * <td>art.gc.gc-count-rate-histogram</td> - * <td>The histogram of the number of garbage collection runs per 10 seconds.</td> + * <td>Every 10 seconds, the gc-count-rate is computed as the number of garbage + * collection runs that have occurred over the last 10 + * seconds. art.gc.gc-count-rate-histogram is a histogram of the gc-count-rate + * samples taken since the process began. The histogram can be used to identify + * instances of high rates of garbage collection runs. For example, a histogram + * of "0:34503,1:45350,2:11281,3:8088,4:43,5:8" shows that most of the time + * there are between 0 and 2 garbage collection runs every 10 seconds, but there + * were 8 distinct 10-second intervals in which 5 garbage collection runs + * occurred.</td> * <td>{@code 0:34503,1:45350,2:11281,3:8088,4:43,5:8}</td> * <td>23</td> * </tr> * <tr> * <td>art.gc.blocking-gc-count-rate-histogram</td> - * <td>The histogram of the number of garbage collection runs per 10 seconds.</td> + * <td>Every 10 seconds, the blocking-gc-count-rate is computed as the number of + * blocking garbage collection runs that have occurred over the last 10 + * seconds. art.gc.blocking-gc-count-rate-histogram is a histogram of the + * blocking-gc-count-rate samples taken since the process began. The histogram + * can be used to identify instances of high rates of blocking garbage + * collection runs. For example, a histogram of "0:99269,1:1,2:1" shows that + * most of the time there are zero blocking garbage collection runs every 10 + * seconds, but there was one 10-second interval in which one blocking garbage + * collection run occurred, and there was one interval in which two blocking + * garbage collection runs occurred.</td> * <td>{@code 0:99269,1:1,2:1}</td> * <td>23</td> * </tr> diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 3c058729880a..9176d9e5d84e 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -17765,7 +17765,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 417e22c57456..dd272e1fbd26 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 d52dd60e00f0..0a6bba829122 100644 --- a/core/java/android/webkit/WebViewClient.java +++ b/core/java/android/webkit/WebViewClient.java @@ -338,7 +338,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/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 6e8da65ad62a..f73c142e574e 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -587,6 +587,8 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) char lockProfThresholdBuf[sizeof("-Xlockprofthreshold:")-1 + PROPERTY_VALUE_MAX]; char nativeBridgeLibrary[sizeof("-XX:NativeBridge=") + PROPERTY_VALUE_MAX]; char cpuAbiListBuf[sizeof("--cpu-abilist=") + PROPERTY_VALUE_MAX]; + char methodTraceFileBuf[sizeof("-Xmethod-trace-file:") + PROPERTY_VALUE_MAX]; + char methodTraceFileSizeBuf[sizeof("-Xmethod-trace-file-size:") + PROPERTY_VALUE_MAX]; bool checkJni = false; property_get("dalvik.vm.checkjni", propBuf, ""); @@ -847,6 +849,24 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) profileMaxStackDepth, "-Xprofile-max-stack-depth:"); + /* + * Tracing options. + */ + property_get("dalvik.vm.method-trace", propBuf, "false"); + if (strcmp(propBuf, "true") == 0) { + addOption("-Xmethod-trace"); + parseRuntimeOption("dalvik.vm.method-trace-file", + methodTraceFileBuf, + "-Xmethod-trace-file:"); + parseRuntimeOption("dalvik.vm.method-trace-file-siz", + methodTraceFileSizeBuf, + "-Xmethod-trace-file-size:"); + property_get("dalvik.vm.method-trace-stream", propBuf, "false"); + if (strcmp(propBuf, "true") == 0) { + addOption("-Xmethod-trace-stream"); + } + } + // Native bridge library. "0" means that native bridge is disabled. property_get("ro.dalvik.vm.native.bridge", propBuf, ""); if (propBuf[0] == '\0') { diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index 9a69c067e498..9a73dfcd275b 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 615dac204f7b..ccfa7ed1a3ee 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -777,7 +777,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/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index da2b91e1b7df..ca21071a513b 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1122,6 +1122,7 @@ public final class ActivityManagerService extends ActivityManagerNative boolean mAutoStopProfiler = false; int mProfileType = 0; String mOpenGlTraceApp = null; + String mTrackAllocationApp = null; final long[] mTmpLong = new long[1]; @@ -6000,6 +6001,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; @@ -6028,7 +6034,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()); @@ -10349,7 +10355,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); } } @@ -10358,11 +10364,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); } } @@ -13173,6 +13192,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 8ab2368a3949..6ea1a55e4748 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -811,20 +811,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); } } |