Merge "Merge pi-dev-plus-aosp-without-vendor into stage-aosp-master" into stage-aosp-master
This commit is contained in:
+14
-1
@@ -97,6 +97,19 @@ endif
|
|||||||
|
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
# Health HAL dependency
|
||||||
|
health_hal_static_libraries := \
|
||||||
|
android.hardware.health@2.0-impl \
|
||||||
|
android.hardware.health@2.0 \
|
||||||
|
android.hardware.health@1.0 \
|
||||||
|
android.hardware.health@1.0-convert \
|
||||||
|
libhealthstoragedefault \
|
||||||
|
libhidltransport \
|
||||||
|
libhidlbase \
|
||||||
|
libhwbinder_noltopgo \
|
||||||
|
libvndksupport \
|
||||||
|
libbatterymonitor
|
||||||
|
|
||||||
librecovery_static_libraries := \
|
librecovery_static_libraries := \
|
||||||
$(TARGET_RECOVERY_UI_LIB) \
|
$(TARGET_RECOVERY_UI_LIB) \
|
||||||
libbootloader_message \
|
libbootloader_message \
|
||||||
@@ -106,8 +119,8 @@ librecovery_static_libraries := \
|
|||||||
libminui \
|
libminui \
|
||||||
libverifier \
|
libverifier \
|
||||||
libotautil \
|
libotautil \
|
||||||
|
$(health_hal_static_libraries) \
|
||||||
libasyncio \
|
libasyncio \
|
||||||
libbatterymonitor \
|
|
||||||
libcrypto_utils \
|
libcrypto_utils \
|
||||||
libcrypto \
|
libcrypto \
|
||||||
libext4_utils \
|
libext4_utils \
|
||||||
|
|||||||
+37
-17
@@ -49,7 +49,7 @@
|
|||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <bootloader_message/bootloader_message.h>
|
#include <bootloader_message/bootloader_message.h>
|
||||||
#include <cutils/properties.h> /* for property_list */
|
#include <cutils/properties.h> /* for property_list */
|
||||||
#include <healthd/BatteryMonitor.h>
|
#include <health2/Health.h>
|
||||||
#include <ziparchive/zip_archive.h>
|
#include <ziparchive/zip_archive.h>
|
||||||
|
|
||||||
#include "adb_install.h"
|
#include "adb_install.h"
|
||||||
@@ -856,6 +856,11 @@ void ui_print(const char* format, ...) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool is_battery_ok(int* required_battery_level) {
|
static bool is_battery_ok(int* required_battery_level) {
|
||||||
|
using android::hardware::health::V1_0::BatteryStatus;
|
||||||
|
using android::hardware::health::V2_0::Result;
|
||||||
|
using android::hardware::health::V2_0::toString;
|
||||||
|
using android::hardware::health::V2_0::implementation::Health;
|
||||||
|
|
||||||
struct healthd_config healthd_config = {
|
struct healthd_config healthd_config = {
|
||||||
.batteryStatusPath = android::String8(android::String8::kEmptyString),
|
.batteryStatusPath = android::String8(android::String8::kEmptyString),
|
||||||
.batteryHealthPath = android::String8(android::String8::kEmptyString),
|
.batteryHealthPath = android::String8(android::String8::kEmptyString),
|
||||||
@@ -873,37 +878,52 @@ static bool is_battery_ok(int* required_battery_level) {
|
|||||||
.boot_min_cap = 0,
|
.boot_min_cap = 0,
|
||||||
.screen_on = nullptr
|
.screen_on = nullptr
|
||||||
};
|
};
|
||||||
healthd_board_init(&healthd_config);
|
|
||||||
|
|
||||||
android::BatteryMonitor monitor;
|
auto health =
|
||||||
monitor.init(&healthd_config);
|
android::hardware::health::V2_0::implementation::Health::initInstance(&healthd_config);
|
||||||
|
|
||||||
static constexpr int BATTERY_READ_TIMEOUT_IN_SEC = 10;
|
static constexpr int BATTERY_READ_TIMEOUT_IN_SEC = 10;
|
||||||
int wait_second = 0;
|
int wait_second = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int charge_status = monitor.getChargeStatus();
|
auto charge_status = BatteryStatus::UNKNOWN;
|
||||||
|
health
|
||||||
|
->getChargeStatus([&charge_status](auto res, auto out_status) {
|
||||||
|
if (res == Result::SUCCESS) {
|
||||||
|
charge_status = out_status;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.isOk(); // should not have transport error
|
||||||
|
|
||||||
// Treat unknown status as charged.
|
// Treat unknown status as charged.
|
||||||
bool charged = (charge_status != android::BATTERY_STATUS_DISCHARGING &&
|
bool charged = (charge_status != BatteryStatus::DISCHARGING &&
|
||||||
charge_status != android::BATTERY_STATUS_NOT_CHARGING);
|
charge_status != BatteryStatus::NOT_CHARGING);
|
||||||
android::BatteryProperty capacity;
|
|
||||||
android::status_t status = monitor.getProperty(android::BATTERY_PROP_CAPACITY, &capacity);
|
Result res = Result::UNKNOWN;
|
||||||
ui_print("charge_status %d, charged %d, status %d, capacity %" PRId64 "\n", charge_status,
|
int32_t capacity = INT32_MIN;
|
||||||
charged, status, capacity.valueInt64);
|
health
|
||||||
|
->getCapacity([&res, &capacity](auto out_res, auto out_capacity) {
|
||||||
|
res = out_res;
|
||||||
|
capacity = out_capacity;
|
||||||
|
})
|
||||||
|
.isOk(); // should not have transport error
|
||||||
|
|
||||||
|
ui_print("charge_status %d, charged %d, status %s, capacity %" PRId32 "\n", charge_status,
|
||||||
|
charged, toString(res).c_str(), capacity);
|
||||||
// At startup, the battery drivers in devices like N5X/N6P take some time to load
|
// At startup, the battery drivers in devices like N5X/N6P take some time to load
|
||||||
// the battery profile. Before the load finishes, it reports value 50 as a fake
|
// the battery profile. Before the load finishes, it reports value 50 as a fake
|
||||||
// capacity. BATTERY_READ_TIMEOUT_IN_SEC is set that the battery drivers are expected
|
// capacity. BATTERY_READ_TIMEOUT_IN_SEC is set that the battery drivers are expected
|
||||||
// to finish loading the battery profile earlier than 10 seconds after kernel startup.
|
// to finish loading the battery profile earlier than 10 seconds after kernel startup.
|
||||||
if (status == 0 && capacity.valueInt64 == 50) {
|
if (res == Result::SUCCESS && capacity == 50) {
|
||||||
if (wait_second < BATTERY_READ_TIMEOUT_IN_SEC) {
|
if (wait_second < BATTERY_READ_TIMEOUT_IN_SEC) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
wait_second++;
|
wait_second++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If we can't read battery percentage, it may be a device without battery. In this situation,
|
// If we can't read battery percentage, it may be a device without battery. In this
|
||||||
// use 100 as a fake battery percentage.
|
// situation, use 100 as a fake battery percentage.
|
||||||
if (status != 0) {
|
if (res != Result::SUCCESS) {
|
||||||
capacity.valueInt64 = 100;
|
capacity = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GmsCore enters recovery mode to install package when having enough battery percentage.
|
// GmsCore enters recovery mode to install package when having enough battery percentage.
|
||||||
@@ -912,7 +932,7 @@ static bool is_battery_ok(int* required_battery_level) {
|
|||||||
static constexpr int BATTERY_OK_PERCENTAGE = 20;
|
static constexpr int BATTERY_OK_PERCENTAGE = 20;
|
||||||
static constexpr int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15;
|
static constexpr int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15;
|
||||||
*required_battery_level = charged ? BATTERY_WITH_CHARGER_OK_PERCENTAGE : BATTERY_OK_PERCENTAGE;
|
*required_battery_level = charged ? BATTERY_WITH_CHARGER_OK_PERCENTAGE : BATTERY_OK_PERCENTAGE;
|
||||||
return capacity.valueInt64 >= *required_battery_level;
|
return capacity >= *required_battery_level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ int format_volume(const char* volume, const char* directory) {
|
|||||||
"-f",
|
"-f",
|
||||||
"-O", "encrypt",
|
"-O", "encrypt",
|
||||||
"-O", "quota",
|
"-O", "quota",
|
||||||
|
"-O", "verity",
|
||||||
"-w", std::to_string(kSectorSize),
|
"-w", std::to_string(kSectorSize),
|
||||||
v->blk_device,
|
v->blk_device,
|
||||||
};
|
};
|
||||||
|
|||||||
+13
-1
@@ -151,6 +151,18 @@ libupdater_static_libraries := \
|
|||||||
libbrotli \
|
libbrotli \
|
||||||
$(tune2fs_static_libraries)
|
$(tune2fs_static_libraries)
|
||||||
|
|
||||||
|
health_hal_static_libraries := \
|
||||||
|
android.hardware.health@2.0-impl \
|
||||||
|
android.hardware.health@2.0 \
|
||||||
|
android.hardware.health@1.0 \
|
||||||
|
android.hardware.health@1.0-convert \
|
||||||
|
libhealthstoragedefault \
|
||||||
|
libhidltransport \
|
||||||
|
libhidlbase \
|
||||||
|
libhwbinder_noltopgo \
|
||||||
|
libvndksupport \
|
||||||
|
libbatterymonitor
|
||||||
|
|
||||||
librecovery_static_libraries := \
|
librecovery_static_libraries := \
|
||||||
librecovery \
|
librecovery \
|
||||||
$(TARGET_RECOVERY_UI_LIB) \
|
$(TARGET_RECOVERY_UI_LIB) \
|
||||||
@@ -161,8 +173,8 @@ librecovery_static_libraries := \
|
|||||||
libminui \
|
libminui \
|
||||||
libverifier \
|
libverifier \
|
||||||
libotautil \
|
libotautil \
|
||||||
|
$(health_hal_static_libraries) \
|
||||||
libasyncio \
|
libasyncio \
|
||||||
libbatterymonitor \
|
|
||||||
libcrypto_utils \
|
libcrypto_utils \
|
||||||
libcrypto \
|
libcrypto \
|
||||||
libext4_utils \
|
libext4_utils \
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<string name="recovery_installing" msgid="2013591905463558223">"আপডেইট ইনষ্টল কৰি থকা হৈছে"</string>
|
||||||
|
<string name="recovery_erasing" msgid="7334826894904037088">"মচি থকা হৈছে"</string>
|
||||||
|
<string name="recovery_no_command" msgid="4465476568623024327">"কোনো আদেশ নাই"</string>
|
||||||
|
<string name="recovery_error" msgid="5748178989622716736">"ত্ৰুটি!"</string>
|
||||||
|
<string name="recovery_installing_security" msgid="9184031299717114342">"সুৰক্ষা আপডেইট ইনষ্টল কৰি থকা হৈছে"</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<string name="recovery_installing" msgid="2013591905463558223">"Installing system update"</string>
|
||||||
|
<string name="recovery_erasing" msgid="7334826894904037088">"Erasing"</string>
|
||||||
|
<string name="recovery_no_command" msgid="4465476568623024327">"No command"</string>
|
||||||
|
<string name="recovery_error" msgid="5748178989622716736">"Error!"</string>
|
||||||
|
<string name="recovery_installing_security" msgid="9184031299717114342">"Installing security update"</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<string name="recovery_installing" msgid="2013591905463558223">"Installing system update"</string>
|
||||||
|
<string name="recovery_erasing" msgid="7334826894904037088">"Erasing"</string>
|
||||||
|
<string name="recovery_no_command" msgid="4465476568623024327">"No command"</string>
|
||||||
|
<string name="recovery_error" msgid="5748178989622716736">"Error!"</string>
|
||||||
|
<string name="recovery_installing_security" msgid="9184031299717114342">"Installing security update"</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||||
|
<string name="recovery_installing" msgid="2013591905463558223">"ସିଷ୍ଟମ ଅପଡେଟ ଇନଷ୍ଟଲ କରୁଛି"</string>
|
||||||
|
<string name="recovery_erasing" msgid="7334826894904037088">"ଲିଭାଉଛି"</string>
|
||||||
|
<string name="recovery_no_command" msgid="4465476568623024327">"କୌଣସି କମାଣ୍ଡ ନାହିଁ"</string>
|
||||||
|
<string name="recovery_error" msgid="5748178989622716736">"ତ୍ରୁଟି!"</string>
|
||||||
|
<string name="recovery_installing_security" msgid="9184031299717114342">"ସୁରକ୍ଷା ଅପ୍ଡେଟ୍ ଇନ୍ଷ୍ଟଲ୍ କରୁଛି"</string>
|
||||||
|
</resources>
|
||||||
+4
-6
@@ -544,12 +544,10 @@ Value* FormatFn(const char* name, State* state, const std::vector<std::unique_pt
|
|||||||
const char* f2fs_argv[] = { "mkfs.f2fs",
|
const char* f2fs_argv[] = { "mkfs.f2fs",
|
||||||
"-d1",
|
"-d1",
|
||||||
"-f",
|
"-f",
|
||||||
"-O",
|
"-O", "encrypt",
|
||||||
"encrypt",
|
"-O", "quota",
|
||||||
"-O",
|
"-O", "verity",
|
||||||
"quota",
|
"-w", "512",
|
||||||
"-w",
|
|
||||||
"512",
|
|
||||||
location.c_str(),
|
location.c_str(),
|
||||||
(size < 512) ? nullptr : num_sectors.c_str(),
|
(size < 512) ? nullptr : num_sectors.c_str(),
|
||||||
nullptr };
|
nullptr };
|
||||||
|
|||||||
Reference in New Issue
Block a user