profcollectd: Move threading from native side
Previously trace processing's threading is handled on the native side while the report creation's threading is on the framework side. Move them all to the frameworks side to reduce complexity. Test: build Bug: 183487233 Change-Id: I5dd405b7a73e5be9e0141c20c6c100acbc6defa9
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user