Get rid of two runtime static destructors
Bug: 153704006
Test: compiles
Change-Id: Icb44c2d2c1e26b13a4d03a4996bffe016a141286
diff --git a/services/incremental/BinderIncrementalService.cpp b/services/incremental/BinderIncrementalService.cpp
index 2dbbc5a..aabc58c 100644
--- a/services/incremental/BinderIncrementalService.cpp
+++ b/services/incremental/BinderIncrementalService.cpp
@@ -17,6 +17,7 @@
#include "BinderIncrementalService.h"
#include <android-base/logging.h>
+#include <android-base/no_destructor.h>
#include <binder/IResultReceiver.h>
#include <binder/PermissionCache.h>
#include <incfs.h>
@@ -93,8 +94,8 @@
}
status_t BinderIncrementalService::dump(int fd, const Vector<String16>&) {
- static const String16 kDump("android.permission.DUMP");
- if (!PermissionCache::checkCallingPermission(kDump)) {
+ static const android::base::NoDestructor<String16> kDump("android.permission.DUMP");
+ if (!PermissionCache::checkCallingPermission(*kDump)) {
return PERMISSION_DENIED;
}
mImpl.onDump(fd);
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 92366e5..4f64cad 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -20,6 +20,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/no_destructor.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -701,8 +702,8 @@
const IncrementalService::IfsMountPtr& IncrementalService::getIfsLocked(StorageId storage) const {
auto it = mMounts.find(storage);
if (it == mMounts.end()) {
- static const IfsMountPtr kEmpty = {};
- return kEmpty;
+ static const android::base::NoDestructor<IfsMountPtr> kEmpty{};
+ return *kEmpty;
}
return it->second;
}