diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000000000000000000000000000000000000..11600fde407f85eb9f0ca4713203efcad1fe10bd --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,15 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "cStandard": "c17", + "cppStandard": "gnu++14", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..41918dffb502b4f35d474df58b6342b9ae5e6876 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "C_Cpp.default.compilerPath": "/usr/bin/g++", + "files.associations": { + "*.cjson": "jsonc", + "*.wxss": "css", + "*.wxs": "javascript", + "new": "cpp" + } +} \ No newline at end of file diff --git a/denpendecy_analysis.log b/denpendecy_analysis.log new file mode 100644 index 0000000000000000000000000000000000000000..7203f1adcf431b57a9712b0be77d552ca8cbd75b --- /dev/null +++ b/denpendecy_analysis.log @@ -0,0 +1,33 @@ +dup filename = data_translator.h +dup filename = constant.h +dup filename = napi_context_common.h + + +./interfaces/kits/js/napi/privacy/include/napi_context_common.h +{'./interfaces/kits/js/napi/common/include', './interfaces/innerkits/privacy/include', './frameworks/common/include'} + +./interfaces/kits/js/napi/accesstoken/include/napi_context_common.h +{'./interfaces/innerkits/accesstoken/include', './interfaces/kits/js/napi/common/include', './frameworks/common/include'} + +./interfaces/innerkits/tokensync/src/token_sync_manager_proxy.h +{'./interfaces/innerkits/accesstoken/include', './frameworks/tokensync/include'} + +./interfaces/innerkits/tokensync/src/token_sync_manager_client.h +{'./interfaces/innerkits/accesstoken/include', './frameworks/tokensync/include'} + + +./interfaces/innerkits/privacy/src/state_change_callback_stub.h +{'./frameworks/privacy/include'} + + +./interfaces/innerkits/privacy/src/privacy_manager_client.h +{'./services/common/proxy_death/include', './interfaces/innerkits/privacy/include'} + +./interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.h +{'./frameworks/privacy/include'} + + +./interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h +{'./interfaces/innerkits/accesstoken/include', './frameworks/accesstoken/include'} + + diff --git a/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h b/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h index 68501905985de265f0253beef0043b375402739a..c3c9efd3411e058f232719a65cc4c5bc71d56518 100644 --- a/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h +++ b/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h @@ -25,9 +25,6 @@ #include "access_token.h" #include "atm_tools_param_info.h" #include "accesstoken_death_recipient.h" -#include "hap_base_info_parcel.h" -#include "hap_info_parcel.h" -#include "hap_policy_parcel.h" #include "hap_token_info.h" #include "iaccess_token_manager.h" #include "nocopyable.h" diff --git a/interfaces/innerkits/privacy/BUILD.gn b/interfaces/innerkits/privacy/BUILD.gn index d1ae53460d51c2ffdc60135d423e552d6a9ace84..fcfb032b9dc548f5403747896d2944f6d47d1103 100644 --- a/interfaces/innerkits/privacy/BUILD.gn +++ b/interfaces/innerkits/privacy/BUILD.gn @@ -45,6 +45,8 @@ if (is_standard_system) { "${access_token_path}/frameworks/privacy/include", "${access_token_path}/frameworks/common/include", "${access_token_path}/interfaces/innerkits/accesstoken/include", + "${access_token_path}/interfaces/innerkits/privacy/include", + "${access_token_path}/interfaces/innerkits/proxy_death/include", "include", "src", ] diff --git a/frameworks/privacy/include/i_perm_active_status_callback.h b/interfaces/innerkits/privacy/include/i_perm_active_status_callback.h similarity index 100% rename from frameworks/privacy/include/i_perm_active_status_callback.h rename to interfaces/innerkits/privacy/include/i_perm_active_status_callback.h diff --git a/frameworks/privacy/include/i_state_change_callback.h b/interfaces/innerkits/privacy/include/i_state_change_callback.h similarity index 100% rename from frameworks/privacy/include/i_state_change_callback.h rename to interfaces/innerkits/privacy/include/i_state_change_callback.h diff --git a/interfaces/innerkits/privacy/src/privacy_manager_client.cpp b/interfaces/innerkits/privacy/src/privacy_manager_client.cpp index 252571abf1bcc9afb824a2eed5f095f3c531a69e..b2d451578d7dfb8fd495f49369059451f0b5aebf 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_client.cpp +++ b/interfaces/innerkits/privacy/src/privacy_manager_client.cpp @@ -448,11 +448,11 @@ void PrivacyManagerClient::ReleaseProxy() serviceDeathObserver_ = nullptr; } -sptr PrivacyManagerClient::GetAnonyStub() +sptr> PrivacyManagerClient::GetAnonyStub() { std::lock_guard lock(stubMutex_); if (anonyStub_ == nullptr) { - anonyStub_ = sptr::MakeSptr(); + anonyStub_ = sptr>::MakeSptr(); } return anonyStub_; } diff --git a/interfaces/innerkits/privacy/src/privacy_manager_client.h b/interfaces/innerkits/privacy/src/privacy_manager_client.h index 0a652cb51c5c998a63b3bd31c0208973b1d7487d..e9682a5f8161e5d2315ddc8df8eba5fb2e353c47 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_client.h +++ b/interfaces/innerkits/privacy/src/privacy_manager_client.h @@ -21,11 +21,12 @@ #include #include +#include "iremote_stub.h" #include "iprivacy_manager.h" #include "perm_active_status_change_callback.h" #include "perm_active_status_customized_cbk.h" #include "privacy_death_recipient.h" -#include "proxy_death_callback_stub.h" +#include "proxy_death_callback.h" #include "state_change_callback.h" #include "state_customized_cbk.h" @@ -75,7 +76,7 @@ private: sptr GetProxy(); void ReleaseProxy(); uint64_t GetUniqueId(uint32_t tokenId, int32_t pid) const; - sptr GetAnonyStub(); + sptr> GetAnonyStub(); private: std::mutex activeCbkMutex_; @@ -83,7 +84,7 @@ private: std::mutex stateCbkMutex_; std::map> stateChangeCallbackMap_; std::mutex stubMutex_; - sptr anonyStub_ = nullptr; + sptr> anonyStub_ = nullptr; }; } // namespace AccessToken } // namespace Security diff --git a/interfaces/innerkits/privacy/test/BUILD.gn b/interfaces/innerkits/privacy/test/BUILD.gn index 0488373833ec75cc0235b140d6ee545a51836817..89a865651843948d5d498b3325226342e30f8e0b 100644 --- a/interfaces/innerkits/privacy/test/BUILD.gn +++ b/interfaces/innerkits/privacy/test/BUILD.gn @@ -33,6 +33,7 @@ ohos_unittest("libprivacy_sdk_test") { "${access_token_path}/interfaces/innerkits/accesstoken/include", "${access_token_path}/interfaces/innerkits/nativetoken/include", "${access_token_path}/interfaces/innerkits/privacy/include", + "${access_token_path}/interfaces/innerkits/proxy_death/include", "${access_token_path}/interfaces/innerkits/token_setproc/include", ] @@ -92,6 +93,7 @@ ohos_unittest("libprivacy_mock_test") { "${access_token_path}/interfaces/innerkits/accesstoken/include", "${access_token_path}/interfaces/innerkits/nativetoken/include", "${access_token_path}/interfaces/innerkits/privacy/include", + "${access_token_path}/interfaces/innerkits/proxy_death/include", ] sources = [ diff --git a/interfaces/innerkits/privacy/test/tool/BUILD.gn b/interfaces/innerkits/privacy/test/tool/BUILD.gn index 6e97cb8e53a58a0639ad5b2533608c46b2c69f76..e04c7b59eebba0893d401cf7fd9826ec5f8a3b4c 100644 --- a/interfaces/innerkits/privacy/test/tool/BUILD.gn +++ b/interfaces/innerkits/privacy/test/tool/BUILD.gn @@ -29,6 +29,7 @@ ohos_executable("AddPermissionUsedRecord") { "${access_token_path}/interfaces/innerkits/nativetoken/include", "${access_token_path}/interfaces/innerkits/token_setproc/include", "${access_token_path}/interfaces/innerkits/privacy/include", + "${access_token_path}/interfaces/innerkits/proxy_death/include", ] deps = [ diff --git a/services/common/proxy_death/include/proxy_death_callback.h b/interfaces/innerkits/proxy_death/include/proxy_death_callback.h similarity index 100% rename from services/common/proxy_death/include/proxy_death_callback.h rename to interfaces/innerkits/proxy_death/include/proxy_death_callback.h diff --git a/frameworks/tokensync/include/i_token_sync_manager.h b/interfaces/innerkits/tokensync/include/i_token_sync_manager.h similarity index 100% rename from frameworks/tokensync/include/i_token_sync_manager.h rename to interfaces/innerkits/tokensync/include/i_token_sync_manager.h diff --git a/interfaces/kits/js/napi/accesstoken/include/napi_context_common.h b/interfaces/kits/js/napi/accesstoken/include/napi_context_common.h index c784ec2bef57089ca9d960df8b06a0df325edfdd..4992ac9ef046a11e26c91b331447fd2b4249c39b 100644 --- a/interfaces/kits/js/napi/accesstoken/include/napi_context_common.h +++ b/interfaces/kits/js/napi/accesstoken/include/napi_context_common.h @@ -16,7 +16,6 @@ #define INTERFACES_ACCESSTOKEN_KITS_NAPI_CONTEXT_COMMON_H #include -#include "accesstoken_log.h" #include "access_token_error.h" #include "napi_error.h" #include "napi_common.h" diff --git a/interfaces/kits/js/napi/privacy/include/napi_context_common.h b/interfaces/kits/js/napi/privacy/include/napi_context_common.h index 59772dc473b7295745b1f9ba3b7e9d15a5f89cff..ebf6b484b61dd8bf0edc48ecb1ec2c9954864af3 100644 --- a/interfaces/kits/js/napi/privacy/include/napi_context_common.h +++ b/interfaces/kits/js/napi/privacy/include/napi_context_common.h @@ -17,7 +17,6 @@ #include #include -#include "accesstoken_log.h" #include "active_change_response_info.h" #include "napi/native_api.h" #include "napi/native_node_api.h" diff --git a/parse_deps.py b/parse_deps.py new file mode 100644 index 0000000000000000000000000000000000000000..ab797fd20794b808f22ef6c8ac203ddd9b4b41a2 --- /dev/null +++ b/parse_deps.py @@ -0,0 +1,74 @@ +import os, sys + + + + +def parse_header(filepath): + deps = [] + with open(filepath, "r") as f: + lines = f.readlines() + for line in lines: + line = line.strip() + if not line.startswith("#include \""): + continue + headername = line.strip("#include").strip().strip("\"") + deps.append(headername) + return deps + +def analyze_deps(filemap, filedeps): + inclue_deps = {} + for filename, deps in filedeps.items(): + merged = set() + for dep in deps: + if dep in filemap: + for dirname in filemap[dep]: + if filename.startswith(dirname): + continue + merged.add(dirname) + if not merged: + continue + print(filename) + print(merged) + inclue_deps[filename] = merged + return inclue_deps + + +def filter_files(pathname): + keywords = [ + "fuzz", + "tool", + "test", + "cj", + "el5" + ] + for key in keywords: + if key in pathname: + return True + return False + + +def traverse_files(path): + filemap = {} + filedeps = {} + for root, dirs, files in os.walk(path): + for filename in files: + if filter_files(root): + continue + if not filename.endswith(".h"): + continue + if not filename in filemap: + filemap[filename] = [] + else: + print("dup filename = " + filename) + filemap[filename].append(root) + filepath = os.path.join(root, filename) + deps = parse_header(filepath) + filedeps[filepath] = deps + + analyze_deps(filemap, filedeps) + return filemap + + + +filemap = traverse_files(sys.argv[1]) +# print(filemap) diff --git a/services/common/proxy_death/BUILD.gn b/services/common/proxy_death/BUILD.gn index d78510021ded149cf28af73cbd35aae1759b4752..f1950e2787a9fb534574741a54058f49635a1743 100644 --- a/services/common/proxy_death/BUILD.gn +++ b/services/common/proxy_death/BUILD.gn @@ -29,7 +29,10 @@ ohos_source_set("proxy_death_stub") { } branch_protector_ret = "pac_ret" - include_dirs = [ "include" ] + include_dirs = [ + "include", + "${access_token_path}/interfaces/innerkits/proxy_death/include", + ] sources = [ "src/proxy_death_callback_stub.cpp" ] diff --git a/services/privacymanager/test/unittest/BUILD.gn b/services/privacymanager/test/unittest/BUILD.gn index 5083c857d58855191ccb0f240e2571f009241f68..9a552a107d3617829247b0d2dbac03ef4f1484f6 100644 --- a/services/privacymanager/test/unittest/BUILD.gn +++ b/services/privacymanager/test/unittest/BUILD.gn @@ -33,6 +33,7 @@ if (is_standard_system && ability_base_enable == true) { "${access_token_path}/interfaces/innerkits/nativetoken/include", "${access_token_path}/interfaces/innerkits/privacy/test/unittest/src", "${access_token_path}/interfaces/innerkits/privacy/src", + "${access_token_path}/interfaces/innerkits/proxy_death/include", "${access_token_path}/services/common/app_manager/include", "${access_token_path}/services/common/json_parse/include", "${access_token_path}/services/common/database/include", diff --git a/services/tokensyncmanager/BUILD.gn b/services/tokensyncmanager/BUILD.gn index 263815cf5aa0da96217449a18ee0ed8651196dc6..5edcf8ffb1ecf78432cab9568575c64e9b800786 100644 --- a/services/tokensyncmanager/BUILD.gn +++ b/services/tokensyncmanager/BUILD.gn @@ -57,6 +57,7 @@ if (token_sync_enable == true) { "${access_token_path}/frameworks/accesstoken/include", "${access_token_path}/frameworks/tokensync/include", "${access_token_path}/interfaces/innerkits/accesstoken/include", + "${access_token_path}/interfaces/innerkits/tokensync/include", "${access_token_path}/services/accesstokenmanager/main/cpp/include/token", "${access_token_path}/services/common/json_parse/include", "${access_token_path}/services/common/handler/include", diff --git a/services/tokensyncmanager/test/coverage/BUILD.gn b/services/tokensyncmanager/test/coverage/BUILD.gn index 1dcf26ef956e3f407ef85e776b067e66658b5d65..947c108c431783bbb0e838f1965c173f989e2014 100644 --- a/services/tokensyncmanager/test/coverage/BUILD.gn +++ b/services/tokensyncmanager/test/coverage/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("libtoken_sync_service_coverage_test") { "${access_token_path}/services/common/json_parse/include", "${access_token_path}/services/common/handler/include", "${access_token_path}/interfaces/innerkits/accesstoken/test/unittest/common/", + "${access_token_path}/interfaces/innerkits/tokensync/include", ] deps = [ diff --git a/services/tokensyncmanager/test/unittest/BUILD.gn b/services/tokensyncmanager/test/unittest/BUILD.gn index 9a8e2dc27ea25321cdaf0b07b618ec7b943a7b9e..8e65906c507b8a0a7ebfe7b77b194b1bbed849a2 100644 --- a/services/tokensyncmanager/test/unittest/BUILD.gn +++ b/services/tokensyncmanager/test/unittest/BUILD.gn @@ -64,6 +64,7 @@ ohos_unittest("libtoken_sync_service_standard_test") { "${access_token_path}/services/common/json_parse/include", "${access_token_path}/services/common/handler/include", "${access_token_path}/interfaces/innerkits/accesstoken/test/unittest/common/", + "${access_token_path}/interfaces/innerkits/tokensync/include", ] deps = [