Merge "profcollectd: Move threading from native side" am: 206e10a3a3 am: 72dda57c0a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1892335

Change-Id: I0d45024a40979c99b9267164ba153386e1de34b2
This commit is contained in:
Yi Kong
2021-11-15 14:37:58 +00:00
committed by Automerger Merge Worker

View File

@@ -35,6 +35,7 @@ import android.provider.DeviceConfig;
import android.util.Log; import android.util.Log;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.os.BackgroundThread;
import com.android.server.IoThread; import com.android.server.IoThread;
import com.android.server.LocalServices; import com.android.server.LocalServices;
import com.android.server.SystemService; import com.android.server.SystemService;
@@ -146,7 +147,7 @@ public final class ProfcollectForwardingService extends SystemService {
connectNativeService(); connectNativeService();
break; break;
default: 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"); Log.d(LOG_TAG, "Starting background process job");
} }
BackgroundThread.get().getThreadHandler().post(
() -> {
try { try {
sSelfService.mIProfcollect.process(false); sSelfService.mIProfcollect.process();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage()); Log.e(LOG_TAG, e.getMessage());
} }
});
return true; return true;
} }
@@ -301,7 +305,7 @@ public final class ProfcollectForwardingService extends SystemService {
} }
Context context = getContext(); Context context = getContext();
new Thread(() -> { BackgroundThread.get().getThreadHandler().post(() -> {
try { try {
// Prepare profile report // Prepare profile report
String reportName = mIProfcollect.report() + ".zip"; String reportName = mIProfcollect.report() + ".zip";
@@ -321,6 +325,6 @@ public final class ProfcollectForwardingService extends SystemService {
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage()); Log.e(LOG_TAG, e.getMessage());
} }
}).start(); });
} }
} }