diff options
| author | 2022-02-01 12:15:06 -0800 | |
|---|---|---|
| committer | 2022-02-07 13:05:47 -0800 | |
| commit | cca4059356f8e8e0ea9efeea8dd15fabbfe6f9de (patch) | |
| tree | 1ecfcca0b76d127a6bbbe2d0a12fd0f6560d89ff | |
| parent | 9d805c35d0829cf3d3142899e6fcbf3473b20741 (diff) | |
profcollectd: register callback to wait until ETM is ready.
ETM may not be ready after boot. So after connecting to profcollectd,
register ProviderStatusCallback to wait until ETM is ready.
Bug: 213519191
Test: on oriole EVT and DVT devices, profcollectd can record applaunch
Test: profiles.
Change-Id: I15326b0c95afcf44cd2e85d063496311dda0d04d
| -rw-r--r-- | services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java index 62a16f7f24fd..c5f990d52b82 100644 --- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java @@ -60,6 +60,12 @@ public final class ProfcollectForwardingService extends SystemService { private static ProfcollectForwardingService sSelfService; private final Handler mHandler = new ProfcollectdHandler(IoThread.getHandler().getLooper()); + private IProviderStatusCallback mProviderStatusCallback = new IProviderStatusCallback.Stub() { + public void onProviderReady() { + mHandler.sendEmptyMessage(ProfcollectdHandler.MESSAGE_REGISTER_SCHEDULERS); + } + }; + public ProfcollectForwardingService(Context context) { super(context); @@ -93,13 +99,23 @@ public final class ProfcollectForwardingService extends SystemService { } BackgroundThread.get().getThreadHandler().post(() -> { if (serviceHasSupportedTraceProvider()) { - registerObservers(); - ProfcollectBGJobService.schedule(getContext()); + registerProviderStatusCallback(); } }); } } + private void registerProviderStatusCallback() { + if (mIProfcollect == null) { + return; + } + try { + mIProfcollect.registerProviderStatusCallback(mProviderStatusCallback); + } catch (RemoteException e) { + Log.e(LOG_TAG, e.getMessage()); + } + } + private boolean serviceHasSupportedTraceProvider() { if (mIProfcollect == null) { return false; @@ -141,6 +157,7 @@ public final class ProfcollectForwardingService extends SystemService { } public static final int MESSAGE_BINDER_CONNECT = 0; + public static final int MESSAGE_REGISTER_SCHEDULERS = 1; @Override public void handleMessage(android.os.Message message) { @@ -148,6 +165,10 @@ public final class ProfcollectForwardingService extends SystemService { case MESSAGE_BINDER_CONNECT: connectNativeService(); break; + case MESSAGE_REGISTER_SCHEDULERS: + registerObservers(); + ProfcollectBGJobService.schedule(getContext()); + break; default: throw new AssertionError("Unknown message: " + message); } |