summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
Diffstat (limited to 'cmds')
-rw-r--r--cmds/installd/otapreopt_chroot.cpp30
-rw-r--r--cmds/installd/utils.cpp2
-rw-r--r--cmds/lshal/test.cpp6
-rw-r--r--cmds/servicemanager/Android.bp1
-rw-r--r--cmds/servicemanager/ServiceManager.cpp12
-rw-r--r--cmds/servicemanager/main.cpp7
-rw-r--r--cmds/servicemanager/test_sm.cpp38
-rw-r--r--cmds/surfacereplayer/proto/src/trace.proto5
-rw-r--r--cmds/surfacereplayer/replayer/Replayer.cpp12
-rw-r--r--cmds/surfacereplayer/replayer/Replayer.h2
10 files changed, 67 insertions, 48 deletions
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index c04b558e2d..3a87776162 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -27,6 +27,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
+#include <android-base/scopeguard.h>
#include <android-base/stringprintf.h>
#include <android-base/unique_fd.h>
#include <libdm/dm.h>
@@ -72,6 +73,15 @@ static void ActivateApexPackages() {
}
}
+static void DeactivateApexPackages() {
+ std::vector<std::string> apexd_cmd{"/system/bin/apexd", "--unmount-all"};
+ std::string apexd_error_msg;
+ bool exec_result = Exec(apexd_cmd, &apexd_error_msg);
+ if (!exec_result) {
+ PLOG(ERROR) << "Running /system/bin/apexd --unmount-all failed: " << apexd_error_msg;
+ }
+}
+
static void TryExtraMount(const char* name, const char* slot, const char* target) {
std::string partition_name = StringPrintf("%s%s", name, slot);
@@ -231,10 +241,30 @@ static int otapreopt_chroot(const int argc, char **arg) {
exit(205);
}
+ // Call apexd --unmount-all to free up loop and dm block devices, so that we can re-use
+ // them during the next invocation. Since otapreopt_chroot calls exit in case something goes
+ // wrong we need to register our own atexit handler.
+ // We want to register this handler before actually activating apex packages. This is mostly
+ // due to the fact that if fail to unmount apexes, then on the next run of otapreopt_chroot
+ // we will ask for new loop devices instead of re-using existing ones, and we really don't want
+ // to do that. :)
+ if (atexit(DeactivateApexPackages) != 0) {
+ LOG(ERROR) << "Failed to register atexit hander";
+ exit(206);
+ }
+
// Try to mount APEX packages in "/apex" in the chroot dir. We need at least
// the ART APEX, as it is required by otapreopt to run dex2oat.
ActivateApexPackages();
+ auto cleanup = android::base::make_scope_guard([](){
+ std::vector<std::string> apexd_cmd{"/system/bin/apexd", "--unmount-all"};
+ std::string apexd_error_msg;
+ bool exec_result = Exec(apexd_cmd, &apexd_error_msg);
+ if (!exec_result) {
+ PLOG(ERROR) << "Running /system/bin/apexd --unmount-all failed: " << apexd_error_msg;
+ }
+ });
// Check that an ART APEX has been activated; clean up and exit
// early otherwise.
static constexpr const std::string_view kRequiredApexs[] = {
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp
index c47df52984..c4ecd070c1 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -1062,6 +1062,8 @@ int prepare_app_cache_dir(const std::string& parent, const char* name, mode_t ta
static const char* kProcFilesystems = "/proc/filesystems";
bool supports_sdcardfs() {
+ if (!property_get_bool("external_storage.sdcardfs.enabled", true))
+ return false;
std::string supported;
if (!android::base::ReadFileToString(kProcFilesystems, &supported)) {
PLOG(ERROR) << "Failed to read supported filesystems";
diff --git a/cmds/lshal/test.cpp b/cmds/lshal/test.cpp
index b6ff28d416..7c1ca91528 100644
--- a/cmds/lshal/test.cpp
+++ b/cmds/lshal/test.cpp
@@ -508,10 +508,10 @@ TEST_F(ListTest, DumpVintf) {
EXPECT_THAT(output, HasSubstr("a.h.foo6@6.0::IFoo/6"));
EXPECT_EQ("", err.str());
+ std::string error;
vintf::HalManifest m;
- EXPECT_EQ(true, vintf::gHalManifestConverter(&m, out.str()))
- << "--init-vintf does not emit valid HAL manifest: "
- << vintf::gHalManifestConverter.lastError();
+ EXPECT_EQ(true, vintf::gHalManifestConverter(&m, out.str(), &error))
+ << "--init-vintf does not emit valid HAL manifest: " << error;
}
// test default columns
diff --git a/cmds/servicemanager/Android.bp b/cmds/servicemanager/Android.bp
index 9de344a820..3ebdeee7aa 100644
--- a/cmds/servicemanager/Android.bp
+++ b/cmds/servicemanager/Android.bp
@@ -14,6 +14,7 @@ cc_defaults {
"-Wall",
"-Wextra",
"-Werror",
+ "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
],
srcs: [
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp
index 0dbab4e055..2f5524940e 100644
--- a/cmds/servicemanager/ServiceManager.cpp
+++ b/cmds/servicemanager/ServiceManager.cpp
@@ -239,7 +239,8 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi
#endif // !VENDORSERVICEMANAGER
// implicitly unlinked when the binder is removed
- if (binder->remoteBinder() != nullptr && binder->linkToDeath(this) != OK) {
+ if (binder->remoteBinder() != nullptr &&
+ binder->linkToDeath(sp<ServiceManager>::fromExisting(this)) != OK) {
LOG(ERROR) << "Could not linkToDeath when adding " << name;
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
}
@@ -307,7 +308,9 @@ Status ServiceManager::registerForNotifications(
return Status::fromExceptionCode(Status::EX_NULL_POINTER);
}
- if (OK != IInterface::asBinder(callback)->linkToDeath(this)) {
+ if (OK !=
+ IInterface::asBinder(callback)->linkToDeath(
+ sp<ServiceManager>::fromExisting(this))) {
LOG(ERROR) << "Could not linkToDeath when adding " << name;
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
}
@@ -461,7 +464,8 @@ Status ServiceManager::registerClientCallback(const std::string& name, const sp<
return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT);
}
- if (OK != IInterface::asBinder(cb)->linkToDeath(this)) {
+ if (OK !=
+ IInterface::asBinder(cb)->linkToDeath(sp<ServiceManager>::fromExisting(this))) {
LOG(ERROR) << "Could not linkToDeath when adding client callback for " << name;
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
}
@@ -491,7 +495,7 @@ void ServiceManager::removeClientCallback(const wp<IBinder>& who,
}
ssize_t ServiceManager::Service::getNodeStrongRefCount() {
- sp<BpBinder> bpBinder = binder->remoteBinder();
+ sp<BpBinder> bpBinder = sp<BpBinder>::fromExisting(binder->remoteBinder());
if (bpBinder == nullptr) return -1;
return ProcessState::self()->getStrongRefCountForNode(bpBinder);
diff --git a/cmds/servicemanager/main.cpp b/cmds/servicemanager/main.cpp
index 627dfe6382..8c1beaca20 100644
--- a/cmds/servicemanager/main.cpp
+++ b/cmds/servicemanager/main.cpp
@@ -39,7 +39,7 @@ using ::android::sp;
class BinderCallback : public LooperCallback {
public:
static sp<BinderCallback> setupTo(const sp<Looper>& looper) {
- sp<BinderCallback> cb = new BinderCallback;
+ sp<BinderCallback> cb = sp<BinderCallback>::make();
int binder_fd = -1;
IPCThreadState::self()->setupPolling(&binder_fd);
@@ -65,7 +65,7 @@ public:
class ClientCallbackCallback : public LooperCallback {
public:
static sp<ClientCallbackCallback> setupTo(const sp<Looper>& looper, const sp<ServiceManager>& manager) {
- sp<ClientCallbackCallback> cb = new ClientCallbackCallback(manager);
+ sp<ClientCallbackCallback> cb = sp<ClientCallbackCallback>::make(manager);
int fdTimer = timerfd_create(CLOCK_MONOTONIC, 0 /*flags*/);
LOG_ALWAYS_FATAL_IF(fdTimer < 0, "Failed to timerfd_create: fd: %d err: %d", fdTimer, errno);
@@ -105,6 +105,7 @@ public:
return 1; // Continue receiving callbacks.
}
private:
+ friend sp<ClientCallbackCallback>;
ClientCallbackCallback(const sp<ServiceManager>& manager) : mManager(manager) {}
sp<ServiceManager> mManager;
};
@@ -120,7 +121,7 @@ int main(int argc, char** argv) {
ps->setThreadPoolMaxThreadCount(0);
ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY);
- sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>());
+ sp<ServiceManager> manager = sp<ServiceManager>::make(std::make_unique<Access>());
if (!manager->addService("manager", manager, false /*allowIsolated*/, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk()) {
LOG(ERROR) << "Could not self register servicemanager";
}
diff --git a/cmds/servicemanager/test_sm.cpp b/cmds/servicemanager/test_sm.cpp
index fb9f9df856..5d5a75e174 100644
--- a/cmds/servicemanager/test_sm.cpp
+++ b/cmds/servicemanager/test_sm.cpp
@@ -46,7 +46,7 @@ static sp<IBinder> getBinder() {
}
};
- return new LinkableBinder;
+ return sp<LinkableBinder>::make();
}
class MockAccess : public Access {
@@ -71,7 +71,7 @@ static sp<ServiceManager> getPermissiveServiceManager() {
ON_CALL(*access, canFind(_, _)).WillByDefault(Return(true));
ON_CALL(*access, canList(_)).WillByDefault(Return(true));
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
return sm;
}
@@ -119,7 +119,7 @@ TEST(AddService, AddDisallowedFromApp) {
.uid = uid,
}));
EXPECT_CALL(*access, canAdd(_, _)).Times(0);
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
EXPECT_FALSE(sm->addService("foo", getBinder(), false /*allowIsolated*/,
IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk());
@@ -161,7 +161,7 @@ TEST(AddService, NoPermissions) {
EXPECT_CALL(*access, getCallingContext()).WillOnce(Return(Access::CallingContext{}));
EXPECT_CALL(*access, canAdd(_, _)).WillOnce(Return(false));
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
EXPECT_FALSE(sm->addService("foo", getBinder(), false /*allowIsolated*/,
IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk());
@@ -194,7 +194,7 @@ TEST(GetService, NoPermissionsForGettingService) {
EXPECT_CALL(*access, canAdd(_, _)).WillOnce(Return(true));
EXPECT_CALL(*access, canFind(_, _)).WillOnce(Return(false));
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
EXPECT_TRUE(sm->addService("foo", getBinder(), false /*allowIsolated*/,
IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk());
@@ -218,7 +218,7 @@ TEST(GetService, AllowedFromIsolated) {
EXPECT_CALL(*access, canAdd(_, _)).WillOnce(Return(true));
EXPECT_CALL(*access, canFind(_, _)).WillOnce(Return(true));
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
sp<IBinder> service = getBinder();
EXPECT_TRUE(sm->addService("foo", service, true /*allowIsolated*/,
@@ -244,7 +244,7 @@ TEST(GetService, NotAllowedFromIsolated) {
// TODO(b/136023468): when security check is first, this should be called first
// EXPECT_CALL(*access, canFind(_, _)).WillOnce(Return(true));
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
EXPECT_TRUE(sm->addService("foo", getBinder(), false /*allowIsolated*/,
IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk());
@@ -261,7 +261,7 @@ TEST(ListServices, NoPermissions) {
EXPECT_CALL(*access, getCallingContext()).WillOnce(Return(Access::CallingContext{}));
EXPECT_CALL(*access, canList(_)).WillOnce(Return(false));
- sp<ServiceManager> sm = new NiceMock<MockServiceManager>(std::move(access));
+ sp<ServiceManager> sm = sp<NiceMock<MockServiceManager>>::make(std::move(access));
std::vector<std::string> out;
EXPECT_FALSE(sm->listServices(IServiceManager::DUMP_FLAG_PRIORITY_ALL, &out).isOk());
@@ -329,9 +329,9 @@ TEST(ServiceNotifications, NoPermissionsRegister) {
EXPECT_CALL(*access, getCallingContext()).WillOnce(Return(Access::CallingContext{}));
EXPECT_CALL(*access, canFind(_,_)).WillOnce(Return(false));
- sp<ServiceManager> sm = new ServiceManager(std::move(access));
+ sp<ServiceManager> sm = sp<ServiceManager>::make(std::move(access));
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
EXPECT_EQ(sm->registerForNotifications("foofoo", cb).exceptionCode(),
Status::EX_SECURITY);
@@ -343,9 +343,9 @@ TEST(ServiceNotifications, NoPermissionsUnregister) {
EXPECT_CALL(*access, getCallingContext()).WillOnce(Return(Access::CallingContext{}));
EXPECT_CALL(*access, canFind(_,_)).WillOnce(Return(false));
- sp<ServiceManager> sm = new ServiceManager(std::move(access));
+ sp<ServiceManager> sm = sp<ServiceManager>::make(std::move(access));
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
// should always hit security error first
EXPECT_EQ(sm->unregisterForNotifications("foofoo", cb).exceptionCode(),
@@ -355,7 +355,7 @@ TEST(ServiceNotifications, NoPermissionsUnregister) {
TEST(ServiceNotifications, InvalidName) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
EXPECT_EQ(sm->registerForNotifications("foo@foo", cb).exceptionCode(),
Status::EX_ILLEGAL_ARGUMENT);
@@ -371,7 +371,7 @@ TEST(ServiceNotifications, NullCallback) {
TEST(ServiceNotifications, Unregister) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
EXPECT_TRUE(sm->registerForNotifications("foofoo", cb).isOk());
EXPECT_EQ(sm->unregisterForNotifications("foofoo", cb).exceptionCode(), 0);
@@ -380,7 +380,7 @@ TEST(ServiceNotifications, Unregister) {
TEST(ServiceNotifications, UnregisterWhenNoRegistrationExists) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
EXPECT_EQ(sm->unregisterForNotifications("foofoo", cb).exceptionCode(),
Status::EX_ILLEGAL_STATE);
@@ -389,7 +389,7 @@ TEST(ServiceNotifications, UnregisterWhenNoRegistrationExists) {
TEST(ServiceNotifications, NoNotification) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
EXPECT_TRUE(sm->registerForNotifications("foofoo", cb).isOk());
EXPECT_TRUE(sm->addService("otherservice", getBinder(),
@@ -402,7 +402,7 @@ TEST(ServiceNotifications, NoNotification) {
TEST(ServiceNotifications, GetNotification) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
sp<IBinder> service = getBinder();
@@ -417,7 +417,7 @@ TEST(ServiceNotifications, GetNotification) {
TEST(ServiceNotifications, GetNotificationForAlreadyRegisteredService) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
sp<IBinder> service = getBinder();
@@ -433,7 +433,7 @@ TEST(ServiceNotifications, GetNotificationForAlreadyRegisteredService) {
TEST(ServiceNotifications, GetMultipleNotification) {
auto sm = getPermissiveServiceManager();
- sp<CallbackHistorian> cb = new CallbackHistorian;
+ sp<CallbackHistorian> cb = sp<CallbackHistorian>::make();
sp<IBinder> binder1 = getBinder();
sp<IBinder> binder2 = getBinder();
diff --git a/cmds/surfacereplayer/proto/src/trace.proto b/cmds/surfacereplayer/proto/src/trace.proto
index 79aab822e4..06afefd3c8 100644
--- a/cmds/surfacereplayer/proto/src/trace.proto
+++ b/cmds/surfacereplayer/proto/src/trace.proto
@@ -50,7 +50,6 @@ message SurfaceChange {
CornerRadiusChange corner_radius = 16;
ReparentChange reparent = 17;
RelativeParentChange relative_parent = 18;
- ReparentChildrenChange reparent_children = 19;
BackgroundBlurRadiusChange background_blur_radius = 20;
ShadowRadiusChange shadow_radius = 21;
BlurRegionsChange blur_regions = 22;
@@ -190,10 +189,6 @@ message ReparentChange {
required int32 parent_id = 1;
}
-message ReparentChildrenChange {
- required int32 parent_id = 1;
-}
-
message RelativeParentChange {
required int32 relative_parent_id = 1;
required int32 z = 2;
diff --git a/cmds/surfacereplayer/replayer/Replayer.cpp b/cmds/surfacereplayer/replayer/Replayer.cpp
index bbbe6f7ec4..a6d9a3feb6 100644
--- a/cmds/surfacereplayer/replayer/Replayer.cpp
+++ b/cmds/surfacereplayer/replayer/Replayer.cpp
@@ -410,9 +410,6 @@ status_t Replayer::doSurfaceTransaction(
case SurfaceChange::SurfaceChangeCase::kReparent:
setReparentChange(transaction, change.id(), change.reparent());
break;
- case SurfaceChange::SurfaceChangeCase::kReparentChildren:
- setReparentChildrenChange(transaction, change.id(), change.reparent_children());
- break;
case SurfaceChange::SurfaceChangeCase::kRelativeParent:
setRelativeParentChange(transaction, change.id(), change.relative_parent());
break;
@@ -709,15 +706,6 @@ void Replayer::setRelativeParentChange(SurfaceComposerClient::Transaction& t,
t.setRelativeLayer(mLayers[id], mLayers[c.relative_parent_id()], c.z());
}
-void Replayer::setReparentChildrenChange(SurfaceComposerClient::Transaction& t,
- layer_id id, const ReparentChildrenChange& c) {
- if (mLayers.count(c.parent_id()) == 0 || mLayers[c.parent_id()] == nullptr) {
- ALOGE("Layer %d not found in reparent children transaction", c.parent_id());
- return;
- }
- t.reparentChildren(mLayers[id], mLayers[c.parent_id()]);
-}
-
void Replayer::setShadowRadiusChange(SurfaceComposerClient::Transaction& t,
layer_id id, const ShadowRadiusChange& c) {
t.setShadowRadius(mLayers[id], c.radius());
diff --git a/cmds/surfacereplayer/replayer/Replayer.h b/cmds/surfacereplayer/replayer/Replayer.h
index 324d591eaa..252db2bfbb 100644
--- a/cmds/surfacereplayer/replayer/Replayer.h
+++ b/cmds/surfacereplayer/replayer/Replayer.h
@@ -116,8 +116,6 @@ class Replayer {
layer_id id, const ReparentChange& c);
void setRelativeParentChange(SurfaceComposerClient::Transaction& t,
layer_id id, const RelativeParentChange& c);
- void setReparentChildrenChange(SurfaceComposerClient::Transaction& t,
- layer_id id, const ReparentChildrenChange& c);
void setShadowRadiusChange(SurfaceComposerClient::Transaction& t,
layer_id id, const ShadowRadiusChange& c);
void setBlurRegionsChange(SurfaceComposerClient::Transaction& t,