/* * Copyright (C) 2009 The Android Open Source 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. */ #ifndef _ANDROID_LOG_H #define _ANDROID_LOG_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit) since * platform release 1.5 * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ /* * Support routines to send messages to the Android in-kernel log buffer, * which can later be accessed through the 'logcat' utility. * * Each log message must have * - a priority * - a log tag * - some text * * The tag normally corresponds to the component that emits the log message, * and should be reasonably small. * * Log message text may be truncated to less than an implementation-specific * limit (e.g. 1023 characters max). * * Note that a newline character ("\n") will be appended automatically to your * log message, if not already there. It is not possible to send several messages * and have them appear on a single line in logcat. * * PLEASE USE LOGS WITH MODERATION: * * - Sending log messages eats CPU and slow down your application and the * system. * * - The circular log buffer is pretty small (<64KB), sending many messages * might push off other important log messages from the rest of the system. * * - In release builds, only send log messages to account for exceptional * conditions. * * NOTE: These functions MUST be implemented by /system/lib/liblog.so */ #include <stdarg.h> #ifdef __cplusplus extern "C" { #endif /* * Android log priority values, in ascending priority order. */ typedef enum android_LogPriority { ANDROID_LOG_UNKNOWN = 0, ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL, ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ } android_LogPriority; /* * Send a simple string to the log. */ int __android_log_write(int prio, const char *tag, const char *text); /* * Send a formatted string to the log, used like printf(fmt,...) */ int __android_log_print(int prio, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((format(printf, 3, 4))) #endif ; /* * A variant of __android_log_print() that takes a va_list to list * additional parameters. */ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); /* * Log an assertion failure and SIGTRAP the process to have a chance * to inspect it, if a debugger is attached. This uses the FATAL priority. */ void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((noreturn)) __attribute__ ((format(printf, 3, 4))) #endif ; #ifdef __cplusplus } #endif #endif /* _ANDROID_LOG_H */
相关推荐
Android源码,/platform/system/core/include/cutils/log.h
我们将依次解析涉及到的文件:JNIHelp-.c、AndroidRuntime.cpp、android_util_Log.cpp、jni.h、JNIHelp.h以及Log.java,以揭示其内部的工作机制。 首先,`JNIHelp-.c`和`AndroidRuntime.cpp`是Android系统中的核心C...
本文将深入探讨如何在Android应用中实现二维码的生成,以及源码背后的原理。 首先,二维码(Quick Response Code)是一种二维条形码,能够存储比传统条形码更多的信息,如网址、文本、联系人信息等。在Android应用...
- **编译C/C++代码**:使用NDK的交叉编译工具链,将源码编译成对应架构的.so文件。 - **链接.so文件**:将编译好的.so文件放入项目的`jniLibs`目录下,Android Studio会自动将其打包进APK。 - **Java中调用本地...
这时,可以利用Android NDK提供的各种平台相关的头文件和库,如`<android/log.h>`用于日志输出,`<android/asset_manager.h>`用于访问APK内的资源。 总结,Android调用C++代码和C++代码调用Java涉及的关键知识点...
本篇文章将深入讲解如何在Android代码中执行`adb shell`命令,并通过源码分析来理解其工作原理。 首先,`adb shell`命令是通过ADB工具在设备的shell环境中执行命令。在Android应用中,我们通常会用到`Runtime`类...
生成.so库源码的过程通常涉及以下步骤: 1. **创建NDK项目**:在Android Studio中,创建一个新的项目时选择“Empty Activity”,然后在“Additional settings”中勾选“Include C++ support”,这会自动添加对C++和...
Android源码下编译JNI(Java Native Interface)示例项目是一种深入理解Android系统与本地C/C++代码交互机制的关键实践。JNI是Java平台提供的一种接口,允许Java代码和其他语言写的代码进行交互。在这个示例项目中,...
7. **视频格式支持**:源码可能包含了对不同视频编码格式(如H.264, VP9)的支持,这通常依赖于Android系统自身的解码能力,也可能涉及第三方库如FFmpeg。 8. **内存管理与性能优化**:良好的内存管理和性能优化是...
Log.v("H3c", "go:" + rSize); int size = mAccompany.read(accompanyBuf, 0, RecorderParameter.bufferSizeInBytes); Log.v("H3c", "s:" + size); if (size ) { isRunning = false; Log.v("H3c", "run=====...
#include <android/log.h> extern "C" { JNIEXPORT void JNICALL Java_com_example_myapp_MyActivity_callCppFunction(JNIEnv *env, jobject /* this */) { __android_log_print(ANDROID_LOG_INFO, "MyApp", ...
这个"android 录音机 源码"项目提供了一个简单的实现,旨在帮助初学者理解和掌握Android录音机制。下面将详细介绍这个项目的相关知识点。 1. **Android MediaRecorder API**: 这是Android系统提供的核心组件,用于...
接着,在Android Studio中,需要在CMakeLists.txt文件中配置NDK编译规则,引入FFmpeg源码并编译。比如: ```cmake add_library( # Sets the name of the library. ffmpeg # Sets the library as a shared ...
源码位置:include/linux/android_pmem.h drivers/android/pmem.c 7.USB Gadget USB 驱动:基于标准 Linux USB gaeget 驱动框架的设备驱动。源码位置:drivers/usb/gadet/ 8.Ram Console 用于调试写入日志信息的...
8. **调试和日志记录**:为了方便开发者理解和调试,Imsdroid源码中应该包含详细的日志记录,使用Android的Log类或第三方库如Logcat,这对于问题排查至关重要。 9. **安全性和隐私保护**:考虑到通信应用的敏感性,...
#include <android/log.h> JNIEXPORT jstring JNICALL Java_com_example_MyActivity_stringFromJNI(JNIEnv *env, jobject /* this */) { __android_log_print(ANDROID_LOG_INFO, "MyApp", "Hello from JNI!"); ...
1. **获取源码**:从官方仓库或镜像站点下载iconv的源代码。 2. **配置环境**:使用NDK提供的`ndk-build`脚本或CMake构建系统,指定目标平台和编译选项。 3. **编译**:执行构建命令,生成适用于Android架构的.so...
总结起来,Android应用源码之Java调用C例子展示了如何利用JNI技术将Java代码和C/C++代码结合起来,以提高程序性能或实现特定功能。这个过程包括创建本地方法、编写C/C++实现、配置构建系统以及在Java层调用。理解并...
#include <android/log.h> JNIEXPORT void JNICALL Java_com_example_MyActivity_doSomething(JNIEnv *env, jobject obj) { __android_log_print(ANDROID_LOG_DEBUG, "MyTag", "Doing something in native code!")...