|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +package com.facebook.react.devsupport; |
| 9 | + |
| 10 | +import android.content.Context; |
| 11 | + |
| 12 | +/** |
| 13 | + * Interface for accessing and interacting with development features related to performance testing. |
| 14 | + * Communication is enabled via the Inspector, but everything else is disabled. |
| 15 | + */ |
| 16 | +public final class PerftestDevSupportManager extends DisabledDevSupportManager { |
| 17 | + private final DevServerHelper mDevServerHelper; |
| 18 | + private final DevInternalSettings mDevSettings; |
| 19 | + private final InspectorPackagerConnection.BundleStatus mBundleStatus; |
| 20 | + |
| 21 | + public PerftestDevSupportManager(Context applicationContext) { |
| 22 | + mDevSettings = |
| 23 | + new DevInternalSettings( |
| 24 | + applicationContext, |
| 25 | + new DevInternalSettings.Listener() { |
| 26 | + @Override |
| 27 | + public void onInternalSettingsChanged() {} |
| 28 | + }); |
| 29 | + mBundleStatus = new InspectorPackagerConnection.BundleStatus(); |
| 30 | + mDevServerHelper = |
| 31 | + new DevServerHelper( |
| 32 | + mDevSettings, |
| 33 | + applicationContext.getPackageName(), |
| 34 | + new InspectorPackagerConnection.BundleStatusProvider() { |
| 35 | + @Override |
| 36 | + public InspectorPackagerConnection.BundleStatus getBundleStatus() { |
| 37 | + return mBundleStatus; |
| 38 | + } |
| 39 | + }); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public DevInternalSettings getDevSettings() { |
| 44 | + return mDevSettings; |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void startInspector() { |
| 49 | + mDevServerHelper.openInspectorConnection(); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public void stopInspector() { |
| 54 | + mDevServerHelper.closeInspectorConnection(); |
| 55 | + } |
| 56 | +} |
0 commit comments