• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package ohos.devtools.samplecode.pluginconfig;
17 
18 import ohos.devtools.datasources.transport.grpc.service.SamplePluginConfig;
19 import ohos.devtools.datasources.utils.plugin.IPluginConfig;
20 import ohos.devtools.datasources.utils.plugin.entity.AnalysisType;
21 import ohos.devtools.datasources.utils.plugin.entity.DPlugin;
22 import ohos.devtools.datasources.utils.plugin.entity.HiProfilerPluginConfig;
23 import ohos.devtools.datasources.utils.plugin.entity.PluginConf;
24 import ohos.devtools.datasources.utils.plugin.entity.PluginMode;
25 import ohos.devtools.samplecode.datasources.utils.datahandler.datapoller.SampleCodeConsumer;
26 import ohos.devtools.samplecode.views.layout.chartview.SampleCodeView;
27 import ohos.devtools.views.layout.chartview.ProfilerMonitorItem;
28 
29 /**
30  * SampleConfig
31  *
32  * @since 2021/11/24
33  */
34 @DPlugin
35 public class SampleConfig extends IPluginConfig {
36     /**
37      * SAMPLE_PLUG
38      */
39     public static final String SAMPLE_PLUG = "sample-plugin";
40 
41     /**
42      * SAMPLE_PLUGIN_NAME
43      */
44     private static final String SAMPLE_PLUGIN_NAME = "/data/local/tmp/libsampleplugin.z.so";
45 
46     /**
47      * createConfig
48      *
49      * @return PluginConf
50      */
51     @Override
createConfig()52     public PluginConf createConfig() {
53         ProfilerMonitorItem sampleItem = new ProfilerMonitorItem(5, "sample", SampleCodeView.class);
54         PluginConf sample = new PluginConf(SAMPLE_PLUGIN_NAME, SAMPLE_PLUG, SampleCodeConsumer.class, true, sampleItem);
55         sample.setICreatePluginConfig((deviceIPPortInfo, processInfo) -> {
56             SamplePluginConfig.SampleConfig.Builder builder =
57                 SamplePluginConfig.SampleConfig.newBuilder().setPid(processInfo.getProcessId());
58             return new HiProfilerPluginConfig(40, builder.build().toByteString());
59         });
60         sample.setPluginMode(PluginMode.ONLINE);
61         sample.addAnalysisTypes(AnalysisType.APPLICATION_TYPE);
62         return sample;
63     }
64 }