summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-08-02 05:12:15 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-08-02 05:12:15 +0200
commit39c4dce3527b6afb6d46210e633b04ca909fa0cd (patch)
tree152a02babbc93f0a5f27c43b4c4b5997b82a0526
parentSnap for 4922124 from e540feb25eb01bddec3ca9bccb63a23846549af3 to qt-release (diff)
parentMerge "Remove non-A/B mention from README." am: f8b04fe48d am: a5d6a661c6 am: e9775341be (diff)
downloadandroid_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.tar
android_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.tar.gz
android_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.tar.bz2
android_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.tar.lz
android_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.tar.xz
android_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.tar.zst
android_bootable_recovery-39c4dce3527b6afb6d46210e633b04ca909fa0cd.zip
-rw-r--r--minui/graphics.cpp67
-rw-r--r--minui/include/minui/minui.h10
-rw-r--r--uncrypt/uncrypt.cpp3
-rw-r--r--updater_sample/README.md12
4 files changed, 58 insertions, 34 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index cc02e9e82..9df058e29 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -40,11 +40,12 @@ static constexpr uint32_t alpha_mask = 0xff000000;
// gr_draw is owned by backends.
static const GRSurface* gr_draw = nullptr;
-static GRRotation rotation = ROTATION_NONE;
+static GRRotation rotation = GRRotation::NONE;
static bool outside(int x, int y) {
- return x < 0 || x >= (rotation % 2 ? gr_draw->height : gr_draw->width) || y < 0 ||
- y >= (rotation % 2 ? gr_draw->width : gr_draw->height);
+ auto swapped = (rotation == GRRotation::LEFT || rotation == GRRotation::RIGHT);
+ return x < 0 || x >= (swapped ? gr_draw->height : gr_draw->width) || y < 0 ||
+ y >= (swapped ? gr_draw->width : gr_draw->height);
}
const GRFont* gr_sys_font() {
@@ -89,36 +90,44 @@ static inline uint32_t pixel_blend(uint8_t alpha, uint32_t pix) {
// Increments pixel pointer right, with current rotation.
static void incr_x(uint32_t** p, int row_pixels) {
- if (rotation % 2) {
- *p = *p + (rotation == 1 ? 1 : -1) * row_pixels;
- } else {
- *p = *p + (rotation ? -1 : 1);
+ if (rotation == GRRotation::LEFT) {
+ *p = *p - row_pixels;
+ } else if (rotation == GRRotation::RIGHT) {
+ *p = *p + row_pixels;
+ } else if (rotation == GRRotation::DOWN) {
+ *p = *p - 1;
+ } else { // GRRotation::NONE
+ *p = *p + 1;
}
}
// Increments pixel pointer down, with current rotation.
static void incr_y(uint32_t** p, int row_pixels) {
- if (rotation % 2) {
- *p = *p + (rotation == 1 ? -1 : 1);
- } else {
- *p = *p + (rotation ? -1 : 1) * row_pixels;
+ if (rotation == GRRotation::LEFT) {
+ *p = *p + 1;
+ } else if (rotation == GRRotation::RIGHT) {
+ *p = *p - 1;
+ } else if (rotation == GRRotation::DOWN) {
+ *p = *p - row_pixels;
+ } else { // GRRotation::NONE
+ *p = *p + row_pixels;
}
}
// Returns pixel pointer at given coordinates with rotation adjustment.
static uint32_t* pixel_at(const GRSurface* surf, int x, int y, int row_pixels) {
switch (rotation) {
- case ROTATION_NONE:
+ case GRRotation::NONE:
return reinterpret_cast<uint32_t*>(surf->data) + y * row_pixels + x;
- case ROTATION_RIGHT:
+ case GRRotation::RIGHT:
return reinterpret_cast<uint32_t*>(surf->data) + x * row_pixels + (surf->width - y);
- case ROTATION_DOWN:
+ case GRRotation::DOWN:
return reinterpret_cast<uint32_t*>(surf->data) + (surf->height - 1 - y) * row_pixels +
(surf->width - 1 - x);
- case ROTATION_LEFT:
+ case GRRotation::LEFT:
return reinterpret_cast<uint32_t*>(surf->data) + (surf->height - 1 - x) * row_pixels + y;
default:
- printf("invalid rotation %d", rotation);
+ printf("invalid rotation %d", static_cast<int>(rotation));
}
return nullptr;
}
@@ -256,7 +265,7 @@ void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy) {
if (outside(dx, dy) || outside(dx + w - 1, dy + h - 1)) return;
- if (rotation) {
+ if (rotation != GRRotation::NONE) {
int src_row_pixels = source->row_bytes / source->pixel_bytes;
int row_pixels = gr_draw->row_bytes / gr_draw->pixel_bytes;
uint32_t* src_py = reinterpret_cast<uint32_t*>(source->data) + sy * source->row_bytes / 4 + sx;
@@ -361,7 +370,19 @@ int gr_init() {
return -1;
}
- gr_rotate(DEFAULT_ROTATION);
+#define __STRINGIFY(x) #x
+#define STRINGIFY(x) __STRINGIFY(x)
+
+ std::string rotation_str(STRINGIFY(DEFAULT_ROTATION));
+ if (rotation_str == "ROTATION_RIGHT") {
+ gr_rotate(GRRotation::RIGHT);
+ } else if (rotation_str == "ROTATION_DOWN") {
+ gr_rotate(GRRotation::DOWN);
+ } else if (rotation_str == "ROTATION_LEFT") {
+ gr_rotate(GRRotation::LEFT);
+ } else { // "ROTATION_NONE"
+ gr_rotate(GRRotation::NONE);
+ }
if (gr_draw->pixel_bytes != 4) {
printf("gr_init: Only 4-byte pixel formats supported\n");
@@ -379,13 +400,15 @@ void gr_exit() {
}
int gr_fb_width() {
- return rotation % 2 ? gr_draw->height - 2 * overscan_offset_y
- : gr_draw->width - 2 * overscan_offset_x;
+ return (rotation == GRRotation::LEFT || rotation == GRRotation::RIGHT)
+ ? gr_draw->height - 2 * overscan_offset_y
+ : gr_draw->width - 2 * overscan_offset_x;
}
int gr_fb_height() {
- return rotation % 2 ? gr_draw->width - 2 * overscan_offset_x
- : gr_draw->height - 2 * overscan_offset_y;
+ return (rotation == GRRotation::LEFT || rotation == GRRotation::RIGHT)
+ ? gr_draw->width - 2 * overscan_offset_x
+ : gr_draw->height - 2 * overscan_offset_y;
}
void gr_fb_blank(bool blank) {
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index ef4abe252..97660d476 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -41,11 +41,11 @@ struct GRFont {
int char_height;
};
-enum GRRotation {
- ROTATION_NONE = 0,
- ROTATION_RIGHT = 1,
- ROTATION_DOWN = 2,
- ROTATION_LEFT = 3,
+enum class GRRotation : int {
+ NONE = 0,
+ RIGHT = 1,
+ DOWN = 2,
+ LEFT = 3,
};
// Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 16036f9ce..95f40c71f 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -332,7 +332,8 @@ static int produce_block_map(const char* path, const char* map_file, const char*
#define F2FS_IOC_GET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 14, __u32)
#endif
if (f2fs_fs) {
- int error = ioctl(fd, F2FS_IOC_SET_PIN_FILE);
+ __u32 set = 1;
+ int error = ioctl(fd, F2FS_IOC_SET_PIN_FILE, &set);
// Don't break the old kernels which don't support it.
if (error && errno != ENOTTY && errno != ENOTSUP) {
PLOG(ERROR) << "Failed to set pin_file for f2fs: " << path << " on " << blk_dev;
diff --git a/updater_sample/README.md b/updater_sample/README.md
index f6a2a044b..306e71e5b 100644
--- a/updater_sample/README.md
+++ b/updater_sample/README.md
@@ -1,9 +1,8 @@
# SystemUpdaterSample
This app demonstrates how to use Android system updates APIs to install
-[OTA updates](https://source.android.com/devices/tech/ota/). It contains a sample
-client for `update_engine` to install A/B (seamless) updates and a sample of
-applying non-A/B updates using `recovery`.
+[OTA updates](https://source.android.com/devices/tech/ota/). It contains a
+sample client for `update_engine` to install A/B (seamless) updates.
A/B (seamless) update is available since Android Nougat (API 24), but this sample
targets the latest android.
@@ -180,7 +179,8 @@ privileged system app, so it's granted the required permissions to access
`update_engine` service as well as OTA package files. Detailed steps are as follows:
1. [Prepare to build](https://source.android.com/setup/build/building)
-2. Add the module (SystemUpdaterSample) to the `PRODUCT_PACKAGES` list for the lunch target.
+2. Add the module (SystemUpdaterSample) to the `PRODUCT_PACKAGES` list for the
+ lunch target.
e.g. add a line containing `PRODUCT_PACKAGES += SystemUpdaterSample`
to `device/google/marlin/device-common.mk`.
3. [Whitelist the sample app](https://source.android.com/devices/tech/config/perms-whitelist)
@@ -221,7 +221,6 @@ privileged system app, so it's granted the required permissions to access
- [x] Add smart update completion detection using onStatusUpdate
- [x] Add pause/resume demo
- [ ] Verify system partition checksum for package
-- [?] Add non-A/B updates demo
## Running tests
@@ -243,7 +242,8 @@ privileged system app, so it's granted the required permissions to access
## Accessing `android.os.UpdateEngine` API
-`android.os.UpdateEngine`` APIs are marked as `@SystemApi`, meaning only system apps can access them.
+`android.os.UpdateEngine` APIs are marked as `@SystemApi`, meaning only system
+apps can access them.
## Getting read/write access to `/data/ota_package/`