diff options
| author | mayankbali <mayankbali3@gmail.com> | 2017-07-10 20:22:36 +0530 |
|---|---|---|
| committer | mayankbali <mayankbali3@gmail.com> | 2017-07-10 20:22:36 +0530 |
| commit | 9cdd9438624e134a4ff4be774df387342a81022a (patch) | |
| tree | 3edd5291f23dd92893fb2727341f0d3cc411b468 | |
| parent | 1ea831147368eb18cb8e07504fbc408cebcc0171 (diff) | |
msm8916-common: kickout non-required cm's crap
| -rw-r--r-- | board/recovery.mk | 2 | ||||
| -rw-r--r-- | board/releasetools.mk | 1 | ||||
| -rw-r--r-- | product/recovery.mk | 3 | ||||
| -rw-r--r-- | recovery/Android.mk | 13 | ||||
| -rw-r--r-- | recovery/recovery_updater.cpp | 291 | ||||
| -rwxr-xr-x | releasetools.py | 139 |
6 files changed, 0 insertions, 449 deletions
diff --git a/board/recovery.mk b/board/recovery.mk deleted file mode 100644 index c32be25..0000000 --- a/board/recovery.mk +++ /dev/null @@ -1,2 +0,0 @@ -# Recovery -TARGET_RECOVERY_UPDATER_LIBS := librecovery_updater_cm diff --git a/board/releasetools.mk b/board/releasetools.mk deleted file mode 100644 index 7d5d417..0000000 --- a/board/releasetools.mk +++ /dev/null @@ -1 +0,0 @@ -TARGET_RELEASETOOLS_EXTENSIONS := $(PLATFORM_PATH) diff --git a/product/recovery.mk b/product/recovery.mk deleted file mode 100644 index 98605a7..0000000 --- a/product/recovery.mk +++ /dev/null @@ -1,3 +0,0 @@ -# Recovery -PRODUCT_PACKAGES += \ - librecovery_updater_cm diff --git a/recovery/Android.mk b/recovery/Android.mk deleted file mode 100644 index 713b46e..0000000 --- a/recovery/Android.mk +++ /dev/null @@ -1,13 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -ifneq ($(TARGET_PLATFORM_DEVICE_BASE),) -LOCAL_CFLAGS += -DUSES_BOOTDEVICE_PATH -endif - -LOCAL_C_INCLUDES := $(call project-path-for,recovery) -LOCAL_SRC_FILES := recovery_updater.cpp -LOCAL_MODULE := librecovery_updater_cm -LOCAL_MODULE_TAGS := eng -include $(BUILD_STATIC_LIBRARY) diff --git a/recovery/recovery_updater.cpp b/recovery/recovery_updater.cpp deleted file mode 100644 index e9eafca..0000000 --- a/recovery/recovery_updater.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2015, The CyanogenMod Project - * Copyright (C) 2017, The LineageOS 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 <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <errno.h> -#include <fcntl.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "edify/expr.h" -#include "updater/install.h" - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#define ALPHABET_LEN 256 - -#ifdef USES_BOOTDEVICE_PATH -#define BASEBAND_PART_PATH "/dev/block/bootdevice/by-name/modem" -#else -#define BASEBAND_PART_PATH "/dev/block/platform/7824900.sdhci/by-name/modem" -#endif -#define BASEBAND_VER_STR_START "QC_IMAGE_VERSION_STRING=MPSS.DPM." -#define BASEBAND_VER_STR_START_LEN 33 -#define BASEBAND_VER_BUF_LEN 255 - -#ifdef USES_BOOTDEVICE_PATH -#define TZ_PART_PATH "/dev/block/bootdevice/by-name/tz" -#else -#define TZ_PART_PATH "/dev/block/platform/7824900.sdhci/by-name/tz" -#endif -#define TZ_VER_STR "QC_IMAGE_VERSION_STRING=" -#define TZ_VER_STR_LEN 24 -#define TZ_VER_BUF_LEN 255 - -/* Boyer-Moore string search implementation from Wikipedia */ - -/* Return longest suffix length of suffix ending at str[p] */ -static int max_suffix_len(const char *str, size_t str_len, size_t p) { - uint32_t i; - - for (i = 0; (str[p - i] == str[str_len - 1 - i]) && (i < p); ) { - i++; - } - - return i; -} - -/* Generate table of distance between last character of pat and rightmost - * occurrence of character c in pat - */ -static void bm_make_delta1(int *delta1, const char *pat, size_t pat_len) { - uint32_t i; - for (i = 0; i < ALPHABET_LEN; i++) { - delta1[i] = pat_len; - } - for (i = 0; i < pat_len - 1; i++) { - uint8_t idx = (uint8_t) pat[i]; - delta1[idx] = pat_len - 1 - i; - } -} - -/* Generate table of next possible full match from mismatch at pat[p] */ -static void bm_make_delta2(int *delta2, const char *pat, size_t pat_len) { - int p; - uint32_t last_prefix = pat_len - 1; - - for (p = pat_len - 1; p >= 0; p--) { - /* Compare whether pat[p-pat_len] is suffix of pat */ - if (strncmp(pat + p, pat, pat_len - p) == 0) { - last_prefix = p + 1; - } - delta2[p] = last_prefix + (pat_len - 1 - p); - } - - for (p = 0; p < (int) pat_len - 1; p++) { - /* Get longest suffix of pattern ending on character pat[p] */ - int suf_len = max_suffix_len(pat, pat_len, p); - if (pat[p - suf_len] != pat[pat_len - 1 - suf_len]) { - delta2[pat_len - 1 - suf_len] = pat_len - 1 - p + suf_len; - } - } -} - -static char * bm_search(const char *str, size_t str_len, const char *pat, - size_t pat_len) { - int delta1[ALPHABET_LEN]; - int delta2[pat_len]; - int i; - - bm_make_delta1(delta1, pat, pat_len); - bm_make_delta2(delta2, pat, pat_len); - - if (pat_len == 0) { - return (char *) str; - } - - i = pat_len - 1; - while (i < (int) str_len) { - int j = pat_len - 1; - while (j >= 0 && (str[i] == pat[j])) { - i--; - j--; - } - if (j < 0) { - return (char *) (str + i + 1); - } - i += MAX(delta1[(uint8_t) str[i]], delta2[j]); - } - - return NULL; -} - -static int get_baseband_version(char *ver_str, size_t len) { - int ret = 0; - int fd; - int baseband_size; - char *baseband_data = NULL; - char *offset = NULL; - - fd = open(BASEBAND_PART_PATH, O_RDONLY); - if (fd < 0) { - ret = errno; - goto err_ret; - } - - baseband_size = lseek64(fd, 0, SEEK_END); - if (baseband_size == -1) { - ret = errno; - goto err_fd_close; - } - - baseband_data = (char *) mmap(NULL, baseband_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (baseband_data == (char *)-1) { - ret = errno; - goto err_fd_close; - } - - /* Do Boyer-Moore search across BASEBAND data */ - offset = bm_search(baseband_data, baseband_size, BASEBAND_VER_STR_START, BASEBAND_VER_STR_START_LEN); - if (offset != NULL) { - strncpy(ver_str, offset + BASEBAND_VER_STR_START_LEN, len); - } else { - ret = -ENOENT; - } - - munmap(baseband_data, baseband_size); -err_fd_close: - close(fd); -err_ret: - return ret; -} - -static int get_tz_version(char *ver_str, size_t len) { - int ret = 0; - int fd; - int tz_size; - char *tz_data = NULL; - char *offset = NULL; - - fd = open(TZ_PART_PATH, O_RDONLY); - if (fd < 0) { - ret = errno; - goto err_ret; - } - - tz_size = lseek64(fd, 0, SEEK_END); - if (tz_size == -1) { - ret = errno; - goto err_fd_close; - } - - tz_data = (char *) mmap(NULL, tz_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (tz_data == (char *)-1) { - ret = errno; - goto err_fd_close; - } - - /* Do Boyer-Moore search across TZ data */ - offset = bm_search(tz_data, tz_size, TZ_VER_STR, TZ_VER_STR_LEN); - if (offset != NULL) { - strncpy(ver_str, offset + TZ_VER_STR_LEN, len); - } else { - ret = -ENOENT; - } - - munmap(tz_data, tz_size); -err_fd_close: - close(fd); -err_ret: - return ret; -} - -/* verify_baseband("BASEBAND_VERSION", "BASEBAND_VERSION", ...) */ -Value * VerifyBasebandFn(const char *name, State *state, int argc, Expr *argv[]) { - char current_baseband_version[BASEBAND_VER_BUF_LEN]; - int i, ret; - - ret = get_baseband_version(current_baseband_version, BASEBAND_VER_BUF_LEN); - if (ret) { - return ErrorAbort(state, kFreadFailure, "%s() failed to read current baseband version: %d", - name, ret); - } - - char** baseband_version = ReadVarArgs(state, argc, argv); - if (baseband_version == NULL) { - return ErrorAbort(state, kArgsParsingFailure, "%s() error parsing arguments", name); - } - - ret = 0; - for (i = 0; i < argc; i++) { - uiPrintf(state, "Comparing baseband version %s to %s", - baseband_version[i], current_baseband_version); - if (strncmp(baseband_version[i], current_baseband_version, strlen(baseband_version[i])) == 0) { - ret = 1; - break; - } - } - - if (ret == 0) { - uiPrintf(state, "ERROR: It appears you are running an unsupported baseband."); - } - - for (i = 0; i < argc; i++) { - free(baseband_version[i]); - } - free(baseband_version); - - return StringValue(strdup(ret ? "1" : "0")); -} - -/* verify_trustzone("TZ_VERSION", "TZ_VERSION", ...) */ -Value * VerifyTrustZoneFn(const char *name, State *state, int argc, Expr *argv[]) { - char current_tz_version[TZ_VER_BUF_LEN]; - int i, ret; - - ret = get_tz_version(current_tz_version, TZ_VER_BUF_LEN); - if (ret) { - return ErrorAbort(state, kFreadFailure, "%s() failed to read current TZ version: %d", - name, ret); - } - - char** tz_version = ReadVarArgs(state, argc, argv); - if (tz_version == NULL) { - return ErrorAbort(state, kArgsParsingFailure, "%s() error parsing arguments", name); - } - - ret = 0; - for (i = 0; i < argc; i++) { - uiPrintf(state, "Comparing TZ version %s to %s", - tz_version[i], current_tz_version); - if (strncmp(tz_version[i], current_tz_version, strlen(tz_version[i])) == 0) { - ret = 1; - break; - } - } - - if (ret == 0) { - uiPrintf(state, "ERROR: It appears you are running an unsupported TZ."); - } - - for (i = 0; i < argc; i++) { - free(tz_version[i]); - } - free(tz_version); - - return StringValue(strdup(ret ? "1" : "0")); -} - -void Register_librecovery_updater_cm() { - RegisterFunction("cm.verify_baseband", VerifyBasebandFn); - RegisterFunction("cm.verify_trustzone", VerifyTrustZoneFn); -} diff --git a/releasetools.py b/releasetools.py deleted file mode 100755 index f8b3810..0000000 --- a/releasetools.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# Copyright (c) 2011, The Linux Foundation. All rights reserved. -# -# 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. - -"""Emit commands needed for QCOM devices during OTA installation -(installing the radio image).""" - -import hashlib -import common -import re - -def LoadFilesMap(zip): - try: - data = zip.read("RADIO/filesmap") - except KeyError: - print "Warning: could not find RADIO/filesmap in %s." % zip - data = "" - d = {} - for line in data.split("\n"): - line = line.strip() - if not line or line.startswith("#"): continue - pieces = line.split() - if not (len(pieces) == 2 or len(pieces) == 3): - raise ValueError("malformed filesmap line: \"%s\"" % (line,)) - file_size = zip.getinfo("RADIO/"+pieces[0]).file_size - sha1 = hashlib.sha1() - sha1.update(zip.read("RADIO/"+pieces[0])) - d[pieces[0]] = (pieces[1], sha1.hexdigest(), file_size) - return d - -def GetRadioFiles(z): - out = {} - for info in z.infolist(): - if info.filename.startswith("RADIO/") and (info.filename.__len__() > len("RADIO/")): - fn = "RADIO/" + info.filename[6:] - out[fn] = fn - return out - -def FullOTA_Assertions(info): - AddBasebandAssertion(info) - AddTrustZoneAssertion(info) - return - -def IncrementalOTA_Assertions(info): - AddBasebandAssertion(info) - AddTrustZoneAssertion(info) - return - -def InstallRawImage(image_data, api_version, input_zip, fn, info, filesmap): - #fn is in RADIO/* format. Extracting just file name. - filename = fn[6:] - if api_version >= 3: - if filename not in filesmap: - return - partition = filesmap[filename][0] - checksum = filesmap[filename][1] - file_size = filesmap[filename][2] - # read_file returns a blob or NULL. Use sha1_check to convert to a string - # that can be evaluated (a NULL results in an empty string) - info.script.AppendExtra('ifelse((sha1_check(read_file("EMMC:%s:%d:%s")) != ""),' - '(ui_print("%s already up to date")),' - '(package_extract_file("%s", "%s")));' - % (partition, file_size, checksum, partition, filename, partition)) - common.ZipWriteStr(info.output_zip, filename, image_data) - return - else: - print "warning radio-update: no support for api_version less than 3." - -def InstallRadioFiles(info): - files = GetRadioFiles(info.input_zip) - if files == {}: - print "warning radio-update: no radio image in input target_files; not flashing radio" - return - info.script.Print("Writing radio image...") - #Load filesmap file - filesmap = LoadFilesMap(info.input_zip) - if filesmap == {}: - print "warning radio-update: no or invalid filesmap file found. not flashing radio" - return - if hasattr(info, 'source_zip'): - source_filesmap = LoadFilesMap(info.source_zip) - else: - source_filesmap = None - for f in files: - if source_filesmap: - filename = f[6:] - source_checksum = source_filesmap.get(filename, [None, 'no_source'])[1] - target_checksum = filesmap.get(filename, [None, 'no_target'])[1] - if source_checksum == target_checksum: - print "info radio-update: source and target match for %s... skipping" % filename - continue - image_data = info.input_zip.read(f) - InstallRawImage(image_data, info.input_version, info.input_zip, f, info, filesmap) - return - -def FullOTA_InstallEnd(info): - InstallRadioFiles(info) - -def IncrementalOTA_InstallEnd(info): - InstallRadioFiles(info) - -def AddBasebandAssertion(info): - # Presence of filesmap indicates packaged firmware - filesmap = LoadFilesMap(info.input_zip) - if filesmap != {}: - return - android_info = info.input_zip.read("OTA/android-info.txt") - m = re.search(r'require\s+version-baseband\s*=\s*(\S+)', android_info) - if m: - versions = m.group(1).split('|') - if len(versions) and '*' not in versions: - cmd = 'assert(cm.verify_baseband(' + ','.join(['"%s"' % baseband for baseband in versions]) + ') == "1");' - info.script.AppendExtra(cmd) - return - -def AddTrustZoneAssertion(info): - # Presence of filesmap indicates packaged firmware - filesmap = LoadFilesMap(info.input_zip) - if filesmap != {}: - return - android_info = info.input_zip.read("OTA/android-info.txt") - m = re.search(r'require\s+version-trustzone\s*=\s*(\S+)', android_info) - if m: - versions = m.group(1).split('|') - if len(versions) and '*' not in versions: - cmd = 'assert(cm.verify_trustzone(' + ','.join(['"%s"' % tz for tz in versions]) + ') == "1");' - info.script.AppendExtra(cmd) - return |
