Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
Allow customizing WearRecoveryUI via Makefile variables.
Browse files Browse the repository at this point in the history
With the following Makefile variables, we can reduce the work of writing
(copy/pasting) device-specific WearRecoveryUI classes.

The list of Makefile variables (the ones useful for Wear devices):
- TARGET_RECOVERY_UI_MARGIN_HEIGHT (default: 0)
- TARGET_RECOVERY_UI_MARGIN_WIDTH (default: 0)
  Specify the margin space that we don't want to display texts. They
  replace the former outer_width and outer_height.

- TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD (default: 50)
- TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD (default: 90)
  Specify the sensitivity of recognizing a swipe. Devices give absolute
  positions, so for some devices we need to adjust the thresholds.

- TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE
  Specify the progress bar vertical position, which should be adjusted
  to the actual height of a device. It replaces the former
  progress_bar_y.

- TARGET_RECOVERY_UI_ANIMATION_FPS (default: 30)
  Specify the animation FPS if using device-specific animation images.
  It replaces the former animation_fps.

Devices can specify "TARGET_RECOVERY_UI_LIB := librecovery_ui_wear",
with optionally defined Makefile vars above, in BoardConfig.mk to
customize their WearRecoveryUI.

Also remove the obsolete wear_touch.{cpp,h}, which has been merged into
ui.cpp in commit 5f8dd99.

Bug: 64307776
Test: Change the device BoardConfig.mk and test recovery image.
Change-Id: Id0fb2d4e3977ab5ddd31e71f9535470cab70e41b
(cherry picked from commit 0470cee)
  • Loading branch information
Tao Bao committed Aug 13, 2017
1 parent 9cf2e97 commit 016120f
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 253 deletions.
23 changes: 22 additions & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ LOCAL_SRC_FILES := \
ui.cpp \
vr_ui.cpp \
wear_ui.cpp \
wear_touch.cpp \

LOCAL_MODULE := recovery

Expand Down Expand Up @@ -120,6 +119,18 @@ else
LOCAL_CFLAGS += -DRECOVERY_UI_TOUCH_HIGH_THRESHOLD=90
endif

ifneq ($(TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE),)
LOCAL_CFLAGS += -DRECOVERY_UI_PROGRESS_BAR_BASELINE=$(TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE)
else
LOCAL_CFLAGS += -DRECOVERY_UI_PROGRESS_BAR_BASELINE=259
endif

ifneq ($(TARGET_RECOVERY_UI_ANIMATION_FPS),)
LOCAL_CFLAGS += -DRECOVERY_UI_ANIMATION_FPS=$(TARGET_RECOVERY_UI_ANIMATION_FPS)
else
LOCAL_CFLAGS += -DRECOVERY_UI_ANIMATION_FPS=30
endif

ifneq ($(TARGET_RECOVERY_UI_VR_STEREO_OFFSET),)
LOCAL_CFLAGS += -DRECOVERY_UI_VR_STEREO_OFFSET=$(TARGET_RECOVERY_UI_VR_STEREO_OFFSET)
else
Expand Down Expand Up @@ -216,6 +227,16 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_CFLAGS := -Werror
include $(BUILD_STATIC_LIBRARY)

# Wear default device
# ===============================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := wear_device.cpp

# Should match TARGET_RECOVERY_UI_LIB in BoardConfig.mk.
LOCAL_MODULE := librecovery_ui_wear

include $(BUILD_STATIC_LIBRARY)

# vr headset default device
# ===============================
include $(CLEAR_VARS)
Expand Down
4 changes: 2 additions & 2 deletions screen_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static double now() {
ScreenRecoveryUI::ScreenRecoveryUI()
: kMarginWidth(RECOVERY_UI_MARGIN_WIDTH),
kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT),
kAnimationFps(RECOVERY_UI_ANIMATION_FPS),
density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
currentIcon(NONE),
progressBarType(EMPTY),
Expand All @@ -77,7 +78,6 @@ ScreenRecoveryUI::ScreenRecoveryUI()
loop_frames(0),
current_frame(0),
intro_done(false),
animation_fps(30), // TODO: there's currently no way to infer this.
stage(-1),
max_stage(-1),
updateMutex(PTHREAD_MUTEX_INITIALIZER) {}
Expand Down Expand Up @@ -375,7 +375,7 @@ void* ScreenRecoveryUI::ProgressThreadStartRoutine(void* data) {
}

void ScreenRecoveryUI::ProgressThreadLoop() {
double interval = 1.0 / animation_fps;
double interval = 1.0 / kAnimationFps;
while (true) {
double start = now();
pthread_mutex_lock(&updateMutex);
Expand Down
6 changes: 3 additions & 3 deletions screen_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class ScreenRecoveryUI : public RecoveryUI {
const int kMarginWidth;
const int kMarginHeight;

// Number of frames per sec (default: 30) for both parts of the animation.
const int kAnimationFps;

// The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi.
const float density_;

Expand Down Expand Up @@ -141,9 +144,6 @@ class ScreenRecoveryUI : public RecoveryUI {
size_t current_frame;
bool intro_done;

// Number of frames per sec (default: 30) for both parts of the animation.
int animation_fps;

int stage, max_stage;

int char_width_;
Expand Down
23 changes: 23 additions & 0 deletions wear_device.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2017 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 "device.h"
#include "wear_ui.h"

Device* make_device() {
return new Device(new WearRecoveryUI);
}

177 changes: 0 additions & 177 deletions wear_touch.cpp

This file was deleted.

58 changes: 0 additions & 58 deletions wear_touch.h

This file was deleted.

Loading

0 comments on commit 016120f

Please sign in to comment.