Skip to content

Commit

Permalink
mt2: Provide global Huawei symbols via libc
Browse files Browse the repository at this point in the history
Huawei included some non-standard functions in libcutils and liblog.
Make these functions globally available by including them in libc.

Parts of this commit originated from:
  libcutils/liblog: Add functions required by Huawei g620_a2 binaries
  Thomas Wendt
  I58604686008340ef4e10f3f67dc329fe7bd864cc

Change-Id: Ie3a84ce5b6b969ef4cc17b2028cc03298a43a79b
  • Loading branch information
mdmower committed Sep 11, 2015
1 parent 2671df7 commit e1d73b1
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
3 changes: 3 additions & 0 deletions BoardConfig.mk
Expand Up @@ -99,6 +99,9 @@ BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02000000
TARGET_KERNEL_CONFIG := cyanogenmod_mt2_defconfig
TARGET_KERNEL_SOURCE := kernel/huawei/msm8928

# Libc extensions
BOARD_PROVIDES_ADDITIONAL_BIONIC_STATIC_LIBS += libc_huawei_symbols

# Lights
TARGET_PROVIDES_LIBLIGHT := true

Expand Down
30 changes: 30 additions & 0 deletions libc_huawei_symbols/Android.mk
@@ -0,0 +1,30 @@
# Copyright (C) 2015 The CyanogenMod 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.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
hw_cutils.c \
hw_log.c

LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_MODULE := libc_huawei_symbols
LOCAL_MODULE_TAGS := optional

# Debugging (uncomment to enable)
# LOCAL_CFLAGS += -DHW_LIBC_DEBUG
# LOCAL_WHOLE_STATIC_LIBRARIES := liblog

include $(BUILD_STATIC_LIBRARY)
81 changes: 81 additions & 0 deletions libc_huawei_symbols/hw_cutils.c
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2015 The CyanogenMod 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.
*/

#ifdef HW_LIBC_DEBUG
#define LOG_TAG "HWAppInfo"
#include <log/log.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

/*
* References in kernel:
* fs/proc/app_info.c
* include/misc/app_info.h
*/

#define APP_INFO_PATH "/proc/app_info"
#define APP_INFO_VALUE_LENGTH 32

int get_app_info(char* key, char* value) {
char buf[128] = { 0 };
char* tok;
FILE* f;

#ifdef HW_LIBC_DEBUG
ALOGI("Getting App Info for %s", key);
#endif

if(key == NULL) {
#ifdef HW_LIBC_DEBUG
ALOGE("Key is null");
#endif
return -1;
}

f = fopen(APP_INFO_PATH, "rb");
if(f == NULL) {
#ifdef HW_LIBC_DEBUG
ALOGE("Failed to open %s: %s", APP_INFO_PATH, strerror(errno));
#endif
return -2;
}

while (!feof(f)) {
if (fgets(buf, 128, f) != NULL &&
strstr(buf, key) != NULL) {
tok = strchr(buf, ':');
if (tok != NULL)
tok = strtok(tok, ": ");
if (tok != NULL) {
snprintf(value, APP_INFO_VALUE_LENGTH, "%s", tok);
strtok(value, "\n");
}
break;
}
}

fclose(f);

#ifdef HW_LIBC_DEBUG
ALOGI("%s=%s", key, value);
#endif

return 0;
}
22 changes: 22 additions & 0 deletions libc_huawei_symbols/hw_log.c
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2015 The CyanogenMod 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.
*/

void __android_logPower_print(void) {
}

int isLogEnabled(void) {
return 0;
}

0 comments on commit e1d73b1

Please sign in to comment.