• 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.pluginconfig;
17 
18 import ohos.devtools.datasources.transport.grpc.service.StreamPluginConfig;
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.HiProfilerPluginConfig;
22 import ohos.devtools.datasources.utils.plugin.entity.PluginConf;
23 import ohos.devtools.datasources.utils.plugin.entity.PluginMode;
24 import ohos.devtools.datasources.utils.profilerlog.ProfilerLogManager;
25 import org.apache.logging.log4j.LogManager;
26 import org.apache.logging.log4j.Logger;
27 
28 /**
29  * Data Verification Config
30  *
31  * @since 2021/9/20
32  */
33 public class DataCheckConfig extends IPluginConfig {
34     private static final Logger LOGGER = LogManager.getLogger(DataCheckConfig.class);
35 
36     private final String DATA_CHECK_PLUGIN_NAME = "/data/local/tmp/libstreamplugin.z.so";
37     private final String DATA_CHECK_PLUG = "/data/local/tmp/libstreamplugin.z.so";
38 
39     @Override
createConfig()40     public PluginConf createConfig() {
41         if (ProfilerLogManager.isInfoEnabled()) {
42             LOGGER.info("createConfig");
43         }
44         PluginConf pluginConf = new PluginConf(DATA_CHECK_PLUGIN_NAME, DATA_CHECK_PLUG, null, false, null);
45         pluginConf.setICreatePluginConfig((deviceIPPortInfo, processInfo) -> {
46             StreamPluginConfig.StreamConfig stream =
47                 StreamPluginConfig.StreamConfig.newBuilder().setPid(processInfo.getProcessId()).build();
48             return new HiProfilerPluginConfig(40, stream.toByteString());
49         });
50         pluginConf.setPluginMode(PluginMode.ONLINE);
51         pluginConf.addAnalysisTypes(AnalysisType.APPLICATION_TYPE);
52         return pluginConf;
53     }
54 }
55