Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04f21095 authored by Steve Kondik's avatar Steve Kondik
Browse files

Merge tag 'android-5.1.1_r1' of...

Merge tag 'android-5.1.1_r1' of https://android.googlesource.com/platform/bootable/recovery into HEAD

Android 5.1.1 release 1

Change-Id: Ie0c1f776db503e8903b1b44154240ade347dbcaa
parents a6ea0d0f 0e5356a9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -792,7 +792,6 @@ wipe_data(int confirm, Device* device) {
    device->WipeData();
    erase_volume("/data");
    erase_volume("/cache");
    erase_persistent_partition();
    ui->Print("Data wipe complete.\n");
}

@@ -1417,6 +1416,7 @@ main(int argc, char **argv) {
        }
        if (status != INSTALL_SUCCESS) {
            ui->Print("Installation aborted.\n");
            ui->Print("OTA failed! Please power off the device to keep it in this state and file a bug report!\n");

            // If this is an eng or userdebug build, then automatically
            // turn the text display on if the script fails so the error
@@ -1431,7 +1431,6 @@ main(int argc, char **argv) {
        if (device->WipeData()) status = INSTALL_ERROR;
        if (erase_volume("/data", wipe_media)) status = INSTALL_ERROR;
        if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR;
        if (erase_persistent_partition() == -1 ) status = INSTALL_ERROR;
        if (status != INSTALL_SUCCESS) ui->Print("Data wipe failed.\n");
    } else if (wipe_cache) {
        if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR;
+0 −37
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ static struct fstab *fstab = NULL;

extern struct selabel_handle *sehandle;

static const char* PERSISTENT_PATH = "/persistent";

static int mkdir_p(const char* path, mode_t mode)
{
    char dir[PATH_MAX];
@@ -613,41 +611,6 @@ int format_volume(const char* volume, bool force) {
    return -1;
}

int erase_persistent_partition() {
    fstab_rec *v = volume_for_path(PERSISTENT_PATH);
    if (v == NULL) {
        // most devices won't have /persistent, so this is not an error.
        return 0;
    }

    int fd = open(v->blk_device, O_RDWR);
    uint64_t size = get_file_size(fd);
    if (size == 0) {
        LOGE("failed to stat size of /persistent\n");
        close(fd);
        return -1;
    }

    char oem_unlock_enabled;
    lseek(fd, size - 1, SEEK_SET);
    read(fd, &oem_unlock_enabled, 1);

    if (oem_unlock_enabled) {
        if (wipe_block_device(fd, size)) {
           LOGE("error wiping /persistent: %s\n", strerror(errno));
           close(fd);
           return -1;
        }

        lseek(fd, size - 1, SEEK_SET);
        write(fd, &oem_unlock_enabled, 1);
    }

    close(fd);

    return (int) oem_unlock_enabled;
}

int setup_install_mounts() {
    if (fstab == NULL) {
        LOGE("can't set up install mounts: no fstab loaded\n");
+0 −5
Original line number Diff line number Diff line
@@ -49,11 +49,6 @@ int format_volume(const char* volume, bool force = false);
// mounted (/tmp and /cache) are mounted.  Returns 0 on success.
int setup_install_mounts();

// Conditionally wipes the /persistent partition if it's marked
// to wipe. Returns -1 on failure, 1 if the partition was wiped
// and 0 if the partition was not wiped.
int erase_persistent_partition();

char* get_android_secure_path();
int get_num_volumes();

+28 −14
Original line number Diff line number Diff line
@@ -687,19 +687,26 @@ Value* BlockImageUpdateFn(const char* name, State* state, int argc, Expr* argv[]
            rss.p_remain = (tgt->pos[1] - tgt->pos[0]) * BLOCKSIZE;
            check_lseek(fd, (off64_t)tgt->pos[0] * BLOCKSIZE, SEEK_SET);

            int ret;
            if (style[0] == 'i') {      // imgdiff
                ApplyImagePatch(buffer, src_blocks * BLOCKSIZE,
                ret = ApplyImagePatch(buffer, src_blocks * BLOCKSIZE,
                                      &patch_value,
                                      &RangeSinkWrite, &rss, NULL, NULL);
            } else {
                ApplyBSDiffPatch(buffer, src_blocks * BLOCKSIZE,
                ret = ApplyBSDiffPatch(buffer, src_blocks * BLOCKSIZE,
                                       &patch_value, 0,
                                       &RangeSinkWrite, &rss, NULL);
            }

            if (ret != 0) {
                ErrorAbort(state, "patch failed\n");
                goto done;
            }

            // We expect the output of the patcher to fill the tgt ranges exactly.
            if (rss.p_block != tgt->count || rss.p_remain != 0) {
                fprintf(stderr, "range sink underrun?\n");
                ErrorAbort(state, "range sink underrun?\n");
                goto done;
            }

            blocks_so_far += tgt->size;
@@ -723,7 +730,8 @@ Value* BlockImageUpdateFn(const char* name, State* state, int argc, Expr* argv[]
                    range[1] = (tgt->pos[i*2+1] - tgt->pos[i*2]) * (uint64_t)BLOCKSIZE;

                    if (ioctl(fd, BLKDISCARD, &range) < 0) {
                        printf("    blkdiscard failed: %s\n", strerror(errno));
                        ErrorAbort(state, "    blkdiscard failed: %s\n", strerror(errno));
                        goto done;
                    }
                }

@@ -732,8 +740,8 @@ Value* BlockImageUpdateFn(const char* name, State* state, int argc, Expr* argv[]
                printf("  ignoring erase (not block device)\n");
            }
        } else {
            fprintf(stderr, "unknown transfer style \"%s\"\n", style);
            exit(1);
            ErrorAbort(state, "unknown transfer style \"%s\"\n", style);
            goto done;
        }
    }

@@ -750,7 +758,13 @@ Value* BlockImageUpdateFn(const char* name, State* state, int argc, Expr* argv[]
    FreeValue(transfer_list_value);
    FreeValue(new_data_fn);
    FreeValue(patch_data_fn);
    return StringValue(success ? strdup("t") : strdup(""));
    if (success) {
        return StringValue(strdup("t"));
    } else {
        // NULL will be passed to its caller at Evaluate() and abort the OTA
        // process.
        return NULL;
    }
}

Value* RangeSha1Fn(const char* name, State* state, int argc, Expr* argv[]) {
@@ -797,7 +811,7 @@ Value* RangeSha1Fn(const char* name, State* state, int argc, Expr* argv[]) {
    FreeValue(blockdev_filename);
    FreeValue(ranges);
    if (digest == NULL) {
        return StringValue(strdup(""));
        return NULL;
    } else {
        return StringValue(PrintSha1(digest));
    }