system/core
Revision | 6031414c003ed0c74ecc9ac77f923abb1902cd39 (tree) |
---|---|
Zeit | 2019-05-19 08:18:15 |
Autor | android-build-team Robot <android-build-team-robot@goog...> |
Commiter | android-build-team Robot |
Snap for 5582435 from 5c1b6041a420be82d457ee40f67f3904a2cb0760 to qt-qpr1-release
Change-Id: I685cef01984848104890618a0530370d87bd7fca
@@ -117,7 +117,7 @@ struct TransferId { | ||
117 | 117 | |
118 | 118 | struct IoBlock { |
119 | 119 | bool pending = false; |
120 | - struct iocb control; | |
120 | + struct iocb control = {}; | |
121 | 121 | std::shared_ptr<Block> payload; |
122 | 122 | |
123 | 123 | TransferId id() const { return TransferId::from_value(control.aio_data); } |
@@ -244,16 +244,29 @@ TEST_F(LogicalPartitionCompliance, FastbootRebootTest) { | ||
244 | 244 | // Testing creation/resize/delete of logical partitions |
245 | 245 | TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) { |
246 | 246 | ASSERT_TRUE(UserSpaceFastboot()); |
247 | + std::string test_partition_name = "test_partition"; | |
248 | + std::string slot_count; | |
249 | + // Add suffix to test_partition_name if device is slotted. | |
250 | + EXPECT_EQ(fb->GetVar("slot-count", &slot_count), SUCCESS) << "getvar slot-count failed"; | |
251 | + int32_t num_slots = strtol(slot_count.c_str(), nullptr, 10); | |
252 | + if (num_slots > 0) { | |
253 | + std::string current_slot; | |
254 | + EXPECT_EQ(fb->GetVar("current-slot", ¤t_slot), SUCCESS) | |
255 | + << "getvar current-slot failed"; | |
256 | + std::string slot_suffix = "_" + current_slot; | |
257 | + test_partition_name += slot_suffix; | |
258 | + } | |
259 | + | |
247 | 260 | GTEST_LOG_(INFO) << "Testing 'fastboot create-logical-partition' command"; |
248 | - EXPECT_EQ(fb->CreatePartition("test_partition_a", "0"), SUCCESS) | |
261 | + EXPECT_EQ(fb->CreatePartition(test_partition_name, "0"), SUCCESS) | |
249 | 262 | << "create-logical-partition failed"; |
250 | 263 | GTEST_LOG_(INFO) << "Testing 'fastboot resize-logical-partition' command"; |
251 | - EXPECT_EQ(fb->ResizePartition("test_partition_a", "4096"), SUCCESS) | |
264 | + EXPECT_EQ(fb->ResizePartition(test_partition_name, "4096"), SUCCESS) | |
252 | 265 | << "resize-logical-partition failed"; |
253 | 266 | std::vector<char> buf(4096); |
254 | 267 | |
255 | 268 | GTEST_LOG_(INFO) << "Flashing a logical partition.."; |
256 | - EXPECT_EQ(fb->FlashPartition("test_partition_a", buf), SUCCESS) | |
269 | + EXPECT_EQ(fb->FlashPartition(test_partition_name, buf), SUCCESS) | |
257 | 270 | << "flash logical -partition failed"; |
258 | 271 | GTEST_LOG_(INFO) << "Rebooting to bootloader mode"; |
259 | 272 | // Reboot to bootloader mode and attempt to flash the logical partitions |
@@ -262,7 +275,7 @@ TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) { | ||
262 | 275 | ReconnectFastbootDevice(); |
263 | 276 | ASSERT_FALSE(UserSpaceFastboot()); |
264 | 277 | GTEST_LOG_(INFO) << "Attempt to flash a logical partition.."; |
265 | - EXPECT_EQ(fb->FlashPartition("test_partition", buf), DEVICE_FAIL) | |
278 | + EXPECT_EQ(fb->FlashPartition(test_partition_name, buf), DEVICE_FAIL) | |
266 | 279 | << "flash logical partition must fail in bootloader"; |
267 | 280 | GTEST_LOG_(INFO) << "Rebooting back to fastbootd mode"; |
268 | 281 | fb->RebootTo("fastboot"); |
@@ -270,7 +283,7 @@ TEST_F(LogicalPartitionCompliance, CreateResizeDeleteLP) { | ||
270 | 283 | ReconnectFastbootDevice(); |
271 | 284 | ASSERT_TRUE(UserSpaceFastboot()); |
272 | 285 | GTEST_LOG_(INFO) << "Testing 'fastboot delete-logical-partition' command"; |
273 | - EXPECT_EQ(fb->DeletePartition("test_partition_a"), SUCCESS) | |
286 | + EXPECT_EQ(fb->DeletePartition(test_partition_name), SUCCESS) | |
274 | 287 | << "delete logical-partition failed"; |
275 | 288 | } |
276 | 289 |
@@ -414,7 +414,8 @@ Commands | ||
414 | 414 | |
415 | 415 | `class_start_post_data <serviceclass>` |
416 | 416 | > Like `class_start`, but only considers services that were started |
417 | - after /data was mounted. Only used for FDE devices. | |
417 | + after /data was mounted, and that were running at the time | |
418 | + `class_reset_post_data` was called. Only used for FDE devices. | |
418 | 419 | |
419 | 420 | `class_stop <serviceclass>` |
420 | 421 | > Stop and disable all services of the specified class if they are |
@@ -104,35 +104,36 @@ static void ForEachServiceInClass(const std::string& classname, F function) { | ||
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -static Result<Success> class_start(const std::string& class_name, bool post_data_only) { | |
107 | +static Result<Success> do_class_start(const BuiltinArguments& args) { | |
108 | 108 | // Do not start a class if it has a property persist.dont_start_class.CLASS set to 1. |
109 | - if (android::base::GetBoolProperty("persist.init.dont_start_class." + class_name, false)) | |
109 | + if (android::base::GetBoolProperty("persist.init.dont_start_class." + args[1], false)) | |
110 | 110 | return Success(); |
111 | 111 | // Starting a class does not start services which are explicitly disabled. |
112 | 112 | // They must be started individually. |
113 | 113 | for (const auto& service : ServiceList::GetInstance()) { |
114 | - if (service->classnames().count(class_name)) { | |
115 | - if (post_data_only && !service->is_post_data()) { | |
116 | - continue; | |
117 | - } | |
114 | + if (service->classnames().count(args[1])) { | |
118 | 115 | if (auto result = service->StartIfNotDisabled(); !result) { |
119 | 116 | LOG(ERROR) << "Could not start service '" << service->name() |
120 | - << "' as part of class '" << class_name << "': " << result.error(); | |
117 | + << "' as part of class '" << args[1] << "': " << result.error(); | |
121 | 118 | } |
122 | 119 | } |
123 | 120 | } |
124 | 121 | return Success(); |
125 | 122 | } |
126 | 123 | |
127 | -static Result<Success> do_class_start(const BuiltinArguments& args) { | |
128 | - return class_start(args[1], false /* post_data_only */); | |
129 | -} | |
130 | - | |
131 | 124 | static Result<Success> do_class_start_post_data(const BuiltinArguments& args) { |
132 | 125 | if (args.context != kInitContext) { |
133 | 126 | return Error() << "command 'class_start_post_data' only available in init context"; |
134 | 127 | } |
135 | - return class_start(args[1], true /* post_data_only */); | |
128 | + for (const auto& service : ServiceList::GetInstance()) { | |
129 | + if (service->classnames().count(args[1])) { | |
130 | + if (auto result = service->StartIfPostData(); !result) { | |
131 | + LOG(ERROR) << "Could not start service '" << service->name() | |
132 | + << "' as part of class '" << args[1] << "': " << result.error(); | |
133 | + } | |
134 | + } | |
135 | + } | |
136 | + return Success(); | |
136 | 137 | } |
137 | 138 | |
138 | 139 | static Result<Success> do_class_stop(const BuiltinArguments& args) { |
@@ -1154,10 +1154,23 @@ void Service::Reset() { | ||
1154 | 1154 | |
1155 | 1155 | void Service::ResetIfPostData() { |
1156 | 1156 | if (post_data_) { |
1157 | + if (flags_ & SVC_RUNNING) { | |
1158 | + running_at_post_data_reset_ = true; | |
1159 | + } | |
1157 | 1160 | StopOrReset(SVC_RESET); |
1158 | 1161 | } |
1159 | 1162 | } |
1160 | 1163 | |
1164 | +Result<Success> Service::StartIfPostData() { | |
1165 | + // Start the service, but only if it was started after /data was mounted, | |
1166 | + // and it was still running when we reset the post-data services. | |
1167 | + if (running_at_post_data_reset_) { | |
1168 | + return Start(); | |
1169 | + } | |
1170 | + | |
1171 | + return Success(); | |
1172 | +} | |
1173 | + | |
1161 | 1174 | void Service::Stop() { |
1162 | 1175 | StopOrReset(SVC_DISABLED); |
1163 | 1176 | } |
@@ -79,6 +79,7 @@ class Service { | ||
79 | 79 | Result<Success> ExecStart(); |
80 | 80 | Result<Success> Start(); |
81 | 81 | Result<Success> StartIfNotDisabled(); |
82 | + Result<Success> StartIfPostData(); | |
82 | 83 | Result<Success> Enable(); |
83 | 84 | void Reset(); |
84 | 85 | void ResetIfPostData(); |
@@ -248,6 +249,8 @@ class Service { | ||
248 | 249 | bool pre_apexd_ = false; |
249 | 250 | |
250 | 251 | bool post_data_ = false; |
252 | + | |
253 | + bool running_at_post_data_reset_ = false; | |
251 | 254 | }; |
252 | 255 | |
253 | 256 | class ServiceList { |
@@ -174,6 +174,7 @@ namespace.media.search.paths = /apex/com.android.media/${LIB} | ||
174 | 174 | namespace.media.asan.search.paths = /apex/com.android.media/${LIB} |
175 | 175 | |
176 | 176 | namespace.media.permitted.paths = /apex/com.android.media/${LIB}/extractors |
177 | +namespace.media.asan.permitted.paths = /apex/com.android.media/${LIB}/extractors | |
177 | 178 | |
178 | 179 | namespace.media.links = default |
179 | 180 | namespace.media.link.default.shared_libs = %LLNDK_LIBRARIES% |
@@ -616,6 +617,7 @@ namespace.media.search.paths = /apex/com.android.media/${LIB} | ||
616 | 617 | namespace.media.asan.search.paths = /apex/com.android.media/${LIB} |
617 | 618 | |
618 | 619 | namespace.media.permitted.paths = /apex/com.android.media/${LIB}/extractors |
620 | +namespace.media.asan.permitted.paths = /apex/com.android.media/${LIB}/extractors | |
619 | 621 | |
620 | 622 | namespace.media.links = default |
621 | 623 | namespace.media.link.default.shared_libs = %LLNDK_LIBRARIES% |