diff --git a/build/android/make-Android.bash b/build/android/make-Android.bash index 1277810b..d0f8095b 100755 --- a/build/android/make-Android.bash +++ b/build/android/make-Android.bash @@ -8,7 +8,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE=./android.toolchain.cmake \ -DANDROID_SYSROOT=${PLATFORM} \ -DANDROID_ABI="armeabi-v7a with NEON" \ -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.8" \ - -DANDROID_NATIVE_API_LEVEL=android-17 \ + -DANDROID_NATIVE_API_LEVEL=android-21 \ -DANDROID_STL=none \ ../../ diff --git a/osal/android/os_env.c b/osal/android/os_env.c new file mode 100644 index 00000000..0ab1e55e --- /dev/null +++ b/osal/android/os_env.c @@ -0,0 +1,74 @@ +/* + * Copyright 2010 Rockchip Electronics S.LSI Co. LTD + * + * 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 +#include +#include +#include "os_env.h" +#include + +/* + * NOTE: __system_property_set only available after android-21 + * So the library should compiled on latest ndk + */ + +RK_S32 os_get_env_u32(const char *name, RK_U32 *val) +{ + RK_S32 ret = -1; + char value[PROP_VALUE_MAX+1]; + int len = __system_property_get(name, value); + *val = 0; + if (len > 0) { + char *endptr; + int base = (value[0] == '0' && value[1] == 'x')?(16):(10); + errno = 0; + *val = strtoul(value, &endptr, base); + if (errno || (value == endptr)) { + errno = 0; + } else { + ret = 0; + } + } + return ret; +} + +RK_S32 os_get_env_str(const char *name, char **val) +{ + // use unsigned char to avoid warnning + static unsigned char env_str[2][PROP_VALUE_MAX+1]; + static RK_U32 env_idx = 0; + char *value = (char *)env_str[env_idx]; + int len = __system_property_get(name, value); + *val = (len)?(value):(NULL); + env_idx = (len)?(!env_idx):(env_idx); + return (len)?(0):(-1); +} + +RK_S32 os_set_env_u32(const char *name, RK_U32 val) +{ + char buf[PROP_VALUE_MAX+1+2]; + snprintf(buf, sizeof(buf), "0x%x", val); + int len = __system_property_set(name, buf); + return (len)?(0):(-1); +} + +RK_S32 os_set_env_str(const char *name, char *val) +{ + int len = __system_property_set(name, val); + return (len)?(0):(-1); +} + +