summaryrefslogtreecommitdiffstats
path: root/recovery_ui
diff options
context:
space:
mode:
Diffstat (limited to 'recovery_ui')
-rw-r--r--recovery_ui/Android.bp12
-rw-r--r--recovery_ui/default_ethernet_device.cpp23
-rw-r--r--recovery_ui/ethernet_device.cpp21
-rw-r--r--recovery_ui/include/recovery_ui/ethernet_device.h42
-rw-r--r--recovery_ui/include/recovery_ui/ui.h4
-rw-r--r--recovery_ui/screen_ui.cpp25
-rw-r--r--recovery_ui/ui.cpp17
7 files changed, 117 insertions, 27 deletions
diff --git a/recovery_ui/Android.bp b/recovery_ui/Android.bp
index 9dfee5fd5..f64b0d1c9 100644
--- a/recovery_ui/Android.bp
+++ b/recovery_ui/Android.bp
@@ -12,6 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "bootable_recovery_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["bootable_recovery_license"],
+}
+
cc_library {
name: "librecovery_ui",
recovery_available: true,
@@ -22,6 +31,7 @@ cc_library {
srcs: [
"device.cpp",
+ "ethernet_device.cpp",
"ethernet_ui.cpp",
"screen_ui.cpp",
"stub_ui.cpp",
@@ -102,7 +112,7 @@ cc_library_static {
],
srcs: [
- "ethernet_device.cpp",
+ "default_ethernet_device.cpp",
],
shared_libs: [
diff --git a/recovery_ui/default_ethernet_device.cpp b/recovery_ui/default_ethernet_device.cpp
new file mode 100644
index 000000000..1fdff0d86
--- /dev/null
+++ b/recovery_ui/default_ethernet_device.cpp
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+#include "recovery_ui/device.h"
+#include "recovery_ui/ethernet_device.h"
+#include "recovery_ui/ethernet_ui.h"
+
+Device* make_device() {
+ return new EthernetDevice(new EthernetRecoveryUI);
+}
diff --git a/recovery_ui/ethernet_device.cpp b/recovery_ui/ethernet_device.cpp
index 39ec65dc4..d79f41dec 100644
--- a/recovery_ui/ethernet_device.cpp
+++ b/recovery_ui/ethernet_device.cpp
@@ -27,23 +27,9 @@
#include <sys/types.h>
#include "recovery_ui/device.h"
+#include "recovery_ui/ethernet_device.h"
#include "recovery_ui/ethernet_ui.h"
-class EthernetDevice : public Device {
- public:
- explicit EthernetDevice(EthernetRecoveryUI* ui);
-
- void PreRecovery() override;
- void PreFastboot() override;
-
- private:
- int SetInterfaceFlags(const unsigned set, const unsigned clr);
- void SetTitleIPv6LinkLocalAddress(const bool interface_up);
-
- android::base::unique_fd ctl_sock_;
- static const std::string interface;
-};
-
const std::string EthernetDevice::interface = "eth0";
EthernetDevice::EthernetDevice(EthernetRecoveryUI* ui)
@@ -129,8 +115,3 @@ void EthernetDevice::SetTitleIPv6LinkLocalAddress(const bool interface_up) {
recovery_ui->SetIPv6LinkLocalAddress();
}
-
-// -----------------------------------------------------------------------------------------
-Device* make_device() {
- return new EthernetDevice(new EthernetRecoveryUI);
-}
diff --git a/recovery_ui/include/recovery_ui/ethernet_device.h b/recovery_ui/include/recovery_ui/ethernet_device.h
new file mode 100644
index 000000000..ea710ab93
--- /dev/null
+++ b/recovery_ui/include/recovery_ui/ethernet_device.h
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#ifndef _ETHERNET_RECOVERY_DEVICE_H
+#define _ETHERNET_RECOVERY_DEVICE_H
+
+#include "device.h"
+
+#include <android-base/unique_fd.h>
+
+// Forward declaration to avoid including "ethernet_ui.h".
+class EthernetRecoveryUI;
+
+class EthernetDevice : public Device {
+ public:
+ explicit EthernetDevice(EthernetRecoveryUI* ui);
+
+ void PreRecovery() override;
+ void PreFastboot() override;
+
+ private:
+ int SetInterfaceFlags(const unsigned set, const unsigned clr);
+ void SetTitleIPv6LinkLocalAddress(const bool interface_up);
+
+ android::base::unique_fd ctl_sock_;
+ static const std::string interface;
+};
+
+#endif // _ETHERNET_RECOVERY_DEVICE_H
diff --git a/recovery_ui/include/recovery_ui/ui.h b/recovery_ui/include/recovery_ui/ui.h
index 08ec1d76a..512732f90 100644
--- a/recovery_ui/include/recovery_ui/ui.h
+++ b/recovery_ui/include/recovery_ui/ui.h
@@ -192,6 +192,8 @@ class RecoveryUI {
return key_interrupted_;
}
+ virtual bool IsUsbConnected();
+
protected:
void EnqueueKey(int key_code);
@@ -226,8 +228,6 @@ class RecoveryUI {
void ProcessKey(int key_code, int updown);
void TimeKey(int key_code, int count);
- bool IsUsbConnected();
-
bool InitScreensaver();
void SetScreensaverState(ScreensaverState state);
diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index 087fc0e84..b2c828f34 100644
--- a/recovery_ui/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -37,6 +37,7 @@
#include <unordered_map>
#include <vector>
+#include <android-base/chrono_utils.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
@@ -448,7 +449,9 @@ void ScreenRecoveryUI::draw_foreground_locked() {
int frame_height = gr_get_height(frame);
int frame_x = (ScreenWidth() - frame_width) / 2;
int frame_y = GetAnimationBaseline();
- DrawSurface(frame, 0, 0, frame_width, frame_height, frame_x, frame_y);
+ if (frame_x >= 0 && frame_y >= 0 && (frame_x + frame_width) < ScreenWidth() &&
+ (frame_y + frame_height) < ScreenHeight())
+ DrawSurface(frame, 0, 0, frame_width, frame_height, frame_x, frame_y);
}
if (progressBarType != EMPTY) {
@@ -879,10 +882,28 @@ bool ScreenRecoveryUI::LoadWipeDataMenuText() {
return true;
}
+static bool InitGraphics() {
+ // Timeout is same as init wait for file default of 5 seconds and is arbitrary
+ const unsigned timeout = 500; // 10ms increments
+ for (auto retry = timeout; retry > 0; --retry) {
+ if (gr_init() == 0) {
+ if (retry < timeout) {
+ // Log message like init wait for file completion log for consistency.
+ LOG(WARNING) << "wait for 'graphics' took " << ((timeout - retry) * 10) << "ms";
+ }
+ return true;
+ }
+ std::this_thread::sleep_for(10ms);
+ }
+ // Log message like init wait for file timeout log for consistency.
+ LOG(ERROR) << "timeout wait for 'graphics' took " << (timeout * 10) << "ms";
+ return false;
+}
+
bool ScreenRecoveryUI::Init(const std::string& locale) {
RecoveryUI::Init(locale);
- if (gr_init() == -1) {
+ if (!InitGraphics()) {
return false;
}
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index 330721773..6e67b1d4e 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -48,6 +48,10 @@ constexpr const char* MAX_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/max_b
constexpr const char* BRIGHTNESS_FILE_SDM = "/sys/class/backlight/panel0-backlight/brightness";
constexpr const char* MAX_BRIGHTNESS_FILE_SDM =
"/sys/class/backlight/panel0-backlight/max_brightness";
+constexpr const char* BRIGHTNESS_FILE_PWM =
+ "/sys/class/backlight/pwm-backlight.0/brightness";
+constexpr const char* MAX_BRIGHTNESS_FILE_PWM =
+ "/sys/class/backlight/pwm-backlight.0/max_brightness";
constexpr int kDefaultTouchLowThreshold = 50;
constexpr int kDefaultTouchHighThreshold = 90;
@@ -106,10 +110,19 @@ bool RecoveryUI::InitScreensaver() {
return false;
}
if (access(brightness_file_.c_str(), R_OK | W_OK)) {
- brightness_file_ = BRIGHTNESS_FILE_SDM;
+ if (!access(BRIGHTNESS_FILE_SDM, R_OK | W_OK)) {
+ brightness_file_ = BRIGHTNESS_FILE_SDM;
+ } else {
+ brightness_file_ = BRIGHTNESS_FILE_PWM;
+ }
}
+
if (access(max_brightness_file_.c_str(), R_OK)) {
- max_brightness_file_ = MAX_BRIGHTNESS_FILE_SDM;
+ if (!access(MAX_BRIGHTNESS_FILE_SDM, R_OK)) {
+ max_brightness_file_ = MAX_BRIGHTNESS_FILE_SDM;
+ } else {
+ max_brightness_file_ = MAX_BRIGHTNESS_FILE_PWM;
+ }
}
// Set the initial brightness level based on the max brightness. Note that reading the initial
// value from BRIGHTNESS_FILE doesn't give the actual brightness value (bullhead, sailfish), so