diff --git a/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp b/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp index 3985c5ba6..3d19d71c7 100644 --- a/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp +++ b/vndk/tools/header-checker/header-abi-util/src/abi_diff_helpers.cpp @@ -518,7 +518,7 @@ DiffStatus AbiDiffHelper::CompareRecordTypes( } DiffStatus final_diff_status = DiffStatus::no_diff; record_type_diff_ir->SetName(old_type->GetName()); - if (old_type->GetAccess() != new_type->GetAccess()) { + if (IsAccessDownGraded(old_type->GetAccess(), new_type->GetAccess())) { final_diff_status = DiffStatus::indirect_diff; record_type_diff_ir->SetAccessDiff( std::make_unique( diff --git a/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h b/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h index 08b7d51d2..8dce7c855 100644 --- a/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h +++ b/vndk/tools/header-checker/tests/integration/cpp/gold/include/abstract_class.h @@ -60,6 +60,7 @@ class SuperSpeaker { #else int mSpeakderId; #endif + #if GOLDEN_FUNCTION_POINTER #if GOLDEN_FUNCTION_POINTER_ADD_PARAM SuperSpeaker * (*speaker_fp)(int, char, int); @@ -67,4 +68,17 @@ class SuperSpeaker { SuperSpeaker * (*speaker_fp)(int, char); #endif #endif + +#if GOLDEN_WITH_INTERNAL_STRUCT +#ifdef GOLDEN_WITH_PUBLIC_INTERNAL_STRUCT + public: +#else + private: +#endif + struct InternalStruct { + int internal; + }; + private: + InternalStruct a; +#endif // GOLDEN_WITH_INTERNAL_STRUCT }; diff --git a/vndk/tools/header-checker/tests/module.py b/vndk/tools/header-checker/tests/module.py index 4f859fffe..327769803 100755 --- a/vndk/tools/header-checker/tests/module.py +++ b/vndk/tools/header-checker/tests/module.py @@ -398,6 +398,32 @@ TEST_MODULES = [ arch = '', api = 'current', ), + Module( + name = 'libgolden_cpp_internal_public_struct', + srcs = ['integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script = 'integration/cpp/gold/map.txt', + export_include_dirs = ['integration/cpp/gold/include'], + cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT', + '-DGOLDEN_WITH_PUBLIC_INTERNAL_STRUCT'], + arch = '', + api = 'current', + ), + Module( + name = 'libgolden_cpp_internal_private_struct', + srcs = ['integration/cpp/gold/golden_1.cpp', + 'integration/cpp/gold/high_volume_speaker.cpp', + 'integration/cpp/gold/low_volume_speaker.cpp', + ], + version_script = 'integration/cpp/gold/map.txt', + export_include_dirs = ['integration/cpp/gold/include'], + cflags = ['-DGOLDEN_WITH_INTERNAL_STRUCT'], + arch = '', + api = 'current', + ), + ] TEST_MODULES = { m.name: m for m in TEST_MODULES } diff --git a/vndk/tools/header-checker/tests/test.py b/vndk/tools/header-checker/tests/test.py index 1c76444e5..f6d9c9122 100755 --- a/vndk/tools/header-checker/tests/test.py +++ b/vndk/tools/header-checker/tests/test.py @@ -238,6 +238,17 @@ class MyTest(unittest.TestCase): "libgolden_cpp_function_pointer_parameter_added", 8, [], True, True) + def test_libgolden_cpp_internal_struct_access_upgraded(self): + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp_internal_private_struct", + "libgolden_cpp_internal_public_struct", 0, [], True, + True) + + def test_libgolden_cpp_internal_struct_access_downgraded(self): + self.prepare_and_run_abi_diff_all_archs( + "libgolden_cpp_internal_public_struct", + "libgolden_cpp_internal_private_struct", 8, [], True, + True) if __name__ == '__main__':