Make userspace_reboot.in_progress sysprop-as-api
sys.init.userspace_reboot.in_progress will be used to notify all the processes (including vendor ones) that userspace reboot is happening, hence it should be treated as stable public api. All other sys.init.userspace_reboot.* props will be internal to /system partition and don't require any stability guarantees. Test: builds Test: adb reboot userspace Bug: 135984674 Change-Id: Ifb64a6bfae2de76bac67edea68df44e33c9cfe2d
This commit is contained in:
parent
dc4bd2714c
commit
23dbd6dc11
8 changed files with 60 additions and 5 deletions
|
@ -152,6 +152,7 @@ cc_library_static {
|
|||
whole_static_libs: [
|
||||
"libcap",
|
||||
"com.android.sysprop.apex",
|
||||
"com.android.sysprop.init",
|
||||
],
|
||||
header_libs: ["bootimg_headers"],
|
||||
proto: {
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include <ApexProperties.sysprop.h>
|
||||
#include <InitProperties.sysprop.h>
|
||||
#include <android-base/chrono_utils.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
|
@ -1222,7 +1223,9 @@ static Result<void> do_finish_userspace_reboot(const BuiltinArguments&) {
|
|||
boot_clock::time_point now = boot_clock::now();
|
||||
property_set("sys.init.userspace_reboot.last_finished",
|
||||
std::to_string(now.time_since_epoch().count()));
|
||||
property_set(kUserspaceRebootInProgress, "0");
|
||||
if (!android::sysprop::InitProperties::userspace_reboot_in_progress(false)) {
|
||||
return Error() << "Failed to set sys.init.userspace_reboot.in_progress property";
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <InitProperties.sysprop.h>
|
||||
#include <android-base/chrono_utils.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
|
@ -743,8 +744,8 @@ static Result<void> DoUserspaceReboot() {
|
|||
// actions. We should make sure, that all of them are propagated before
|
||||
// proceeding with userspace reboot. Synchronously setting kUserspaceRebootInProgress property
|
||||
// is not perfect, but it should do the trick.
|
||||
if (property_set(kUserspaceRebootInProgress, "1") != 0) {
|
||||
return Error() << "Failed to set property " << kUserspaceRebootInProgress;
|
||||
if (!android::sysprop::InitProperties::userspace_reboot_in_progress(true)) {
|
||||
return Error() << "Failed to set sys.init.userspace_reboot.in_progress property";
|
||||
}
|
||||
EnterShutdown();
|
||||
std::vector<Service*> stop_first;
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
namespace android {
|
||||
namespace init {
|
||||
|
||||
static const constexpr char* kUserspaceRebootInProgress = "sys.init.userspace_reboot.in_progress";
|
||||
|
||||
// Parses and handles a setprop sys.powerctl message.
|
||||
void HandlePowerctlMessage(const std::string& command);
|
||||
|
||||
|
|
7
init/sysprop/Android.bp
Normal file
7
init/sysprop/Android.bp
Normal file
|
@ -0,0 +1,7 @@
|
|||
sysprop_library {
|
||||
name: "com.android.sysprop.init",
|
||||
srcs: ["InitProperties.sysprop"],
|
||||
property_owner: "Platform",
|
||||
api_packages: ["android.sysprop"],
|
||||
recovery_available: true,
|
||||
}
|
27
init/sysprop/InitProperties.sysprop
Normal file
27
init/sysprop/InitProperties.sysprop
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Copyright (C) 2019 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
owner: Platform
|
||||
module: "android.sysprop.InitProperties"
|
||||
|
||||
# Serves as a signal to all processes that userspace reboot is happening.
|
||||
prop {
|
||||
api_name: "userspace_reboot_in_progress"
|
||||
type: Boolean
|
||||
scope: Public
|
||||
access: ReadWrite
|
||||
prop_name: "sys.init.userspace_reboot.in_progress"
|
||||
integer_as_bool: true
|
||||
}
|
||||
|
9
init/sysprop/api/com.android.sysprop.init-current.txt
Normal file
9
init/sysprop/api/com.android.sysprop.init-current.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
props {
|
||||
module: "android.sysprop.InitProperties"
|
||||
prop {
|
||||
api_name: "userspace_reboot_in_progress"
|
||||
access: ReadWrite
|
||||
prop_name: "sys.init.userspace_reboot.in_progress"
|
||||
integer_as_bool: true
|
||||
}
|
||||
}
|
9
init/sysprop/api/com.android.sysprop.init-latest.txt
Normal file
9
init/sysprop/api/com.android.sysprop.init-latest.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
props {
|
||||
module: "android.sysprop.InitProperties"
|
||||
prop {
|
||||
api_name: "userspace_reboot_in_progress"
|
||||
scope: Public
|
||||
prop_name: "sys.init.userspace_reboot.in_progress"
|
||||
integer_as_bool: true
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue