Allow SharedRefBase::make to use the deprecated new operator
The direct use of the new operator is discouraged in favor or SharedRefBase::make. So, we have been completely hiding the operator for newer builds (i.e. min_sdk_version >= 30). For older builds, we don't hide it in order to keep the backwards compatibility, but mark it as deprecated to give clients a warning. However, we have missed a legit use of the operator: from inside the make function. When the code is built for a module whose min_sdk_version < 30, it triggers the -Wdeprecated-declarations check and might fail the build if it is with -Werror. ``` frameworks/native/libs/binder/ndk/include_cpp/android/binder_interface_utils.h:85:16: error: 'operator new' is deprecated: Prefer SharedRefBase::make<T>(...) if possible. [-Werror,-Wdeprecated-declarations] T* t = new T(std::forward<Args>(args)...); ^ out/soong/.intermediates/packages/modules/DnsResolver/dnsresolver_aidl_interface-V7-ndk_platform-source/gen/android/net/resolv/aidl/IDnsResolverUnsolicitedEventListener.cpp:483:32: note: in instantiation of function template specialization 'ndk::SharedRefBase::make<aidl::android::net::resolv::a idl::BpDnsResolverUnsolicitedEventListener, const ndk::SpAIBinder &>' requested here return ::ndk::SharedRefBase::make<BpDnsResolverUnsolicitedEventListener>(binder); ^ frameworks/native/libs/binder/ndk/include_cpp/android/binder_interface_utils.h:100:7: note: 'operator new' has been explicitly marked deprecated here [[deprecated("Prefer SharedRefBase::make<T>(...) if possible.")]] ^ 1 error generated. ``` This change silence the deprecation check at the point where the new operator is used inside the make function. Bug: N/A Test: m resolv_stress_test. Change-Id: I79b10851d587da62fa0df151c1e9604d31446c04
Loading
Please register or sign in to comment