Use property to start heapprofd in heap_profile.
Change-Id: I2d374540bcac6c2e1486f796c239e03fa636dd09
diff --git a/tools/heap_profile b/tools/heap_profile
index c0224ec..d318c28 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -176,9 +176,13 @@
subprocess.check_call(['adb', 'shell', 'su root setenforce 0'])
if not args.no_start:
- atexit.register(subprocess.check_call,
- ['adb', 'shell', 'su root stop heapprofd'])
- subprocess.check_call(['adb', 'shell', 'su root start heapprofd'])
+ heapprofd_prop = subprocess.check_output(
+ ['adb', 'shell', 'getprop persist.heapprofd.enable'])
+ if heapprofd_prop.strip() != '1':
+ subprocess.check_call(
+ ['adb', 'shell', 'setprop persist.heapprofd.enable 1'])
+ atexit.register(subprocess.check_call,
+ ['adb', 'shell', 'setprop persist.heapprofd.enable 0'])
perfetto_pid = subprocess.check_output(
['adb', 'exec-out', PERFETTO_CMD.format(cfg)]).strip()