From e8f1a7fdc8f8f7db975d8cb27b718b60749a413b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 7 Oct 2019 12:28:18 -0700 Subject: [PATCH] Introduce IBootControl 1.1. libsnapshot needs to communicate to the bootloader that a merge is in progress. This can be used to prevent factory data resets, prevent flashing or wiping userdata/metadata, and warning when the active slot changes. Bug: 138861550 Test: builds Change-Id: I577877696b5ec6920b9520d518374931ce9ddfaa Merged-In: I577877696b5ec6920b9520d518374931ce9ddfaa --- boot/1.1/Android.bp | 18 +++++ boot/1.1/IBootControl.hal | 66 +++++++++++++++++++ boot/1.1/types.hal | 44 +++++++++++++ .../compatibility_matrix.current.xml | 2 +- current.txt | 4 ++ 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 boot/1.1/Android.bp create mode 100644 boot/1.1/IBootControl.hal create mode 100644 boot/1.1/types.hal diff --git a/boot/1.1/Android.bp b/boot/1.1/Android.bp new file mode 100644 index 0000000000..6a8d57aa8c --- /dev/null +++ b/boot/1.1/Android.bp @@ -0,0 +1,18 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "android.hardware.boot@1.1", + root: "android.hardware", + vndk: { + enabled: true, + }, + srcs: [ + "types.hal", + "IBootControl.hal", + ], + interfaces: [ + "android.hardware.boot@1.0", + "android.hidl.base@1.0", + ], + gen_java: true, +} diff --git a/boot/1.1/IBootControl.hal b/boot/1.1/IBootControl.hal new file mode 100644 index 0000000000..939dfb3d74 --- /dev/null +++ b/boot/1.1/IBootControl.hal @@ -0,0 +1,66 @@ +/* + * Copyright 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. + */ + +package android.hardware.boot@1.1; + +import @1.0::IBootControl; + +interface IBootControl extends @1.0::IBootControl { + /** + * Sets whether a snapshot-merge of any dynamic partition is in progress. + * + * After the merge status is set to a given value, subsequent calls to + * getSnapshotMergeStatus must return the set value. + * + * The merge status must be persistent across reboots. That is, getSnapshotMergeStatus + * must return the same value after a reboot if the merge status is not altered in any way + * (e.g. set by setSnapshotMergeStatus or set to CANCELLED by bootloader). + * + * Read/write access to the merge status must be atomic. When the HAL is processing a + * setSnapshotMergeStatus call, all subsequent calls to getSnapshotMergeStatus must block until + * setSnapshotMergeStatus has returned. + * + * A MERGING state indicates that dynamic partitions are partially comprised by blocks in the + * userdata partition. + * + * When the merge status is set to MERGING, the following operations must be prohibited from the + * bootloader: + * - Flashing or erasing "userdata" or "metadata". + * + * The following operations may be prohibited when the status is set to MERGING. If not + * prohibited, it is recommended that the user receive a warning. + * - Changing the active slot (e.g. via "fastboot set_active") + * + * @param status Merge status. + * + * @return success True on success, false otherwise. + */ + setSnapshotMergeStatus(MergeStatus status) generates (bool success); + + /** + * Returns whether a snapshot-merge of any dynamic partition is in progress. + * + * This function must return the merge status set by the last setSnapshotMergeStatus call and + * recorded by the bootloader with one exception. If the partitions are being flashed from the + * bootloader such that the pending merge must be canceled (for example, if the super partition + * is being flashed), this function must return CANCELLED. + * + * @return success True if the merge status is read successfully, false otherwise. + * @return status Merge status. + */ + getSnapshotMergeStatus() generates (MergeStatus status); +}; + diff --git a/boot/1.1/types.hal b/boot/1.1/types.hal new file mode 100644 index 0000000000..6346078c81 --- /dev/null +++ b/boot/1.1/types.hal @@ -0,0 +1,44 @@ +/* + * Copyright 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. + */ + +package android.hardware.boot@1.1; + +enum MergeStatus : int32_t { + /** + * No snapshot or merge is in progress. + */ + NONE = 0, + + /** + * The merge status could not be determined. + */ + UNKNOWN, + + /** + * Partitions are being snapshotted, but no merge has been started. + */ + SNAPSHOTTED, + + /** + * At least one partition has merge is in progress. + */ + MERGING, + + /** + * A merge was in progress, but it was canceled by the bootloader. + */ + CANCELLED, +}; diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml index be8d7cadd7..82bb94181b 100644 --- a/compatibility_matrices/compatibility_matrix.current.xml +++ b/compatibility_matrices/compatibility_matrix.current.xml @@ -89,7 +89,7 @@ android.hardware.boot - 1.0 + 1.1 IBootControl default diff --git a/current.txt b/current.txt index 6f9f4d4c81..66dbf652f4 100644 --- a/current.txt +++ b/current.txt @@ -579,3 +579,7 @@ fb382e986c10b8fbb797a8546e8f9ea6d1107bfe6f3fb7e57f6bbbf1f807a906 android.hardwar a785a57447a81e9c130eef6904c3a5c256076c6a04588c40620ebd6fa2660d77 android.hardware.radio@1.2::types 1a6e2bd289f22931c526b21916910f1d4c436b7acb9556e4243de4ce8e6cc2e4 android.hardware.soundtrigger@2.0::ISoundTriggerHwCallback fd65298e1e09e0e3c781ab18305920d757dbe55a3b459ce17814ec5cf6dfee99 android.hardware.wifi@1.0::IWifiP2pIface + +# HALs released in Android R +07d0a252b2d8fa35887908a996ba395cf392968395fc30afab791f46e0c22a52 android.hardware.boot@1.1::IBootControl +74049a402be913963edfdd80828a53736570e9d8124a1bf18166b6ed46a6b0ab android.hardware.boot@1.1::types