summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yi Kong <yikong@google.com> 2021-11-15 14:07:14 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-11-15 14:07:14 +0000
commit206e10a3a307a6b8f4558bb84e0143ec9fa5cfbd (patch)
tree0e7e673bf6d383fa32a6c2acfa16c00598e4b796
parent1176dd4409a3632259a4d2331f82c6b0bec441cc (diff)
parenta1c7df76d3b03de85cbb7e2d16b2321d634e7eeb (diff)
Merge "profcollectd: Move threading from native side"
-rw-r--r--services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
index 4fb801e188d0..8369319ec55d 100644
--- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
+++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java
@@ -35,6 +35,7 @@ import android.provider.DeviceConfig;
import android.util.Log;
import com.android.internal.R;
+import com.android.internal.os.BackgroundThread;
import com.android.server.IoThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
@@ -146,7 +147,7 @@ public final class ProfcollectForwardingService extends SystemService {
connectNativeService();
break;
default:
- throw new AssertionError("Unknown message: " + message.toString());
+ throw new AssertionError("Unknown message: " + message);
}
}
}
@@ -190,11 +191,14 @@ public final class ProfcollectForwardingService extends SystemService {
Log.d(LOG_TAG, "Starting background process job");
}
- try {
- sSelfService.mIProfcollect.process(false);
- } catch (RemoteException e) {
- Log.e(LOG_TAG, e.getMessage());
- }
+ BackgroundThread.get().getThreadHandler().post(
+ () -> {
+ try {
+ sSelfService.mIProfcollect.process();
+ } catch (RemoteException e) {
+ Log.e(LOG_TAG, e.getMessage());
+ }
+ });
return true;
}
@@ -301,7 +305,7 @@ public final class ProfcollectForwardingService extends SystemService {
}
Context context = getContext();
- new Thread(() -> {
+ BackgroundThread.get().getThreadHandler().post(() -> {
try {
// Prepare profile report
String reportName = mIProfcollect.report() + ".zip";
@@ -321,6 +325,6 @@ public final class ProfcollectForwardingService extends SystemService {
} catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage());
}
- }).start();
+ });
}
}