Close file descriptors of ProfilerInfo

When using "am start --start-profiler" command, am doesn't close
instances of related ParcelFileDescriptor of the profiler file path,
but relies on garbage collection, so at the system level the file
kept open for longer than it is needed. In a result, some processes
that monitors the file close event using unix inotify_add_watch
method would wait 20~30 Seconds.

This change closes file descriptors after passing it to ActivityThread
process, which is similar to what "am profile start" does.

Bug: b/73891014
Test: tested manually by flashing into Pixel XL device.
Merged-In: I5b63b96335fdaf86f0cd0caec2c53c32c0e41d72
Change-Id: I5b63b96335fdaf86f0cd0caec2c53c32c0e41d72
This commit is contained in:
Madiyar Aitbayev
2018-03-19 16:51:48 +00:00
parent 2543fbd8a2
commit b436ce9cea

View File

@@ -7145,6 +7145,9 @@ public class ActivityManagerService extends IActivityManager.Stub
if (profilerInfo != null && profilerInfo.profileFd != null) {
profilerInfo.profileFd = profilerInfo.profileFd.dup();
if (TextUtils.equals(mProfileApp, processName) && mProfilerInfo != null) {
clearProfilerLocked();
}
}
// We deprecated Build.SERIAL and it is not accessible to
@@ -7211,7 +7214,10 @@ public class ActivityManagerService extends IActivityManager.Stub
mCoreSettingsObserver.getCoreSettingsLocked(),
buildSerial);
}
if (profilerInfo != null) {
profilerInfo.closeFd();
profilerInfo = null;
}
checkTime(startTime, "attachApplicationLocked: immediately after bindApplication");
updateLruProcessLocked(app, false, null);
checkTime(startTime, "attachApplicationLocked: after updateLruProcessLocked");