Snap for 11227258 from 477d1dae77f35050987d292a5ad1b6593df1475c to 24Q2-release
Change-Id: I456dbb7f7bb1d9fb211a3883e61cbdca56e41820
This commit is contained in:
commit
1a4ee7e1aa
45
Android.bp
Normal file
45
Android.bp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright (C) 2023 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 {
|
||||
default_applicable_licenses: ["device_google_gs-common_license"],
|
||||
}
|
||||
|
||||
// Added automatically by a large-scale-change that took the approach of
|
||||
// 'apply every license found to every target'. While this makes sure we respect
|
||||
// every license restriction, it may not be entirely correct.
|
||||
//
|
||||
// e.g. GPL in an MIT project might only apply to the contrib/ directory.
|
||||
//
|
||||
// Please consider splitting the single license below into multiple licenses,
|
||||
// taking care not to lose any license_kind information, and overriding the
|
||||
// default license using the 'licenses: [...]' property on targets as needed.
|
||||
//
|
||||
// For unused files, consider creating a 'fileGroup' with "//visibility:private"
|
||||
// to attach the license to, and including a comment whether the files may be
|
||||
// used in the current project.
|
||||
// See: http://go/android-license-faq
|
||||
license {
|
||||
name: "device_google_gs-common_license",
|
||||
visibility: [":__subpackages__"],
|
||||
license_kinds: [
|
||||
"SPDX-license-identifier-Apache-2.0",
|
||||
"SPDX-license-identifier-BSD",
|
||||
],
|
||||
license_text: [
|
||||
"NOTICE",
|
||||
],
|
||||
}
|
190
NOTICE
Normal file
190
NOTICE
Normal file
@ -0,0 +1,190 @@
|
||||
|
||||
Copyright (c) 2014, 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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
@ -20,4 +20,5 @@ allow aocd device:dir r_dir_perms;
|
||||
|
||||
# set properties
|
||||
set_prop(aocd, vendor_aoc_prop)
|
||||
set_prop(aocd, vendor_timeout_aoc_prop)
|
||||
set_prop(aocd, vendor_timeout_aoc_prop)
|
||||
get_prop(aocd, vendor_volte_mif_off)
|
@ -20,6 +20,8 @@
|
||||
/dev/acd-com.google.usf.non_wake_up u:object_r:aoc_device:s0
|
||||
/dev/acd-com.google.chre u:object_r:aoc_device:s0
|
||||
/dev/acd-com.google.chre.non_wake_up u:object_r:aoc_device:s0
|
||||
/dev/acd-com.google.bt u:object_r:aoc_device:s0
|
||||
/dev/acd-com.google.bt.non_wake_up u:object_r:aoc_device:s0
|
||||
/dev/acd-logging u:object_r:aoc_device:s0
|
||||
/dev/aoc u:object_r:aoc_device:s0
|
||||
/dev/acd-audio_ap_offload_rx u:object_r:aoc_device:s0
|
||||
|
@ -1,3 +1,4 @@
|
||||
# AoC
|
||||
vendor_internal_prop(vendor_aoc_prop)
|
||||
vendor_internal_prop(vendor_timeout_aoc_prop)
|
||||
vendor_internal_prop(vendor_timeout_aoc_prop)
|
||||
vendor_internal_prop(vendor_volte_mif_off)
|
||||
|
@ -1,3 +1,4 @@
|
||||
# AoC
|
||||
vendor.aoc.firmware.version u:object_r:vendor_aoc_prop:s0
|
||||
persist.vendor.aoc.status_request_timed_out u:object_r:vendor_timeout_aoc_prop:s0
|
||||
persist.vendor.aoc.status_request_timed_out u:object_r:vendor_timeout_aoc_prop:s0
|
||||
persist.vendor.radio.volte_mif_off u:object_r:vendor_volte_mif_off:s0
|
@ -26,6 +26,8 @@ hal_client_domain(hal_audio_default, hal_health);
|
||||
hal_client_domain(hal_audio_default, hal_thermal);
|
||||
allow hal_audio_default fwk_sensor_hwservice:hwservice_manager find;
|
||||
|
||||
hal_client_domain(hal_audio_default, hal_graphics_allocator);
|
||||
|
||||
userdebug_or_eng(`
|
||||
allow hal_audio_default self:unix_stream_socket create_stream_socket_perms;
|
||||
allow hal_audio_default audio_vendor_data_file:sock_file { create unlink };
|
||||
|
@ -77,7 +77,6 @@ const struct MitigationConfig::EventThreadConfig eventThreadCfg = {
|
||||
{"cpu0_freq", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"},
|
||||
{"cpu1_freq", "/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq"},
|
||||
{"cpu2_freq", "/sys/devices/system/cpu/cpu2/cpufreq/scaling_cur_freq"},
|
||||
{"gpu_freq", "/sys/devices/platform/1f000000.mali/cur_freq"},
|
||||
{"battery_temp", "/dev/thermal/tz-by-name/battery/temp"},
|
||||
{"battery_cycle", "/dev/thermal/tz-by-name/battery_cycle/temp"},
|
||||
{"voltage_now", "/sys/class/power_supply/battery/voltage_now"},
|
||||
@ -115,25 +114,24 @@ const struct MitigationConfig::EventThreadConfig eventThreadCfg = {
|
||||
},
|
||||
},
|
||||
.PlatformSpecific = {
|
||||
/* MIN_SUPPORTED_PLATFORM */
|
||||
{
|
||||
.MainPmicName = "s2mpg10-odpm\n",
|
||||
.SubPmicName = "s2mpg11-odpm\n",
|
||||
},
|
||||
{
|
||||
.MainPmicName = "s2mpg12-odpm\n",
|
||||
.SubPmicName = "s2mpg13-odpm\n",
|
||||
},
|
||||
{
|
||||
.MainPmicName = "s2mpg14-odpm\n",
|
||||
.SubPmicName = "s2mpg15-odpm\n",
|
||||
},
|
||||
/* MAX_SUPPORTED_PLATFORM */
|
||||
{
|
||||
.MainPmicName = "s2mpg14-odpm\n",
|
||||
.SubPmicName = "s2mpg15-odpm\n",
|
||||
},
|
||||
.NumericSysfsStatPaths = {
|
||||
{
|
||||
.name = "battery_soc",
|
||||
.paths = {
|
||||
"/sys/class/power_supply/max77759fg/capacity",
|
||||
"/sys/class/power_supply/max77779fg/capacity",
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = "gpu_freq",
|
||||
.paths = {
|
||||
"/sys/devices/platform/1c500000.mali/cur_freq",
|
||||
"/sys/devices/platform/28000000.mali/cur_freq",
|
||||
"/sys/devices/platform/1f000000.mali/cur_freq",
|
||||
},
|
||||
},
|
||||
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -142,29 +140,17 @@ const char kReadyProperty[] = "vendor.brownout.mitigation.ready";
|
||||
const char kLastMealPath[] = "/data/vendor/mitigation/lastmeal.txt";
|
||||
const char kBRRequestedProperty[] = "vendor.brownout_reason";
|
||||
const char kLastMealProperty[] = "vendor.brownout.br.feasible";
|
||||
const char kCDTProperty[] = "ro.boot.cdt_hwid";
|
||||
const std::regex kTimestampRegex("^\\S+\\s[0-9]+:[0-9]+:[0-9]+\\S+$");
|
||||
|
||||
std::string GetSystemProperty(std::string property) {
|
||||
char value[PROP_VALUE_MAX];
|
||||
__system_property_get(property.c_str(), value);
|
||||
return std::string(value);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::string cdt = GetSystemProperty(kCDTProperty);
|
||||
int platformNum = atoi(cdt.substr(5, 1).c_str());
|
||||
batteryMitigationService = new BatteryMitigationService(eventThreadCfg,
|
||||
platformNum);
|
||||
batteryMitigationService = new BatteryMitigationService(eventThreadCfg);
|
||||
if (!batteryMitigationService) {
|
||||
return 0;
|
||||
}
|
||||
bool platformSupported = batteryMitigationService->isPlatformSupported();
|
||||
bool brownoutStatsBinarySupported = batteryMitigationService->isBrownoutStatsBinarySupported();
|
||||
if (argc == 2) {
|
||||
if(strcmp(argv[1], "-d") == 0 &&
|
||||
brownoutStatsBinarySupported &&
|
||||
platformSupported) {
|
||||
brownoutStatsBinarySupported) {
|
||||
/* Create thismeal.txt from thismeal.bin */
|
||||
batteryMitigationService->genParsedMeal(eventThreadCfg.ParsedThismealPath);
|
||||
}
|
||||
|
89
bootctrl/1.2/Android.bp
Normal file
89
bootctrl/1.2/Android.bp
Normal file
@ -0,0 +1,89 @@
|
||||
//
|
||||
// Copyright (C) 2020 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.
|
||||
|
||||
soong_namespace {
|
||||
imports: [
|
||||
"hardware/google/pixel",
|
||||
],
|
||||
}
|
||||
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "//device/google/gs-common:device_google_gs-common_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: [
|
||||
"//device/google/gs-common:device_google_gs-common_license",
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.boot@1.2-service-pixel",
|
||||
defaults: ["hidl_defaults"],
|
||||
relative_install_path: "hw",
|
||||
vendor: true,
|
||||
init_rc: ["android.hardware.boot@1.2-service-pixel.rc"],
|
||||
srcs: [
|
||||
"BootControl.cpp",
|
||||
"GptUtils.cpp",
|
||||
"service.cpp"
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"liblog",
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"libz",
|
||||
"libtrusty",
|
||||
"android.hardware.boot@1.0",
|
||||
"android.hardware.boot@1.1",
|
||||
"android.hardware.boot@1.2",
|
||||
],
|
||||
static_libs: [
|
||||
"libboot_control",
|
||||
"libbootloader_message_vendor",
|
||||
"libfstab",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "android.hardware.boot@1.2-impl-pixel",
|
||||
stem: "android.hardware.boot@1.0-impl-1.2-impl-pixel",
|
||||
recovery: true,
|
||||
srcs: [
|
||||
"BootControl.cpp",
|
||||
"GptUtils.cpp",
|
||||
],
|
||||
relative_install_path: "hw",
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"liblog",
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"libz",
|
||||
"libtrusty",
|
||||
"android.hardware.boot@1.0",
|
||||
"android.hardware.boot@1.1",
|
||||
"android.hardware.boot@1.2",
|
||||
],
|
||||
static_libs: [
|
||||
"libboot_control",
|
||||
"libbootloader_message_vendor",
|
||||
"libfstab",
|
||||
],
|
||||
}
|
526
bootctrl/1.2/BootControl.cpp
Normal file
526
bootctrl/1.2/BootControl.cpp
Normal file
@ -0,0 +1,526 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "bootcontrolhal"
|
||||
|
||||
#include "BootControl.h"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <bootloader_message/bootloader_message.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <libboot_control/libboot_control.h>
|
||||
#include <log/log.h>
|
||||
#include <trusty/tipc.h>
|
||||
|
||||
#include "DevInfo.h"
|
||||
#include "GptUtils.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace boot {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
using android::bootable::GetMiscVirtualAbMergeStatus;
|
||||
using android::bootable::InitMiscVirtualAbMessageIfNeeded;
|
||||
using android::bootable::SetMiscVirtualAbMergeStatus;
|
||||
using android::hardware::boot::V1_0::BoolResult;
|
||||
using android::hardware::boot::V1_0::CommandResult;
|
||||
using android::hardware::boot::V1_1::MergeStatus;
|
||||
|
||||
namespace {
|
||||
|
||||
// clang-format off
|
||||
|
||||
#define BOOT_A_PATH "/dev/block/by-name/boot_a"
|
||||
#define BOOT_B_PATH "/dev/block/by-name/boot_b"
|
||||
#define DEVINFO_PATH "/dev/block/by-name/devinfo"
|
||||
|
||||
#define BLOW_AR_PATH "/sys/kernel/boot_control/blow_ar"
|
||||
|
||||
// slot flags
|
||||
#define AB_ATTR_PRIORITY_SHIFT 52
|
||||
#define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT)
|
||||
#define AB_ATTR_ACTIVE_SHIFT 54
|
||||
#define AB_ATTR_ACTIVE (1UL << AB_ATTR_ACTIVE_SHIFT)
|
||||
#define AB_ATTR_RETRY_COUNT_SHIFT (55)
|
||||
#define AB_ATTR_RETRY_COUNT_MASK (7UL << AB_ATTR_RETRY_COUNT_SHIFT)
|
||||
#define AB_ATTR_SUCCESSFUL (1UL << 58)
|
||||
#define AB_ATTR_UNBOOTABLE (1UL << 59)
|
||||
|
||||
#define AB_ATTR_MAX_PRIORITY 3UL
|
||||
#define AB_ATTR_MAX_RETRY_COUNT 3UL
|
||||
|
||||
// clang-format on
|
||||
|
||||
static std::string getDevPath(uint32_t slot) {
|
||||
char real_path[PATH_MAX];
|
||||
|
||||
const char *path = slot == 0 ? BOOT_A_PATH : BOOT_B_PATH;
|
||||
|
||||
int ret = readlink(path, real_path, sizeof real_path);
|
||||
if (ret < 0) {
|
||||
ALOGE("readlink failed for boot device %s\n", strerror(errno));
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string dp(real_path);
|
||||
// extract /dev/sda.. part
|
||||
return dp.substr(0, sizeof "/dev/block/sdX" - 1);
|
||||
}
|
||||
|
||||
static bool isSlotFlagSet(uint32_t slot, uint64_t flag) {
|
||||
std::string dev_path = getDevPath(slot);
|
||||
if (dev_path.empty()) {
|
||||
ALOGI("Could not get device path for slot %d\n", slot);
|
||||
return false;
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
if (gpt.Load()) {
|
||||
ALOGI("failed to load gpt data\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
|
||||
if (e == nullptr) {
|
||||
ALOGI("failed to get gpt entry\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(e->attr & flag);
|
||||
}
|
||||
|
||||
static bool setSlotFlag(uint32_t slot, uint64_t flag) {
|
||||
std::string dev_path = getDevPath(slot);
|
||||
if (dev_path.empty()) {
|
||||
ALOGI("Could not get device path for slot %d\n", slot);
|
||||
return false;
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
if (gpt.Load()) {
|
||||
ALOGI("failed to load gpt data\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
|
||||
if (e == nullptr) {
|
||||
ALOGI("failed to get gpt entry\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
e->attr |= flag;
|
||||
gpt.Sync();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool is_devinfo_valid;
|
||||
static bool is_devinfo_initialized;
|
||||
static std::mutex devinfo_lock;
|
||||
static devinfo_t devinfo;
|
||||
|
||||
static bool isDevInfoValid() {
|
||||
const std::lock_guard<std::mutex> lock(devinfo_lock);
|
||||
|
||||
if (is_devinfo_initialized) {
|
||||
return is_devinfo_valid;
|
||||
}
|
||||
|
||||
is_devinfo_initialized = true;
|
||||
|
||||
android::base::unique_fd fd(open(DEVINFO_PATH, O_RDONLY));
|
||||
android::base::ReadFully(fd, &devinfo, sizeof devinfo);
|
||||
|
||||
if (devinfo.magic != DEVINFO_MAGIC) {
|
||||
return is_devinfo_valid;
|
||||
}
|
||||
|
||||
uint32_t version = ((uint32_t)devinfo.ver_major << 16) | devinfo.ver_minor;
|
||||
// only version 3.3+ supports A/B data
|
||||
if (version >= 0x0003'0003) {
|
||||
is_devinfo_valid = true;
|
||||
}
|
||||
|
||||
return is_devinfo_valid;
|
||||
}
|
||||
|
||||
static bool DevInfoSync() {
|
||||
if (!isDevInfoValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY | O_DSYNC));
|
||||
return android::base::WriteFully(fd, &devinfo, sizeof devinfo);
|
||||
}
|
||||
|
||||
static void DevInfoInitSlot(devinfo_ab_slot_data_t &slot_data) {
|
||||
slot_data.retry_count = AB_ATTR_MAX_RETRY_COUNT;
|
||||
slot_data.unbootable = 0;
|
||||
slot_data.successful = 0;
|
||||
slot_data.active = 1;
|
||||
slot_data.fastboot_ok = 0;
|
||||
}
|
||||
|
||||
static int blow_otp_AR(bool secure) {
|
||||
static const char *dev_name = "/dev/trusty-ipc-dev0";
|
||||
static const char *otp_name = "com.android.trusty.otp_manager.tidl";
|
||||
int fd = 1, ret = 0;
|
||||
uint32_t cmd = secure? OTP_CMD_write_antirbk_secure_ap : OTP_CMD_write_antirbk_non_secure_ap;
|
||||
fd = tipc_connect(dev_name, otp_name);
|
||||
if (fd < 0) {
|
||||
ALOGI("Failed to connect to OTP_MGR ns TA - is it missing?\n");
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct otp_mgr_req_base req = {
|
||||
.command = cmd,
|
||||
.resp_payload_size = 0,
|
||||
};
|
||||
struct iovec iov[] = {
|
||||
{
|
||||
.iov_base = &req,
|
||||
.iov_len = sizeof(req),
|
||||
},
|
||||
};
|
||||
|
||||
int rc = tipc_send(fd, iov, 1, NULL, 0);
|
||||
if (rc != sizeof(req)) {
|
||||
ALOGI("Send fail! %x\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct otp_mgr_rsp_base resp;
|
||||
rc = read(fd, &resp, sizeof(resp));
|
||||
if (rc < 0) {
|
||||
ALOGI("Read fail! %x\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc < sizeof(resp)) {
|
||||
ALOGI("Not enough data! %x\n", rc);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (resp.command != (cmd | OTP_RESP_BIT)) {
|
||||
ALOGI("Wrong command! %x\n", resp.command);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (resp.result != 0) {
|
||||
fprintf(stderr, "AR writing error! %x\n", resp.result);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tipc_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool blowAR_zuma() {
|
||||
int ret = blow_otp_AR(true);
|
||||
if (ret) {
|
||||
ALOGI("Blow secure anti-rollback OTP failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = blow_otp_AR(false);
|
||||
if (ret) {
|
||||
ALOGI("Blow non-secure anti-rollback OTP failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool blowAR_gs101() {
|
||||
android::base::unique_fd fd(open(BLOW_AR_PATH, O_WRONLY | O_DSYNC));
|
||||
return android::base::WriteStringToFd("1", fd);
|
||||
}
|
||||
|
||||
static bool blowAR() {
|
||||
char platform[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.boot.hardware.platform", platform, "");
|
||||
|
||||
if (std::string(platform) == "gs101") {
|
||||
return blowAR_gs101();
|
||||
} else if (std::string(platform) == "gs201" || std::string(platform) == "zuma") {
|
||||
return blowAR_zuma();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
|
||||
Return<uint32_t> BootControl::getNumberSlots() {
|
||||
uint32_t slots = 0;
|
||||
|
||||
if (access(BOOT_A_PATH, F_OK) == 0)
|
||||
slots++;
|
||||
|
||||
if (access(BOOT_B_PATH, F_OK) == 0)
|
||||
slots++;
|
||||
|
||||
return slots;
|
||||
}
|
||||
|
||||
Return<uint32_t> BootControl::getCurrentSlot() {
|
||||
char suffix[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.boot.slot_suffix", suffix, "_a");
|
||||
return std::string(suffix) == "_b" ? 1 : 0;
|
||||
}
|
||||
|
||||
Return<void> BootControl::markBootSuccessful(markBootSuccessful_cb _hidl_cb) {
|
||||
if (getNumberSlots() == 0) {
|
||||
// no slots, just return true otherwise Android keeps trying
|
||||
_hidl_cb({true, ""});
|
||||
return Void();
|
||||
}
|
||||
|
||||
bool ret;
|
||||
if (isDevInfoValid()) {
|
||||
auto const slot = getCurrentSlot();
|
||||
devinfo.ab_data.slots[slot].successful = 1;
|
||||
ret = DevInfoSync();
|
||||
} else {
|
||||
ret = setSlotFlag(getCurrentSlot(), AB_ATTR_SUCCESSFUL);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
_hidl_cb({false, "Failed to set successful flag"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (!blowAR()) {
|
||||
ALOGE("Failed to blow anti-rollback counter");
|
||||
// Ignore the error, since ABL will re-trigger it on reboot
|
||||
}
|
||||
|
||||
_hidl_cb({true, ""});
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BootControl::setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) {
|
||||
if (slot >= 2) {
|
||||
_hidl_cb({false, "Invalid slot"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (isDevInfoValid()) {
|
||||
auto &active_slot_data = devinfo.ab_data.slots[slot];
|
||||
auto &inactive_slot_data = devinfo.ab_data.slots[!slot];
|
||||
|
||||
inactive_slot_data.active = 0;
|
||||
DevInfoInitSlot(active_slot_data);
|
||||
|
||||
if (!DevInfoSync()) {
|
||||
_hidl_cb({false, "Could not update DevInfo data"});
|
||||
return Void();
|
||||
}
|
||||
} else {
|
||||
std::string dev_path = getDevPath(slot);
|
||||
if (dev_path.empty()) {
|
||||
_hidl_cb({false, "Could not get device path for slot"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
if (gpt.Load()) {
|
||||
_hidl_cb({false, "failed to load gpt data"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
gpt_entry *active_entry = gpt.GetPartitionEntry(slot == 0 ? "boot_a" : "boot_b");
|
||||
gpt_entry *inactive_entry = gpt.GetPartitionEntry(slot == 0 ? "boot_b" : "boot_a");
|
||||
if (active_entry == nullptr || inactive_entry == nullptr) {
|
||||
_hidl_cb({false, "failed to get entries for boot partitions"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
ALOGV("slot active attributes %lx\n", active_entry->attr);
|
||||
ALOGV("slot inactive attributes %lx\n", inactive_entry->attr);
|
||||
|
||||
// update attributes for active and inactive
|
||||
inactive_entry->attr &= ~AB_ATTR_ACTIVE;
|
||||
active_entry->attr = AB_ATTR_ACTIVE | (AB_ATTR_MAX_PRIORITY << AB_ATTR_PRIORITY_SHIFT) |
|
||||
(AB_ATTR_MAX_RETRY_COUNT << AB_ATTR_RETRY_COUNT_SHIFT);
|
||||
}
|
||||
|
||||
char boot_dev[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.boot.bootdevice", boot_dev, "");
|
||||
if (boot_dev[0] == '\0') {
|
||||
ALOGI("failed to get ro.boot.bootdevice. try ro.boot.boot_devices\n");
|
||||
property_get("ro.boot.boot_devices", boot_dev, "");
|
||||
if (boot_dev[0] == '\0') {
|
||||
_hidl_cb({false, "invalid ro.boot.bootdevice and ro.boot.boot_devices prop"});
|
||||
return Void();
|
||||
}
|
||||
}
|
||||
|
||||
std::string boot_lun_path =
|
||||
std::string("/sys/devices/platform/") + boot_dev + "/pixel/boot_lun_enabled";
|
||||
int fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
|
||||
if (fd < 0) {
|
||||
// Try old path for kernels < 5.4
|
||||
// TODO: remove once kernel 4.19 support is deprecated
|
||||
std::string boot_lun_path =
|
||||
std::string("/sys/devices/platform/") + boot_dev + "/attributes/boot_lun_enabled";
|
||||
fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
|
||||
if (fd < 0) {
|
||||
_hidl_cb({false, "failed to open ufs attr boot_lun_enabled"});
|
||||
return Void();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// bBootLunEn
|
||||
// 0x1 => Boot LU A = enabled, Boot LU B = disable
|
||||
// 0x2 => Boot LU A = disable, Boot LU B = enabled
|
||||
//
|
||||
int ret = android::base::WriteStringToFd(slot == 0 ? "1" : "2", fd);
|
||||
close(fd);
|
||||
if (ret < 0) {
|
||||
_hidl_cb({false, "faied to write boot_lun_enabled attribute"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
_hidl_cb({true, ""});
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BootControl::setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) {
|
||||
if (slot >= 2) {
|
||||
_hidl_cb({false, "Invalid slot"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (isDevInfoValid()) {
|
||||
auto &slot_data = devinfo.ab_data.slots[slot];
|
||||
slot_data.unbootable = 1;
|
||||
if (!DevInfoSync()) {
|
||||
_hidl_cb({false, "Could not update DevInfo data"});
|
||||
return Void();
|
||||
}
|
||||
} else {
|
||||
std::string dev_path = getDevPath(slot);
|
||||
if (dev_path.empty()) {
|
||||
_hidl_cb({false, "Could not get device path for slot"});
|
||||
return Void();
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
gpt.Load();
|
||||
|
||||
gpt_entry *e = gpt.GetPartitionEntry(slot ? "boot_b" : "boot_a");
|
||||
e->attr |= AB_ATTR_UNBOOTABLE;
|
||||
|
||||
gpt.Sync();
|
||||
}
|
||||
|
||||
_hidl_cb({true, ""});
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotBootable(uint32_t slot) {
|
||||
if (getNumberSlots() == 0)
|
||||
return BoolResult::FALSE;
|
||||
if (slot >= getNumberSlots())
|
||||
return BoolResult::INVALID_SLOT;
|
||||
|
||||
bool unbootable;
|
||||
if (isDevInfoValid()) {
|
||||
auto &slot_data = devinfo.ab_data.slots[slot];
|
||||
unbootable = !!slot_data.unbootable;
|
||||
} else {
|
||||
unbootable = isSlotFlagSet(slot, AB_ATTR_UNBOOTABLE);
|
||||
}
|
||||
|
||||
return unbootable ? BoolResult::FALSE : BoolResult::TRUE;
|
||||
}
|
||||
|
||||
Return<::android::hardware::boot::V1_0::BoolResult> BootControl::isSlotMarkedSuccessful(
|
||||
uint32_t slot) {
|
||||
if (getNumberSlots() == 0) {
|
||||
// just return true so that we don't we another call trying to mark it as successful
|
||||
// when there is no slots
|
||||
return BoolResult::TRUE;
|
||||
}
|
||||
if (slot >= getNumberSlots())
|
||||
return BoolResult::INVALID_SLOT;
|
||||
|
||||
bool successful;
|
||||
if (isDevInfoValid()) {
|
||||
auto &slot_data = devinfo.ab_data.slots[slot];
|
||||
successful = !!slot_data.successful;
|
||||
} else {
|
||||
successful = isSlotFlagSet(slot, AB_ATTR_SUCCESSFUL);
|
||||
}
|
||||
|
||||
return successful ? BoolResult::TRUE : BoolResult::FALSE;
|
||||
}
|
||||
|
||||
Return<void> BootControl::getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) {
|
||||
_hidl_cb(slot == 0 ? "_a" : slot == 1 ? "_b" : "");
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::boot::V1_1::IBootControl follow.
|
||||
bool BootControl::Init() {
|
||||
return InitMiscVirtualAbMessageIfNeeded();
|
||||
}
|
||||
|
||||
Return<bool> BootControl::setSnapshotMergeStatus(
|
||||
::android::hardware::boot::V1_1::MergeStatus status) {
|
||||
return SetMiscVirtualAbMergeStatus(getCurrentSlot(), status);
|
||||
}
|
||||
|
||||
Return<::android::hardware::boot::V1_1::MergeStatus> BootControl::getSnapshotMergeStatus() {
|
||||
MergeStatus status;
|
||||
if (!GetMiscVirtualAbMergeStatus(getCurrentSlot(), &status)) {
|
||||
return MergeStatus::UNKNOWN;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::boot::V1_2::IBootControl follow.
|
||||
Return<uint32_t> BootControl::getActiveBootSlot() {
|
||||
if (getNumberSlots() == 0)
|
||||
return 0;
|
||||
|
||||
if (isDevInfoValid())
|
||||
return devinfo.ab_data.slots[1].active ? 1 : 0;
|
||||
return isSlotFlagSet(1, AB_ATTR_ACTIVE) ? 1 : 0;
|
||||
}
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
|
||||
IBootControl *HIDL_FETCH_IBootControl(const char * /* name */) {
|
||||
auto module = new BootControl();
|
||||
|
||||
module->Init();
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace boot
|
||||
} // namespace hardware
|
||||
} // namespace android
|
88
bootctrl/1.2/BootControl.h
Normal file
88
bootctrl/1.2/BootControl.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android/hardware/boot/1.2/IBootControl.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace boot {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
struct BootControl : public IBootControl {
|
||||
bool Init();
|
||||
|
||||
// Methods from ::android::hardware::boot::V1_0::IBootControl follow.
|
||||
Return<uint32_t> getNumberSlots() override;
|
||||
Return<uint32_t> getCurrentSlot() override;
|
||||
Return<void> markBootSuccessful(markBootSuccessful_cb _hidl_cb) override;
|
||||
Return<void> setActiveBootSlot(uint32_t slot, setActiveBootSlot_cb _hidl_cb) override;
|
||||
Return<void> setSlotAsUnbootable(uint32_t slot, setSlotAsUnbootable_cb _hidl_cb) override;
|
||||
Return<::android::hardware::boot::V1_0::BoolResult> isSlotBootable(uint32_t slot) override;
|
||||
Return<::android::hardware::boot::V1_0::BoolResult> isSlotMarkedSuccessful(
|
||||
uint32_t slot) override;
|
||||
Return<void> getSuffix(uint32_t slot, getSuffix_cb _hidl_cb) override;
|
||||
|
||||
// Methods from ::android::hardware::boot::V1_1::IBootControl follow.
|
||||
Return<bool> setSnapshotMergeStatus(
|
||||
::android::hardware::boot::V1_1::MergeStatus status) override;
|
||||
Return<::android::hardware::boot::V1_1::MergeStatus> getSnapshotMergeStatus() override;
|
||||
|
||||
// Methods from ::android::hardware::boot::V1_2::IBootControl follow.
|
||||
Return<uint32_t> getActiveBootSlot() override;
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
};
|
||||
|
||||
// FIXME: most likely delete, this is only for passthrough implementations
|
||||
extern "C" IBootControl *HIDL_FETCH_IBootControl(const char *name);
|
||||
|
||||
enum otpmgr_command : uint32_t {
|
||||
OTP_REQ_SHIFT = 1,
|
||||
OTP_RESP_BIT = 1,
|
||||
OTP_CMD_write_antirbk_non_secure_ap = (7 << OTP_REQ_SHIFT),
|
||||
OTP_CMD_write_antirbk_secure_ap = (8 << OTP_REQ_SHIFT),
|
||||
};
|
||||
|
||||
struct otp_mgr_req_base {
|
||||
uint32_t command;
|
||||
uint32_t resp_payload_size;
|
||||
uint8_t handle;
|
||||
}__packed;
|
||||
|
||||
struct otp_mgr_rsp_base {
|
||||
uint32_t command;
|
||||
uint32_t resp_payload_size;
|
||||
int result;
|
||||
}__packed;
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace boot
|
||||
} // namespace hardware
|
||||
} // namespace android
|
61
bootctrl/1.2/DevInfo.h
Normal file
61
bootctrl/1.2/DevInfo.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace boot {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
//
|
||||
// definitions taken from ABL code
|
||||
//
|
||||
|
||||
constexpr uint32_t DEVINFO_MAGIC = 0x49564544;
|
||||
constexpr size_t DEVINFO_AB_SLOT_COUNT = 2;
|
||||
|
||||
struct devinfo_ab_slot_data_t {
|
||||
uint8_t retry_count;
|
||||
uint8_t unbootable : 1;
|
||||
uint8_t successful : 1;
|
||||
uint8_t active : 1;
|
||||
uint8_t fastboot_ok : 1;
|
||||
uint8_t : 4;
|
||||
uint8_t unused[2];
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct {
|
||||
devinfo_ab_slot_data_t slots[DEVINFO_AB_SLOT_COUNT];
|
||||
} __attribute__((packed)) devinfo_ab_data_t;
|
||||
|
||||
struct devinfo_t {
|
||||
uint32_t magic;
|
||||
uint16_t ver_major;
|
||||
uint16_t ver_minor;
|
||||
uint8_t unused[40];
|
||||
devinfo_ab_data_t ab_data;
|
||||
uint8_t unused1[72]; // use remaining up to complete 128 bytes
|
||||
} __attribute__((packed));
|
||||
|
||||
static_assert(sizeof(devinfo_t) == 128, "invalid devinfo struct size");
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace boot
|
||||
} // namespace hardware
|
||||
} // namespace android
|
193
bootctrl/1.2/GptUtils.cpp
Normal file
193
bootctrl/1.2/GptUtils.cpp
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "bootcontrolhal"
|
||||
|
||||
#include "GptUtils.h"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <errno.h>
|
||||
#include <linux/fs.h>
|
||||
#include <log/log.h>
|
||||
#include <zlib.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace boot {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
namespace {
|
||||
|
||||
static int ValidateGptHeader(gpt_header *gpt) {
|
||||
if (gpt->signature != GPT_SIGNATURE) {
|
||||
ALOGE("invalid gpt signature 0x%lx\n", gpt->signature);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gpt->header_size != sizeof(gpt_header)) {
|
||||
ALOGE("invalid gpt header size %u\n", gpt->header_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gpt->entry_size != sizeof(gpt_entry)) {
|
||||
ALOGE("invalid gpt entry size %u\n", gpt->entry_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
GptUtils::GptUtils(const std::string dev_path) : dev_path(dev_path), fd(0) {}
|
||||
|
||||
int GptUtils::Load(void) {
|
||||
fd = open(dev_path.c_str(), O_RDWR);
|
||||
if (fd < 0) {
|
||||
ALOGE("failed to open block dev %s, %d\n", dev_path.c_str(), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, BLKSSZGET, &block_size);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to get block size %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read primary header
|
||||
lseek64(fd, block_size, SEEK_SET);
|
||||
ret = read(fd, &gpt_primary, sizeof gpt_primary);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to read gpt primary header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ValidateGptHeader(&gpt_primary)) {
|
||||
ALOGE("error validating gpt header\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read partition entries
|
||||
entry_array.resize(gpt_primary.entry_count);
|
||||
uint32_t entries_size = gpt_primary.entry_size * gpt_primary.entry_count;
|
||||
lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
|
||||
ret = read(fd, entry_array.data(), entries_size);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to read gpt partition entries %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read gpt back header
|
||||
lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
|
||||
ret = read(fd, &gpt_backup, sizeof gpt_backup);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to read gpt backup header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ValidateGptHeader(&gpt_backup)) {
|
||||
ALOGW("error validating gpt backup\n"); // just warn about it, not fail
|
||||
}
|
||||
|
||||
// Create map <partition name, gpt_entry pointer>
|
||||
auto get_name = [](const uint16_t *efi_name) {
|
||||
char name[37] = {};
|
||||
for (int i = 0; efi_name[i] && i < sizeof name - 1; ++i) name[i] = efi_name[i];
|
||||
return std::string(name);
|
||||
};
|
||||
|
||||
for (auto const &e : entry_array) {
|
||||
if (e.name[0] == 0)
|
||||
break; // stop at the first partition with no name
|
||||
std::string s = get_name(e.name);
|
||||
entries[s] = const_cast<gpt_entry *>(&e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gpt_entry *GptUtils::GetPartitionEntry(std::string name) {
|
||||
return entries.find(name) != entries.end() ? entries[name] : nullptr;
|
||||
}
|
||||
|
||||
int GptUtils::Sync(void) {
|
||||
if (!fd)
|
||||
return -1;
|
||||
|
||||
// calculate crc and check if we need to update gpt
|
||||
gpt_primary.entries_crc32 = crc32(0, reinterpret_cast<uint8_t *>(entry_array.data()),
|
||||
entry_array.size() * sizeof(gpt_entry));
|
||||
|
||||
// save old crc
|
||||
uint32_t crc = gpt_primary.crc32;
|
||||
gpt_primary.crc32 = 0;
|
||||
|
||||
gpt_primary.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_primary), sizeof gpt_primary);
|
||||
if (crc == gpt_primary.crc32)
|
||||
return 0; // nothing to do (no changes)
|
||||
|
||||
ALOGI("updating GPT\n");
|
||||
|
||||
lseek64(fd, block_size * gpt_primary.current_lba, SEEK_SET);
|
||||
int ret = write(fd, &gpt_primary, sizeof gpt_primary);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt primary header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
|
||||
ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt partition entries %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// update GPT backup entries and backup
|
||||
lseek64(fd, block_size * gpt_backup.start_lba, SEEK_SET);
|
||||
ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt backup partition entries %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpt_backup.entries_crc32 = gpt_primary.entries_crc32;
|
||||
gpt_backup.crc32 = 0;
|
||||
gpt_backup.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_backup), sizeof gpt_backup);
|
||||
lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
|
||||
ret = write(fd, &gpt_backup, sizeof gpt_backup);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt backup header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fsync(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GptUtils::~GptUtils() {
|
||||
if (fd) {
|
||||
Sync();
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace boot
|
||||
} // namespace hardware
|
||||
} // namespace android
|
79
bootctrl/1.2/GptUtils.h
Normal file
79
bootctrl/1.2/GptUtils.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace boot {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
#define GPT_SIGNATURE 0x5452415020494645UL
|
||||
|
||||
typedef struct {
|
||||
uint8_t type_guid[16];
|
||||
uint8_t guid[16];
|
||||
uint64_t first_lba;
|
||||
uint64_t last_lba;
|
||||
uint64_t attr;
|
||||
uint16_t name[36];
|
||||
} __attribute__((packed)) gpt_entry;
|
||||
|
||||
typedef struct {
|
||||
uint64_t signature;
|
||||
uint32_t revision;
|
||||
uint32_t header_size;
|
||||
uint32_t crc32;
|
||||
uint32_t reserved;
|
||||
uint64_t current_lba;
|
||||
uint64_t backup_lba;
|
||||
uint64_t first_usable_lba;
|
||||
uint64_t last_usable_lba;
|
||||
uint8_t disk_guid[16];
|
||||
uint64_t start_lba;
|
||||
uint32_t entry_count;
|
||||
uint32_t entry_size;
|
||||
uint32_t entries_crc32;
|
||||
} __attribute__((packed)) gpt_header;
|
||||
|
||||
class GptUtils {
|
||||
public:
|
||||
GptUtils(const std::string dev_path);
|
||||
int Load(void);
|
||||
gpt_entry *GetPartitionEntry(std::string name);
|
||||
int Sync(void);
|
||||
~GptUtils();
|
||||
|
||||
private:
|
||||
std::string dev_path;
|
||||
int fd;
|
||||
uint32_t block_size;
|
||||
gpt_header gpt_primary;
|
||||
gpt_header gpt_backup;
|
||||
std::vector<gpt_entry> entry_array;
|
||||
std::map<std::string, gpt_entry *> entries;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace boot
|
||||
} // namespace hardware
|
||||
} // namespace android
|
7
bootctrl/1.2/android.hardware.boot@1.2-service-pixel.rc
Normal file
7
bootctrl/1.2/android.hardware.boot@1.2-service-pixel.rc
Normal file
@ -0,0 +1,7 @@
|
||||
service vendor.boot-hal-1-2 /vendor/bin/hw/android.hardware.boot@1.2-service-pixel
|
||||
interface android.hardware.boot@1.0::IBootControl default
|
||||
interface android.hardware.boot@1.1::IBootControl default
|
||||
interface android.hardware.boot@1.2::IBootControl default
|
||||
class early_hal
|
||||
user root
|
||||
group root drmrpc
|
50
bootctrl/1.2/service.cpp
Normal file
50
bootctrl/1.2/service.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.boot@1.2-service"
|
||||
|
||||
#include <android/hardware/boot/1.2/IBootControl.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <log/log.h>
|
||||
|
||||
#include "BootControl.h"
|
||||
|
||||
using ::android::status_t;
|
||||
|
||||
using ::android::hardware::boot::V1_2::IBootControl;
|
||||
|
||||
using ::android::hardware::boot::V1_2::implementation::BootControl;
|
||||
// using ::android::hardware::boot::implementation::BootControl;
|
||||
|
||||
int main(int /* argc */, char * /* argv */[]) {
|
||||
// This function must be called before you join to ensure the proper
|
||||
// number of threads are created. The threadpool will never exceed
|
||||
// size one because of this call.
|
||||
::android::hardware::configureRpcThreadpool(1 /*threads*/, true /*willJoin*/);
|
||||
|
||||
::android::sp bootctrl = new BootControl();
|
||||
const status_t status = bootctrl->registerAsService();
|
||||
if (status != ::android::OK) {
|
||||
return 1; // or handle error
|
||||
}
|
||||
|
||||
// Adds this thread to the threadpool, resulting in one total
|
||||
// thread in the threadpool. We could also do other things, but
|
||||
// would have to specify 'false' to willJoin in configureRpcThreadpool.
|
||||
::android::hardware::joinRpcThreadpool();
|
||||
return 1; // joinRpcThreadpool should never return
|
||||
}
|
71
bootctrl/aidl/Android.bp
Normal file
71
bootctrl/aidl/Android.bp
Normal file
@ -0,0 +1,71 @@
|
||||
//
|
||||
// Copyright (C) 2023 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.
|
||||
//
|
||||
|
||||
soong_namespace {
|
||||
imports: [
|
||||
"hardware/google/pixel",
|
||||
],
|
||||
}
|
||||
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "//device/google/gs-common:device_google_gs-common_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: [
|
||||
"//device/google/gs-common:device_google_gs-common_license",
|
||||
],
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
name: "android.hardware.boot-service_common-pixel",
|
||||
relative_install_path: "hw",
|
||||
defaults: ["libboot_control_defaults"],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"libcutils",
|
||||
"libz",
|
||||
"libtrusty",
|
||||
"android.hardware.boot@1.1",
|
||||
"android.hardware.boot-V1-ndk",
|
||||
],
|
||||
static_libs: [
|
||||
"libboot_control",
|
||||
"libbootloader_message_vendor",
|
||||
],
|
||||
srcs: [
|
||||
"BootControl.cpp",
|
||||
"GptUtils.cpp",
|
||||
"service.cpp"
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.boot-service.default-pixel",
|
||||
defaults: ["android.hardware.boot-service_common-pixel"],
|
||||
init_rc: ["android.hardware.boot-service.default-pixel.rc"],
|
||||
vendor: true,
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.boot-service.default_recovery-pixel",
|
||||
defaults: ["android.hardware.boot-service_common-pixel"],
|
||||
vintf_fragments: ["android.hardware.boot-service.default_recovery-pixel.xml"],
|
||||
init_rc: ["android.hardware.boot-service.default_recovery-pixel.rc"],
|
||||
recovery: true,
|
||||
}
|
562
bootctrl/aidl/BootControl.cpp
Normal file
562
bootctrl/aidl/BootControl.cpp
Normal file
@ -0,0 +1,562 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "bootcontrolhal"
|
||||
|
||||
#include "BootControl.h"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <bootloader_message/bootloader_message.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <libboot_control/libboot_control.h>
|
||||
#include <log/log.h>
|
||||
#include <trusty/tipc.h>
|
||||
|
||||
#include "DevInfo.h"
|
||||
#include "GptUtils.h"
|
||||
|
||||
using HIDLMergeStatus = ::android::bootable::BootControl::MergeStatus;
|
||||
using ndk::ScopedAStatus;
|
||||
|
||||
using android::bootable::GetMiscVirtualAbMergeStatus;
|
||||
using android::bootable::InitMiscVirtualAbMessageIfNeeded;
|
||||
using android::bootable::SetMiscVirtualAbMergeStatus;
|
||||
|
||||
namespace aidl::android::hardware::boot {
|
||||
|
||||
namespace {
|
||||
|
||||
// clang-format off
|
||||
|
||||
#define BOOT_A_PATH "/dev/block/by-name/boot_a"
|
||||
#define BOOT_B_PATH "/dev/block/by-name/boot_b"
|
||||
#define DEVINFO_PATH "/dev/block/by-name/devinfo"
|
||||
|
||||
#define BLOW_AR_PATH "/sys/kernel/boot_control/blow_ar"
|
||||
|
||||
// slot flags
|
||||
#define AB_ATTR_PRIORITY_SHIFT 52
|
||||
#define AB_ATTR_PRIORITY_MASK (3UL << AB_ATTR_PRIORITY_SHIFT)
|
||||
#define AB_ATTR_ACTIVE_SHIFT 54
|
||||
#define AB_ATTR_ACTIVE (1UL << AB_ATTR_ACTIVE_SHIFT)
|
||||
#define AB_ATTR_RETRY_COUNT_SHIFT (55)
|
||||
#define AB_ATTR_RETRY_COUNT_MASK (7UL << AB_ATTR_RETRY_COUNT_SHIFT)
|
||||
#define AB_ATTR_SUCCESSFUL (1UL << 58)
|
||||
#define AB_ATTR_UNBOOTABLE (1UL << 59)
|
||||
|
||||
#define AB_ATTR_MAX_PRIORITY 3UL
|
||||
#define AB_ATTR_MAX_RETRY_COUNT 3UL
|
||||
|
||||
// clang-format on
|
||||
|
||||
static std::string getDevPath(int32_t in_slot) {
|
||||
char real_path[PATH_MAX];
|
||||
|
||||
const char *path = in_slot == 0 ? BOOT_A_PATH : BOOT_B_PATH;
|
||||
|
||||
int ret = readlink(path, real_path, sizeof real_path);
|
||||
if (ret < 0) {
|
||||
ALOGE("readlink failed for boot device %s\n", strerror(errno));
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string dp(real_path);
|
||||
// extract /dev/sda.. part
|
||||
return dp.substr(0, sizeof "/dev/block/sdX" - 1);
|
||||
}
|
||||
|
||||
static bool isSlotFlagSet(int32_t in_slot, uint64_t flag) {
|
||||
std::string dev_path = getDevPath(in_slot);
|
||||
if (dev_path.empty()) {
|
||||
ALOGI("Could not get device path for slot %d\n", in_slot);
|
||||
return false;
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
if (gpt.Load()) {
|
||||
ALOGI("failed to load gpt data\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
gpt_entry *e = gpt.GetPartitionEntry(in_slot ? "boot_b" : "boot_a");
|
||||
if (e == nullptr) {
|
||||
ALOGI("failed to get gpt entry\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(e->attr & flag);
|
||||
}
|
||||
|
||||
static bool setSlotFlag(int32_t in_slot, uint64_t flag) {
|
||||
std::string dev_path = getDevPath(in_slot);
|
||||
if (dev_path.empty()) {
|
||||
ALOGI("Could not get device path for slot %d\n", in_slot);
|
||||
return false;
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
if (gpt.Load()) {
|
||||
ALOGI("failed to load gpt data\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
gpt_entry *e = gpt.GetPartitionEntry(in_slot ? "boot_b" : "boot_a");
|
||||
if (e == nullptr) {
|
||||
ALOGI("failed to get gpt entry\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
e->attr |= flag;
|
||||
gpt.Sync();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool is_devinfo_valid;
|
||||
static bool is_devinfo_initialized;
|
||||
static std::mutex devinfo_lock;
|
||||
static devinfo_t devinfo;
|
||||
|
||||
static bool isDevInfoValid() {
|
||||
const std::lock_guard<std::mutex> lock(devinfo_lock);
|
||||
|
||||
if (is_devinfo_initialized) {
|
||||
return is_devinfo_valid;
|
||||
}
|
||||
|
||||
is_devinfo_initialized = true;
|
||||
|
||||
::android::base::unique_fd fd(open(DEVINFO_PATH, O_RDONLY));
|
||||
::android::base::ReadFully(fd, &devinfo, sizeof devinfo);
|
||||
|
||||
if (devinfo.magic != DEVINFO_MAGIC) {
|
||||
return is_devinfo_valid;
|
||||
}
|
||||
|
||||
uint32_t version = ((uint32_t)devinfo.ver_major << 16) | devinfo.ver_minor;
|
||||
// only version 3.3+ supports A/B data
|
||||
if (version >= 0x0003'0003) {
|
||||
is_devinfo_valid = true;
|
||||
}
|
||||
|
||||
return is_devinfo_valid;
|
||||
}
|
||||
|
||||
static bool DevInfoSync() {
|
||||
if (!isDevInfoValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
::android::base::unique_fd fd(open(DEVINFO_PATH, O_WRONLY | O_DSYNC));
|
||||
return ::android::base::WriteFully(fd, &devinfo, sizeof devinfo);
|
||||
}
|
||||
|
||||
static void DevInfoInitSlot(devinfo_ab_slot_data_t &slot_data) {
|
||||
slot_data.retry_count = AB_ATTR_MAX_RETRY_COUNT;
|
||||
slot_data.unbootable = 0;
|
||||
slot_data.successful = 0;
|
||||
slot_data.active = 1;
|
||||
slot_data.fastboot_ok = 0;
|
||||
}
|
||||
|
||||
static int blow_otp_AR(bool secure) {
|
||||
static const char *dev_name = "/dev/trusty-ipc-dev0";
|
||||
static const char *otp_name = "com.android.trusty.otp_manager.tidl";
|
||||
int fd = 1, ret = 0;
|
||||
uint32_t cmd = secure? OTP_CMD_write_antirbk_secure_ap : OTP_CMD_write_antirbk_non_secure_ap;
|
||||
fd = tipc_connect(dev_name, otp_name);
|
||||
if (fd < 0) {
|
||||
ALOGI("Failed to connect to OTP_MGR ns TA - is it missing?\n");
|
||||
ret = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct otp_mgr_req_base req = {
|
||||
.command = cmd,
|
||||
.resp_payload_size = 0,
|
||||
};
|
||||
struct iovec iov[] = {
|
||||
{
|
||||
.iov_base = &req,
|
||||
.iov_len = sizeof(req),
|
||||
},
|
||||
};
|
||||
|
||||
size_t rc = tipc_send(fd, iov, 1, NULL, 0);
|
||||
if (rc != sizeof(req)) {
|
||||
ALOGI("Send fail! %zx\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct otp_mgr_rsp_base resp;
|
||||
rc = read(fd, &resp, sizeof(resp));
|
||||
if (rc < 0) {
|
||||
ALOGI("Read fail! %zx\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc < sizeof(resp)) {
|
||||
ALOGI("Not enough data! %zx\n", rc);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (resp.command != (cmd | OTP_RESP_BIT)) {
|
||||
ALOGI("Wrong command! %x\n", resp.command);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (resp.result != 0) {
|
||||
fprintf(stderr, "AR writing error! %x\n", resp.result);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tipc_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool blowAR_zuma() {
|
||||
int ret = blow_otp_AR(true);
|
||||
if (ret) {
|
||||
ALOGI("Blow secure anti-rollback OTP failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
ret = blow_otp_AR(false);
|
||||
if (ret) {
|
||||
ALOGI("Blow non-secure anti-rollback OTP failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool blowAR_gs101() {
|
||||
::android::base::unique_fd fd(open(BLOW_AR_PATH, O_WRONLY | O_DSYNC));
|
||||
return ::android::base::WriteStringToFd("1", fd);
|
||||
}
|
||||
|
||||
static bool blowAR() {
|
||||
char platform[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.boot.hardware.platform", platform, "");
|
||||
|
||||
if (std::string(platform) == "gs101") {
|
||||
return blowAR_gs101();
|
||||
} else if (std::string(platform) == "gs201" || std::string(platform) == "zuma") {
|
||||
return blowAR_zuma();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static constexpr MergeStatus ToAIDLMergeStatus(HIDLMergeStatus status) {
|
||||
switch (status) {
|
||||
case HIDLMergeStatus::NONE:
|
||||
return MergeStatus::NONE;
|
||||
case HIDLMergeStatus::UNKNOWN:
|
||||
return MergeStatus::UNKNOWN;
|
||||
case HIDLMergeStatus::SNAPSHOTTED:
|
||||
return MergeStatus::SNAPSHOTTED;
|
||||
case HIDLMergeStatus::MERGING:
|
||||
return MergeStatus::MERGING;
|
||||
case HIDLMergeStatus::CANCELLED:
|
||||
return MergeStatus::CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr HIDLMergeStatus ToHIDLMergeStatus(MergeStatus status) {
|
||||
switch (status) {
|
||||
case MergeStatus::NONE:
|
||||
return HIDLMergeStatus::NONE;
|
||||
case MergeStatus::UNKNOWN:
|
||||
return HIDLMergeStatus::UNKNOWN;
|
||||
case MergeStatus::SNAPSHOTTED:
|
||||
return HIDLMergeStatus::SNAPSHOTTED;
|
||||
case MergeStatus::MERGING:
|
||||
return HIDLMergeStatus::MERGING;
|
||||
case MergeStatus::CANCELLED:
|
||||
return HIDLMergeStatus::CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BootControl::BootControl() {
|
||||
CHECK(InitMiscVirtualAbMessageIfNeeded());
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::getActiveBootSlot(int32_t* _aidl_return) {
|
||||
int32_t slots = 0;
|
||||
getNumberSlots(&slots);
|
||||
if (slots == 0) {
|
||||
*_aidl_return = 0;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
if (isDevInfoValid()) {
|
||||
*_aidl_return = devinfo.ab_data.slots[1].active ? 1 : 0;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
*_aidl_return = isSlotFlagSet(1, AB_ATTR_ACTIVE) ? 1 : 0;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::getCurrentSlot(int32_t* _aidl_return) {
|
||||
char suffix[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.boot.slot_suffix", suffix, "_a");
|
||||
*_aidl_return = std::string(suffix) == "_b" ? 1 : 0;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::getNumberSlots(int32_t* _aidl_return) {
|
||||
int32_t slots = 0;
|
||||
|
||||
if (access(BOOT_A_PATH, F_OK) == 0)
|
||||
slots++;
|
||||
|
||||
if (access(BOOT_B_PATH, F_OK) == 0)
|
||||
slots++;
|
||||
|
||||
*_aidl_return = slots;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::getSnapshotMergeStatus(MergeStatus* _aidl_return) {
|
||||
HIDLMergeStatus status;
|
||||
int32_t current_slot = 0;
|
||||
getCurrentSlot(¤t_slot);
|
||||
if (!GetMiscVirtualAbMergeStatus(current_slot, &status)) {
|
||||
*_aidl_return = MergeStatus::UNKNOWN;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
*_aidl_return = ToAIDLMergeStatus(status);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::getSuffix(int32_t in_slot, std::string* _aidl_return) {
|
||||
*_aidl_return = in_slot == 0 ? "_a" : in_slot == 1 ? "_b" : "";
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::isSlotBootable(int32_t in_slot, bool* _aidl_return) {
|
||||
int32_t slots = 0;
|
||||
getNumberSlots(&slots);
|
||||
if (slots == 0) {
|
||||
*_aidl_return = false;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
if (in_slot >= slots)
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
INVALID_SLOT, (std::string("Invalid slot ") + std::to_string(in_slot)).c_str());
|
||||
|
||||
bool unbootable;
|
||||
if (isDevInfoValid()) {
|
||||
auto &slot_data = devinfo.ab_data.slots[in_slot];
|
||||
unbootable = !!slot_data.unbootable;
|
||||
} else {
|
||||
unbootable = isSlotFlagSet(in_slot, AB_ATTR_UNBOOTABLE);
|
||||
}
|
||||
|
||||
*_aidl_return = unbootable ? false: true;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::isSlotMarkedSuccessful(int32_t in_slot, bool* _aidl_return) {
|
||||
int32_t slots = 0;
|
||||
getNumberSlots(&slots);
|
||||
if (slots == 0) {
|
||||
// just return true so that we don't we another call trying to mark it as successful
|
||||
// when there is no slots
|
||||
*_aidl_return = true;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
if (in_slot >= slots)
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
INVALID_SLOT, (std::string("Invalid slot ") + std::to_string(in_slot)).c_str());
|
||||
|
||||
bool successful;
|
||||
if (isDevInfoValid()) {
|
||||
auto &slot_data = devinfo.ab_data.slots[in_slot];
|
||||
successful = !!slot_data.successful;
|
||||
} else {
|
||||
successful = isSlotFlagSet(in_slot, AB_ATTR_SUCCESSFUL);
|
||||
}
|
||||
|
||||
*_aidl_return = successful ? true : false;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::markBootSuccessful() {
|
||||
int32_t slots = 0;
|
||||
getNumberSlots(&slots);
|
||||
if (slots == 0) {
|
||||
// no slots, just return true otherwise Android keeps trying
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
bool ret;
|
||||
int32_t current_slot = 0;
|
||||
getCurrentSlot(¤t_slot);
|
||||
if (isDevInfoValid()) {
|
||||
auto const slot = current_slot;
|
||||
devinfo.ab_data.slots[slot].successful = 1;
|
||||
ret = DevInfoSync();
|
||||
} else {
|
||||
ret = setSlotFlag(current_slot, AB_ATTR_SUCCESSFUL);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(COMMAND_FAILED,
|
||||
"Failed to set successful flag");
|
||||
}
|
||||
|
||||
if (!blowAR()) {
|
||||
ALOGE("Failed to blow anti-rollback counter");
|
||||
// Ignore the error, since ABL will re-trigger it on reboot
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::setActiveBootSlot(int32_t in_slot) {
|
||||
if (in_slot >= 2) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
INVALID_SLOT, (std::string("Invalid slot ") + std::to_string(in_slot)).c_str());
|
||||
}
|
||||
|
||||
if (isDevInfoValid()) {
|
||||
auto &active_slot_data = devinfo.ab_data.slots[in_slot];
|
||||
auto &inactive_slot_data = devinfo.ab_data.slots[!in_slot];
|
||||
|
||||
inactive_slot_data.active = 0;
|
||||
DevInfoInitSlot(active_slot_data);
|
||||
|
||||
if (!DevInfoSync()) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "Could not update DevInfo data");
|
||||
}
|
||||
} else {
|
||||
std::string dev_path = getDevPath(in_slot);
|
||||
if (dev_path.empty()) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "Could not get device path for slot");
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
if (gpt.Load()) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(COMMAND_FAILED,
|
||||
"failed to load gpt data");
|
||||
}
|
||||
|
||||
gpt_entry *active_entry = gpt.GetPartitionEntry(in_slot == 0 ? "boot_a" : "boot_b");
|
||||
gpt_entry *inactive_entry = gpt.GetPartitionEntry(in_slot == 0 ? "boot_b" : "boot_a");
|
||||
if (active_entry == nullptr || inactive_entry == nullptr) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "failed to get entries for boot partitions");
|
||||
}
|
||||
|
||||
ALOGV("slot active attributes %lx\n", active_entry->attr);
|
||||
ALOGV("slot inactive attributes %lx\n", inactive_entry->attr);
|
||||
|
||||
// update attributes for active and inactive
|
||||
inactive_entry->attr &= ~AB_ATTR_ACTIVE;
|
||||
active_entry->attr = AB_ATTR_ACTIVE | (AB_ATTR_MAX_PRIORITY << AB_ATTR_PRIORITY_SHIFT) |
|
||||
(AB_ATTR_MAX_RETRY_COUNT << AB_ATTR_RETRY_COUNT_SHIFT);
|
||||
}
|
||||
|
||||
char boot_dev[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.boot.bootdevice", boot_dev, "");
|
||||
if (boot_dev[0] == '\0') {
|
||||
ALOGI("failed to get ro.boot.bootdevice. try ro.boot.boot_devices\n");
|
||||
property_get("ro.boot.boot_devices", boot_dev, "");
|
||||
if (boot_dev[0] == '\0') {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "invalid ro.boot.bootdevice and ro.boot.boot_devices prop");
|
||||
}
|
||||
}
|
||||
|
||||
std::string boot_lun_path =
|
||||
std::string("/sys/devices/platform/") + boot_dev + "/pixel/boot_lun_enabled";
|
||||
int fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
|
||||
if (fd < 0) {
|
||||
// Try old path for kernels < 5.4
|
||||
// TODO: remove once kernel 4.19 support is deprecated
|
||||
std::string boot_lun_path =
|
||||
std::string("/sys/devices/platform/") + boot_dev + "/attributes/boot_lun_enabled";
|
||||
fd = open(boot_lun_path.c_str(), O_RDWR | O_DSYNC);
|
||||
if (fd < 0) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "failed to open ufs attr boot_lun_enabled");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// bBootLunEn
|
||||
// 0x1 => Boot LU A = enabled, Boot LU B = disable
|
||||
// 0x2 => Boot LU A = disable, Boot LU B = enabled
|
||||
//
|
||||
int ret = ::android::base::WriteStringToFd(in_slot == 0 ? "1" : "2", fd);
|
||||
close(fd);
|
||||
if (ret < 0) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "faied to write boot_lun_enabled attribute");
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::setSlotAsUnbootable(int32_t in_slot) {
|
||||
if (in_slot >= 2)
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
INVALID_SLOT, (std::string("Invalid slot ") + std::to_string(in_slot)).c_str());
|
||||
|
||||
if (isDevInfoValid()) {
|
||||
auto &slot_data = devinfo.ab_data.slots[in_slot];
|
||||
slot_data.unbootable = 1;
|
||||
if (!DevInfoSync()) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "Could not update DevInfo data");
|
||||
}
|
||||
} else {
|
||||
std::string dev_path = getDevPath(in_slot);
|
||||
if (dev_path.empty()) {
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
|
||||
COMMAND_FAILED, "Could not get device path for slot");
|
||||
}
|
||||
|
||||
GptUtils gpt(dev_path);
|
||||
gpt.Load();
|
||||
|
||||
gpt_entry *e = gpt.GetPartitionEntry(in_slot ? "boot_b" : "boot_a");
|
||||
e->attr |= AB_ATTR_UNBOOTABLE;
|
||||
|
||||
gpt.Sync();
|
||||
}
|
||||
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus BootControl::setSnapshotMergeStatus(MergeStatus in_status) {
|
||||
int32_t current_slot = 0;
|
||||
getCurrentSlot(¤t_slot);
|
||||
if (!SetMiscVirtualAbMergeStatus(current_slot, ToHIDLMergeStatus(in_status)))
|
||||
return ScopedAStatus::fromServiceSpecificErrorWithMessage(COMMAND_FAILED,
|
||||
"Operation failed");
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::boot
|
61
bootctrl/aidl/BootControl.h
Normal file
61
bootctrl/aidl/BootControl.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/android/hardware/boot/BnBootControl.h>
|
||||
#include <libboot_control/libboot_control.h>
|
||||
|
||||
namespace aidl::android::hardware::boot {
|
||||
|
||||
class BootControl final : public BnBootControl {
|
||||
public:
|
||||
BootControl();
|
||||
::ndk::ScopedAStatus getActiveBootSlot(int32_t* _aidl_return) override;
|
||||
::ndk::ScopedAStatus getCurrentSlot(int32_t* _aidl_return) override;
|
||||
::ndk::ScopedAStatus getNumberSlots(int32_t* _aidl_return) override;
|
||||
::ndk::ScopedAStatus getSnapshotMergeStatus(
|
||||
::aidl::android::hardware::boot::MergeStatus* _aidl_return) override;
|
||||
::ndk::ScopedAStatus getSuffix(int32_t in_slot, std::string* _aidl_return) override;
|
||||
::ndk::ScopedAStatus isSlotBootable(int32_t in_slot, bool* _aidl_return) override;
|
||||
::ndk::ScopedAStatus isSlotMarkedSuccessful(int32_t in_slot, bool* _aidl_return) override;
|
||||
::ndk::ScopedAStatus markBootSuccessful() override;
|
||||
::ndk::ScopedAStatus setActiveBootSlot(int32_t in_slot) override;
|
||||
::ndk::ScopedAStatus setSlotAsUnbootable(int32_t in_slot) override;
|
||||
::ndk::ScopedAStatus setSnapshotMergeStatus(
|
||||
::aidl::android::hardware::boot::MergeStatus in_status) override;
|
||||
};
|
||||
|
||||
enum otpmgr_command : uint32_t {
|
||||
OTP_REQ_SHIFT = 1,
|
||||
OTP_RESP_BIT = 1,
|
||||
OTP_CMD_write_antirbk_non_secure_ap = (7 << OTP_REQ_SHIFT),
|
||||
OTP_CMD_write_antirbk_secure_ap = (8 << OTP_REQ_SHIFT),
|
||||
};
|
||||
|
||||
struct otp_mgr_req_base {
|
||||
uint32_t command;
|
||||
uint32_t resp_payload_size;
|
||||
uint8_t handle;
|
||||
}__packed;
|
||||
|
||||
struct otp_mgr_rsp_base {
|
||||
uint32_t command;
|
||||
uint32_t resp_payload_size;
|
||||
int result;
|
||||
}__packed;
|
||||
|
||||
} // namespace aidl::android::hardware::boot
|
53
bootctrl/aidl/DevInfo.h
Normal file
53
bootctrl/aidl/DevInfo.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace aidl::android::hardware::boot {
|
||||
|
||||
//
|
||||
// definitions taken from ABL code
|
||||
//
|
||||
|
||||
constexpr uint32_t DEVINFO_MAGIC = 0x49564544;
|
||||
constexpr size_t DEVINFO_AB_SLOT_COUNT = 2;
|
||||
|
||||
struct devinfo_ab_slot_data_t {
|
||||
uint8_t retry_count;
|
||||
uint8_t unbootable : 1;
|
||||
uint8_t successful : 1;
|
||||
uint8_t active : 1;
|
||||
uint8_t fastboot_ok : 1;
|
||||
uint8_t : 4;
|
||||
uint8_t unused[2];
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef struct {
|
||||
devinfo_ab_slot_data_t slots[DEVINFO_AB_SLOT_COUNT];
|
||||
} __attribute__((packed)) devinfo_ab_data_t;
|
||||
|
||||
struct devinfo_t {
|
||||
uint32_t magic;
|
||||
uint16_t ver_major;
|
||||
uint16_t ver_minor;
|
||||
uint8_t unused[40];
|
||||
devinfo_ab_data_t ab_data;
|
||||
uint8_t unused1[72]; // use remaining up to complete 128 bytes
|
||||
} __attribute__((packed));
|
||||
|
||||
static_assert(sizeof(devinfo_t) == 128, "invalid devinfo struct size");
|
||||
|
||||
} // namespace aidl::android::hardware::boot
|
185
bootctrl/aidl/GptUtils.cpp
Normal file
185
bootctrl/aidl/GptUtils.cpp
Normal file
@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "bootcontrolhal"
|
||||
|
||||
#include "GptUtils.h"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <errno.h>
|
||||
#include <linux/fs.h>
|
||||
#include <log/log.h>
|
||||
#include <zlib.h>
|
||||
|
||||
namespace aidl::android::hardware::boot {
|
||||
|
||||
namespace {
|
||||
|
||||
static int ValidateGptHeader(gpt_header *gpt) {
|
||||
if (gpt->signature != GPT_SIGNATURE) {
|
||||
ALOGE("invalid gpt signature 0x%lx\n", gpt->signature);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gpt->header_size != sizeof(gpt_header)) {
|
||||
ALOGE("invalid gpt header size %u\n", gpt->header_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (gpt->entry_size != sizeof(gpt_entry)) {
|
||||
ALOGE("invalid gpt entry size %u\n", gpt->entry_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
GptUtils::GptUtils(const std::string dev_path) : dev_path(dev_path), fd(0) {}
|
||||
|
||||
int GptUtils::Load(void) {
|
||||
fd = open(dev_path.c_str(), O_RDWR);
|
||||
if (fd < 0) {
|
||||
ALOGE("failed to open block dev %s, %d\n", dev_path.c_str(), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = ioctl(fd, BLKSSZGET, &block_size);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to get block size %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read primary header
|
||||
lseek64(fd, block_size, SEEK_SET);
|
||||
ret = read(fd, &gpt_primary, sizeof gpt_primary);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to read gpt primary header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ValidateGptHeader(&gpt_primary)) {
|
||||
ALOGE("error validating gpt header\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read partition entries
|
||||
entry_array.resize(gpt_primary.entry_count);
|
||||
uint32_t entries_size = gpt_primary.entry_size * gpt_primary.entry_count;
|
||||
lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
|
||||
ret = read(fd, entry_array.data(), entries_size);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to read gpt partition entries %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read gpt back header
|
||||
lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
|
||||
ret = read(fd, &gpt_backup, sizeof gpt_backup);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to read gpt backup header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ValidateGptHeader(&gpt_backup)) {
|
||||
ALOGW("error validating gpt backup\n"); // just warn about it, not fail
|
||||
}
|
||||
|
||||
// Create map <partition name, gpt_entry pointer>
|
||||
auto get_name = [](const uint16_t *efi_name) {
|
||||
char name[37] = {};
|
||||
for (size_t i = 0; efi_name[i] && i < sizeof name - 1; ++i) name[i] = efi_name[i];
|
||||
return std::string(name);
|
||||
};
|
||||
|
||||
for (auto const &e : entry_array) {
|
||||
if (e.name[0] == 0)
|
||||
break; // stop at the first partition with no name
|
||||
std::string s = get_name(e.name);
|
||||
entries[s] = const_cast<gpt_entry *>(&e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gpt_entry *GptUtils::GetPartitionEntry(std::string name) {
|
||||
return entries.find(name) != entries.end() ? entries[name] : nullptr;
|
||||
}
|
||||
|
||||
int GptUtils::Sync(void) {
|
||||
if (!fd)
|
||||
return -1;
|
||||
|
||||
// calculate crc and check if we need to update gpt
|
||||
gpt_primary.entries_crc32 = crc32(0, reinterpret_cast<uint8_t *>(entry_array.data()),
|
||||
entry_array.size() * sizeof(gpt_entry));
|
||||
|
||||
// save old crc
|
||||
uint32_t crc = gpt_primary.crc32;
|
||||
gpt_primary.crc32 = 0;
|
||||
|
||||
gpt_primary.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_primary), sizeof gpt_primary);
|
||||
if (crc == gpt_primary.crc32)
|
||||
return 0; // nothing to do (no changes)
|
||||
|
||||
ALOGI("updating GPT\n");
|
||||
|
||||
lseek64(fd, block_size * gpt_primary.current_lba, SEEK_SET);
|
||||
int ret = write(fd, &gpt_primary, sizeof gpt_primary);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt primary header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lseek64(fd, block_size * gpt_primary.start_lba, SEEK_SET);
|
||||
ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt partition entries %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// update GPT backup entries and backup
|
||||
lseek64(fd, block_size * gpt_backup.start_lba, SEEK_SET);
|
||||
ret = write(fd, entry_array.data(), entry_array.size() * sizeof(gpt_entry));
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt backup partition entries %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpt_backup.entries_crc32 = gpt_primary.entries_crc32;
|
||||
gpt_backup.crc32 = 0;
|
||||
gpt_backup.crc32 = crc32(0, reinterpret_cast<uint8_t *>(&gpt_backup), sizeof gpt_backup);
|
||||
lseek64(fd, block_size * gpt_primary.backup_lba, SEEK_SET);
|
||||
ret = write(fd, &gpt_backup, sizeof gpt_backup);
|
||||
if (ret < 0) {
|
||||
ALOGE("failed to write gpt backup header %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fsync(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GptUtils::~GptUtils() {
|
||||
if (fd) {
|
||||
Sync();
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::boot
|
71
bootctrl/aidl/GptUtils.h
Normal file
71
bootctrl/aidl/GptUtils.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace aidl::android::hardware::boot {
|
||||
|
||||
#define GPT_SIGNATURE 0x5452415020494645UL
|
||||
|
||||
typedef struct {
|
||||
uint8_t type_guid[16];
|
||||
uint8_t guid[16];
|
||||
uint64_t first_lba;
|
||||
uint64_t last_lba;
|
||||
uint64_t attr;
|
||||
uint16_t name[36];
|
||||
} __attribute__((packed)) gpt_entry;
|
||||
|
||||
typedef struct {
|
||||
uint64_t signature;
|
||||
uint32_t revision;
|
||||
uint32_t header_size;
|
||||
uint32_t crc32;
|
||||
uint32_t reserved;
|
||||
uint64_t current_lba;
|
||||
uint64_t backup_lba;
|
||||
uint64_t first_usable_lba;
|
||||
uint64_t last_usable_lba;
|
||||
uint8_t disk_guid[16];
|
||||
uint64_t start_lba;
|
||||
uint32_t entry_count;
|
||||
uint32_t entry_size;
|
||||
uint32_t entries_crc32;
|
||||
} __attribute__((packed)) gpt_header;
|
||||
|
||||
class GptUtils {
|
||||
public:
|
||||
GptUtils(const std::string dev_path);
|
||||
int Load(void);
|
||||
gpt_entry *GetPartitionEntry(std::string name);
|
||||
int Sync(void);
|
||||
~GptUtils();
|
||||
|
||||
private:
|
||||
std::string dev_path;
|
||||
int fd;
|
||||
uint32_t block_size;
|
||||
gpt_header gpt_primary;
|
||||
gpt_header gpt_backup;
|
||||
std::vector<gpt_entry> entry_array;
|
||||
std::map<std::string, gpt_entry *> entries;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::boot
|
@ -0,0 +1,5 @@
|
||||
service vendor.boot-default /vendor/bin/hw/android.hardware.boot-service.default-pixel
|
||||
class early_hal
|
||||
user root
|
||||
group root drmrpc
|
||||
|
@ -0,0 +1,7 @@
|
||||
service vendor.boot-default /system/bin/hw/android.hardware.boot-service.default_recovery-pixel
|
||||
class early_hal
|
||||
user root
|
||||
group root
|
||||
seclabel u:r:hal_bootctl_default:s0
|
||||
interface aidl android.hardware.boot.IBootControl/default
|
||||
|
@ -0,0 +1,6 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.boot</name>
|
||||
<fqname>IBootControl/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
44
bootctrl/aidl/service.cpp
Normal file
44
bootctrl/aidl/service.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2023 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "aidl.android.hardware.boot-service.default"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <hidl/HidlSupport.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include "BootControl.h"
|
||||
|
||||
using aidl::android::hardware::boot::BootControl;
|
||||
using aidl::android::hardware::boot::IBootControl;
|
||||
using ::android::hardware::configureRpcThreadpool;
|
||||
using ::android::hardware::joinRpcThreadpool;
|
||||
|
||||
int main(int, char* argv[]) {
|
||||
android::base::InitLogging(argv, android::base::KernelLogger);
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<IBootControl> service = ndk::SharedRefBase::make<BootControl>();
|
||||
|
||||
const std::string instance = std::string(BootControl::descriptor) + "/default";
|
||||
auto status = AServiceManager_addService(service->asBinder().get(), instance.c_str());
|
||||
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << instance << " " << status;
|
||||
LOG(INFO) << "IBootControl AIDL service running...";
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
6
bootctrl/bootctrl_aidl.mk
Normal file
6
bootctrl/bootctrl_aidl.mk
Normal file
@ -0,0 +1,6 @@
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.boot-service.default-pixel \
|
||||
android.hardware.boot-service.default_recovery-pixel
|
||||
|
||||
PRODUCT_SOONG_NAMESPACES += device/google/gs-common/bootctrl/aidl
|
||||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/bootctrl/sepolicy/aidl
|
6
bootctrl/bootctrl_hidl_1.2.mk
Normal file
6
bootctrl/bootctrl_hidl_1.2.mk
Normal file
@ -0,0 +1,6 @@
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.boot@1.2-impl-pixel \
|
||||
android.hardware.boot@1.2-service-pixel
|
||||
|
||||
PRODUCT_SOONG_NAMESPACES += device/google/gs-common/bootctrl/1.2
|
||||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/bootctrl/sepolicy/1.2
|
5
bootctrl/sepolicy/1.2/device.te
Normal file
5
bootctrl/sepolicy/1.2/device.te
Normal file
@ -0,0 +1,5 @@
|
||||
# devinfo block device
|
||||
type devinfo_block_device, dev_type;
|
||||
|
||||
# OTA
|
||||
type sda_block_device, dev_type;
|
2
bootctrl/sepolicy/1.2/file.te
Normal file
2
bootctrl/sepolicy/1.2/file.te
Normal file
@ -0,0 +1,2 @@
|
||||
# sysfs
|
||||
type sysfs_ota, sysfs_type, fs_type;
|
1
bootctrl/sepolicy/1.2/file_contexts
Normal file
1
bootctrl/sepolicy/1.2/file_contexts
Normal file
@ -0,0 +1 @@
|
||||
/vendor/bin/hw/android\.hardware\.boot@1\.2-service-pixel u:object_r:hal_bootctl_default_exec:s0
|
3
bootctrl/sepolicy/1.2/hal_bootctl_default.te
Normal file
3
bootctrl/sepolicy/1.2/hal_bootctl_default.te
Normal file
@ -0,0 +1,3 @@
|
||||
allow hal_bootctl_default devinfo_block_device:blk_file rw_file_perms;
|
||||
allow hal_bootctl_default sda_block_device:blk_file rw_file_perms;
|
||||
allow hal_bootctl_default sysfs_ota:file rw_file_perms;
|
5
bootctrl/sepolicy/aidl/device.te
Normal file
5
bootctrl/sepolicy/aidl/device.te
Normal file
@ -0,0 +1,5 @@
|
||||
# devinfo block device
|
||||
type devinfo_block_device, dev_type;
|
||||
|
||||
# OTA
|
||||
type sda_block_device, dev_type;
|
2
bootctrl/sepolicy/aidl/file.te
Normal file
2
bootctrl/sepolicy/aidl/file.te
Normal file
@ -0,0 +1,2 @@
|
||||
# sysfs
|
||||
type sysfs_ota, sysfs_type, fs_type;
|
1
bootctrl/sepolicy/aidl/file_contexts
Normal file
1
bootctrl/sepolicy/aidl/file_contexts
Normal file
@ -0,0 +1 @@
|
||||
/vendor/bin/hw/android\.hardware\.boot-service\.default-pixel u:object_r:hal_bootctl_default_exec:s0
|
8
bootctrl/sepolicy/aidl/hal_bootctl_default.te
Normal file
8
bootctrl/sepolicy/aidl/hal_bootctl_default.te
Normal file
@ -0,0 +1,8 @@
|
||||
allow hal_bootctl_default devinfo_block_device:blk_file rw_file_perms;
|
||||
allow hal_bootctl_default sda_block_device:blk_file rw_file_perms;
|
||||
allow hal_bootctl_default sysfs_ota:file rw_file_perms;
|
||||
allow hal_bootctl_default tee_device:chr_file rw_file_perms;
|
||||
|
||||
recovery_only(`
|
||||
allow hal_bootctl_default rootfs:dir r_dir_perms;
|
||||
')
|
@ -37,6 +37,7 @@ PRODUCT_SOONG_NAMESPACES += \
|
||||
|
||||
# Calibration tool for debug builds
|
||||
PRODUCT_PACKAGES_DEBUG += tarasque_test
|
||||
PRODUCT_PACKAGES_DEBUG += ProtoCalibGenerator
|
||||
|
||||
endif # vendor/google/camera check
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
ifeq (,$(filter true, $(PRODUCT_WITHOUT_TTS_VOICE_PACKS)))
|
||||
include device/google/gs-common/tts/voice_packs.mk
|
||||
endif
|
||||
|
||||
PRODUCT_SOONG_NAMESPACES += \
|
||||
device/google/gs-common/powerstats
|
||||
|
19
display_logbuffer/Android.bp
Normal file
19
display_logbuffer/Android.bp
Normal file
@ -0,0 +1,19 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "dump_display_logbuffer",
|
||||
srcs: ["dump_display_logbuffer.cpp"],
|
||||
init_rc: ["init.display_logbuffer.rc"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
],
|
||||
shared_libs: [
|
||||
"libdump",
|
||||
],
|
||||
vendor: true,
|
||||
relative_install_path: "dump",
|
||||
}
|
3
display_logbuffer/dump.mk
Normal file
3
display_logbuffer/dump.mk
Normal file
@ -0,0 +1,3 @@
|
||||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/display_logbuffer/sepolicy
|
||||
|
||||
PRODUCT_PACKAGES += dump_display_logbuffer
|
32
display_logbuffer/dump_display_logbuffer.cpp
Normal file
32
display_logbuffer/dump_display_logbuffer.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
#include <dump/pixel_dump.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char* logbuffer_paths[][2] = {
|
||||
{"DSIM0", "/dev/logbuffer_dsim0"},
|
||||
{"DSIM1", "/dev/logbuffer_dsim1"},
|
||||
};
|
||||
|
||||
int main() {
|
||||
for (auto &logbuffer_path : logbuffer_paths) {
|
||||
if(!access(logbuffer_path[1], R_OK)) {
|
||||
dumpFileContent(logbuffer_path[0], logbuffer_path[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
3
display_logbuffer/init.display_logbuffer.rc
Normal file
3
display_logbuffer/init.display_logbuffer.rc
Normal file
@ -0,0 +1,3 @@
|
||||
on property:ro.build.type=userdebug
|
||||
chown system system /dev/logbuffer_dsim0
|
||||
chown system system /dev/logbuffer_dsim1
|
1
display_logbuffer/sepolicy/device.te
Normal file
1
display_logbuffer/sepolicy/device.te
Normal file
@ -0,0 +1 @@
|
||||
type display_log_device, dev_type;
|
3
display_logbuffer/sepolicy/dump_display_logbuffer.te
Normal file
3
display_logbuffer/sepolicy/dump_display_logbuffer.te
Normal file
@ -0,0 +1,3 @@
|
||||
pixel_bugreport(dump_display_logbuffer)
|
||||
|
||||
allow dump_display_logbuffer display_log_device:chr_file r_file_perms;
|
4
display_logbuffer/sepolicy/file_contexts
Normal file
4
display_logbuffer/sepolicy/file_contexts
Normal file
@ -0,0 +1,4 @@
|
||||
/vendor/bin/dump/dump_display_logbuffer u:object_r:dump_display_logbuffer_exec:s0
|
||||
|
||||
/dev/logbuffer_dsim0 u:object_r:display_log_device:s0
|
||||
/dev/logbuffer_dsim1 u:object_r:display_log_device:s0
|
@ -27,6 +27,9 @@ allow edgetpu_tachyon_server gpu_device:chr_file rw_file_perms;
|
||||
allow edgetpu_tachyon_server gpu_device:dir r_dir_perms;
|
||||
allow edgetpu_tachyon_server ion_device:chr_file r_file_perms;
|
||||
|
||||
# Allow Tachyon service to access dmabuf sysytem.
|
||||
allow edgetpu_tachyon_server dmabuf_system_heap_device:chr_file r_file_perms;
|
||||
|
||||
# Allow Tachyon service to read the overcommit_memory info.
|
||||
allow edgetpu_tachyon_server proc_overcommit_memory:file r_file_perms;
|
||||
|
||||
|
3
gxp/sepolicy/edgetpu_tachyon_service.te
Normal file
3
gxp/sepolicy/edgetpu_tachyon_service.te
Normal file
@ -0,0 +1,3 @@
|
||||
# Allow Tachyon service to access the GXP device and read GXP properties.
|
||||
allow edgetpu_tachyon_server gxp_device:chr_file rw_file_perms;
|
||||
get_prop(edgetpu_tachyon_server, vendor_gxp_prop)
|
@ -1,44 +0,0 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
sh_binary {
|
||||
name: "dump_modem.sh",
|
||||
src: "dump_modem.sh",
|
||||
vendor: true,
|
||||
sub_dir: "dump",
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
name: "dump_modemlog_defaults",
|
||||
srcs: ["modem_log_dumper.cpp"],
|
||||
local_include_dirs: ["include"],
|
||||
shared_libs: ["liblog"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "dump_modemlog",
|
||||
srcs: ["dump_modemlog.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libdump",
|
||||
"liblog",
|
||||
],
|
||||
defaults: ["dump_modemlog_defaults"],
|
||||
vendor: true,
|
||||
relative_install_path: "dump",
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "dump_modemlog_test",
|
||||
srcs: ["test/*.cpp"],
|
||||
defaults: ["dump_modemlog_defaults"],
|
||||
local_include_dirs: ["test/include"],
|
||||
static_libs: ["libgmock"],
|
||||
vendor: true,
|
||||
}
|
3
modem/OWNERS
Normal file
3
modem/OWNERS
Normal file
@ -0,0 +1,3 @@
|
||||
# Give ownership of code files to Apps and Services team.
|
||||
# SEPolicy files are intentionally ignored since they should be reviewed by the SEPolicy team.
|
||||
per-file *.bp,*.cpp,*.h,*.sh=kierancyphus@google.com,everrosales@google.com,nicoleytlee@google.com,alanblc@google.com
|
9
modem/android_property_manager/Android.bp
Normal file
9
modem/android_property_manager/Android.bp
Normal file
@ -0,0 +1,9 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "modem_android_property_manager",
|
||||
export_include_dirs: [ "include" ],
|
||||
vendor_available: true,
|
||||
}
|
23
modem/android_property_manager/fake/Android.bp
Normal file
23
modem/android_property_manager/fake/Android.bp
Normal file
@ -0,0 +1,23 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
// When `modem_android_property_manager_fake` is included statically, its
|
||||
// dependencies are not transitively included, so the target will also have to
|
||||
// include this default to restate them.
|
||||
cc_defaults {
|
||||
name: "modem_android_property_manager_fake_defaults",
|
||||
static_libs: [
|
||||
"modem_android_property_manager",
|
||||
"libbase",
|
||||
"modem_log_constants",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "modem_android_property_manager_fake",
|
||||
export_include_dirs: [ "include" ],
|
||||
srcs: [ "fake_android_property_manager.cpp" ],
|
||||
defaults: [ "modem_android_property_manager_fake_defaults" ],
|
||||
vendor_available: true,
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
#include "fake_android_property_manager.h"
|
||||
|
||||
#include <android-base/parseint.h>
|
||||
#include <android-base/result.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "modem_log_constants.h"
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
bool FakeAndroidPropertyManager::GetBoolProperty(const std::string& key,
|
||||
bool default_value) {
|
||||
auto value_result = GetProperty(key);
|
||||
return value_result.ok() ? (*value_result) == kTruthString : default_value;
|
||||
}
|
||||
|
||||
std::string FakeAndroidPropertyManager::GetProperty(
|
||||
const std::string& key, const std::string& default_value) {
|
||||
auto value_result = GetProperty(key);
|
||||
return value_result.ok() ? *value_result : default_value;
|
||||
}
|
||||
|
||||
int FakeAndroidPropertyManager::GetIntProperty(const std::string& key,
|
||||
int default_value) {
|
||||
int value = default_value;
|
||||
|
||||
auto property_result = GetProperty(key);
|
||||
if (property_result.ok()) {
|
||||
android::base::ParseInt<int>((*property_result).data(), &value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function needs to copy the behaviour of `modem_logging_control` to
|
||||
* ensure that the right properties are being set in order.
|
||||
*
|
||||
* More specifically, this function will also set the
|
||||
* `kModemLoggingStatusProperty` whenever `kModemLoggingEnabledProperty` is
|
||||
* set to simulate modem logging stopping / starting.
|
||||
*/
|
||||
bool FakeAndroidPropertyManager::SetProperty(const std::string& key,
|
||||
const std::string& value) {
|
||||
if (key == logging::kModemLoggingEnabledProperty) {
|
||||
property_map_[logging::kModemLoggingStatusProperty.data()] = value;
|
||||
|
||||
// need to track if modem logging has restarted or not
|
||||
if (value == kFalseString) {
|
||||
modem_logging_has_been_off_ = true;
|
||||
}
|
||||
if (modem_logging_has_been_off_ && (value == kTruthString)) {
|
||||
modem_logging_has_restarted_ = true;
|
||||
}
|
||||
}
|
||||
property_map_[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets android system property if present.
|
||||
*
|
||||
* @param[in] key Name of property.
|
||||
*
|
||||
* @return Status of get operation and value if successful.
|
||||
* @retval EINVAL Key not present in map.
|
||||
*/
|
||||
android::base::Result<std::string> FakeAndroidPropertyManager::GetProperty(
|
||||
const std::string& key) {
|
||||
const auto it = property_map_.find(key);
|
||||
if (it == property_map_.end()) {
|
||||
return android::base::Error()
|
||||
<< "Property: " << key << " not found." << EINVAL;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
} // namespace pixel_modem
|
@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "android-base/result.h"
|
||||
#include "android_property_manager.h"
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
/**
|
||||
* @brief Fake Implementation of AndroidPropertyManager that mocks some of the
|
||||
* property changing behaviour from pixellogger's `modem_logging_control`.
|
||||
*/
|
||||
class FakeAndroidPropertyManager : public AndroidPropertyManager {
|
||||
public:
|
||||
bool GetBoolProperty(const std::string& key, bool default_value) override;
|
||||
|
||||
std::string GetProperty(const std::string& key,
|
||||
const std::string& default_value) override;
|
||||
|
||||
int GetIntProperty(const std::string& key, int default_value) override;
|
||||
|
||||
/**
|
||||
* This function needs to copy the behaviour of `modem_logging_control` to
|
||||
* ensure that the right properties are being set in order.
|
||||
*
|
||||
* More specifically, this function will also set the
|
||||
* `kModemLoggingStatusProperty` whenever `kModemLoggingEnabledProperty` is
|
||||
* set to simulate modem logging stopping / starting.
|
||||
*/
|
||||
bool SetProperty(const std::string& key, const std::string& value) override;
|
||||
|
||||
inline bool ModemLoggingHasRestarted() {
|
||||
return modem_logging_has_restarted_;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Gets android system property if present.
|
||||
*
|
||||
* @param[in] key Name of property.
|
||||
*
|
||||
* @return Status of get operation and value if successful.
|
||||
* @retval EINVAL Key not present in map.
|
||||
*/
|
||||
android::base::Result<std::string> GetProperty(const std::string& key);
|
||||
|
||||
std::map<std::string, std::string> property_map_;
|
||||
bool modem_logging_has_been_off_ = false;
|
||||
bool modem_logging_has_restarted_ = false;
|
||||
};
|
||||
|
||||
} // namespace pixel_modem
|
18
modem/android_property_manager/impl/Android.bp
Normal file
18
modem/android_property_manager/impl/Android.bp
Normal file
@ -0,0 +1,18 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
modem_android_property_manager_impl_public_deps = [
|
||||
"modem_android_property_manager",
|
||||
]
|
||||
|
||||
cc_library_shared {
|
||||
name: "modem_android_property_manager_impl",
|
||||
export_include_dirs: [ "include" ],
|
||||
srcs: [ "android_property_manager_impl.cpp" ],
|
||||
shared_libs: modem_android_property_manager_impl_public_deps + [
|
||||
"libbase",
|
||||
],
|
||||
export_shared_lib_headers: modem_android_property_manager_impl_public_deps,
|
||||
vendor_available: true,
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
#include "android_property_manager_impl.h"
|
||||
|
||||
#include <android-base/properties.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
bool AndroidPropertyManagerImpl::GetBoolProperty(const std::string& key,
|
||||
bool default_value) {
|
||||
return android::base::GetBoolProperty(key, default_value);
|
||||
}
|
||||
|
||||
std::string AndroidPropertyManagerImpl::GetProperty(
|
||||
const std::string& key, const std::string& default_value) {
|
||||
return android::base::GetProperty(key, default_value);
|
||||
}
|
||||
|
||||
int AndroidPropertyManagerImpl::GetIntProperty(const std::string& key,
|
||||
int default_value) {
|
||||
return android::base::GetIntProperty(key, default_value);
|
||||
}
|
||||
|
||||
bool AndroidPropertyManagerImpl::SetProperty(const std::string& key,
|
||||
const std::string& value) {
|
||||
return android::base::SetProperty(key, value);
|
||||
}
|
||||
|
||||
} // namespace pixel_modem
|
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "android_property_manager.h"
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
/**
|
||||
* @brief Implementation of AndroidPropertyManager that directly forwards to
|
||||
* android base methods.
|
||||
*/
|
||||
class AndroidPropertyManagerImpl : public AndroidPropertyManager {
|
||||
public:
|
||||
bool GetBoolProperty(const std::string& key, bool default_value) override;
|
||||
|
||||
std::string GetProperty(const std::string& key,
|
||||
const std::string& default_value) override;
|
||||
|
||||
int GetIntProperty(const std::string& key, int default_value) override;
|
||||
|
||||
bool SetProperty(const std::string& key, const std::string& value) override;
|
||||
};
|
||||
|
||||
} // namespace pixel_modem
|
@ -1,9 +1,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
namespace pixel_modem {
|
||||
|
||||
// Used to set boolean parameters to true / false
|
||||
inline constexpr std::string_view kTruthString = "true";
|
||||
inline constexpr std::string_view kFalseString = "false";
|
||||
|
||||
/**
|
||||
* @brief Interface for interacting with Android System Properties.
|
||||
@ -11,11 +16,12 @@ namespace logging {
|
||||
class AndroidPropertyManager {
|
||||
public:
|
||||
virtual ~AndroidPropertyManager() = default;
|
||||
virtual bool GetBoolProperty(const std::string& key, bool default_value);
|
||||
virtual bool GetBoolProperty(const std::string& key, bool default_value) = 0;
|
||||
virtual std::string GetProperty(const std::string& key,
|
||||
const std::string& default_value);
|
||||
virtual int GetIntProperty(const std::string& key, int default_value);
|
||||
virtual void SetProperty(const std::string& key, const std::string& value);
|
||||
const std::string& default_value) = 0;
|
||||
virtual int GetIntProperty(const std::string& key, int default_value) = 0;
|
||||
virtual bool SetProperty(const std::string& key,
|
||||
const std::string& value) = 0;
|
||||
};
|
||||
} // namespace logging
|
||||
} // namespace modem
|
||||
|
||||
} // namespace pixel_modem
|
9
modem/clock_manager/Android.bp
Normal file
9
modem/clock_manager/Android.bp
Normal file
@ -0,0 +1,9 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "modem_clock_manager",
|
||||
export_include_dirs: [ "include" ],
|
||||
vendor_available: true,
|
||||
}
|
15
modem/clock_manager/fake/Android.bp
Normal file
15
modem/clock_manager/fake/Android.bp
Normal file
@ -0,0 +1,15 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_defaults {
|
||||
name: "fake_modem_clock_manager_defaults",
|
||||
shared_libs: [ "modem_clock_manager" ],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "fake_modem_clock_manager",
|
||||
export_include_dirs: [ "include" ],
|
||||
defaults: [ "fake_modem_clock_manager_defaults" ],
|
||||
vendor_available: true,
|
||||
}
|
21
modem/clock_manager/fake/include/fake_clock_manager.h
Normal file
21
modem/clock_manager/fake/include/fake_clock_manager.h
Normal file
@ -0,0 +1,21 @@
|
||||
#include "clock_manager.h"
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
/**
|
||||
* @brief Fake implementation of clock manager that doesn't actually sleep.
|
||||
*
|
||||
* A lot of vendor code don't have return values and instead force the client
|
||||
* codes to sleep for a specified period of time before checking some system
|
||||
* properties. However, since unit tests don't rely on the real vendor
|
||||
* implementations, these sleeps should be ignored and so a fake clock should be
|
||||
* used.
|
||||
*
|
||||
* Since this definition is unlikely to change, it will be defined in the header
|
||||
* and not an implementation file.
|
||||
*/
|
||||
struct FakeClockManager : public ClockManager {
|
||||
void Sleep(size_t /*seconds*/) const override{};
|
||||
};
|
||||
|
||||
} // namespace pixel_modem
|
16
modem/clock_manager/impl/Android.bp
Normal file
16
modem/clock_manager/impl/Android.bp
Normal file
@ -0,0 +1,16 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
modem_clock_manager_impl_public_deps = [
|
||||
"modem_clock_manager",
|
||||
]
|
||||
|
||||
cc_library {
|
||||
name: "modem_clock_manager_impl",
|
||||
export_include_dirs: [ "include" ],
|
||||
srcs: [ "clock_manager_impl.cpp" ],
|
||||
shared_libs: modem_clock_manager_impl_public_deps,
|
||||
export_shared_lib_headers: modem_clock_manager_impl_public_deps,
|
||||
vendor_available: true,
|
||||
}
|
9
modem/clock_manager/impl/clock_manager_impl.cpp
Normal file
9
modem/clock_manager/impl/clock_manager_impl.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "clock_manager_impl.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
void ClockManagerImpl::Sleep(size_t seconds) const { sleep(seconds); }
|
||||
|
||||
} // namespace pixel_modem
|
13
modem/clock_manager/impl/include/clock_manager_impl.h
Normal file
13
modem/clock_manager/impl/include/clock_manager_impl.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "clock_manager.h"
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
struct ClockManagerImpl : public ClockManager {
|
||||
void Sleep(size_t seconds) const override;
|
||||
};
|
||||
|
||||
} // namespace pixel_modem
|
28
modem/clock_manager/include/clock_manager.h
Normal file
28
modem/clock_manager/include/clock_manager.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace pixel_modem {
|
||||
|
||||
/**
|
||||
* @brief Interface for time based operations.
|
||||
*
|
||||
* This interface was intentionally not called `Clock`, like the Java side
|
||||
* counterpart since it's likely that clients would call the local variable
|
||||
* `clock(_)`, which would clash with the C defined `clock` method.
|
||||
*/
|
||||
struct ClockManager {
|
||||
virtual ~ClockManager() = default;
|
||||
|
||||
/**
|
||||
* @brief Sleep the thread for a given number of seconds.
|
||||
*
|
||||
* @param seconds Minimum number of seconds to sleep for. Note, this is
|
||||
* different than the Java android clock which accepts seconds. This was done
|
||||
* because C++ developers are likely more familiar with the `sleep` command,
|
||||
* which accepts seconds.
|
||||
*/
|
||||
virtual void Sleep(size_t seconds) const = 0;
|
||||
};
|
||||
|
||||
} // namespace pixel_modem
|
79
modem/dump_modemlog/Android.bp
Normal file
79
modem/dump_modemlog/Android.bp
Normal file
@ -0,0 +1,79 @@
|
||||
package {
|
||||
default_applicable_licenses: [ "Android-Apache-2.0" ],
|
||||
}
|
||||
|
||||
sh_binary {
|
||||
name: "dump_modem.sh",
|
||||
src: "dump_modem.sh",
|
||||
vendor: true,
|
||||
sub_dir: "dump",
|
||||
}
|
||||
|
||||
// Modem Log Dumper
|
||||
|
||||
modem_log_dumper_public_deps = [
|
||||
"modem_android_property_manager",
|
||||
]
|
||||
|
||||
// When `modem_log_dumper` is included statically, its dependencies are not
|
||||
// transitively included, so the target will also have to include this default
|
||||
// to restate them.
|
||||
cc_defaults {
|
||||
name: "modem_log_dumper_defaults",
|
||||
shared_libs: modem_log_dumper_public_deps + [
|
||||
"libbase",
|
||||
// liblog is not directly used by us, but it's a transitive dependency of libbase
|
||||
"liblog",
|
||||
"modem_log_constants",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "modem_log_dumper",
|
||||
srcs: [ "modem_log_dumper.cpp" ],
|
||||
defaults: [ "modem_log_dumper_defaults" ],
|
||||
export_shared_lib_headers: modem_log_dumper_public_deps,
|
||||
export_include_dirs: [ "include" ],
|
||||
vendor_available: true,
|
||||
}
|
||||
|
||||
// dump_modemlog
|
||||
|
||||
cc_binary {
|
||||
name: "dump_modemlog",
|
||||
srcs: [ "dump_modemlog.cpp" ],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libdump",
|
||||
"liblog",
|
||||
"modem_android_property_manager_impl",
|
||||
"modem_log_dumper",
|
||||
],
|
||||
vendor: true,
|
||||
relative_install_path: "dump",
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "dump_modemlog_test",
|
||||
srcs: [ "modem_log_dumper_test.cpp" ],
|
||||
defaults: [
|
||||
"modem_log_dumper_defaults",
|
||||
"modem_android_property_manager_fake_defaults",
|
||||
],
|
||||
static_libs: [
|
||||
"modem_android_property_manager",
|
||||
"modem_android_property_manager_fake",
|
||||
"modem_log_constants",
|
||||
"modem_log_dumper",
|
||||
"libgmock",
|
||||
],
|
||||
vendor: true,
|
||||
// Shared libs in vendor folder are guarded by SEPolicy, so tests need root
|
||||
// access to run them.
|
||||
require_root: true,
|
||||
}
|
@ -16,33 +16,11 @@
|
||||
#include <android-base/properties.h>
|
||||
#include <dump/pixel_dump.h>
|
||||
|
||||
#include "android_property_manager_impl.h"
|
||||
#include "dumper.h"
|
||||
#include "modem_log_dumper.h"
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
|
||||
/**
|
||||
* @brief Implementation of AndroidPropertyManager that directly forwards to
|
||||
* android base methods.
|
||||
*/
|
||||
class AndroidPropertyManagerImpl : public AndroidPropertyManager {
|
||||
public:
|
||||
bool GetBoolProperty(const std::string& key, bool default_value) override {
|
||||
return android::base::GetBoolProperty(key, default_value);
|
||||
};
|
||||
|
||||
std::string GetProperty(const std::string& key,
|
||||
const std::string& default_value) override {
|
||||
return android::base::GetProperty(key, default_value);
|
||||
};
|
||||
int GetIntProperty(const std::string& key, int default_value) override {
|
||||
return android::base::GetIntProperty(key, default_value);
|
||||
};
|
||||
void SetProperty(const std::string& key, const std::string& value) override {
|
||||
android::base::SetProperty(key, value);
|
||||
};
|
||||
};
|
||||
namespace pixel_modem::logging {
|
||||
|
||||
/**
|
||||
* @brief Implementation of Dumper that directly forwards to their corresponding
|
||||
@ -59,13 +37,12 @@ class DumperImpl : public Dumper {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace logging
|
||||
} // namespace modem
|
||||
} // namespace pixel_modem::logging
|
||||
|
||||
int main() {
|
||||
modem::logging::DumperImpl dumper_impl;
|
||||
modem::logging::AndroidPropertyManagerImpl android_property_manager_impl;
|
||||
modem::logging::ModemLogDumper modem_log_dumper(
|
||||
pixel_modem::logging::DumperImpl dumper_impl;
|
||||
pixel_modem::AndroidPropertyManagerImpl android_property_manager_impl;
|
||||
pixel_modem::logging::ModemLogDumper modem_log_dumper(
|
||||
dumper_impl, android_property_manager_impl);
|
||||
|
||||
modem_log_dumper.DumpModemLogs();
|
5
modem/dump_modemlog/dump_modemlog.mk
Normal file
5
modem/dump_modemlog/dump_modemlog.mk
Normal file
@ -0,0 +1,5 @@
|
||||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/modem/dump_modemlog/sepolicy
|
||||
|
||||
PRODUCT_PACKAGES += dump_modem.sh
|
||||
PRODUCT_PACKAGES += dump_modemlog
|
||||
|
33
modem/dump_modemlog/include/bugreport_constants.h
Normal file
33
modem/dump_modemlog/include/bugreport_constants.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "dumper.h"
|
||||
|
||||
namespace pixel_modem::logging {
|
||||
|
||||
inline constexpr std::string_view kBugreportPackingDirectory =
|
||||
"/data/vendor/radio/logs/always-on/all_logs";
|
||||
|
||||
inline constexpr LogDumpInfo kLogDumpInfo[] = {
|
||||
{.src_dir = "/data/vendor/radio/extended_logs",
|
||||
.dest_dir = kBugreportPackingDirectory,
|
||||
.limit = 20,
|
||||
.prefix = "extended_log_"},
|
||||
{.src_dir = "/data/vendor/radio/sim/",
|
||||
.dest_dir = kBugreportPackingDirectory,
|
||||
.limit = 1,
|
||||
.prefix = "sim_poweron_log_"},
|
||||
{.src_dir = "data/vendor/radio/logs/history",
|
||||
.dest_dir = kBugreportPackingDirectory,
|
||||
.limit = 2,
|
||||
.prefix = "Logging"}};
|
||||
|
||||
constexpr FileCopyInfo kFileCopyInfo[] = {
|
||||
{.src_dir = "/mnt/vendor/efs/nv_normal.bin",
|
||||
.dest_dir = "/data/vendor/radio/logs/always-on/all_logs/nv_normal.bin"},
|
||||
{.src_dir = "/mnt/vendor/efs/nv_protected.bin",
|
||||
.dest_dir =
|
||||
"/data/vendor/radio/logs/always-on/all_logs/nv_protected.bin"}};
|
||||
|
||||
} // namespace pixel_modem::logging
|
@ -3,8 +3,7 @@
|
||||
#include <ostream>
|
||||
#include <string_view>
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
namespace pixel_modem::logging {
|
||||
|
||||
/**
|
||||
* @brief Data object for information about dumpings logs.
|
||||
@ -67,5 +66,5 @@ class Dumper {
|
||||
virtual void DumpLogs(const LogDumpInfo& log_dump_info);
|
||||
virtual void CopyFile(const FileCopyInfo& file_copy_info);
|
||||
};
|
||||
} // namespace logging
|
||||
} // namespace modem
|
||||
|
||||
} // namespace pixel_modem::logging
|
@ -3,8 +3,7 @@
|
||||
#include "android_property_manager.h"
|
||||
#include "dumper.h"
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
namespace pixel_modem::logging {
|
||||
|
||||
/**
|
||||
* @brief Responsible for dumping all relevant modem logs.
|
||||
@ -77,5 +76,4 @@ class ModemLogDumper {
|
||||
AndroidPropertyManager& android_property_manager_;
|
||||
};
|
||||
|
||||
} // namespace logging
|
||||
} // namespace modem
|
||||
} // namespace pixel_modem::logging
|
@ -2,11 +2,11 @@
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
#include "bugreport_constants.h"
|
||||
#include "dumper.h"
|
||||
#include "modem_log_constants.h"
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
namespace pixel_modem::logging {
|
||||
|
||||
void ModemLogDumper::DumpModemLogs() {
|
||||
bool shouldRestartModemLogging =
|
||||
@ -15,7 +15,11 @@ void ModemLogDumper::DumpModemLogs() {
|
||||
kModemLoggingNumberBugreportProperty.data(),
|
||||
kDefaultBugreportNumberFiles);
|
||||
|
||||
if (shouldRestartModemLogging) {
|
||||
// Should always trigger `stopModemLogging`. This is because currently copying
|
||||
// modem logs and stopping modem logging are entangled.
|
||||
// TODO: b/289435256 - Always copy logs and return this to checking if logging
|
||||
// is actively running.
|
||||
if (allowedToStopModemLogging()) {
|
||||
// If modem logging is running at time of bugreport, it needs to be stopped
|
||||
// to ensure that the most recent logs are included in the bugreport. If
|
||||
// this command fails, only older log files will be included, as seen in
|
||||
@ -76,5 +80,5 @@ void ModemLogDumper::startModemLogging() {
|
||||
android_property_manager_.SetProperty(kModemLoggingEnabledProperty.data(),
|
||||
"true");
|
||||
}
|
||||
} // namespace logging
|
||||
} // namespace modem
|
||||
|
||||
} // namespace pixel_modem::logging
|
@ -2,13 +2,15 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "android_property_manager.h"
|
||||
#include "bugreport_constants.h"
|
||||
#include "dumper.h"
|
||||
#include "fake_android_property_manager.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "modem_log_constants.h"
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
namespace pixel_modem::logging {
|
||||
namespace {
|
||||
|
||||
using ::testing::Eq;
|
||||
@ -23,9 +25,8 @@ inline constexpr static LogDumpInfo kAlwaysOnLogDumpInfo = {
|
||||
|
||||
void StartModemLogging(
|
||||
FakeAndroidPropertyManager& fake_android_property_manager) {
|
||||
fake_android_property_manager.SetProperty(
|
||||
kModemLoggingEnabledProperty.data(),
|
||||
FakeAndroidPropertyManager::kTruthString.data());
|
||||
fake_android_property_manager.SetProperty(kModemLoggingEnabledProperty.data(),
|
||||
kTruthString.data());
|
||||
}
|
||||
|
||||
class MockDumper : public Dumper {
|
||||
@ -101,6 +102,6 @@ TEST_F(ModemLogDumperTest,
|
||||
|
||||
EXPECT_FALSE(fake_android_property_manager.ModemLoggingHasRestarted());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace logging
|
||||
} // namespace modem
|
||||
} // namespace pixel_modem::logging
|
@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
#include "dumper.h"
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
|
||||
// Modem related Android System Properties
|
||||
|
||||
// Controls triggering `modem_logging_start` and `modem_logging_stop`.
|
||||
inline constexpr static std::string_view kModemLoggingEnabledProperty =
|
||||
"vendor.sys.modem.logging.enable";
|
||||
// Signals the current modem logging state. This will be set to
|
||||
// `vendor.sys.modem.logging.enable` when `modem_log_start` or `modem_log_stop`
|
||||
// terminates.
|
||||
inline constexpr static std::string_view kModemLoggingStatusProperty =
|
||||
"vendor.sys.modem.logging.status";
|
||||
// Int which specifies how many files to include in the bugreport.
|
||||
inline constexpr static std::string_view kModemLoggingNumberBugreportProperty =
|
||||
"persist.vendor.sys.modem.logging.br_num";
|
||||
// Signals the current location that is being logged to. This can be used to
|
||||
// determine the logging type.
|
||||
inline constexpr static std::string_view kModemLoggingPathProperty =
|
||||
"vendor.sys.modem.logging.log_path";
|
||||
|
||||
// Bugreport constants
|
||||
inline constexpr static int kDefaultBugreportNumberFiles = 100;
|
||||
inline constexpr static std::string_view kModemAlwaysOnLogDirectory =
|
||||
"/data/vendor/radio/logs/always-on";
|
||||
inline constexpr static std::string_view kModemLogPrefix = "sbuff_";
|
||||
inline constexpr static std::string_view kBugreportPackingDirectory =
|
||||
"/data/vendor/radio/logs/always-on/all_logs";
|
||||
|
||||
inline constexpr static LogDumpInfo kLogDumpInfo[] = {
|
||||
{.src_dir = "/data/vendor/radio/extended_logs",
|
||||
.dest_dir = kBugreportPackingDirectory,
|
||||
.limit = 20,
|
||||
.prefix = "extended_log_"},
|
||||
{.src_dir = "/data/vendor/radio/sim/",
|
||||
.dest_dir = kBugreportPackingDirectory,
|
||||
.limit = 1,
|
||||
.prefix = "sim_poweron_log_"},
|
||||
{.src_dir = "data/vendor/radio/logs/history",
|
||||
.dest_dir = kBugreportPackingDirectory,
|
||||
.limit = 2,
|
||||
.prefix = "Logging"}};
|
||||
|
||||
constexpr static FileCopyInfo kFileCopyInfo[] = {
|
||||
{.src_dir = "/mnt/vendor/efs/nv_normal.bin",
|
||||
.dest_dir = "/data/vendor/radio/logs/always-on/all_logs/nv_normal.bin"},
|
||||
{.src_dir = "/mnt/vendor/efs/nv_protected.bin",
|
||||
.dest_dir =
|
||||
"/data/vendor/radio/logs/always-on/all_logs/nv_protected.bin"}};
|
||||
} // namespace logging
|
||||
} // namespace modem
|
@ -1,5 +1 @@
|
||||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/modem/sepolicy
|
||||
|
||||
PRODUCT_PACKAGES += dump_modem.sh
|
||||
PRODUCT_PACKAGES += dump_modemlog
|
||||
|
||||
include device/google/gs-common/modem/dump_modemlog/dump_modemlog.mk
|
||||
|
9
modem/modem_log_constants/Android.bp
Normal file
9
modem/modem_log_constants/Android.bp
Normal file
@ -0,0 +1,9 @@
|
||||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "modem_log_constants",
|
||||
export_include_dirs: [ "include" ],
|
||||
vendor_available: true,
|
||||
}
|
35
modem/modem_log_constants/include/modem_log_constants.h
Normal file
35
modem/modem_log_constants/include/modem_log_constants.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace pixel_modem::logging {
|
||||
|
||||
// Modem related Android System Properties
|
||||
|
||||
// Controls triggering `modem_logging_start` and `modem_logging_stop`.
|
||||
inline constexpr std::string_view kModemLoggingEnabledProperty =
|
||||
"vendor.sys.modem.logging.enable";
|
||||
// Signals the current modem logging state. This will be set to
|
||||
// `vendor.sys.modem.logging.enable` when `modem_log_start` or `modem_log_stop`
|
||||
// terminates.
|
||||
inline constexpr std::string_view kModemLoggingStatusProperty =
|
||||
"vendor.sys.modem.logging.status";
|
||||
// Int which specifies how many files to include in the bugreport.
|
||||
inline constexpr std::string_view kModemLoggingNumberBugreportProperty =
|
||||
"persist.vendor.sys.modem.logging.br_num";
|
||||
// Signals the current location that is being logged to. This can be used to
|
||||
// determine the logging type.
|
||||
inline constexpr std::string_view kModemLoggingPathProperty =
|
||||
"vendor.sys.modem.logging.log_path";
|
||||
inline constexpr std::string_view kModemLoggingLogCountProperty =
|
||||
"vendor.sys.modem.logging.log_count";
|
||||
inline constexpr std::string_view kModemLoggingLogPath =
|
||||
"vendor.sys.modem.logging.log_path";
|
||||
|
||||
// Bugreport constants
|
||||
inline constexpr int kDefaultBugreportNumberFiles = 100;
|
||||
inline constexpr std::string_view kModemAlwaysOnLogDirectory =
|
||||
"/data/vendor/radio/logs/always-on";
|
||||
inline constexpr std::string_view kModemLogPrefix = "sbuff_";
|
||||
|
||||
} // namespace pixel_modem::logging
|
@ -1,77 +0,0 @@
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "android_property_manager.h"
|
||||
#include "modem_log_constants.h"
|
||||
|
||||
namespace modem {
|
||||
namespace logging {
|
||||
|
||||
/**
|
||||
* @brief Fake Implementation of AndroidPropertyManager that mocks some of the
|
||||
* property changing behaviour from pixellogger's `modem_logging_control`.
|
||||
*/
|
||||
class FakeAndroidPropertyManager : public AndroidPropertyManager {
|
||||
public:
|
||||
inline constexpr static std::string_view kTruthString = "true";
|
||||
inline constexpr static std::string_view kFalseString = "false";
|
||||
|
||||
bool GetBoolProperty(const std::string& key, bool default_value) override {
|
||||
return MapContainsKey(key)
|
||||
? GetPropertyInternal(key) == kTruthString
|
||||
: default_value;
|
||||
};
|
||||
|
||||
std::string GetProperty(const std::string& key,
|
||||
const std::string& default_value) override {
|
||||
return MapContainsKey(key) ? GetPropertyInternal(key) : default_value;
|
||||
;
|
||||
};
|
||||
|
||||
int GetIntProperty(const std::string& key, int default_value) override {
|
||||
return MapContainsKey(key) ? std::stoi(GetPropertyInternal(key))
|
||||
: default_value;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function needs to copy the behaviour of `modem_logging_control` to
|
||||
* ensure that the right properties are being set in order.
|
||||
*
|
||||
* More specifically, this function will also set the
|
||||
* `kModemLoggingStatusProperty` whenever `kModemLoggingEnabledProperty` is
|
||||
* set to simulate modem logging stopping / starting.
|
||||
*/
|
||||
void SetProperty(const std::string& key, const std::string& value) override {
|
||||
if (key == kModemLoggingEnabledProperty) {
|
||||
property_map_[kModemLoggingStatusProperty.data()] = value;
|
||||
|
||||
// need to track if modem logging has restarted or not
|
||||
if (value == kFalseString) {
|
||||
modem_logging_has_been_off_ = true;
|
||||
}
|
||||
if (modem_logging_has_been_off_ && (value == kTruthString)) {
|
||||
modem_logging_has_restarted_ = true;
|
||||
}
|
||||
}
|
||||
property_map_[key] = value;
|
||||
};
|
||||
|
||||
bool ModemLoggingHasRestarted() { return modem_logging_has_restarted_; }
|
||||
|
||||
private:
|
||||
bool MapContainsKey(const std::string& key) {
|
||||
return property_map_.find(key) != property_map_.end();
|
||||
}
|
||||
std::string GetPropertyInternal(const std::string& key) {
|
||||
return property_map_.find(key)->second;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> property_map_;
|
||||
bool modem_logging_has_been_off_ = false;
|
||||
bool modem_logging_has_restarted_ = false;
|
||||
};
|
||||
} // namespace logging
|
||||
} // namespace modem
|
105
powerstats/TpuDvfsStateResidencyDataProvider.cpp
Normal file
105
powerstats/TpuDvfsStateResidencyDataProvider.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.
|
||||
*/
|
||||
#include "TpuDvfsStateResidencyDataProvider.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
static const std::string ENTITY_NAME = "TPU-DVFS";
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace stats {
|
||||
|
||||
TpuDvfsStateResidencyDataProvider::TpuDvfsStateResidencyDataProvider(
|
||||
const std::string& path,
|
||||
std::vector<std::string> frequencies,
|
||||
uint64_t clockRate)
|
||||
: mPath(path), mFrequencies(std::move(frequencies)), mClockRate(clockRate) {}
|
||||
|
||||
bool TpuDvfsStateResidencyDataProvider::getStateResidencies(
|
||||
std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
|
||||
// Using FILE* instead of std::ifstream for performance reasons
|
||||
std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(mPath.c_str(), "r"), fclose);
|
||||
if (!fp) {
|
||||
PLOG(ERROR) << "Failed to open file " << mPath;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<StateResidency> stateResidencies;
|
||||
for (int i = 0; i < mFrequencies.size(); i++) {
|
||||
StateResidency s = {.id = i, .totalTimeInStateMs = 0};
|
||||
stateResidencies.push_back(s);
|
||||
}
|
||||
|
||||
char *line = nullptr;
|
||||
size_t len = 0;
|
||||
std::istringstream ssLine;
|
||||
std::string split;
|
||||
int32_t lineIdx = 0;
|
||||
std::vector<int32_t> stateIdxMap;
|
||||
int32_t colIdx;
|
||||
std::vector<std::string>::const_iterator found;
|
||||
while (getline(&line, &len, fp.get()) != -1) {
|
||||
ssLine.clear();
|
||||
ssLine.str(line);
|
||||
colIdx = 0;
|
||||
for (std::string split; std::getline(ssLine, split, ' ');) {
|
||||
// Skip first column
|
||||
if (split.find(':') != std::string::npos)
|
||||
continue;
|
||||
|
||||
if (lineIdx == 0) {
|
||||
// Build the state index map by first row
|
||||
split.erase(split.find_last_not_of(" \n\r\t") + 1);
|
||||
found = std::find(mFrequencies.begin(), mFrequencies.end(), split);
|
||||
if (found != mFrequencies.end()) {
|
||||
stateIdxMap.push_back(found - mFrequencies.begin());
|
||||
} else {
|
||||
PLOG(ERROR) << "TPU frequency " << split << " is not found in " << mPath;
|
||||
stateIdxMap.push_back(0);
|
||||
}
|
||||
} else {
|
||||
// Add up time in frequency per uid
|
||||
stateResidencies[stateIdxMap[colIdx]].totalTimeInStateMs +=
|
||||
std::atoll(split.c_str()) / mClockRate;
|
||||
}
|
||||
colIdx++;
|
||||
}
|
||||
lineIdx++;
|
||||
}
|
||||
|
||||
residencies->emplace(ENTITY_NAME, stateResidencies);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::vector<State>> TpuDvfsStateResidencyDataProvider::getInfo() {
|
||||
std::vector<State> states;
|
||||
for (int32_t id = 0; id < mFrequencies.size(); id++) {
|
||||
State s =
|
||||
{.id = id, .name = std::to_string(std::atol(mFrequencies[id].c_str()) / 1000) + "MHz"};
|
||||
states.push_back(s);
|
||||
}
|
||||
|
||||
return {{ENTITY_NAME, states}};
|
||||
}
|
||||
|
||||
} // namespace stats
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
53
powerstats/include/TpuDvfsStateResidencyDataProvider.h
Normal file
53
powerstats/include/TpuDvfsStateResidencyDataProvider.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <PowerStatsAidl.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace stats {
|
||||
|
||||
class TpuDvfsStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
|
||||
public:
|
||||
TpuDvfsStateResidencyDataProvider(
|
||||
const std::string& path, std::vector<std::string> frequencies, uint64_t clockRate);
|
||||
~TpuDvfsStateResidencyDataProvider() = default;
|
||||
|
||||
/*
|
||||
* See IStateResidencyDataProvider::getStateResidencies
|
||||
*/
|
||||
bool getStateResidencies(
|
||||
std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
|
||||
|
||||
/*
|
||||
* See IStateResidencyDataProvider::getInfo
|
||||
*/
|
||||
std::unordered_map<std::string, std::vector<State>> getInfo() override;
|
||||
|
||||
private:
|
||||
const std::string mPath;
|
||||
const std::vector<std::string> mFrequencies;
|
||||
const uint64_t mClockRate;
|
||||
};
|
||||
|
||||
} // namespace stats
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
@ -1,3 +1,4 @@
|
||||
type debugfs_f2fs, debugfs_type, fs_type;
|
||||
type dump_storage_data_file, file_type, data_file_type;
|
||||
type sg_device, dev_type;
|
||||
type sg_util_exec, exec_type, vendor_file_type, file_type;
|
||||
|
1
storage/sepolicy/vendor_init.te
Normal file
1
storage/sepolicy/vendor_init.te
Normal file
@ -0,0 +1 @@
|
||||
allow vendor_init sg_device:chr_file r_file_perms;
|
1
trusty/sepolicy/tee.te
Normal file
1
trusty/sepolicy/tee.te
Normal file
@ -0,0 +1 @@
|
||||
allow tee sg_device:chr_file rw_file_perms;
|
Loading…
x
Reference in New Issue
Block a user