Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0f5d52f authored by Steven Moreland's avatar Steven Moreland
Browse files

Use SharedRefBase::make to allocate.

SharedRefBase now encapsulates heap allocation in order to guard against
some types of double-ownership.

Bug: 149249948
Test: TH
Change-Id: I827798299747829397bb93bc4460319f59b41a3e
parent 78a4fb5e
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -78,7 +78,8 @@ DnsResolverService::DnsResolverService() {
binder_status_t DnsResolverService::start() {
binder_status_t DnsResolverService::start() {
    // TODO: Add disableBackgroundScheduling(true) after libbinder_ndk support it. b/126506010
    // TODO: Add disableBackgroundScheduling(true) after libbinder_ndk support it. b/126506010
    // NetdNativeService does call disableBackgroundScheduling currently, so it is fine now.
    // NetdNativeService does call disableBackgroundScheduling currently, so it is fine now.
    DnsResolverService* resolverService = new DnsResolverService();
    std::shared_ptr<DnsResolverService> resolverService =
            ::ndk::SharedRefBase::make<DnsResolverService>();
    binder_status_t status =
    binder_status_t status =
            AServiceManager_addService(resolverService->asBinder().get(), getServiceName());
            AServiceManager_addService(resolverService->asBinder().get(), getServiceName());
    if (status != STATUS_OK) {
    if (status != STATUS_OK) {
+2 −1
Original line number Original line Diff line number Diff line
@@ -61,8 +61,9 @@ class DnsResolverService : public aidl::android::net::BnDnsResolver {
    // Debug log command
    // Debug log command
    ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override;
    ::ndk::ScopedAStatus setLogSeverity(int32_t logSeverity) override;


  private:
    DnsResolverService();
    DnsResolverService();

  private:
    // TODO: Remove below items after libbiner_ndk supports check_permission.
    // TODO: Remove below items after libbiner_ndk supports check_permission.
    ::ndk::ScopedAStatus checkAnyPermission(const std::vector<const char*>& permissions);
    ::ndk::ScopedAStatus checkAnyPermission(const std::vector<const char*>& permissions);
};
};