summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorJeff Hao <jeffhao@google.com>2014-08-20 10:35:34 -0700
committerJeff Hao <jeffhao@google.com>2014-08-26 15:54:25 -0700
commit1b012d302b56b4adf950035136d1d191a1936d5a (patch)
tree4b6fc0a3e89f7a2251680e7e13f7211a8dff7ba2 /core/java/android
parent987eb9734445bd92f6925b596b9b0ece90ad70b8 (diff)
downloadframeworks_base-1b012d302b56b4adf950035136d1d191a1936d5a.zip
frameworks_base-1b012d302b56b4adf950035136d1d191a1936d5a.tar.gz
frameworks_base-1b012d302b56b4adf950035136d1d191a1936d5a.tar.bz2
Add sample profiling option to am.
Also bundles all profiling options into a class. Bug: 17040932 Change-Id: I85d675ee1494bdc7308caffdf94145d27c996e9d
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Activity.java7
-rw-r--r--core/java/android/app/ActivityManager.java7
-rw-r--r--core/java/android/app/ActivityManagerNative.java108
-rw-r--r--core/java/android/app/ActivityThread.java82
-rw-r--r--core/java/android/app/ApplicationThreadNative.java84
-rw-r--r--core/java/android/app/ContextImpl.java2
-rw-r--r--core/java/android/app/IActivityManager.java35
-rw-r--r--core/java/android/app/IApplicationThread.java12
-rw-r--r--core/java/android/app/Instrumentation.java8
-rw-r--r--core/java/android/app/ProfilerInfo.java86
10 files changed, 228 insertions, 203 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 9b7cc1c..2387553 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -4145,10 +4145,9 @@ public class Activity extends ContextThemeWrapper
intent.prepareToLeaveProcess();
result = ActivityManagerNative.getDefault()
.startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
- intent, intent.resolveTypeIfNeeded(getContentResolver()),
- mToken, mEmbeddedID, requestCode,
- ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null,
- options);
+ intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken,
+ mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED,
+ null, options);
} catch (RemoteException e) {
// Empty
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 586e7d4..da7c790 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -193,13 +193,6 @@ public class ActivityManager {
public static final int START_FLAG_OPENGL_TRACES = 1<<2;
/**
- * Flag for IActivityManaqer.startActivity: if the app is being
- * launched for profiling, automatically stop the profiler once done.
- * @hide
- */
- public static final int START_FLAG_AUTO_STOP_PROFILER = 1<<3;
-
- /**
* Result for IActivityManaqer.broadcastIntent: success!
* @hide
*/
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 36e8892..16d091a 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -17,6 +17,7 @@
package android.app;
import android.app.ActivityManager.StackInfo;
+import android.app.ProfilerInfo;
import android.content.ComponentName;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
@@ -132,14 +133,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
String resultWho = data.readString();
int requestCode = data.readInt();
int startFlags = data.readInt();
- String profileFile = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivity(app, callingPackage, intent, resolvedType,
- resultTo, resultWho, requestCode, startFlags,
- profileFile, profileFd, options);
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -157,15 +156,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
String resultWho = data.readString();
int requestCode = data.readInt();
int startFlags = data.readInt();
- String profileFile = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int userId = data.readInt();
int result = startActivityAsUser(app, callingPackage, intent, resolvedType,
- resultTo, resultWho, requestCode, startFlags,
- profileFile, profileFd, options, userId);
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, options, userId);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -183,14 +180,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
String resultWho = data.readString();
int requestCode = data.readInt();
int startFlags = data.readInt();
- String profileFile = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? data.readFileDescriptor() : null;
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityAsCaller(app, callingPackage, intent, resolvedType,
- resultTo, resultWho, requestCode, startFlags,
- profileFile, profileFd, options);
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -208,15 +203,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
String resultWho = data.readString();
int requestCode = data.readInt();
int startFlags = data.readInt();
- String profileFile = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int userId = data.readInt();
WaitResult result = startActivityAndWait(app, callingPackage, intent, resolvedType,
- resultTo, resultWho, requestCode, startFlags,
- profileFile, profileFd, options, userId);
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, options, userId);
reply.writeNoException();
result.writeToParcel(reply, 0);
return true;
@@ -284,15 +277,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
IVoiceInteractor interactor = IVoiceInteractor.Stub.asInterface(
data.readStrongBinder());
int startFlags = data.readInt();
- String profileFile = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int userId = data.readInt();
- int result = startVoiceActivity(callingPackage, callingPid, callingUid,
- intent, resolvedType, session, interactor, startFlags,
- profileFile, profileFd, options, userId);
+ int result = startVoiceActivity(callingPackage, callingPid, callingUid, intent,
+ resolvedType, session, interactor, startFlags, profilerInfo, options, userId);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1468,22 +1459,21 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
config.writeToParcel(reply, 0);
return true;
}
-
+
case PROFILE_CONTROL_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
String process = data.readString();
int userId = data.readInt();
boolean start = data.readInt() != 0;
int profileType = data.readInt();
- String path = data.readString();
- ParcelFileDescriptor fd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
- boolean res = profileControl(process, userId, start, path, fd, profileType);
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
+ boolean res = profileControl(process, userId, start, profilerInfo, profileType);
reply.writeNoException();
reply.writeInt(res ? 1 : 0);
return true;
}
-
+
case SHUTDOWN_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
boolean res = shutdown(data.readInt());
@@ -2343,8 +2333,7 @@ class ActivityManagerProxy implements IActivityManager
public int startActivity(IApplicationThread caller, String callingPackage, Intent intent,
String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
+ int startFlags, ProfilerInfo profilerInfo, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -2356,10 +2345,9 @@ class ActivityManagerProxy implements IActivityManager
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(startFlags);
- data.writeString(profileFile);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -2379,8 +2367,8 @@ class ActivityManagerProxy implements IActivityManager
public int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent,
String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException {
+ int startFlags, ProfilerInfo profilerInfo, Bundle options,
+ int userId) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -2392,10 +2380,9 @@ class ActivityManagerProxy implements IActivityManager
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(startFlags);
- data.writeString(profileFile);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -2415,8 +2402,7 @@ class ActivityManagerProxy implements IActivityManager
}
public int startActivityAsCaller(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
+ int startFlags, ProfilerInfo profilerInfo, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -2428,10 +2414,9 @@ class ActivityManagerProxy implements IActivityManager
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(startFlags);
- data.writeString(profileFile);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -2450,8 +2435,8 @@ class ActivityManagerProxy implements IActivityManager
}
public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
- int requestCode, int startFlags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException {
+ int requestCode, int startFlags, ProfilerInfo profilerInfo, Bundle options,
+ int userId) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -2463,10 +2448,9 @@ class ActivityManagerProxy implements IActivityManager
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(startFlags);
- data.writeString(profileFile);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -2550,8 +2534,8 @@ class ActivityManagerProxy implements IActivityManager
}
public int startVoiceActivity(String callingPackage, int callingPid, int callingUid,
Intent intent, String resolvedType, IVoiceInteractionSession session,
- IVoiceInteractor interactor, int startFlags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException {
+ IVoiceInteractor interactor, int startFlags, ProfilerInfo profilerInfo,
+ Bundle options, int userId) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -2563,10 +2547,9 @@ class ActivityManagerProxy implements IActivityManager
data.writeStrongBinder(session.asBinder());
data.writeStrongBinder(interactor.asBinder());
data.writeInt(startFlags);
- data.writeString(profileFile);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -4189,9 +4172,9 @@ class ActivityManagerProxy implements IActivityManager
data.recycle();
return res;
}
-
+
public boolean profileControl(String process, int userId, boolean start,
- String path, ParcelFileDescriptor fd, int profileType) throws RemoteException
+ ProfilerInfo profilerInfo, int profileType) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
@@ -4200,10 +4183,9 @@ class ActivityManagerProxy implements IActivityManager
data.writeInt(userId);
data.writeInt(start ? 1 : 0);
data.writeInt(profileType);
- data.writeString(path);
- if (fd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -4214,7 +4196,7 @@ class ActivityManagerProxy implements IActivityManager
data.recycle();
return res;
}
-
+
public boolean shutdown(int timeout) throws RemoteException
{
Parcel data = Parcel.obtain();
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 0356093..d70e5df 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -124,6 +124,7 @@ import libcore.io.EventLogger;
import libcore.io.IoUtils;
import dalvik.system.CloseGuard;
+import dalvik.system.VMDebug;
import dalvik.system.VMRuntime;
final class RemoteServiceException extends AndroidRuntimeException {
@@ -282,9 +283,7 @@ public final class ActivityThread {
Configuration createdConfig;
ActivityClientRecord nextIdle;
- String profileFile;
- ParcelFileDescriptor profileFd;
- boolean autoStopProfiler;
+ ProfilerInfo profilerInfo;
ActivityInfo activityInfo;
CompatibilityInfo compatInfo;
@@ -436,9 +435,7 @@ public final class ActivityThread {
CompatibilityInfo compatInfo;
/** Initial values for {@link Profiler}. */
- String initProfileFile;
- ParcelFileDescriptor initProfileFd;
- boolean initAutoStopProfiler;
+ ProfilerInfo initProfilerInfo;
public String toString() {
return "AppBindData{appInfo=" + appInfo + "}";
@@ -448,10 +445,12 @@ public final class ActivityThread {
static final class Profiler {
String profileFile;
ParcelFileDescriptor profileFd;
+ int samplingInterval;
boolean autoStopProfiler;
boolean profiling;
boolean handlingProfiling;
- public void setProfiler(String file, ParcelFileDescriptor fd) {
+ public void setProfiler(ProfilerInfo profilerInfo) {
+ ParcelFileDescriptor fd = profilerInfo.profileFd;
if (profiling) {
if (fd != null) {
try {
@@ -469,16 +468,18 @@ public final class ActivityThread {
// Ignore
}
}
- profileFile = file;
+ profileFile = profilerInfo.profileFile;
profileFd = fd;
+ samplingInterval = profilerInfo.samplingInterval;
+ autoStopProfiler = profilerInfo.autoStopProfiler;
}
public void startProfiling() {
if (profileFd == null || profiling) {
return;
}
try {
- Debug.startMethodTracing(profileFile, profileFd.getFileDescriptor(),
- 8 * 1024 * 1024, 0);
+ VMDebug.startMethodTracing(profileFile, profileFd.getFileDescriptor(),
+ 8 * 1024 * 1024, 0, samplingInterval != 0, samplingInterval);
profiling = true;
} catch (RuntimeException e) {
Slog.w(TAG, "Profiling failed on path " + profileFile);
@@ -527,11 +528,6 @@ public final class ActivityThread {
String who;
}
- static final class ProfilerControlData {
- String path;
- ParcelFileDescriptor fd;
- }
-
static final class DumpHeapData {
String path;
ParcelFileDescriptor fd;
@@ -612,7 +608,7 @@ public final class ActivityThread {
IVoiceInteractor voiceInteractor, int procState, Bundle state,
PersistableBundle persistentState, List<ResultInfo> pendingResults,
List<Intent> pendingNewIntents, boolean notResumed, boolean isForward,
- String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler) {
+ ProfilerInfo profilerInfo) {
updateProcessState(procState, false);
@@ -633,9 +629,7 @@ public final class ActivityThread {
r.startsNotResumed = notResumed;
r.isForward = isForward;
- r.profileFile = profileName;
- r.profileFd = profileFd;
- r.autoStopProfiler = autoStopProfiler;
+ r.profilerInfo = profilerInfo;
updatePendingConfiguration(curConfig);
@@ -742,11 +736,10 @@ public final class ActivityThread {
sendMessage(H.STOP_SERVICE, token);
}
- public final void bindApplication(String processName,
- ApplicationInfo appInfo, List<ProviderInfo> providers,
- ComponentName instrumentationName, String profileFile,
- ParcelFileDescriptor profileFd, boolean autoStopProfiler,
- Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
+ public final void bindApplication(String processName, ApplicationInfo appInfo,
+ List<ProviderInfo> providers, ComponentName instrumentationName,
+ ProfilerInfo profilerInfo, Bundle instrumentationArgs,
+ IInstrumentationWatcher instrumentationWatcher,
IUiAutomationConnection instrumentationUiConnection, int debugMode,
boolean enableOpenGlTrace, boolean isRestrictedBackupMode, boolean persistent,
Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services,
@@ -810,9 +803,7 @@ public final class ActivityThread {
data.persistent = persistent;
data.config = config;
data.compatInfo = compatInfo;
- data.initProfileFile = profileFile;
- data.initProfileFd = profileFd;
- data.initAutoStopProfiler = false;
+ data.initProfilerInfo = profilerInfo;
sendMessage(H.BIND_APPLICATION, data);
}
@@ -878,12 +869,8 @@ public final class ActivityThread {
sendMessage(H.ACTIVITY_CONFIGURATION_CHANGED, token);
}
- public void profilerControl(boolean start, String path, ParcelFileDescriptor fd,
- int profileType) {
- ProfilerControlData pcd = new ProfilerControlData();
- pcd.path = path;
- pcd.fd = fd;
- sendMessage(H.PROFILER_CONTROL, pcd, start ? 1 : 0, profileType);
+ public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) {
+ sendMessage(H.PROFILER_CONTROL, profilerInfo, start ? 1 : 0, profileType);
}
public void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd) {
@@ -1417,7 +1404,7 @@ public final class ActivityThread {
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
case PROFILER_CONTROL:
- handleProfilerControl(msg.arg1 != 0, (ProfilerControlData)msg.obj, msg.arg2);
+ handleProfilerControl(msg.arg1 != 0, (ProfilerInfo)msg.obj, msg.arg2);
break;
case CREATE_BACKUP_AGENT:
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "backupCreateAgent");
@@ -2354,10 +2341,9 @@ public final class ActivityThread {
unscheduleGcIdler();
mSomeActivitiesChanged = true;
- if (r.profileFd != null) {
- mProfiler.setProfiler(r.profileFile, r.profileFd);
+ if (r.profilerInfo != null) {
+ mProfiler.setProfiler(r.profilerInfo);
mProfiler.startProfiling();
- mProfiler.autoStopProfiler = r.autoStopProfiler;
}
// Make sure we are running with the most recent config.
@@ -4118,22 +4104,21 @@ public final class ActivityThread {
mSomeActivitiesChanged = true;
}
- final void handleProfilerControl(boolean start, ProfilerControlData pcd, int profileType) {
+ final void handleProfilerControl(boolean start, ProfilerInfo profilerInfo, int profileType) {
if (start) {
try {
switch (profileType) {
- default:
- mProfiler.setProfiler(pcd.path, pcd.fd);
- mProfiler.autoStopProfiler = false;
+ default:
+ mProfiler.setProfiler(profilerInfo);
mProfiler.startProfiling();
break;
}
} catch (RuntimeException e) {
- Slog.w(TAG, "Profiling failed on path " + pcd.path
+ Slog.w(TAG, "Profiling failed on path " + profilerInfo.profileFile
+ " -- can the process access this path?");
} finally {
try {
- pcd.fd.close();
+ profilerInfo.profileFd.close();
} catch (IOException e) {
Slog.w(TAG, "Failure closing profile fd", e);
}
@@ -4265,9 +4250,12 @@ public final class ActivityThread {
mCompatConfiguration = new Configuration(data.config);
mProfiler = new Profiler();
- mProfiler.profileFile = data.initProfileFile;
- mProfiler.profileFd = data.initProfileFd;
- mProfiler.autoStopProfiler = data.initAutoStopProfiler;
+ if (data.initProfilerInfo != null) {
+ mProfiler.profileFile = data.initProfilerInfo.profileFile;
+ mProfiler.profileFd = data.initProfilerInfo.profileFd;
+ mProfiler.samplingInterval = data.initProfilerInfo.samplingInterval;
+ mProfiler.autoStopProfiler = data.initProfilerInfo.autoStopProfiler;
+ }
// send up app name; do this *before* waiting for debugger
Process.setArgV0(data.processName);
@@ -4282,7 +4270,7 @@ public final class ActivityThread {
HardwareRenderer.disable(false);
}
}
-
+
if (mProfiler.profileFd != null) {
mProfiler.startProfiling();
}
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index 52b69e1..63e8707 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -129,7 +129,7 @@ public abstract class ApplicationThreadNative extends Binder
scheduleSendResult(b, ri);
return true;
}
-
+
case SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION:
{
data.enforceInterface(IApplicationThread.descriptor);
@@ -148,17 +148,13 @@ public abstract class ApplicationThreadNative extends Binder
List<Intent> pi = data.createTypedArrayList(Intent.CREATOR);
boolean notResumed = data.readInt() != 0;
boolean isForward = data.readInt() != 0;
- String profileName = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
- boolean autoStopProfiler = data.readInt() != 0;
- scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo,
- voiceInteractor, procState, state, persistentState,
- ri, pi, notResumed, isForward, profileName, profileFd,
- autoStopProfiler);
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
+ scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo, voiceInteractor,
+ procState, state, persistentState, ri, pi, notResumed, isForward, profilerInfo);
return true;
}
-
+
case SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION:
{
data.enforceInterface(IApplicationThread.descriptor);
@@ -274,10 +270,8 @@ public abstract class ApplicationThreadNative extends Binder
data.createTypedArrayList(ProviderInfo.CREATOR);
ComponentName testName = (data.readInt() != 0)
? new ComponentName(data) : null;
- String profileName = data.readString();
- ParcelFileDescriptor profileFd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
- boolean autoStopProfiler = data.readInt() != 0;
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle testArgs = data.readBundle();
IBinder binder = data.readStrongBinder();
IInstrumentationWatcher testWatcher = IInstrumentationWatcher.Stub.asInterface(binder);
@@ -292,11 +286,9 @@ public abstract class ApplicationThreadNative extends Binder
CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data);
HashMap<String, IBinder> services = data.readHashMap(null);
Bundle coreSettings = data.readBundle();
- bindApplication(packageName, info,
- providers, testName, profileName, profileFd, autoStopProfiler,
- testArgs, testWatcher, uiAutomationConnection, testMode,
- openGlTrace, restrictedBackupMode, persistent, config, compatInfo,
- services, coreSettings);
+ bindApplication(packageName, info, providers, testName, profilerInfo, testArgs,
+ testWatcher, uiAutomationConnection, testMode, openGlTrace,
+ restrictedBackupMode, persistent, config, compatInfo, services, coreSettings);
return true;
}
@@ -403,7 +395,7 @@ public abstract class ApplicationThreadNative extends Binder
scheduleLowMemory();
return true;
}
-
+
case SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION:
{
data.enforceInterface(IApplicationThread.descriptor);
@@ -411,19 +403,18 @@ public abstract class ApplicationThreadNative extends Binder
scheduleActivityConfigurationChanged(b);
return true;
}
-
+
case PROFILER_CONTROL_TRANSACTION:
{
data.enforceInterface(IApplicationThread.descriptor);
boolean start = data.readInt() != 0;
int profileType = data.readInt();
- String path = data.readString();
- ParcelFileDescriptor fd = data.readInt() != 0
- ? ParcelFileDescriptor.CREATOR.createFromParcel(data) : null;
- profilerControl(start, path, fd, profileType);
+ ProfilerInfo profilerInfo = data.readInt() != 0
+ ? ProfilerInfo.CREATOR.createFromParcel(data) : null;
+ profilerControl(start, profilerInfo, profileType);
return true;
}
-
+
case SET_SCHEDULING_GROUP_TRANSACTION:
{
data.enforceInterface(IApplicationThread.descriptor);
@@ -774,8 +765,7 @@ class ApplicationThreadProxy implements IApplicationThread {
IVoiceInteractor voiceInteractor, int procState, Bundle state,
PersistableBundle persistentState, List<ResultInfo> pendingResults,
List<Intent> pendingNewIntents, boolean notResumed, boolean isForward,
- String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler)
- throws RemoteException {
+ ProfilerInfo profilerInfo) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
intent.writeToParcel(data, 0);
@@ -792,14 +782,12 @@ class ApplicationThreadProxy implements IApplicationThread {
data.writeTypedList(pendingNewIntents);
data.writeInt(notResumed ? 1 : 0);
data.writeInt(isForward ? 1 : 0);
- data.writeString(profileName);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
- data.writeInt(autoStopProfiler ? 1 : 0);
mRemote.transact(SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION, data, null,
IBinder.FLAG_ONEWAY);
data.recycle();
@@ -959,9 +947,8 @@ class ApplicationThreadProxy implements IApplicationThread {
}
public final void bindApplication(String packageName, ApplicationInfo info,
- List<ProviderInfo> providers, ComponentName testName, String profileName,
- ParcelFileDescriptor profileFd, boolean autoStopProfiler, Bundle testArgs,
- IInstrumentationWatcher testWatcher,
+ 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,
@@ -977,14 +964,12 @@ class ApplicationThreadProxy implements IApplicationThread {
data.writeInt(1);
testName.writeToParcel(data, 0);
}
- data.writeString(profileName);
- if (profileFd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- profileFd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
- data.writeInt(autoStopProfiler ? 1 : 0);
data.writeBundle(testArgs);
data.writeStrongInterface(testWatcher);
data.writeStrongInterface(uiAutomationConnection);
@@ -1111,7 +1096,7 @@ class ApplicationThreadProxy implements IApplicationThread {
IBinder.FLAG_ONEWAY);
data.recycle();
}
-
+
public final void scheduleActivityConfigurationChanged(
IBinder token) throws RemoteException {
Parcel data = Parcel.obtain();
@@ -1121,17 +1106,16 @@ class ApplicationThreadProxy implements IApplicationThread {
IBinder.FLAG_ONEWAY);
data.recycle();
}
-
- public void profilerControl(boolean start, String path,
- ParcelFileDescriptor fd, int profileType) throws RemoteException {
+
+ public void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
+ throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
data.writeInt(start ? 1 : 0);
data.writeInt(profileType);
- data.writeString(path);
- if (fd != null) {
+ if (profilerInfo != null) {
data.writeInt(1);
- fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+ profilerInfo.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} else {
data.writeInt(0);
}
@@ -1139,7 +1123,7 @@ class ApplicationThreadProxy implements IApplicationThread {
IBinder.FLAG_ONEWAY);
data.recycle();
}
-
+
public void setSchedulingGroup(int group) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -1148,7 +1132,7 @@ class ApplicationThreadProxy implements IApplicationThread {
IBinder.FLAG_ONEWAY);
data.recycle();
}
-
+
public void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -1157,9 +1141,8 @@ class ApplicationThreadProxy implements IApplicationThread {
mRemote.transact(DISPATCH_PACKAGE_BROADCAST_TRANSACTION, data, null,
IBinder.FLAG_ONEWAY);
data.recycle();
-
}
-
+
public void scheduleCrash(String msg) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
@@ -1167,7 +1150,6 @@ class ApplicationThreadProxy implements IApplicationThread {
mRemote.transact(SCHEDULE_CRASH_TRANSACTION, data, null,
IBinder.FLAG_ONEWAY);
data.recycle();
-
}
public void dumpHeap(boolean managed, String path,
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index fb5a8f5..91a0aed 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1247,7 +1247,7 @@ class ContextImpl extends Context {
ActivityManagerNative.getDefault().startActivityAsUser(
mMainThread.getApplicationThread(), getBasePackageName(), intent,
intent.resolveTypeIfNeeded(getContentResolver()),
- null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, options,
+ null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options,
user.getIdentifier());
} catch (RemoteException re) {
}
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 57c4b71..71bdf8c 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -61,22 +61,19 @@ import java.util.List;
* {@hide}
*/
public interface IActivityManager extends IInterface {
- public int startActivity(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho,
- int requestCode, int flags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options) throws RemoteException;
- public int startActivityAsUser(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho,
- int requestCode, int flags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException;
+ public int startActivity(IApplicationThread caller, String callingPackage, Intent intent,
+ String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags,
+ ProfilerInfo profilerInfo, Bundle options) throws RemoteException;
+ public int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent,
+ String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags,
+ ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException;
public int startActivityAsCaller(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho,
- int requestCode, int flags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options) throws RemoteException;
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int flags, ProfilerInfo profilerInfo, Bundle options) throws RemoteException;
public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
- int requestCode, int flags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException;
+ int requestCode, int flags, ProfilerInfo profilerInfo, Bundle options,
+ int userId) throws RemoteException;
public int startActivityWithConfig(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int startFlags, Configuration newConfig,
@@ -87,8 +84,8 @@ public interface IActivityManager extends IInterface {
int flagsMask, int flagsValues, Bundle options) throws RemoteException;
public int startVoiceActivity(String callingPackage, int callingPid, int callingUid,
Intent intent, String resolvedType, IVoiceInteractionSession session,
- IVoiceInteractor interactor, int flags, String profileFile,
- ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException;
+ IVoiceInteractor interactor, int flags, ProfilerInfo profilerInfo, Bundle options,
+ int userId) throws RemoteException;
public boolean startNextMatchingActivity(IBinder callingActivity,
Intent intent, Bundle options) throws RemoteException;
public int startActivityFromRecents(int taskId, Bundle options) throws RemoteException;
@@ -296,13 +293,13 @@ public interface IActivityManager extends IInterface {
throws RemoteException;
// Get device configuration
public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException;
-
+
// Turn on/off profiling in a particular process.
public boolean profileControl(String process, int userId, boolean start,
- String path, ParcelFileDescriptor fd, int profileType) throws RemoteException;
-
+ ProfilerInfo profilerInfo, int profileType) throws RemoteException;
+
public boolean shutdown(int timeout) throws RemoteException;
-
+
public void stopAppSwitches() throws RemoteException;
public void resumeAppSwitches() throws RemoteException;
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index 01b6fdf..a7546d9 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -62,8 +62,7 @@ public interface IApplicationThread extends IInterface {
IVoiceInteractor voiceInteractor, int procState, Bundle state,
PersistableBundle persistentState, List<ResultInfo> pendingResults,
List<Intent> pendingNewIntents, boolean notResumed, boolean isForward,
- String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler)
- throws RemoteException;
+ ProfilerInfo profilerInfo) throws RemoteException;
void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults,
List<Intent> pendingNewIntents, int configChanges,
boolean notResumed, Configuration config) throws RemoteException;
@@ -94,10 +93,9 @@ public interface IApplicationThread extends IInterface {
static final int DEBUG_ON = 1;
static final int DEBUG_WAIT = 2;
void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
- ComponentName testName, String profileName, ParcelFileDescriptor profileFd,
- boolean autoStopProfiler, Bundle testArguments, IInstrumentationWatcher testWatcher,
- IUiAutomationConnection uiAutomationConnection, int debugMode,
- boolean openGlTrace, boolean restrictedBackupMode, boolean persistent,
+ 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,
Bundle coreSettings) throws RemoteException;
void scheduleExit() throws RemoteException;
@@ -117,7 +115,7 @@ public interface IApplicationThread extends IInterface {
boolean sticky, int sendingUser, int processState) throws RemoteException;
void scheduleLowMemory() throws RemoteException;
void scheduleActivityConfigurationChanged(IBinder token) throws RemoteException;
- void profilerControl(boolean start, String path, ParcelFileDescriptor fd, int profileType)
+ void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
throws RemoteException;
void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd)
throws RemoteException;
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index bc71bad..ba3a234 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1481,7 +1481,7 @@ public class Instrumentation {
.startActivity(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
- requestCode, 0, null, null, options);
+ requestCode, 0, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1598,7 +1598,7 @@ public class Instrumentation {
.startActivity(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mWho : null,
- requestCode, 0, null, null, options);
+ requestCode, 0, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1658,7 +1658,7 @@ public class Instrumentation {
.startActivityAsUser(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
- requestCode, 0, null, null, options, user.getIdentifier());
+ requestCode, 0, null, options, user.getIdentifier());
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1695,7 +1695,7 @@ public class Instrumentation {
.startActivityAsCaller(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
- requestCode, 0, null, null, options);
+ requestCode, 0, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
diff --git a/core/java/android/app/ProfilerInfo.java b/core/java/android/app/ProfilerInfo.java
new file mode 100644
index 0000000..cea7c3c
--- /dev/null
+++ b/core/java/android/app/ProfilerInfo.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2014 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.app;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.os.ParcelFileDescriptor;
+
+/**
+ * System private API for passing profiler settings.
+ *
+ * {@hide}
+ */
+public class ProfilerInfo implements Parcelable {
+
+ /* Name of profile output file. */
+ public final String profileFile;
+
+ /* File descriptor for profile output file, can be null. */
+ public ParcelFileDescriptor profileFd;
+
+ /* Indicates sample profiling when nonzero, interval in microseconds. */
+ public final int samplingInterval;
+
+ /* Automatically stop the profiler when the app goes idle. */
+ public final boolean autoStopProfiler;
+
+ public ProfilerInfo(String filename, ParcelFileDescriptor fd, int interval, boolean autoStop) {
+ profileFile = filename;
+ profileFd = fd;
+ samplingInterval = interval;
+ autoStopProfiler = autoStop;
+ }
+
+ public int describeContents() {
+ if (profileFd != null) {
+ return profileFd.describeContents();
+ } else {
+ return 0;
+ }
+ }
+
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeString(profileFile);
+ if (profileFd != null) {
+ out.writeInt(1);
+ profileFd.writeToParcel(out, flags);
+ } else {
+ out.writeInt(0);
+ }
+ out.writeInt(samplingInterval);
+ out.writeInt(autoStopProfiler ? 1 : 0);
+ }
+
+ public static final Parcelable.Creator<ProfilerInfo> CREATOR =
+ new Parcelable.Creator<ProfilerInfo>() {
+ public ProfilerInfo createFromParcel(Parcel in) {
+ return new ProfilerInfo(in);
+ }
+
+ public ProfilerInfo[] newArray(int size) {
+ return new ProfilerInfo[size];
+ }
+ };
+
+ private ProfilerInfo(Parcel in) {
+ profileFile = in.readString();
+ profileFd = in.readInt() != 0 ? ParcelFileDescriptor.CREATOR.createFromParcel(in) : null;
+ samplingInterval = in.readInt();
+ autoStopProfiler = in.readInt() != 0;
+ }
+}