Loading services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +21 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.camera2.CameraManager; import android.hardware.usb.UsbManager; import android.os.Handler; import android.os.IBinder.DeathRecipient; import android.os.Looper; Loading Loading @@ -67,6 +68,8 @@ public final class ProfcollectForwardingService extends SystemService { private int mUsageSetting; private boolean mUploadEnabled; private boolean mAdbActive; private IProfCollectd mIProfcollect; private static ProfcollectForwardingService sSelfService; private final Handler mHandler = new ProfcollectdHandler(IoThread.getHandler().getLooper()); Loading @@ -84,6 +87,14 @@ public final class ProfcollectForwardingService extends SystemService { Log.d(LOG_TAG, "Received broadcast to pack and upload reports"); createAndUploadReport(sSelfService); } if (UsbManager.ACTION_USB_STATE.equals(intent.getAction())) { boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false); boolean isADB = intent.getBooleanExtra(UsbManager.USB_FUNCTION_ADB, false); if (isADB) { Log.d(LOG_TAG, "Received broadcast that ADB became " + connected); mAdbActive = connected; } } } }; Loading @@ -106,8 +117,12 @@ public final class ProfcollectForwardingService extends SystemService { mUploadEnabled = context.getResources().getBoolean(R.bool.config_profcollectReportUploaderEnabled); // TODO: ADB might already be active when our service started. mAdbActive = false; final IntentFilter filter = new IntentFilter(); filter.addAction(INTENT_UPLOAD_PROFILES); filter.addAction(UsbManager.ACTION_USB_STATE); context.registerReceiver(mBroadcastReceiver, filter, Context.RECEIVER_NOT_EXPORTED); } Loading Loading @@ -281,6 +296,9 @@ public final class ProfcollectForwardingService extends SystemService { if (mIProfcollect == null) { return; } if (mAdbActive) { return; } if (Utils.withFrequency("applaunch_trace_freq", 5)) { Utils.traceSystem(mIProfcollect, "applaunch"); } Loading @@ -303,6 +321,9 @@ public final class ProfcollectForwardingService extends SystemService { if (mIProfcollect == null) { return; } if (mAdbActive) { return; } if (Utils.withFrequency("dex2oat_trace_freq", 25)) { // Dex2oat could take a while before it starts. Add a short delay before start tracing. Utils.traceSystem(mIProfcollect, "dex2oat", /* delayMs */ 1000); Loading Loading
services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +21 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.camera2.CameraManager; import android.hardware.usb.UsbManager; import android.os.Handler; import android.os.IBinder.DeathRecipient; import android.os.Looper; Loading Loading @@ -67,6 +68,8 @@ public final class ProfcollectForwardingService extends SystemService { private int mUsageSetting; private boolean mUploadEnabled; private boolean mAdbActive; private IProfCollectd mIProfcollect; private static ProfcollectForwardingService sSelfService; private final Handler mHandler = new ProfcollectdHandler(IoThread.getHandler().getLooper()); Loading @@ -84,6 +87,14 @@ public final class ProfcollectForwardingService extends SystemService { Log.d(LOG_TAG, "Received broadcast to pack and upload reports"); createAndUploadReport(sSelfService); } if (UsbManager.ACTION_USB_STATE.equals(intent.getAction())) { boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false); boolean isADB = intent.getBooleanExtra(UsbManager.USB_FUNCTION_ADB, false); if (isADB) { Log.d(LOG_TAG, "Received broadcast that ADB became " + connected); mAdbActive = connected; } } } }; Loading @@ -106,8 +117,12 @@ public final class ProfcollectForwardingService extends SystemService { mUploadEnabled = context.getResources().getBoolean(R.bool.config_profcollectReportUploaderEnabled); // TODO: ADB might already be active when our service started. mAdbActive = false; final IntentFilter filter = new IntentFilter(); filter.addAction(INTENT_UPLOAD_PROFILES); filter.addAction(UsbManager.ACTION_USB_STATE); context.registerReceiver(mBroadcastReceiver, filter, Context.RECEIVER_NOT_EXPORTED); } Loading Loading @@ -281,6 +296,9 @@ public final class ProfcollectForwardingService extends SystemService { if (mIProfcollect == null) { return; } if (mAdbActive) { return; } if (Utils.withFrequency("applaunch_trace_freq", 5)) { Utils.traceSystem(mIProfcollect, "applaunch"); } Loading @@ -303,6 +321,9 @@ public final class ProfcollectForwardingService extends SystemService { if (mIProfcollect == null) { return; } if (mAdbActive) { return; } if (Utils.withFrequency("dex2oat_trace_freq", 25)) { // Dex2oat could take a while before it starts. Add a short delay before start tracing. Utils.traceSystem(mIProfcollect, "dex2oat", /* delayMs */ 1000); Loading