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

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

Change-Id: I160d6dabf1660ad2ca434c8b14c74c5216c8c9a4
This commit is contained in:
Yi Kong
2021-11-15 14:21:46 +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");
} }
try { BackgroundThread.get().getThreadHandler().post(
sSelfService.mIProfcollect.process(false); () -> {
} catch (RemoteException e) { try {
Log.e(LOG_TAG, e.getMessage()); sSelfService.mIProfcollect.process();
} } catch (RemoteException e) {
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(); });
} }
} }