Merge "Trace Protolog trace in Traceur" into main
diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml
index c6486d9..6d1315e 100644
--- a/AndroidManifest-common.xml
+++ b/AndroidManifest-common.xml
@@ -23,7 +23,7 @@
   -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
-    package="com.android.traceur"
+    package="com.android.traceur.common"
     tools:ignore="ImpliedTouchscreenHardware,MissingLeanbackLauncher,MissingLeanbackSupport,ProtectedPermissions">
     <!--- Used to query for Betterbug. -->
     <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
@@ -40,4 +40,4 @@
 
     <!-- Used to control view capture Winscope tracing (not yet migrated to perfetto). -->
     <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/src/com/android/traceur/MainFragment.java b/src/com/android/traceur/MainFragment.java
index 6e7ce5f..3176590 100644
--- a/src/com/android/traceur/MainFragment.java
+++ b/src/com/android/traceur/MainFragment.java
@@ -334,13 +334,6 @@
         mStackSamplingOn.setChecked(mPrefs.getBoolean(mStackSamplingOn.getKey(), false));
         mHeapDumpOn.setChecked(mPrefs.getBoolean(mHeapDumpOn.getKey(), false));
 
-        // Enable or disable each toggle based on the state of the others. This path exists in case
-        // the tracing state was updated with the QS tile or the ongoing-trace notification, which
-        // would not call the toggles' OnClickListeners.
-        mTracingOn.setEnabled(!(mStackSamplingOn.isChecked() || mHeapDumpOn.isChecked()));
-        mStackSamplingOn.setEnabled(!(mTracingOn.isChecked() || mHeapDumpOn.isChecked()));
-        mHeapDumpOn.setEnabled(!(mTracingOn.isChecked() || mStackSamplingOn.isChecked()));
-
         SwitchPreference stopOnReport =
                 (SwitchPreference) findPreference(getString(R.string.pref_key_stop_on_bugreport));
         stopOnReport.setChecked(mPrefs.getBoolean(stopOnReport.getKey(), false));
@@ -384,10 +377,17 @@
             mRefreshing = false;
         }
 
-        // Disallow heap dumps if no process is selected at all.
-        boolean heapDumpToggleEnabled = mHeapDumpProcesses.getValues().size() > 0;
-        mHeapDumpOn.setEnabled(heapDumpToggleEnabled);
-        mHeapDumpOn.setSummary(heapDumpToggleEnabled
+        // Enable or disable each toggle based on the state of the others. This path exists in case
+        // the tracing state was updated with the QS tile or the ongoing-trace notification, which
+        // would not call the toggles' OnClickListeners.
+        mTracingOn.setEnabled(!(mStackSamplingOn.isChecked() || mHeapDumpOn.isChecked()));
+        mStackSamplingOn.setEnabled(!(mTracingOn.isChecked() || mHeapDumpOn.isChecked()));
+
+        // Disallow heap dumps if no process is selected, or if tracing/stack sampling is active.
+        boolean heapDumpProcessSelected = mHeapDumpProcesses.getValues().size() > 0;
+        mHeapDumpOn.setEnabled(heapDumpProcessSelected &&
+                !(mTracingOn.isChecked() || mStackSamplingOn.isChecked()));
+        mHeapDumpOn.setSummary(heapDumpProcessSelected
                 ? context.getString(R.string.record_heap_dump_summary_enabled)
                 : context.getString(R.string.record_heap_dump_summary_disabled));
 
diff --git a/src_common/com/android/traceur/PerfettoUtils.java b/src_common/com/android/traceur/PerfettoUtils.java
index 006453f..d73b487 100644
--- a/src_common/com/android/traceur/PerfettoUtils.java
+++ b/src_common/com/android/traceur/PerfettoUtils.java
@@ -518,6 +518,7 @@
                 .append("    target_buffer: " + targetBuffer + "\n")
                 .append("    sys_stats_config {\n")
                 .append("      meminfo_period_ms: 1000\n")
+                .append("      psi_period_ms: 1000\n")
                 .append("      vmstat_period_ms: 1000\n")
                 .append("    }\n")
                 .append("  }\n")
diff --git a/src_common/com/android/traceur/TraceUtils.java b/src_common/com/android/traceur/TraceUtils.java
index d81e63f..d05f623 100644
--- a/src_common/com/android/traceur/TraceUtils.java
+++ b/src_common/com/android/traceur/TraceUtils.java
@@ -128,7 +128,7 @@
 
     public static TreeMap<String, String> listCategories() {
         TreeMap<String, String> categories = PerfettoUtils.perfettoListCategories();
-        categories.put("sys_stats", "meminfo and vmstats");
+        categories.put("sys_stats", "meminfo, psi, and vmstats");
         categories.put("logs", "android logcat");
         categories.put("cpu", "callstack samples");
         return categories;