diff --git a/BUILD.gn b/BUILD.gn index c27f896e6d..67c8eff578 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,12 +16,7 @@ import("//foundation/graphic/graphic_2d/utils/wmlayout/wmlayout.gni") import("graphic_config.gni") group("default") { - public_deps = [ - ":graphic.rc", - "frameworks/dumper:gdumper", - "frameworks/dumper:gdumper.ini", - "frameworks/dumper:graphic_dumper_server", - ] + public_deps = [ ":graphic.rc" ] if (graphic_standard_feature_bootanimation_enable) { public_deps += [ "frameworks/bootanimation:bootanimation" ] @@ -75,10 +70,6 @@ group("libvulkan") { public_deps = libvulkan } -group("libgraphic_dumper_client") { - public_deps = [ "frameworks/dumper:libgraphic_dumper_client" ] -} - group("libnative_image") { public_deps = [ "frameworks/surfaceimage:libnative_image" ] } diff --git a/README.md b/README.md index 949b127e15..f6c58dc84a 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ foundataion/graphic/graphic_2d ├── frameworks # framework code directory │ ├── animation_server # animationServer code │ ├── bootanimation # Boot animation directory -│ ├── dumper # graphic dumper code │ ├── fence # fence code │ ├── vsync # Vsync code ├── rosen # framework code directory diff --git a/README_zh.md b/README_zh.md index f55a46aa27..a778766460 100644 --- a/README_zh.md +++ b/README_zh.md @@ -35,7 +35,6 @@ foundation/graphic/graphic_2d/ ├── frameworks # 框架代码目录 │ ├── animation_server # AnimationServer代码 │ ├── bootanimation # 开机动画目录 -│ ├── dumper # graphic dumper代码 │ ├── fence # fence代码 │ ├── opengl_wrapper # opengl_wrapper │ ├── surface # Surface代码 diff --git a/frameworks/dumper/BUILD.gn b/frameworks/dumper/BUILD.gn deleted file mode 100755 index 72b350d11a..0000000000 --- a/frameworks/dumper/BUILD.gn +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") - -## Build libgraphic_dumper_client.so {{{ -config("graphic_dumper_client_config") { - visibility = [ ":*" ] - - include_dirs = [ "include" ] - - cflags = [ - "-Wall", - "-Werror", - "-g3", - ] -} - -config("graphic_dumper_client_public_config") { - include_dirs = [ "common" ] -} - -ohos_shared_library("libgraphic_dumper_client") { - sources = [ - "src/graphic_dumper_helper.cpp", - "src/graphic_dumper_helper_impl.cpp", - "src/ipc/graphic_dumper_client_listener_stub.cpp", - "src/ipc/graphic_dumper_service_proxy.cpp", - ] - - configs = [ ":graphic_dumper_client_config" ] - - public_configs = [ ":graphic_dumper_client_public_config" ] - - deps = [ "//foundation/graphic/graphic_2d/utils:libgraphic_utils" ] - - external_deps = [ - "c_utils:utils", - "hilog_native:libhilog", - "ipc:ipc_core", - "samgr:samgr_proxy", - ] - - part_name = "graphic_standard" - subsystem_name = "graphic" -} - -## Build libgraphic_dumper_client.so }}} - -## Build graphic_dumper_server {{{ -config("graphic_dumper_server_config") { - visibility = [ ":*" ] - - include_dirs = [ "include" ] - - cflags = [ - "-Wall", - "-Werror", - "-g3", - ] -} - -ohos_executable("graphic_dumper_server") { - install_enable = true - - sources = [ - "src/graphic_dumper_server.cpp", - "src/graphic_dumper_server_main.cpp", - "src/graphic_dumper_tree.cpp", - "src/graphic_dumper_util.cpp", - "src/ipc/graphic_dumper_client_listener_death_recipient.cpp", - "src/ipc/graphic_dumper_client_listener_proxy.cpp", - "src/ipc/graphic_dumper_command_proxy.cpp", - "src/ipc/graphic_dumper_command_stub.cpp", - "src/ipc/graphic_dumper_info_listener_death_recipient.cpp", - "src/ipc/graphic_dumper_info_listener_proxy.cpp", - "src/ipc/graphic_dumper_service_proxy.cpp", - "src/ipc/graphic_dumper_service_stub.cpp", - ] - - configs = [ - ":graphic_dumper_server_config", - ":graphic_dumper_client_public_config", - ] - - deps = [ - "//foundation/graphic/graphic_2d/utils:libgraphic_utils", - "//third_party/zlib:libz", - ] - - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr:samgr_proxy", - ] - - part_name = "graphic_standard" - subsystem_name = "graphic" -} - -## Build graphic_dumper_server }}} - -## Build gdumper {{{ -config("gdumper_config") { - visibility = [ ":*" ] - - include_dirs = [ "include" ] - - cflags = [ - "-Wall", - "-Werror", - "-g3", - ] -} - -ohos_executable("gdumper") { - install_enable = true - - sources = [ - "src/graphic_dumper_command_line.cpp", - "src/graphic_dumper_command_line_main.cpp", - "src/graphic_dumper_server.cpp", - "src/graphic_dumper_tree.cpp", - "src/graphic_dumper_util.cpp", - "src/ipc/graphic_dumper_client_listener_death_recipient.cpp", - "src/ipc/graphic_dumper_command_proxy.cpp", - "src/ipc/graphic_dumper_command_stub.cpp", - "src/ipc/graphic_dumper_info_listener_death_recipient.cpp", - "src/ipc/graphic_dumper_info_listener_proxy.cpp", - "src/ipc/graphic_dumper_info_listener_stub.cpp", - "src/ipc/graphic_dumper_service_proxy.cpp", - "src/ipc/graphic_dumper_service_stub.cpp", - ] - - configs = [ - ":gdumper_config", - ":graphic_dumper_client_public_config", - ] - - deps = [ - "//foundation/graphic/graphic_2d/utils:libgraphic_utils", - "//third_party/zlib:libz", - ] - - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr:samgr_proxy", - ] - - part_name = "graphic_standard" - subsystem_name = "graphic" -} - -## Build gdumper }}} - -## Install gdumper.ini to /system/etc/./gdumper.ini {{{ -ohos_prebuilt_etc("gdumper.ini") { - source = "gdumper.ini" - relative_install_dir = "." - part_name = "graphic_standard" - subsystem_name = "graphic" -} -## Install gdumper.ini to /system/etc/./gdumper.ini }}} diff --git a/frameworks/dumper/common/graphic_dumper_helper.h b/frameworks/dumper/common/graphic_dumper_helper.h deleted file mode 100644 index 98cb70f81d..0000000000 --- a/frameworks/dumper/common/graphic_dumper_helper.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_HELPER_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_HELPER_H - -#include "graphic_common.h" - -#ifdef __cplusplus -#include - -namespace OHOS { -using OnConfigChangeFunc = std::function; -using OnDumpFunc = std::function; -class GraphicDumperHelper : public RefBase { -public: - static sptr GetInstance(); - virtual GSError SendInfo(const std::string &tag, const char *fmt, ...) = 0; - - virtual int32_t AddConfigChangeListener(const std::string &tag, OnConfigChangeFunc func) = 0; - virtual GSError RemoveConfigChangeListener(const int32_t listenerId) = 0; - virtual int32_t AddDumpListener(const std::string &tag, OnDumpFunc func) = 0; - virtual GSError RemoveDumpListener(const int32_t listenerId) = 0; -}; -} // namespace OHOS - -extern "C" { -#endif - -typedef void(*OnDumpFuncPtr)(void); -typedef void(*OnConfigChangeFuncPtr)(const char *, const char *); - -int SendInfo(const char* tag, const char *fmt, ...); -int AddConfigChangeListener(const char* tag, OnConfigChangeFuncPtr func); -int RemoveConfigChangeListener(int listenerId); -int AddDumpListener(const char* tag, OnDumpFuncPtr func); -int RemoveDumpListener(int listenerId); - -#ifdef __cplusplus -} -#endif - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_HELPER_H diff --git a/frameworks/dumper/gdumper.ini b/frameworks/dumper/gdumper.ini deleted file mode 100644 index 9cac8da51a..0000000000 --- a/frameworks/dumper/gdumper.ini +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http=//www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# [dumper] -# A.B=true diff --git a/frameworks/dumper/include/graphic_dumper_command_line.h b/frameworks/dumper/include/graphic_dumper_command_line.h deleted file mode 100644 index 5fc8f70ba5..0000000000 --- a/frameworks/dumper/include/graphic_dumper_command_line.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_LINE_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_LINE_H - -#include -#include - -#include "ipc/graphic_dumper_info_listener_stub.h" -#include "ipc/igraphic_dumper_command.h" - -namespace OHOS { -struct DumperArgs { - bool wait = false; - std::string dumpTag = {}; - std::string logTag = {}; - std::string getCfgKey = {}; - std::string setCfgKey = {}; - std::string setCfgValue = {}; -}; - -class GraphicDumperCommandLine : public GraphicDumperInfoListenerStub { -public: - static sptr GetInstance(); - virtual void OnInfoComing(const std::string &info) override; - GSError Main(int32_t argc, char *argv[]); - -private: - GraphicDumperCommandLine() = default; - ~GraphicDumperCommandLine() = default; - static inline sptr instance_; - - void HandlerOfArgs(); - GSError OptionParse(const char option); - GSError Parse(int32_t argc, char *argv[]); - GSError InitSA(int32_t systemAbilityId); - - sptr service_; - DumperArgs dumperArgs_ = {}; -}; - -class GDumperCommandDeathRecipient : public IRemoteObject::DeathRecipient { -public: - GDumperCommandDeathRecipient() = default; - virtual ~GDumperCommandDeathRecipient() = default; - void OnRemoteDied(const wptr &object) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_LINE_H diff --git a/frameworks/dumper/include/graphic_dumper_helper_impl.h b/frameworks/dumper/include/graphic_dumper_helper_impl.h deleted file mode 100644 index 46058dbced..0000000000 --- a/frameworks/dumper/include/graphic_dumper_helper_impl.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_HELPER_IMPL_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_HELPER_IMPL_H - -#include -#include -#include -#include -#include - -#include "ipc/graphic_dumper_service_proxy.h" -#include "ipc/graphic_dumper_client_listener_stub.h" -#include "graphic_dumper_helper.h" - -namespace OHOS { -namespace { -class GraphicDumperClientListener; -} - -using ConfigFuncMapPtr = std::unique_ptr>; -using DumpFuncMapPtr = std::unique_ptr>; - -class GraphicDumperHelperImpl : public GraphicDumperHelper { - friend class GraphicDumperClientListener; -public: - static sptr GetInstance(); - - virtual GSError SendInfo(const std::string &tag, const char *fmt, ...) override; - virtual int32_t AddConfigChangeListener(const std::string &tag, OnConfigChangeFunc func) override; - virtual GSError RemoveConfigChangeListener(const int32_t listenerId) override; - virtual int32_t AddDumpListener(const std::string &tag, OnDumpFunc func) override; - virtual GSError RemoveDumpListener(const int32_t listenerId) override; - - void SetConnectState(bool state); - -private: - virtual ~GraphicDumperHelperImpl() = default; - static inline sptr currentHelper = nullptr; - static void SetNoopInstance(); - - GSError Init(); - GSError InitSA(int32_t systemAbilityId); - GSError AddClientListener(const std::string &tag); - void DispenseOnConfigChange(const std::string &tag, const std::string &val); - void DispenseOnDump(const std::string &tag); - - std::mutex initMutex_; - std::atomic_int64_t requestConnectTime = 0; - std::atomic_bool serverConnected = false; - sptr service_ = nullptr; - - std::mutex clientListenerMutex_; - sptr listener_ = nullptr; - - int32_t onConfigChangeFuncId_ = 0; - std::mutex onConfigChangeMutex_; - std::map onConfigChangeMap_; - - int32_t onDumperFuncId_ = 0; - std::mutex onDumperFuncsMutex_; - std::map onDumpFuncsMap_; - - struct InfoStruct { - std::string tag; - std::string info; - }; - std::mutex cacheInfoMutex_; - std::vector cacheInfo_; -}; - -class GDumperServiceDeathRecipient : public IRemoteObject::DeathRecipient { -public: - GDumperServiceDeathRecipient() = default; - virtual ~GDumperServiceDeathRecipient() = default; - void OnRemoteDied(const wptr &object) override; -}; - -class GraphicDumperHelperNoop : public GraphicDumperHelper { -public: - virtual GSError SendInfo(const std::string &tag, const char *fmt, ...) - { - return GSERROR_CONNOT_CONNECT_SERVER; - } - virtual int32_t AddConfigChangeListener(const std::string &tag, OnConfigChangeFunc func) - { - return 0; - } - virtual GSError RemoveConfigChangeListener(const int32_t listenerId) - { - return GSERROR_CONNOT_CONNECT_SERVER; - } - virtual int32_t AddDumpListener(const std::string &tag, OnDumpFunc func) - { - return 0; - } - virtual GSError RemoveDumpListener(const int32_t listenerId) - { - return GSERROR_CONNOT_CONNECT_SERVER; - } -}; - -namespace { -class GraphicDumperClientListener : public GraphicDumperClientListenerStub { -public: - GraphicDumperClientListener(sptr& helper); - virtual ~GraphicDumperClientListener() = default; - - void OnConfigChange(const std::string &tag, const std::string &val) override; - void OnDump(const std::string &tag) override; - -private: - sptr helperImpl_ = nullptr; -}; -} // namespace -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_HELPER_IMPL_H diff --git a/frameworks/dumper/include/graphic_dumper_hilog.h b/frameworks/dumper/include/graphic_dumper_hilog.h deleted file mode 100644 index d107358666..0000000000 --- a/frameworks/dumper/include/graphic_dumper_hilog.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPER_INCLUDE_GRAPHIC_DUMPER_HILOG_H -#define FRAMEWORKS_DUMPER_INCLUDE_GRAPHIC_DUMPER_HILOG_H - -#include "hilog/log.h" -namespace OHOS { -#define GD_CPRINTF(func, fmt, ...) func(LABEL, "<%{public}d>" fmt, __LINE__, ##__VA_ARGS__) - -#define GDLOGD(fmt, ...) GD_CPRINTF(HiviewDFX::HiLog::Debug, fmt, ##__VA_ARGS__) -#define GDLOGI(fmt, ...) GD_CPRINTF(HiviewDFX::HiLog::Info, fmt, ##__VA_ARGS__) -#define GDLOGW(fmt, ...) GD_CPRINTF(HiviewDFX::HiLog::Warn, fmt, ##__VA_ARGS__) -#define GDLOGE(fmt, ...) GD_CPRINTF(HiviewDFX::HiLog::Error, fmt, ##__VA_ARGS__) - -#define GDLOGFD(fmt, ...) GDLOGD("%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define GDLOGFI(fmt, ...) GDLOGI("%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define GDLOGFW(fmt, ...) GDLOGW("%{public}s: " fmt, __func__, ##__VA_ARGS__) -#define GDLOGFE(fmt, ...) GDLOGE("%{public}s: " fmt, __func__, ##__VA_ARGS__) - -#define GDLOG_SUCCESS(fmt, ...) GDLOGI("Success, Way: " fmt, ##__VA_ARGS__) -#define GDLOG_FAILURE(fmt, ...) GDLOGE("Failure, Reason: " fmt, ##__VA_ARGS__) -#define GDLOG_FAILURE_NO(gs_error) GDLOG_FAILURE("%{public}s", GSErrorStr(gs_error).c_str()) -#define GDLOG_FAILURE_RET(gs_error) \ - do { \ - GDLOG_FAILURE_NO(gs_error); \ - return gs_error; \ - } while (0) -#define GDLOG_FAILURE_API(api, ret) GDLOG_FAILURE(#api " failed with %{public}s", GSErrorStr(ret).c_str()) - -#define GDLOG_ERROR(errno, fmt, ...) \ - GDLOGE(fmt ", means %{public}s", ##__VA_ARGS__, strerror(errno)) - -#define GDLOG_ERROR_API(ret, api) \ - GDLOG_ERROR(ret, #api " failed with %{public}d", ret) -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPER_INCLUDE_GRAPHIC_DUMPER_HILOG_H diff --git a/frameworks/dumper/include/graphic_dumper_server.h b/frameworks/dumper/include/graphic_dumper_server.h deleted file mode 100644 index 2aa77a8990..0000000000 --- a/frameworks/dumper/include/graphic_dumper_server.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVER_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVER_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "graphic_dumper_tree.h" -#include "ipc/igraphic_dumper_client_listener.h" -#include "ipc/igraphic_dumper_command.h" -#include "ipc/igraphic_dumper_info_listener.h" -#include "ipc/igraphic_dumper_service.h" - -namespace OHOS { -struct LogBuffer { - bool canSave = false; - bool needSave = false; - bool sync = false; - uint32_t index = 0; - uint32_t size[2] = {0}; - std::mutex mutex[2]; - std::vector>> vec; - std::string mask = {}; -}; - -struct LogBlock { - uint32_t size; - uint32_t length; - uint8_t data[0]; -}; - -struct ConfigTags { - uint32_t id = 0; - sptr listener = nullptr; - std::vector tags = {}; -}; - -class GraphicDumperServer : public RefBase { -public: - static sptr GetInstance(); - int32_t Init(); - - GSError AddConfigListener(const std::string &tag, sptr &listener); - GSError RemoveConfigListener(sptr object); - GSError GetConfig(const std::string &k, std::string &v); - GSError SetConfig(const std::string &k, const std::string &v); - GSError Dump(const std::string &tag); - - GSError AddInfoListener(sptr &listener); - GSError RemoveInfoListener(const wptr &object); - GSError InfoHandle(const std::string &tag, const std::string &info); - GSError GetLog(const std::string &tag, const std::string &info); - -private: - GraphicDumperServer() = default; - virtual ~GraphicDumperServer() = default; - static inline sptr instance_; - - int32_t StartServer(int32_t systemAbility, sptr obj); - int32_t ReadDefaultConfig(); - void AddConfigDeathRecipient(sptr &object); - bool HaveConfigDeathRecipient(sptr &object); - bool HaveObject(const sptr &obj); - void VisitEach(const TreeNodePtr &node, std::function func); - void RemoveNode(std::vector &vec, TreeNodePtr &sub, uint32_t &listenerId); - void DispenseConfig(const TreeNodePtr &node, const std::string &k, const std::string &v); - void DispenseDump(const TreeNodePtr &node, const std::string &tag); - - void AddInfoDeathRecipient(sptr &object); - bool HaveInfoDeathRecipient(sptr &object); - void SendToInfoListener(const std::string &info); - static void SaveLog(std::any server); - GSError LogHandle(const std::string &tag, const std::string &info); - -private: - std::mutex infoListenersMutex_; - std::map, sptr> infoListeners_; - std::map, sptr> infoListenerDeathRecipientMap_; - - uint32_t objectId_ = 0; - std::map configTagsMap_; - std::map, uint32_t> objectIdMap_; - std::mutex treeMutex_; - const TreeNodePtr root = std::make_shared(); - - LogBuffer logBuf_; - uint32_t logBlockSize_ = 0; - std::mutex logBlockVectorMutex_; - std::vector> logBlockVector_; - std::unique_ptr thread_ = nullptr; - std::map, sptr> configListenerDeathRecipientMap_; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVER_H diff --git a/frameworks/dumper/include/graphic_dumper_tree.h b/frameworks/dumper/include/graphic_dumper_tree.h deleted file mode 100644 index 56773c32e2..0000000000 --- a/frameworks/dumper/include/graphic_dumper_tree.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_TREE_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_TREE_H - -#include -#include -#include -#include -#include - -#include - -#include "ipc/igraphic_dumper_client_listener.h" - -namespace OHOS { -class GraphicDumperTree; -using TreeNodePtr = std::shared_ptr; -using TreeNodeVisitFunc = std::function; -using TreeNodeMap = std::map; - -class GraphicDumperTree { -public: - TreeNodePtr GetSetNode(const std::string str); - bool HasNode(const std::string str); - bool IsEmptyNode(); - void EraseNode(const std::string &tag); - std::string GetTag(); - void SetValue(const std::string str); - std::string GetValue(); - void AddListenerId(uint32_t &listenerId); - void RemoveListenerId(uint32_t &listenerId); - std::vector GetListenerIds() const; - void Foreach(TreeNodeVisitFunc func) const; - -private: - std::string tag_ = ""; - std::string value_ = ""; - std::unique_ptr nodeMap_ = nullptr; - std::vector listenerIds_ = {}; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_TREE_H diff --git a/frameworks/dumper/include/graphic_dumper_util.h b/frameworks/dumper/include/graphic_dumper_util.h deleted file mode 100644 index 682775dd88..0000000000 --- a/frameworks/dumper/include/graphic_dumper_util.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPER_INCLUDE_GRAPHIC_DUMPER_UTIL_H -#define FRAMEWORKS_DUMPER_INCLUDE_GRAPHIC_DUMPER_UTIL_H - -#include -#include - -namespace OHOS { -constexpr int32_t CFGTERMSIZE = 2; - -std::vector Split(std::string src, const std::string &splitStr); -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPER_INCLUDE_GRAPHIC_DUMPER_UTIL_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_client_listener_death_recipient.h b/frameworks/dumper/include/ipc/graphic_dumper_client_listener_death_recipient.h deleted file mode 100644 index a505068912..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_client_listener_death_recipient.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_DEATH_RECIPIENT_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_DEATH_RECIPIENT_H - -#include - -#include -#include -#include -#include - -#include "ipc/igraphic_dumper_service.h" - -namespace OHOS { -class GraphicDumperClientListenerDeathRecipient : public IRemoteObject::DeathRecipient { -public: - GraphicDumperClientListenerDeathRecipient() = default; - virtual ~GraphicDumperClientListenerDeathRecipient() = default; - void OnRemoteDied(const wptr &object) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_client_listener_proxy.h b/frameworks/dumper/include/ipc/graphic_dumper_client_listener_proxy.h deleted file mode 100644 index a3d875485e..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_client_listener_proxy.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_PROXY_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_PROXY_H - -#include -#include - -#include "ipc/igraphic_dumper_client_listener.h" - -namespace OHOS { -class GraphicDumperClientListenerProxy : public IRemoteProxy { -public: - GraphicDumperClientListenerProxy(const sptr& impl); - virtual ~GraphicDumperClientListenerProxy() = default; - - void OnConfigChange(const std::string &tag, const std::string &val) override; - void OnDump(const std::string &tag) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_STUB_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_client_listener_stub.h b/frameworks/dumper/include/ipc/graphic_dumper_client_listener_stub.h deleted file mode 100644 index 7ea82b9edc..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_client_listener_stub.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_STUB_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_STUB_H - -#include -#include -#include - -#include "ipc/igraphic_dumper_client_listener.h" - -namespace OHOS { -class GraphicDumperClientListenerStub : public IRemoteStub { -public: - virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_CLIENT_LISTENER_STUB_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_command_proxy.h b/frameworks/dumper/include/ipc/graphic_dumper_command_proxy.h deleted file mode 100644 index fef09c8af6..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_command_proxy.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_PROXY_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_PROXY_H - -#include -#include - -#include "ipc/igraphic_dumper_command.h" - -namespace OHOS { -class GraphicDumperCommandProxy : public IRemoteProxy { -public: - GraphicDumperCommandProxy(const sptr& impl); - virtual ~GraphicDumperCommandProxy() = default; - - GSError GetConfig(const std::string &k, std::string &v) override; - GSError SetConfig(const std::string &k, const std::string &v) override; - GSError Dump(const std::string &key) override; - GSError GetLog(const std::string &tag, std::string &log) override; - GSError AddInfoListener(const std::string &tag, sptr &listener) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_STUB_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_command_stub.h b/frameworks/dumper/include/ipc/graphic_dumper_command_stub.h deleted file mode 100644 index f71ace8947..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_command_stub.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_STUB_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_STUB_H - -#include -#include -#include - -#include "ipc/igraphic_dumper_command.h" - -namespace OHOS { -class GraphicDumperCommandStub : public IRemoteStub { -public: - virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) override; - virtual GSError GetConfig(const std::string &k, std::string &v) override; - virtual GSError SetConfig(const std::string &k, const std::string &v) override; - - using IPCObjectStub::Dump; - virtual GSError Dump(const std::string &tag) override; - virtual GSError GetLog(const std::string &tag, std::string &log) override; - virtual GSError AddInfoListener(const std::string &tag, sptr &listener) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_info_listener_death_recipient.h b/frameworks/dumper/include/ipc/graphic_dumper_info_listener_death_recipient.h deleted file mode 100644 index 707e2d0f03..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_info_listener_death_recipient.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_DEATH_RECIPIENT_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_DEATH_RECIPIENT_H - -#include -#include -#include - -#include "ipc/igraphic_dumper_command.h" - -namespace OHOS { -class GraphicDumperInfoListenerDeathRecipient : public IRemoteObject::DeathRecipient { -public: - GraphicDumperInfoListenerDeathRecipient() = default; - virtual ~GraphicDumperInfoListenerDeathRecipient() = default; - void OnRemoteDied(const wptr &object) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_COMMAND_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_info_listener_proxy.h b/frameworks/dumper/include/ipc/graphic_dumper_info_listener_proxy.h deleted file mode 100644 index 6a3c07b51f..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_info_listener_proxy.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_PROXY_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_PROXY_H - -#include -#include - -#include "ipc/igraphic_dumper_info_listener.h" - -namespace OHOS { -class GraphicDumperInfoListenerProxy : public IRemoteProxy { -public: - GraphicDumperInfoListenerProxy(const sptr& impl); - virtual ~GraphicDumperInfoListenerProxy() = default; - void OnInfoComing(const std::string &info) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_STUB_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_info_listener_stub.h b/frameworks/dumper/include/ipc/graphic_dumper_info_listener_stub.h deleted file mode 100644 index 51835e30e6..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_info_listener_stub.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_STUB_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_STUB_H - -#include -#include -#include - -#include "ipc/igraphic_dumper_info_listener.h" - -namespace OHOS { -class GraphicDumperInfoListenerStub : public IRemoteStub { -public: - virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_INFO_LISTENER_STUB_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_service_proxy.h b/frameworks/dumper/include/ipc/graphic_dumper_service_proxy.h deleted file mode 100644 index 8fb929ab00..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_service_proxy.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_PROXY_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_PROXY_H - -#include -#include - -#include "ipc/igraphic_dumper_service.h" - -namespace OHOS { -class GraphicDumperServiceProxy : public IRemoteProxy { -public: - GraphicDumperServiceProxy(const sptr& impl); - virtual ~GraphicDumperServiceProxy() = default; - GSError AddClientListener(const std::string &tag, sptr &listener) override; - GSError SendInfo(const std::string &tag, const std::string &info) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_PROXY_H diff --git a/frameworks/dumper/include/ipc/graphic_dumper_service_stub.h b/frameworks/dumper/include/ipc/graphic_dumper_service_stub.h deleted file mode 100644 index d1381210a3..0000000000 --- a/frameworks/dumper/include/ipc/graphic_dumper_service_stub.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_STUB_H -#define FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_STUB_H - -#include - -#include -#include -#include -#include - -#include "ipc/igraphic_dumper_service.h" - -namespace OHOS { -class GraphicDumperServiceStub : public IRemoteStub { -public: - virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) override; - GSError AddClientListener(const std::string &tag, sptr &listener) override; - GSError SendInfo(const std::string &tag, const std::string &info) override; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_GRAPHIC_DUMPER_SERVICE_H diff --git a/frameworks/dumper/include/ipc/igraphic_dumper_client_listener.h b/frameworks/dumper/include/ipc/igraphic_dumper_client_listener.h deleted file mode 100644 index b87ea13d3a..0000000000 --- a/frameworks/dumper/include/ipc/igraphic_dumper_client_listener.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_CLIENT_LISTENER_H -#define FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_CLIENT_LISTENER_H - -#include - -#include - -namespace OHOS { -class IGraphicDumperClientListener : public IRemoteBroker { -public: - virtual void OnConfigChange(const std::string &tag, const std::string &val) = 0; - virtual void OnDump(const std::string &key) = 0; - DECLARE_INTERFACE_DESCRIPTOR(u"IGraphicDumperClientListener"); - -protected: - enum { - IGRAPHIC_DUMPER_CLIENT_LISTENER_ON_CONFIG_CHANGE, - IGRAPHIC_DUMPER_CLIENT_LISTENER_ON_DUMP, - }; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_CLIENT_LISTENER_H diff --git a/frameworks/dumper/include/ipc/igraphic_dumper_command.h b/frameworks/dumper/include/ipc/igraphic_dumper_command.h deleted file mode 100644 index a265ff1935..0000000000 --- a/frameworks/dumper/include/ipc/igraphic_dumper_command.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_COMMAND_H -#define FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_COMMAND_H - -#include - -#include - -#include "graphic_common.h" -#include "ipc/igraphic_dumper_info_listener.h" - -namespace OHOS { -class IGraphicDumperCommand : public IRemoteBroker { -public: - virtual GSError GetConfig(const std::string &k, std::string &v) = 0; - virtual GSError SetConfig(const std::string &k, const std::string &v) = 0; - virtual GSError Dump(const std::string &tag) = 0; - virtual GSError GetLog(const std::string &tag, std::string &log) = 0; - virtual GSError AddInfoListener(const std::string &tag, sptr &listener) = 0; - - DECLARE_INTERFACE_DESCRIPTOR(u"IGraphicDumperCommand"); - -protected: - enum { - IGRAPHIC_DUMPER_COMMAND_GET_CONFIG, - IGRAPHIC_DUMPER_COMMAND_SET_CONFIG, - IGRAPHIC_DUMPER_COMMAND_DUMP, - IGRAPHIC_DUMPER_COMMAND_GET_LOG, - IGRAPHIC_DUMPER_COMMAND_ADD_INFO_LISTENER, - }; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_COMMAND_H diff --git a/frameworks/dumper/include/ipc/igraphic_dumper_info_listener.h b/frameworks/dumper/include/ipc/igraphic_dumper_info_listener.h deleted file mode 100644 index 7005a0f4c3..0000000000 --- a/frameworks/dumper/include/ipc/igraphic_dumper_info_listener.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_INFO_LISTENER_H -#define FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_INFO_LISTENER_H - -#include - -#include - -namespace OHOS { -class IGraphicDumperInfoListener : public IRemoteBroker { -public: - virtual void OnInfoComing(const std::string &info) = 0; - DECLARE_INTERFACE_DESCRIPTOR(u"IGraphicDumperInfoListener"); - -protected: - enum { - IGRAPHIC_DUMPER_INFO_LISTENER_ON_INFO_COMING, - }; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_INFO_LISTENER_H diff --git a/frameworks/dumper/include/ipc/igraphic_dumper_service.h b/frameworks/dumper/include/ipc/igraphic_dumper_service.h deleted file mode 100644 index 8b4a69f40e..0000000000 --- a/frameworks/dumper/include/ipc/igraphic_dumper_service.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_SERVICE_H -#define FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_SERVICE_H - -#include - -#include - -#include "graphic_common.h" -#include "ipc/igraphic_dumper_client_listener.h" - -namespace OHOS { -class IGraphicDumperService : public IRemoteBroker { -public: - virtual GSError AddClientListener(const std::string &tag, sptr &listener) = 0; - virtual GSError SendInfo(const std::string &tag, const std::string &info) = 0; - DECLARE_INTERFACE_DESCRIPTOR(u"IGraphicDumperService"); - -protected: - enum { - IGRAPHIC_DUMPER_SERVICE_ADD_CLIENT_LISTENER, - IGRAPHIC_DUMPER_SERVICE_SEND_INFO, - }; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_DUMPRE_INCLUDE_IGRAPHIC_DUMPER_SERVICE_H diff --git a/frameworks/dumper/src/graphic_dumper_command_line.cpp b/frameworks/dumper/src/graphic_dumper_command_line.cpp deleted file mode 100644 index 942f72d2a1..0000000000 --- a/frameworks/dumper/src/graphic_dumper_command_line.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_command_line.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "graphic_dumper_hilog.h" -#include "graphic_dumper_util.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperCommandLine" }; -constexpr int SLEEP_TIME = 5 * 1000; -Promise signalPromise; - -static void Helper() -{ - std::cerr << - "Usage: [options]\n" - "options include:\n" - " -h --help show this message.\n" - " -w --wait wait mode; listen for new prints.\n" - " -g , --get \n" - " get config with key.\n" - " -s =, --set =\n" - " set config of key is equal to value.\n" - " -l --log \n" - " read log with tag.\n" - " -d --dump \n" - " read dump info with tag.\n" - " read all dump info with --all.\n" - << std::endl; -} -} // namespace - -sptr GraphicDumperCommandLine::GetInstance() -{ - if (instance_ == nullptr) { - static std::mutex mutex; - std::lock_guard guard(mutex); - if (instance_ == nullptr) { - instance_ = new GraphicDumperCommandLine(); - } - } - return instance_; -} - -void GraphicDumperCommandLine::OnInfoComing(const std::string &info) -{ - std::cerr << info.c_str() << std::endl; -} - -void Handler(int signal) -{ - switch (signal) { - case SIGINT: - case SIGTERM: - case SIGTSTP: - case SIGQUIT: - case SIGHUP: { - signalPromise.Resolve(signal); - break; - } - default: - break; - } -} - -void SignalInit() -{ - std::signal(SIGINT, Handler); - std::signal(SIGKILL, Handler); - std::signal(SIGTERM, Handler); - std::signal(SIGTSTP, Handler); - std::signal(SIGQUIT, Handler); - std::signal(SIGHUP, Handler); -} - -GSError GraphicDumperCommandLine::Main(int32_t argc, char *argv[]) -{ - GSError iRet = GSERROR_OK; - if (argc <= 1) { - Helper(); - return iRet; - } - - iRet = Parse(argc, argv); - if (iRet != GSERROR_OK) { - return iRet; - } - - SignalInit(); - - iRet = InitSA(GRAPHIC_DUMPER_COMMAND_SA_ID); - if (iRet != GSERROR_OK) { - std::cerr << "Init SA failed: " << GSErrorStr(iRet) << std::endl; - return iRet; - } - - sptr listener = this; - iRet = service_->AddInfoListener("", listener); - if (iRet != GSERROR_OK) { - std::cerr << "Add info listener failed: " << GSErrorStr(iRet) << std::endl; - return iRet; - } - - HandlerOfArgs(); - usleep(SLEEP_TIME); - return GSERROR_OK; -} - -void GraphicDumperCommandLine::HandlerOfArgs() -{ - if (!dumperArgs_.dumpTag.empty()) { - service_->Dump("*#dp#*." + dumperArgs_.dumpTag); - std::cerr << "get dump with tag:" << dumperArgs_.dumpTag.c_str() << std::endl; - } - if (!dumperArgs_.logTag.empty()) { - std::string getLog = {}; - std::cerr << "get log with tag:" << dumperArgs_.logTag.c_str() << std::endl; - service_->GetLog(dumperArgs_.logTag, getLog); - std::cerr << "log is" << getLog.c_str() << std::endl; - } - if (!dumperArgs_.getCfgKey.empty()) { - std::string getCfgValue = {}; - service_->GetConfig(dumperArgs_.getCfgKey, getCfgValue); - std::cerr << "get cfg with key:" << dumperArgs_.getCfgKey.c_str() << "value is:" - << getCfgValue.c_str() << std::endl; - } - if ((!dumperArgs_.setCfgKey.empty()) && (!dumperArgs_.setCfgKey.empty())) { - service_->SetConfig(dumperArgs_.setCfgKey, dumperArgs_.setCfgValue); - std::cerr << "set cfg with key:" << dumperArgs_.setCfgKey.c_str() << "value is:" - << dumperArgs_.setCfgValue.c_str() << std::endl; - } - if (dumperArgs_.wait) { - signalPromise.Await(); - } -} - -GSError GraphicDumperCommandLine::OptionParse(const char option) -{ - switch (option) { - case 'h': { - Helper(); - return GSERROR_OK; - } - case 'w': { - dumperArgs_.wait = true; - break; - } - case 'g': { - dumperArgs_.getCfgKey = optarg; - break; - } - case 's': { - auto ret = Split(optarg, "="); - if (ret.size() != CFGTERMSIZE) { - std::cerr << "Parameter format error." << std::endl; - return GSERROR_INVALID_OPERATING; - } - dumperArgs_.setCfgKey = ret[0]; - dumperArgs_.setCfgValue = ret[1]; - break; - } - case 'l': { - dumperArgs_.logTag = optarg; - break; - } - case 'd': { - dumperArgs_.dumpTag = optarg; - break; - } - default: { - std::cerr << "Command not found." << std::endl; - return GSERROR_INVALID_OPERATING; - } - } // switch - return GSERROR_OK; -} - -GSError GraphicDumperCommandLine::Parse(int32_t argc, char *argv[]) -{ - int optIndex = 0; - static const struct option longOptions[] = { - { "help", no_argument, nullptr, 'h' }, - { "wait", no_argument, nullptr, 'w' }, - { "log", required_argument, nullptr, 'l' }, - { "dump", required_argument, nullptr, 'd' }, - { "get", required_argument, nullptr, 'g' }, - { "set", required_argument, nullptr, 's' }, - {nullptr, 0, nullptr, 0} - }; - - while (true) { - int opt = getopt_long(argc, argv, "hwg:s:l:d:", longOptions, &optIndex); - if (opt == -1) { - break; - } - auto ret = OptionParse(opt); - if (ret != GSERROR_OK) { - return ret; - } - } // while - return GSERROR_OK; -} - -GSError GraphicDumperCommandLine::InitSA(int32_t systemAbilityId) -{ - if (service_ != nullptr) { - GDLOG_SUCCESS("_instance != nullptr"); - return GSERROR_OK; - } - - auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (sm == nullptr) { - GDLOG_FAILURE_RET(GSERROR_CONNOT_CONNECT_SAMGR); - } - - auto remoteObject = sm->GetSystemAbility(systemAbilityId); - if (remoteObject == nullptr) { - GDLOG_FAILURE_RET(GSERROR_CONNOT_CONNECT_SERVER); - } - - sptr deathRecipient = new GDumperCommandDeathRecipient(); - if ((remoteObject->IsProxyObject()) && (!remoteObject->AddDeathRecipient(deathRecipient))) { - GDLOGFE("Failed to add death recipient"); - } - - service_ = iface_cast(remoteObject); - if (service_ == nullptr) { - GDLOG_FAILURE_RET(GSERROR_PROXY_NOT_INCLUDE); - } - - GDLOG_SUCCESS("service_ = iface_cast"); - return GSERROR_OK; -} - -void GDumperCommandDeathRecipient::OnRemoteDied(const wptr &object) -{ - GDLOGFE("Command server Died!"); - std::raise(SIGQUIT); -} -} // namespace OHOS diff --git a/frameworks/dumper/src/graphic_dumper_command_line_main.cpp b/frameworks/dumper/src/graphic_dumper_command_line_main.cpp deleted file mode 100644 index 435f143773..0000000000 --- a/frameworks/dumper/src/graphic_dumper_command_line_main.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_command_line.h" - -using namespace OHOS; - -int32_t main(int32_t argc, char *argv[]) -{ - return GraphicDumperCommandLine::GetInstance()->Main(argc, argv); -} diff --git a/frameworks/dumper/src/graphic_dumper_helper.cpp b/frameworks/dumper/src/graphic_dumper_helper.cpp deleted file mode 100644 index 90894ac68a..0000000000 --- a/frameworks/dumper/src/graphic_dumper_helper.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_helper.h" - -#include - -#include - -#include "graphic_dumper_helper_impl.h" - -namespace OHOS { -sptr GraphicDumperHelper::GetInstance() -{ - return GraphicDumperHelperImpl::GetInstance(); -} -} // namespace OHOS - -int SendInfo(const char* tag, const char *fmt, ...) -{ - constexpr int infoSize = 4096; - char info[infoSize]; - va_list args; - va_start(args, fmt); - int ret = vsnprintf_s(info, sizeof(info), (sizeof(info) - 1), fmt, args); - if (ret < 0) { - va_end(args); - return 0; - } - va_end(args); - return OHOS::GraphicDumperHelperImpl::GetInstance()->SendInfo(std::string(tag), "%s", info); -} - -int AddConfigChangeListener(const char* tag, OnConfigChangeFuncPtr func) -{ - auto cfunc = [func](const std::string &a, const std::string &b) { - func(a.c_str(), b.c_str()); - }; - return OHOS::GraphicDumperHelperImpl::GetInstance()->AddConfigChangeListener(std::string(tag), cfunc); -} - -int RemoveConfigChangeListener(int listenerId) -{ - return OHOS::GraphicDumperHelperImpl::GetInstance()->RemoveConfigChangeListener(listenerId); -} - -int AddDumpListener(const char* tag, OnDumpFuncPtr func) -{ - return OHOS::GraphicDumperHelperImpl::GetInstance()->AddDumpListener(std::string(tag), func); -} - -int RemoveDumpListener(int listenerId) -{ - return OHOS::GraphicDumperHelperImpl::GetInstance()->RemoveDumpListener(listenerId); -} diff --git a/frameworks/dumper/src/graphic_dumper_helper_impl.cpp b/frameworks/dumper/src/graphic_dumper_helper_impl.cpp deleted file mode 100644 index 074bbfb9ef..0000000000 --- a/frameworks/dumper/src/graphic_dumper_helper_impl.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_helper_impl.h" - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "graphic_dumper_hilog.h" -#include "ipc/igraphic_dumper_command.h" - -namespace OHOS { -namespace { -DEFINE_HILOG_LABEL("GraphicDumperHelperImpl"); -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperHelperImpl" }; -constexpr int INFO_SIZE_MAX = 4096; -} - -GraphicDumperClientListener::GraphicDumperClientListener(sptr& helper) - : helperImpl_(helper) -{ -} - -void GraphicDumperClientListener::OnConfigChange(const std::string &tag, const std::string &val) -{ - GDLOGI("%{public}s -> %{public}s", tag.c_str(), val.c_str()); - if (helperImpl_) { - helperImpl_->DispenseOnConfigChange(tag, val); - } -} - -void GraphicDumperClientListener::OnDump(const std::string &tag) -{ - if (helperImpl_) { - std::string flag = "*#dp#*."; - if (tag.find(flag) == 0) { - std::string sTag = tag.substr(flag.length()); - helperImpl_->DispenseOnDump(sTag); - } - } -} - -sptr GraphicDumperHelperImpl::GetInstance() -{ - if (currentHelper == nullptr) { - static std::mutex mutex; - std::lock_guard guard(mutex); - if (currentHelper == nullptr) { - currentHelper = new GraphicDumperHelperImpl(); - } - } - return currentHelper; -} - -void GraphicDumperHelperImpl::SetNoopInstance() -{ - static std::mutex mutex; - std::lock_guard guard(mutex); - currentHelper = new GraphicDumperHelperNoop(); -} - -GSError GraphicDumperHelperImpl::Init() -{ - if (serverConnected) { - return GSERROR_OK; - } - - if (access("/data/gdumper_enable", F_OK) != 0) { - SetNoopInstance(); - return GSERROR_NOT_SUPPORT; - } - - auto now = std::chrono::steady_clock::now().time_since_epoch(); - auto nowTime = (int64_t)std::chrono::duration_cast(now).count(); - constexpr int64_t reconnectTime = 1000; - if ((nowTime - requestConnectTime) < reconnectTime) { - return GSERROR_OUT_OF_RANGE; - } - - requestConnectTime = nowTime; - GSError ret = InitSA(GRAPHIC_DUMPER_SERVICE_SA_ID); - if (ret != GSERROR_OK) { - GSLOG2HI(ERROR) << "InitSA failed with " << ret; - return ret; - } - - { - std::lock_guard guard(onConfigChangeMutex_); - for (const auto& iter : onConfigChangeMap_) { - ret = AddClientListener(iter.first); - if (ret != GSERROR_OK) { - return ret; - } - } - } - - { - std::lock_guard guard(onDumperFuncsMutex_); - for (const auto& iter : onDumpFuncsMap_) { - ret = AddClientListener(iter.first); - if (ret != GSERROR_OK) { - return ret; - } - } - } - - { - std::lock_guard guard(cacheInfoMutex_); - for (const auto& infoStruct : cacheInfo_) { - ret = service_->SendInfo(infoStruct.tag, infoStruct.info); - GDLOG_SUCCESS("SendInfo is %{public}d", ret); - } - cacheInfo_.clear(); - cacheInfo_.shrink_to_fit(); - } - return ret; -} - -GSError GraphicDumperHelperImpl::InitSA(int32_t systemAbilityId) -{ - if (serverConnected) { - return GSERROR_OK; - } - - auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (sam == nullptr) { - GSLOG2HI(ERROR) << "failed with " << GSERROR_CONNOT_CONNECT_SAMGR; - return GSERROR_CONNOT_CONNECT_SAMGR; - } - - auto remoteObject = sam->GetSystemAbility(systemAbilityId); - if (remoteObject == nullptr) { - GSLOG2HI(ERROR) << "failed with " << GSERROR_CONNOT_CONNECT_SERVER; - return GSERROR_CONNOT_CONNECT_SERVER; - } - - sptr deathRecipient = new GDumperServiceDeathRecipient(); - if ((remoteObject->IsProxyObject()) && (!remoteObject->AddDeathRecipient(deathRecipient))) { - GSLOG2HI(WARN) << "failed to add death recipient"; - } - - service_ = iface_cast(remoteObject); - if (service_ == nullptr) { - GSLOG2HI(ERROR) << "failed with " << GSERROR_PROXY_NOT_INCLUDE; - return GSERROR_PROXY_NOT_INCLUDE; - } - - serverConnected = true; - GSLOG2HI(INFO) << "service_ = iface_cast"; - return GSERROR_OK; -} - -GSError GraphicDumperHelperImpl::AddClientListener(const std::string &tag) -{ - if (Init() != GSERROR_OK) { - GSLOG2HI(ERROR) << "Init() failed"; - return GSERROR_CONNOT_CONNECT_SERVER; - } - - if (listener_ == nullptr) { - std::lock_guard guard(clientListenerMutex_); - if (listener_ == nullptr) { - sptr helper = this; - listener_ = new GraphicDumperClientListener(helper); - } - } - - GSLOG2HI(INFO) << "AddClientListener Success"; - return service_->AddClientListener(tag, listener_); -} - -GSError GraphicDumperHelperImpl::SendInfo(const std::string &tag, const char *fmt, ...) -{ - char info[INFO_SIZE_MAX]; // clear by vsnprintf - { - static std::mutex sprintfMutex_; - std::lock_guard lock(sprintfMutex_); - va_list args; - va_start(args, fmt); - int ret = vsnprintf_s(info, sizeof(info), (sizeof(info) - 1), fmt, args); - if (ret < 0) { - va_end(args); - return GSERROR_INVALID_ARGUMENTS; - } - va_end(args); - } - GSError retInit = Init(); - if (retInit == GSERROR_OK) { - return service_->SendInfo(tag, std::string(info)); - } else if (retInit == GSERROR_NOT_SUPPORT) { - return retInit; - } else { - struct InfoStruct infoStruct = { - .tag = tag, - .info = info, - }; - std::lock_guard guard(cacheInfoMutex_); - cacheInfo_.push_back(infoStruct); - return GSERROR_OK; - } -} - -int32_t GraphicDumperHelperImpl::AddConfigChangeListener(const std::string &tag, OnConfigChangeFunc func) -{ - { - std::lock_guard guard(onConfigChangeMutex_); - if (onConfigChangeMap_.find(tag) != onConfigChangeMap_.end()) { - (*onConfigChangeMap_[tag])[++onConfigChangeFuncId_] = func; - return onConfigChangeFuncId_; - } - } - int ret = AddClientListener(tag); - if (ret != GSERROR_OK) { - return 0; - } - auto onConfigChangeFuncs = std::make_unique>(); - (*onConfigChangeFuncs)[++onConfigChangeFuncId_] = func; - onConfigChangeMap_[tag] = std::move(onConfigChangeFuncs); - return onConfigChangeFuncId_; -} - -GSError GraphicDumperHelperImpl::RemoveConfigChangeListener(const int32_t listenerId) -{ - std::lock_guard guard(onConfigChangeMutex_); - for (auto& [k, v] : onConfigChangeMap_) { - if (v->find(listenerId) != v->end()) { - v->erase(listenerId); - return GSERROR_OK; - } - } - return GSERROR_INVALID_ARGUMENTS; -} - -int32_t GraphicDumperHelperImpl::AddDumpListener(const std::string &tag, OnDumpFunc func) -{ - { - std::lock_guard guard(onDumperFuncsMutex_); - if (onDumpFuncsMap_.find(tag) != onDumpFuncsMap_.end()) { - (*onDumpFuncsMap_[tag])[++onDumperFuncId_] = func; - return onDumperFuncId_; - } - } - auto dumpTag = "*#dp#*." + tag; - int ret = AddClientListener(dumpTag); - if (ret != GSERROR_OK) { - GSLOG2HI(ERROR) << "AddClientListener failed with " << ret; - return 0; - } - auto onDumpFuncs = std::make_unique>(); - (*onDumpFuncs)[++onDumperFuncId_] = func; - onDumpFuncsMap_[tag] = std::move(onDumpFuncs); - return onDumperFuncId_; -} - -GSError GraphicDumperHelperImpl::RemoveDumpListener(const int32_t listenerId) -{ - std::lock_guard guard(onDumperFuncsMutex_); - for (auto& [k, v] : onDumpFuncsMap_) { - if (v->find(listenerId) != v->end()) { - v->erase(listenerId); - return GSERROR_OK; - } - } - return GSERROR_INVALID_ARGUMENTS; -} - -void GraphicDumperHelperImpl::SetConnectState(bool state) -{ - GDLOGFI(""); - serverConnected = state; -} - -void GraphicDumperHelperImpl::DispenseOnConfigChange(const std::string &tag, const std::string &val) -{ - GDLOGI("%{public}s -> %{public}s", tag.c_str(), val.c_str()); - std::lock_guard guard(onConfigChangeMutex_); - if (onConfigChangeMap_.empty()) { - return; - } - if (!onConfigChangeMap_[tag]->empty()) { - for (const auto &[id, func] : *onConfigChangeMap_[tag]) { - func(tag, val); - } - } -} - -void GraphicDumperHelperImpl::DispenseOnDump(const std::string &tag) -{ - std::lock_guard guard(onDumperFuncsMutex_); - if (onDumpFuncsMap_.empty()) { - return; - } - - if (tag == "--all") { - for (const auto& [t, mapPtr] : onDumpFuncsMap_) { - if (mapPtr != nullptr) { - for (const auto &[id, func] : *mapPtr) { - func(); - } - } - } - return; - } - - if (onDumpFuncsMap_.find(tag) != onDumpFuncsMap_.end()) { - if (onDumpFuncsMap_[tag] != nullptr) { - for (const auto &[id, func] : *onDumpFuncsMap_[tag]) { - func(); - } - } - } -} - -void GDumperServiceDeathRecipient::OnRemoteDied(const wptr &object) -{ - auto helper = GraphicDumperHelperImpl::GetInstance(); - auto helperImpl = reinterpret_cast(helper.GetRefPtr()); - helperImpl->SetConnectState(false); -} -} // namespace OHOS diff --git a/frameworks/dumper/src/graphic_dumper_server.cpp b/frameworks/dumper/src/graphic_dumper_server.cpp deleted file mode 100644 index 66f37deb20..0000000000 --- a/frameworks/dumper/src/graphic_dumper_server.cpp +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_server.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "ipc/graphic_dumper_info_listener_death_recipient.h" -#include "ipc/graphic_dumper_client_listener_death_recipient.h" -#include "ipc/graphic_dumper_service_stub.h" -#include "ipc/graphic_dumper_command_stub.h" -#include "graphic_dumper_hilog.h" -#include "graphic_dumper_util.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperServer" }; -constexpr int SLEEP_TIME = 500 * 1000; -constexpr uint32_t LOG_BUF_SIZE_MAX = 192 * 1024; -constexpr uint32_t LOG_BLOCK_SIZE_MAX = 4 * 1000 * 1024; -constexpr uint32_t LOG_VEC_SIZE = 2; -constexpr const char *GDUMPER_INI_PATH = "/system/etc/gdumper.ini"; - -std::string& Trim (std::string &s) -{ - std::regex fmt("\\s"); - s = std::regex_replace(s, fmt, ""); - return s; -} - -void StrLogRomveTag(bool getAll, const std::string &tag, - const std::string &strIn, std::string &strOut) -{ - auto pos = strIn.find_first_of("| ["); - constexpr int offset = 2; - if (pos == std::string::npos) { - pos = 0; - } else { - pos += offset; - } - if (getAll) { - strOut += strIn.substr(pos); - } else if (strIn.compare(0, tag.size(), tag) == 0) { - strOut += strIn.substr(pos); - } -} -} // namespace - -sptr GraphicDumperServer::GetInstance() -{ - if (instance_ == nullptr) { - static std::mutex mutex; - std::lock_guard guard(mutex); - if (instance_ == nullptr) { - instance_ = new GraphicDumperServer(); - } - } - return instance_; -} - -int32_t GraphicDumperServer::Init() -{ - int32_t ret = 0; - ret = ReadDefaultConfig(); - if (ret) { - GDLOGI("Read default config error with %d.\n", ret); - } - - for (auto& s : logBuf_.size) { - s = 0; - logBuf_.vec.push_back(std::make_unique>()); - } - - sptr service = new GraphicDumperServiceStub(); - ret = StartServer(GRAPHIC_DUMPER_SERVICE_SA_ID, service); - if (ret) { - GDLOGI("Start graphic dumper service failed: %d\n", ret); - return ret; - } - - sptr command = new GraphicDumperCommandStub(); - ret = StartServer(GRAPHIC_DUMPER_COMMAND_SA_ID, command); - if (ret) { - GDLOGI("Start graphic dumper command failed: %d\n", ret); - return ret; - } - return ret; -} - -GSError GraphicDumperServer::AddConfigListener(const std::string &tag, - sptr &listener) -{ - if (listener == nullptr) { - return GSERROR_INVALID_ARGUMENTS; - } - GDLOGFE("%{public}s", tag.c_str()); - - auto object = listener->AsObject(); - AddConfigDeathRecipient(object); - - if (HaveObject(object) == false) { - objectIdMap_[object] = ++objectId_; - configTagsMap_[objectId_].id = objectId_; - configTagsMap_[objectId_].listener = listener; - } - auto &objectId = objectIdMap_[object]; - auto &configTags = configTagsMap_[objectId]; - for (const auto &iter : configTags.tags) { - if (iter == tag) { - return GSERROR_OK; - } - } - configTags.tags.push_back(tag); - - for (auto &tag__ : configTags.tags) { - GDLOGFE("configTagsMap %{public}s", tag__.c_str()); - } - std::lock_guard lock(treeMutex_); - std::vector nodes = Split(tag, "."); - TreeNodePtr sub = root; - for (const auto& iter : nodes) { - sub = sub->GetSetNode(iter); - } - sub->AddListenerId(configTags.id); - - return GSERROR_OK; -} - -GSError GraphicDumperServer::RemoveConfigListener(sptr object) -{ - if (object == nullptr) { - return GSERROR_INVALID_ARGUMENTS; - } - auto &deathRecipient = configListenerDeathRecipientMap_[object]; - if (deathRecipient != nullptr) { - object->RemoveDeathRecipient(deathRecipient); - } - configListenerDeathRecipientMap_.erase(object); - - auto &objectId = objectIdMap_[object]; - auto &configTags = configTagsMap_[objectId]; - - for (auto &tag : configTags.tags) { - GDLOGFE("configTagsMap %{public}s", tag.c_str()); - std::lock_guard lock(treeMutex_); - std::vector nodes = Split(tag, "."); - TreeNodePtr sub = root; - RemoveNode(nodes, sub, configTags.id); - } - - object = nullptr; - return GSERROR_OK; -} - -GSError GraphicDumperServer::GetConfig(const std::string &k, std::string &v) -{ - GDLOGI("%{public}s -> %{public}s", k.c_str(), v.c_str()); - std::lock_guard lock(treeMutex_); - std::vector nodes = Split(k, "."); - TreeNodePtr sub = root; - for (const auto& iter : nodes) { - if (sub->HasNode(iter)) { - sub = sub->GetSetNode(iter); - } else { - return GSERROR_INVALID_ARGUMENTS; - } - } - v = sub->GetValue(); - GDLOGI("%{public}s -> %{public}s", k.c_str(), v.c_str()); - return GSERROR_OK; -} - -GSError GraphicDumperServer::SetConfig(const std::string &k, const std::string &v) -{ - GDLOGI("%{public}s -> %{public}s", k.c_str(), v.c_str()); - std::lock_guard lock(treeMutex_); - std::vector nodes = Split(k, "."); - TreeNodePtr sub = root; - for (const auto& iter : nodes) { - sub = sub->GetSetNode(iter); - } - if (sub->GetValue().compare(v)) { - sub->SetValue(v); - DispenseConfig(sub, k, v); - } - GDLOGI("%{public}s -> %{public}s", k.c_str(), v.c_str()); - return GSERROR_OK; -} - -GSError GraphicDumperServer::Dump(const std::string &tag) -{ - std::lock_guard lock(treeMutex_); - std::vector nodes = Split(tag, "."); - TreeNodePtr sub = root; - for (const auto& iter : nodes) { - if (iter.compare("--all") == 0) { - break; - } - GDLOGFE("%{public}s", iter.c_str()); - sub = sub->GetSetNode(iter); - } - DispenseDump(sub, tag); - GDLOGFE("%{public}s", tag.c_str()); - return GSERROR_OK; -} - -GSError GraphicDumperServer::AddInfoListener(sptr &listener) -{ - if (listener == nullptr) { - return GSERROR_INVALID_ARGUMENTS; - } - std::lock_guard guard(infoListenersMutex_); - auto object = listener->AsObject(); - AddInfoDeathRecipient(object); - infoListeners_[object] = listener; - return GSERROR_OK; -} - -GSError GraphicDumperServer::RemoveInfoListener(const wptr &object) -{ - std::lock_guard guard(infoListenersMutex_); - auto sObject = object.promote(); - if (infoListeners_.find(sObject) != infoListeners_.end()) { - infoListeners_.erase(sObject); - } - if (infoListeners_.empty()) { - logBuf_.sync = false; - logBuf_.mask.clear(); - } - return GSERROR_OK; -} - -GSError GraphicDumperServer::InfoHandle(const std::string &tag, const std::string &info) -{ - GDLOGFE("GraphicDumperServer::InfoHandle --start!!!!!!!!!"); - std::string logFlag = {"log."}; - GDLOGFE("%{public}s -> %{public}s", tag.c_str(), info.c_str()); - if (tag.compare(0, logFlag.size(), logFlag) == 0) { - GDLOGFE("InfoHandle to LogHandle"); - return LogHandle(tag.substr(logFlag.size()), info); - } - GDLOGFE("InfoHandle to SendToInfoListener"); - SendToInfoListener(tag + " : " + info); - return GSERROR_OK; -} -GSError GraphicDumperServer::GetLog(const std::string &tag, const std::string &info) -{ - GDLOGFE("%{public}s -> %{public}s", tag.c_str(), info.c_str()); - bool getAll = false; - if (tag.compare("--all") == 0) { - getAll = true; - logBuf_.mask.clear(); - } else { - logBuf_.mask = tag; - } - - { - std::lock_guard lock(logBlockVectorMutex_); - for (const auto& array : logBlockVector_) { - auto logBlock = reinterpret_cast(array.get()); - std::string toSendStr = {}; - uint32_t offset = 0; - GDLOGFE("logBlock->size = %{public}d", logBlock->size); - while (offset < logBlock->size) { - std::string str(reinterpret_cast(logBlock->data + offset)); - GDLOGFE("logBlock = %{public}s", str.c_str()); - StrLogRomveTag(getAll, tag, str, toSendStr); - offset += (str.size() + 1); - } - SendToInfoListener(toSendStr); - } - } - - std::string logStr = {}; - if (logBuf_.canSave || logBuf_.needSave) { - uint32_t index = (logBuf_.index + 1) % LOG_VEC_SIZE; - std::lock_guard guard(logBuf_.mutex[index]); - for (const auto& str : *logBuf_.vec[index]) { - GDLOGFE("logBuf_cansave = %{public}s", str.c_str()); - StrLogRomveTag(getAll, tag, str, logStr); - } - } - SendToInfoListener(logStr); - - logStr.clear(); - - { - uint32_t index = logBuf_.index; - std::lock_guard guard(logBuf_.mutex[index]); - for (const auto& str : *logBuf_.vec[index]) { - GDLOGFE("logBuf_ = %{public}s", str.c_str()); - StrLogRomveTag(getAll, tag, str, logStr); - } - } - SendToInfoListener(logStr); - - logBuf_.sync = true; - return GSERROR_OK; -} - -int32_t GraphicDumperServer::StartServer(int32_t systemAbility, sptr obj) -{ - if (systemAbility == 0 || obj == nullptr) { - GDLOGI("graphic dumper start_server parameter error"); - return 1; - } - - int result = 0; - while (1) { - auto sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (sm != nullptr) { - result = sm->AddSystemAbility(systemAbility, obj); - break; - } - GDLOGI("graphic dumper start_server SystemAbilityManager is nullptr"); - usleep(SLEEP_TIME); - } - return result; -} - -int32_t GraphicDumperServer::ReadDefaultConfig() -{ - int32_t successConst = 0; - int32_t failConst = 0; - std::string getLineStr = {}; - std::vector cfgStrs = {}; - std::ifstream input(GDUMPER_INI_PATH); - if (!input.is_open()) { - GDLOGE("failed to open: %{public}s", GDUMPER_INI_PATH); - } else { - while (!input.eof()) { - getline(input, getLineStr); - Trim(getLineStr); - std::string first = getLineStr.substr(0, 1); - if (first != "#" && first != "") { - cfgStrs.push_back(getLineStr); - } - } - input.clear(); - input.close(); - } - - std::lock_guard lock(treeMutex_); - for (auto iter : cfgStrs) { - if (!iter.empty()) { - std::vector cfg = Split(iter, "="); - if (cfg.size() != CFGTERMSIZE) { - failConst++; - GDLOGE("fail cfg(%{public}d): %{public}s", failConst, iter.c_str()); - } - std::vector nodes = Split(cfg[0], "."); - TreeNodePtr sub = root; - for (const auto& iter : nodes) { - sub = sub->GetSetNode(iter); - } - sub->SetValue(cfg[1]); - successConst++; - } - } - GDLOGI("There are %{public}d items successfully configured", successConst); - return failConst; -} - -void GraphicDumperServer::AddConfigDeathRecipient(sptr &object) -{ - if (!HaveConfigDeathRecipient(object)) { - sptr deathRecipient = new GraphicDumperClientListenerDeathRecipient(); - if ((object->IsProxyObject()) && (!object->AddDeathRecipient(deathRecipient))) { - GDLOGFE("Failed to add death recipient"); - } - configListenerDeathRecipientMap_[object] = deathRecipient; - } -} - -bool GraphicDumperServer::HaveConfigDeathRecipient(sptr &object) -{ - auto &map = configListenerDeathRecipientMap_; - return map.find(object) != map.end(); -} - -bool GraphicDumperServer::HaveObject(const sptr &obj) -{ - return objectIdMap_.find(obj) != objectIdMap_.end(); -} - -void GraphicDumperServer::VisitEach(const TreeNodePtr &node, TreeNodeVisitFunc func) -{ - GDLOGFI(""); - TreeNodeVisitFunc getV = [&](const TreeNodePtr &v) { - GDLOGFI(""); - func(v); - v->Foreach(getV); - }; - node->Foreach(getV); -} - -void GraphicDumperServer::RemoveNode(std::vector &vec, - TreeNodePtr &sub, - uint32_t &listenerId) -{ - GDLOGFE("listener: %{public}u", listenerId); - if (vec.empty() || sub == nullptr || listenerId == 0) { - return; - } - std::string tag = *vec.begin(); - GDLOGFE("tag: %{public}s", tag.c_str()); - vec.erase(vec.begin()); - - if (sub->HasNode(tag)) { - TreeNodePtr subNd = sub->GetSetNode(tag); - if (vec.empty()) { - subNd->RemoveListenerId(listenerId); - return; - } - RemoveNode(vec, subNd, listenerId); - if (subNd->IsEmptyNode()) { - sub->EraseNode(subNd->GetTag()); - } - } -} - -void GraphicDumperServer::DispenseConfig(const TreeNodePtr &node, const std::string &k, const std::string &v) -{ - GDLOGFI("%{public}s -> %{public}s", k.c_str(), v.c_str()); - auto dispenseConfig = [&](const TreeNodePtr &nd) { - GDLOGFI("%{public}s -> %{public}s", k.c_str(), v.c_str()); - auto ls = nd->GetListenerIds(); - for (const auto& id : ls) { - configTagsMap_[id].listener->OnConfigChange(k, v); - } - }; - dispenseConfig(node); - VisitEach(node, dispenseConfig); -} - -void GraphicDumperServer::DispenseDump(const TreeNodePtr &node, const std::string &tag) -{ - GDLOGFI("%{public}s", tag.c_str()); - auto dispenseDump = [&](const TreeNodePtr &nd) { - GDLOGFI("%{public}s", tag.c_str()); - auto ls = nd->GetListenerIds(); - for (const auto& id : ls) { - configTagsMap_[id].listener->OnDump(tag); - } - }; - dispenseDump(node); - VisitEach(node, dispenseDump); -} - -void GraphicDumperServer::AddInfoDeathRecipient(sptr &object) -{ - if (!HaveInfoDeathRecipient(object)) { - sptr deathRecipient = new GraphicDumperInfoListenerDeathRecipient(); - if ((object->IsProxyObject()) && (!object->AddDeathRecipient(deathRecipient))) { - GDLOGFE("Failed to add death recipient"); - } - infoListenerDeathRecipientMap_[object] = deathRecipient; - } -} - -bool GraphicDumperServer::HaveInfoDeathRecipient(sptr &object) -{ - auto &map = infoListenerDeathRecipientMap_; - return map.find(object) != map.end(); -} - -void GraphicDumperServer::SendToInfoListener(const std::string &info) -{ - std::lock_guard guard(infoListenersMutex_); - for (const auto& [k, v] : infoListeners_) { - v->OnInfoComing(info); - } -} - -void GraphicDumperServer::SaveLog(std::any server) -{ - auto serverPtr = std::any_cast(server); - uint32_t index = (serverPtr->logBuf_.index + 1) % LOG_VEC_SIZE; - std::lock_guard guard(serverPtr->logBuf_.mutex[index]); - - uint32_t size = sizeof(LogBlock) + serverPtr->logBuf_.size[index] + 1; - auto logArray = std::make_unique(size); - auto logBlock = reinterpret_cast(logArray.get()); - logBlock->size = serverPtr->logBuf_.size[index]; - logBlock->length = serverPtr->logBuf_.size[index]; - uint32_t offset = 0; - for (const auto& str : *serverPtr->logBuf_.vec[index]) { - int ret = memcpy_s(logBlock->data + offset, - serverPtr->logBuf_.size[index] - offset, - str.c_str(), str.size() + 1); - if (ret < 0) { - return; - } - offset += str.size() + 1; - } - std::lock_guard lock(serverPtr->logBlockVectorMutex_); - if ((serverPtr->logBlockSize_ + serverPtr->logBuf_.size[index]) > LOG_BLOCK_SIZE_MAX) { - auto logFirstBlock = reinterpret_cast(serverPtr->logBlockVector_.begin()->get()); - serverPtr->logBlockSize_ -= logFirstBlock->size; - serverPtr->logBlockVector_.erase(serverPtr->logBlockVector_.begin()); - } - serverPtr->logBlockVector_.push_back(std::move(logArray)); - serverPtr->logBlockSize_ += serverPtr->logBuf_.size[index]; - serverPtr->logBuf_.vec[index]->clear(); - serverPtr->logBuf_.size[index] = 0; -} - -GSError GraphicDumperServer::LogHandle(const std::string &tag, const std::string &info) -{ - std::string log = tag + " | " + info; - GDLOGFI("%{public}s -> %{public}s", tag.c_str(), info.c_str()); - { - std::lock_guard guard(logBuf_.mutex[logBuf_.index]); - logBuf_.size[logBuf_.index] += log.size() + 1; - logBuf_.vec[logBuf_.index]->push_back(log); - if (logBuf_.canSave && (logBuf_.size[logBuf_.index] > (LOG_BUF_SIZE_MAX / LOG_VEC_SIZE))) { - thread_ = std::make_unique(&GraphicDumperServer::SaveLog, this); - logBuf_.needSave = true; - logBuf_.canSave = false; - } - if (logBuf_.size[logBuf_.index] >= LOG_BUF_SIZE_MAX) { - logBuf_.vec[logBuf_.index]->shrink_to_fit(); - if (logBuf_.needSave) { - thread_->join(); - logBuf_.needSave = false; - } - logBuf_.index = (logBuf_.index + 1) % LOG_VEC_SIZE; - logBuf_.canSave = true; - } - } - if (logBuf_.sync) { - if ((!logBuf_.mask.empty()) && (log.compare(0, logBuf_.mask.size(), logBuf_.mask) != 0)) { - return GSERROR_OK; - } - auto pos = log.find_first_of("| ["); - constexpr int offset = 2; - if (pos == std::string::npos) { - pos = 0; - } else { - pos += offset; - } - SendToInfoListener(log.substr(pos)); - } - return GSERROR_OK; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/graphic_dumper_server_main.cpp b/frameworks/dumper/src/graphic_dumper_server_main.cpp deleted file mode 100644 index f768b62f18..0000000000 --- a/frameworks/dumper/src/graphic_dumper_server_main.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "graphic_dumper_server.h" - -using namespace OHOS; - -int main() -{ - int ret = GraphicDumperServer::GetInstance()->Init(); - if (ret == 0) { - IPCSkeleton::JoinWorkThread(); - } - return ret; -} diff --git a/frameworks/dumper/src/graphic_dumper_tree.cpp b/frameworks/dumper/src/graphic_dumper_tree.cpp deleted file mode 100644 index e65eabd58d..0000000000 --- a/frameworks/dumper/src/graphic_dumper_tree.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_tree.h" - -#include "graphic_dumper_hilog.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperTree" }; -} // namespace - -TreeNodePtr GraphicDumperTree::GetSetNode(const std::string s) -{ - if (nodeMap_ == nullptr) { - nodeMap_ = std::make_unique(); - } - if (!HasNode(s)) { - (*nodeMap_)[s] = std::make_shared(); - (*nodeMap_)[s]->tag_ = s; - } - return (*nodeMap_)[s]; -} - -bool GraphicDumperTree::HasNode(const std::string s) -{ - return nodeMap_->find(s) != nodeMap_->end(); -} - -bool GraphicDumperTree::IsEmptyNode() -{ - if (nodeMap_->empty() && listenerIds_.empty()) { - return true; - } - return false; -} - -void GraphicDumperTree::EraseNode(const std::string &s) -{ - (*nodeMap_)[s] = nullptr; - nodeMap_->erase(s); -} - -std::string GraphicDumperTree::GetTag() -{ - return tag_; -} - -void GraphicDumperTree::SetValue(const std::string s) -{ - value_ = s; -} - -std::string GraphicDumperTree::GetValue() -{ - return value_; -} - -void GraphicDumperTree::AddListenerId(uint32_t &listenerId) -{ - GDLOGFI(""); - listenerIds_.push_back(listenerId); -} - -void GraphicDumperTree::RemoveListenerId(uint32_t &listenerId) -{ - GDLOGFI("%{public}u", listenerId); - for (auto iter = listenerIds_.begin(); iter != listenerIds_.end(); ++iter) { - GDLOGFI("%{public}u <==> %{public}u", (*iter), listenerId); - if (*iter == listenerId) { - GDLOGFI(""); - listenerIds_.erase(iter--); - } - } -} - -std::vector GraphicDumperTree::GetListenerIds() const -{ - GDLOGFI(""); - return listenerIds_; -} - -void GraphicDumperTree::Foreach(TreeNodeVisitFunc func) const -{ - GDLOGFI(""); - if (nodeMap_ == nullptr) { - return; - } - for (const auto& [k, v] : (*nodeMap_)) { - GDLOGFI("%{public}s", k.c_str()); - func(v); - } -} -} // namespace OHOS diff --git a/frameworks/dumper/src/graphic_dumper_util.cpp b/frameworks/dumper/src/graphic_dumper_util.cpp deleted file mode 100644 index 6eb36cb4cb..0000000000 --- a/frameworks/dumper/src/graphic_dumper_util.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graphic_dumper_util.h" - -namespace OHOS { -std::vector Split(std::string src, const std::string &splitStr) -{ - std::vector ret; - std::string::size_type pos = 0; - while (pos != std::string::npos) { - pos = src.find(splitStr); - if (pos == std::string::npos) { - if (!src.empty()) { - ret.push_back(src); - } - } else { - if (!src.empty()) { - ret.push_back(src.substr(0, pos)); - } - src = src.substr(pos + splitStr.size()); - } - } - return ret; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_client_listener_death_recipient.cpp b/frameworks/dumper/src/ipc/graphic_dumper_client_listener_death_recipient.cpp deleted file mode 100644 index 0d6117d705..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_client_listener_death_recipient.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_client_listener_death_recipient.h" - -#include "graphic_dumper_server.h" - -namespace OHOS { -void GraphicDumperClientListenerDeathRecipient::OnRemoteDied(const wptr &object) -{ - if (object == nullptr) { - return; - } - GraphicDumperServer::GetInstance()->RemoveConfigListener(object.promote()); -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_client_listener_proxy.cpp b/frameworks/dumper/src/ipc/graphic_dumper_client_listener_proxy.cpp deleted file mode 100644 index 0313d85a9c..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_client_listener_proxy.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_client_listener_proxy.h" - -#include -#include - -#include "graphic_dumper_hilog.h" -#include "graphic_common.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperClientListenerProxy" }; -} - -GraphicDumperClientListenerProxy::GraphicDumperClientListenerProxy(const sptr& impl) - : IRemoteProxy(impl) -{ -} - -void GraphicDumperClientListenerProxy::OnConfigChange(const std::string &tag, const std::string &val) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - GDLOGFI("%{public}s -> %{public}s", tag.c_str(), val.c_str()); - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(tag); - arg.WriteString(val); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_CLIENT_LISTENER_ON_CONFIG_CHANGE, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return; - } - return; -} - -void GraphicDumperClientListenerProxy::OnDump(const std::string &tag) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - GDLOGFI("%{public}s", tag.c_str()); - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(tag); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_CLIENT_LISTENER_ON_DUMP, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return; - } - return; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_client_listener_stub.cpp b/frameworks/dumper/src/ipc/graphic_dumper_client_listener_stub.cpp deleted file mode 100644 index 7a8635e044..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_client_listener_stub.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_client_listener_stub.h" - -#include "graphic_dumper_hilog.h" -#include "graphic_common.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperClientListenerStub" }; -} - -int32_t GraphicDumperClientListenerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - auto remoteDescriptor = data.ReadInterfaceToken(); - if (GetDescriptor() != remoteDescriptor) { - return 1; - } - - switch (code) { - case IGRAPHIC_DUMPER_CLIENT_LISTENER_ON_CONFIG_CHANGE: { - std::string tag = data.ReadString(); - std::string val = data.ReadString(); - GDLOGI("%{public}s -> %{public}s", tag.c_str(), val.c_str()); - OnConfigChange(tag, val); - reply.WriteInt32(GSERROR_OK); - } - break; - case IGRAPHIC_DUMPER_CLIENT_LISTENER_ON_DUMP: { - std::string val = data.ReadString(); - OnDump(val); - reply.WriteInt32(GSERROR_OK); - } - break; - default: - GDLOGFE("code %{public}d cannot process", code); - return 1; - } - return 0; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_command_proxy.cpp b/frameworks/dumper/src/ipc/graphic_dumper_command_proxy.cpp deleted file mode 100644 index 52a952720d..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_command_proxy.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_command_proxy.h" - -#include -#include - -#include "graphic_dumper_hilog.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperCommandProxy" }; -} - -GraphicDumperCommandProxy::GraphicDumperCommandProxy(const sptr& impl) - : IRemoteProxy(impl) -{ -} - -GSError GraphicDumperCommandProxy::GetConfig(const std::string &k, std::string &v) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - GDLOGFE("%{public}s -> %{public}s", k.c_str(), v.c_str()); - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(k); - arg.WriteString(v); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_COMMAND_GET_CONFIG, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_API_FAILED; - } - GSError retCode = static_cast(ret.ReadInt32()); - if (retCode == GSERROR_OK) { - v = ret.ReadString(); - GDLOGFE("%{public}s -> %{public}s", k.c_str(), v.c_str()); - } - return retCode; -} - -GSError GraphicDumperCommandProxy::SetConfig(const std::string &k, const std::string &v) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - GDLOGFE("%{public}s -> %{public}s", k.c_str(), v.c_str()); - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(k); - arg.WriteString(v); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_COMMAND_SET_CONFIG, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_API_FAILED; - } - return GSERROR_OK; -} - -GSError GraphicDumperCommandProxy::Dump(const std::string &tag) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - GDLOGFE("%{public}s", tag.c_str()); - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(tag); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_COMMAND_DUMP, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_API_FAILED; - } - return GSERROR_OK; -} - -GSError GraphicDumperCommandProxy::GetLog(const std::string &tag, std::string &log) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - GDLOGFE("%{public}s -> %{public}s", tag.c_str(), log.c_str()); - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(tag); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_COMMAND_GET_LOG, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_API_FAILED; - } - return GSERROR_OK; -} - -GSError GraphicDumperCommandProxy::AddInfoListener(const std::string &tag, sptr &listener) -{ - if (listener == nullptr) { - GDLOG_FAILURE_NO(GSERROR_INVALID_ARGUMENTS); - return GSERROR_INVALID_ARGUMENTS; - } - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - arg.WriteString(tag); - arg.WriteRemoteObject(listener->AsObject()); - - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_COMMAND_ADD_INFO_LISTENER, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_BINDER; - } - - GSError err = (GSError)ret.ReadInt32(); - if (err != GSERROR_OK) { - GDLOG_FAILURE_NO(err); - } - return err; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_command_stub.cpp b/frameworks/dumper/src/ipc/graphic_dumper_command_stub.cpp deleted file mode 100644 index 02623e1a94..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_command_stub.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_command_stub.h" - -#include "graphic_dumper_hilog.h" -#include "graphic_dumper_server.h" -#include "ipc/igraphic_dumper_command.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperCommandStub" }; -} - -int32_t GraphicDumperCommandStub::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - auto remoteDescriptor = data.ReadInterfaceToken(); - if (GetDescriptor() != remoteDescriptor) { - return 1; - } - switch (code) { - case IGRAPHIC_DUMPER_COMMAND_GET_CONFIG: { - std::string k = data.ReadString(); - std::string v = data.ReadString(); - GSError ret = GetConfig(k, v); - reply.WriteInt32(ret); - reply.WriteString(v); - break; - } - - case IGRAPHIC_DUMPER_COMMAND_SET_CONFIG: { - std::string k = data.ReadString(); - std::string v = data.ReadString(); - GSError ret = SetConfig(k, v); - reply.WriteInt32(ret); - break; - } - - case IGRAPHIC_DUMPER_COMMAND_DUMP: { - std::string v = data.ReadString(); - GSError ret = Dump(v); - reply.WriteInt32(ret); - break; - } - - case IGRAPHIC_DUMPER_COMMAND_GET_LOG: { - std::string tag = data.ReadString(); - std::string log = ""; - GSError ret = GetLog(tag, log); - reply.WriteInt32(ret); - break; - } - case IGRAPHIC_DUMPER_COMMAND_ADD_INFO_LISTENER: { - auto tag = data.ReadString(); - auto remoteObject = data.ReadRemoteObject(); - if (remoteObject == nullptr) { - reply.WriteInt32(GSERROR_INVALID_ARGUMENTS); - GDLOG_FAILURE_NO(GSERROR_INVALID_ARGUMENTS); - break; - } - - auto l = iface_cast(remoteObject); - GSError ret = AddInfoListener(tag, l); - reply.WriteInt32(ret); - if (ret != GSERROR_OK) { - GDLOG_FAILURE_NO(ret); - } - break; - } - default: { - return 1; - } - } - return 0; -} - -GSError GraphicDumperCommandStub::GetConfig(const std::string &k, std::string &v) -{ - GDLOGFE("%{public}s -> %{public}s", k.c_str(), v.c_str()); - GraphicDumperServer::GetInstance()->GetConfig(k, v); - GDLOGFE("%{public}s -> %{public}s", k.c_str(), v.c_str()); - return GSERROR_OK; -} - -GSError GraphicDumperCommandStub::SetConfig(const std::string &k, const std::string &v) -{ - GDLOGFE("%{public}s -> %{public}s", k.c_str(), v.c_str()); - GraphicDumperServer::GetInstance()->SetConfig(k, v); - return GSERROR_OK; -} - -GSError GraphicDumperCommandStub::Dump(const std::string &tag) -{ - GDLOGFE("%{public}s", tag.c_str()); - GraphicDumperServer::GetInstance()->Dump(tag); - return GSERROR_OK; -} - -GSError GraphicDumperCommandStub::GetLog(const std::string &tag, std::string &log) -{ - GDLOGFE("%{public}s -> %{public}s", tag.c_str(), log.c_str()); - GraphicDumperServer::GetInstance()->GetLog(tag, log); - return GSERROR_OK; -} - -GSError GraphicDumperCommandStub::AddInfoListener(const std::string &tag, sptr &listener) -{ - GDLOGFE(""); - if (listener == nullptr) { - return GSERROR_INVALID_ARGUMENTS; - } - return GraphicDumperServer::GetInstance()->AddInfoListener(listener); -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_info_listener_death_recipient.cpp b/frameworks/dumper/src/ipc/graphic_dumper_info_listener_death_recipient.cpp deleted file mode 100644 index a6b973e728..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_info_listener_death_recipient.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_info_listener_death_recipient.h" -#include "graphic_dumper_server.h" -#include "ipc/igraphic_dumper_command.h" -#include "graphic_common.h" -#include "graphic_dumper_hilog.h" -namespace OHOS { -void GraphicDumperInfoListenerDeathRecipient::OnRemoteDied(const wptr &object) -{ - if (object == nullptr) { - return; - } - GraphicDumperServer::GetInstance()->RemoveInfoListener(object); -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_info_listener_proxy.cpp b/frameworks/dumper/src/ipc/graphic_dumper_info_listener_proxy.cpp deleted file mode 100644 index efad0f22ef..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_info_listener_proxy.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_info_listener_proxy.h" - -#include -#include - -#include "graphic_dumper_hilog.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperInfoListenerProxy" }; -} - -GraphicDumperInfoListenerProxy::GraphicDumperInfoListenerProxy(const sptr& impl) - : IRemoteProxy(impl) -{ -} - -void GraphicDumperInfoListenerProxy::OnInfoComing(const std::string &info) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - - arg.WriteString(info); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_INFO_LISTENER_ON_INFO_COMING, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return; - } - return; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_info_listener_stub.cpp b/frameworks/dumper/src/ipc/graphic_dumper_info_listener_stub.cpp deleted file mode 100644 index 44eeb42f66..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_info_listener_stub.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_info_listener_stub.h" - -#include "graphic_dumper_hilog.h" -#include "graphic_common.h" - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperInfoListenerStub" }; -} - -int32_t GraphicDumperInfoListenerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - auto remoteDescriptor = data.ReadInterfaceToken(); - if (GetDescriptor() != remoteDescriptor) { - return 1; - } - - switch (code) { - case IGRAPHIC_DUMPER_INFO_LISTENER_ON_INFO_COMING: { - std::string info = data.ReadString(); - OnInfoComing(info); - reply.WriteInt32(GSERROR_OK); - break; - } - - default: { - GDLOGFE("code %{public}d cannot process", code); - return 1; - } - } - return 0; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_service_proxy.cpp b/frameworks/dumper/src/ipc/graphic_dumper_service_proxy.cpp deleted file mode 100644 index ad556de2cd..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_service_proxy.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_service_proxy.h" - -#include -#include - -#include "graphic_dumper_hilog.h" - - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperServiceProxy" }; -} - -GraphicDumperServiceProxy::GraphicDumperServiceProxy(const sptr& impl) - : IRemoteProxy(impl) -{ -} - -GSError GraphicDumperServiceProxy::AddClientListener(const std::string &tag, - sptr &listener) -{ - if (listener == nullptr) { - GDLOG_FAILURE_NO(GSERROR_INVALID_ARGUMENTS); - return GSERROR_INVALID_ARGUMENTS; - } - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - arg.WriteString(tag); - arg.WriteRemoteObject(listener->AsObject()); - - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_SERVICE_ADD_CLIENT_LISTENER, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_BINDER; - } - - GSError err = (GSError)ret.ReadInt32(); - if (err != GSERROR_OK) { - GDLOG_FAILURE_NO(err); - } - - return err; -} - -GSError GraphicDumperServiceProxy::SendInfo(const std::string &tag, const std::string &info) -{ - MessageOption opt; - MessageParcel arg; - MessageParcel ret; - - if (!arg.WriteInterfaceToken(GetDescriptor())) { - GDLOGE("write interface token failed"); - } - arg.WriteString(tag); - arg.WriteString(info); - GDLOGE("SendInfo SendRequest !!!!!"); - int result = Remote()->SendRequest(IGRAPHIC_DUMPER_SERVICE_SEND_INFO, arg, ret, opt); - if (result) { - GDLOG_ERROR_API(result, SendRequest); - return GSERROR_BINDER; - } - return GSERROR_OK; -} -} // namespace OHOS diff --git a/frameworks/dumper/src/ipc/graphic_dumper_service_stub.cpp b/frameworks/dumper/src/ipc/graphic_dumper_service_stub.cpp deleted file mode 100644 index 82a2580de4..0000000000 --- a/frameworks/dumper/src/ipc/graphic_dumper_service_stub.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc/graphic_dumper_service_stub.h" - -#include "graphic_dumper_hilog.h" -#include "graphic_dumper_server.h" - -#define REMOTE_RETURN(reply, gs_error) \ - do { \ - (reply).WriteInt32(gs_error); \ - if ((gs_error) != GSERROR_OK) { \ - GDLOG_FAILURE_NO(gs_error); \ - } \ - } while (0); \ - break - -namespace OHOS { -namespace { -constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0, "GraphicDumperServiceStub" }; -} - -int32_t GraphicDumperServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, - MessageParcel &reply, MessageOption &option) -{ - auto remoteDescriptor = data.ReadInterfaceToken(); - if (GetDescriptor() != remoteDescriptor) { - return 1; - } - - switch (code) { - case IGRAPHIC_DUMPER_SERVICE_ADD_CLIENT_LISTENER: { - auto tag = data.ReadString(); - GDLOGFE("%{public}s", tag.c_str()); - auto remoteObject = data.ReadRemoteObject(); - if (remoteObject == nullptr) { - reply.WriteInt32(GSERROR_INVALID_ARGUMENTS); - GDLOG_FAILURE_NO(GSERROR_INVALID_ARGUMENTS); - break; - } - auto l = iface_cast(remoteObject); - GSError ret = AddClientListener(tag, l); - reply.WriteInt32(ret); - if (ret != GSERROR_OK) { - GDLOG_FAILURE_NO(ret); - } - break; - } - case IGRAPHIC_DUMPER_SERVICE_SEND_INFO: { - std::string tag = data.ReadString(); - std::string info = data.ReadString(); - GSError ret = SendInfo(tag, info); - reply.WriteInt32(ret); - if (ret != GSERROR_OK) { - GDLOG_FAILURE_NO(ret); - } - break; - } - default: { - GDLOGFE("code %{public}d cannot process", code); - return 1; - } - } - return 0; -} -GSError GraphicDumperServiceStub::AddClientListener(const std::string &tag, - sptr &listener) -{ - if (listener == nullptr) { - return GSERROR_INVALID_ARGUMENTS; - } - return GraphicDumperServer::GetInstance()->AddConfigListener(tag, listener); -} -GSError GraphicDumperServiceStub::SendInfo(const std::string &tag, const std::string &info) -{ - return GraphicDumperServer::GetInstance()->InfoHandle(tag, info); -} -} // namespace OHOS