From 91c006def37f1038858f5c1aaba22d31ca86ec17 Mon Sep 17 00:00:00 2001
From: Yi Kong <yikong@google.com>
Date: Fri, 24 May 2024 18:12:21 +0000
Subject: [PATCH] profcollect: Make binder call on a background thread

Bug: 342527967
Change-Id: I41811e2dae454c67435c1c99d10bc3a28894fbd1
Test: presubmit
---
 .../ProfcollectForwardingService.java         | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
index 488fe57cf6f8..9f9764853bef 100644
--- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
+++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
@@ -370,18 +370,18 @@ public final class ProfcollectForwardingService extends SystemService {
     }
 
     private static void createAndUploadReport(ProfcollectForwardingService pfs) {
-        String reportName;
-        try {
-            reportName = pfs.mIProfcollect.report(pfs.mUsageSetting) + ".zip";
-        } catch (RemoteException e) {
-            Log.e(LOG_TAG, "Failed to create report: " + e.getMessage());
-            return;
-        }
-        if (!pfs.mUploadEnabled) {
-            Log.i(LOG_TAG, "Upload is not enabled.");
-            return;
-        }
         BackgroundThread.get().getThreadHandler().post(() -> {
+            String reportName;
+            try {
+                reportName = pfs.mIProfcollect.report(pfs.mUsageSetting) + ".zip";
+            } catch (RemoteException e) {
+                Log.e(LOG_TAG, "Failed to create report: " + e.getMessage());
+                return;
+            }
+            if (!pfs.mUploadEnabled) {
+                Log.i(LOG_TAG, "Upload is not enabled.");
+                return;
+            }
             Intent intent = new Intent()
                     .setPackage("com.android.shell")
                     .setAction("com.android.shell.action.PROFCOLLECT_UPLOAD")
-- 
GitLab