问题描述
我正在使用YuvImage
将android.hardware.Camera
提要压缩为jpeg.从那时起,我一直在logcat中看到skia onFlyCompress
消息,这完全污染了它.有什么办法可以禁用此消息?我知道我可以过滤logcat的输出,但这意味着可以一直在任何地方进行处理,这不是解决方法,而是一种解决方法.我就是根本不想打印这些消息
I am using YuvImage
to compress the android.hardware.Camera
feed to jpeg. Since then, I keep seeing skia onFlyCompress
messages in logcat, which completely pollutes it. Is there any way to disable this message? I know I can filter the logcat output but that means doing it everywhere all the time, which is not a fix but a workaround. I simply don't want those messages printed at all
推荐答案
简短答案
尝试使用方法挂钩实现目标.
您可以使用 XPosed Framework 来挂钩android.util.log
方法在 ROOTED 设备上.
You can hook android.util.log
methods using XPosed Frameworkon ROOTed devices.
详细方法
- 使用XPosed Framework挂钩
android.util.Log
的方法. - 在挂钩方法中,检查邮件是否包含
skia onFlyCompress
. - 如果然后致电
setResult(null);
以防止其打印出日志消息.
- Use XPosed Framework to hook the
android.util.Log
's methods. - In the hooking method, check if the message contains
skia onFlyCompress
. - If then call
setResult(null);
to prevent it from printing out the log message.
尽管,这些方法仅可在有根设备上使用,,但我希望我的回答至少对某些可以使用有根设备的用户有所帮助
Though these methods can only be used on rooted devices, but I hope my answer help at least some users that can use rooted devices.
(嗯,因为没有客户,您将不得不阻止日志消息,因此您要做的就是仅将您的本地设备仅作为根目录并安装使用XPosed框架的自动过滤应用.)
(Hmm, because no customers will have to block the log messages, so all you need to do is to just root your local device only and install the auto-filtering app that uses XPosed framework.)
要查看阻止方法执行其其余代码的示例:此答案(尤其是最后一段)包含一些使用Xposed框架的示例.如您所见,代码非常短(不超过40行.)
To see an example of blocking a method from executing rest of its code:This answer(especially the last paragraph) contains some examples to use Xposed framework. As you can see, the codes are very short(no longer than 40 lines.)
如果需要/看到可能有用的代码,我将实施一些代码.
I will implement some codes if needed/seen potentially useful.
示例代码段
当有人支持我的建议时,我认为有人喜欢我的建议.所以我发布了一些代码.
As someone upvoted mine, I assume that someone liked my suggestions. So I post some codes.
import android.util.*;
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_LoadPackage.*;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
public class LogFilterApp implements IXposedHookLoadPackage
{
private String TAG="LogFilter";
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable
{
XposedBridge.log("Package name: " + lpparam.packageName);
try
{
findAndHookMethod("android.util.Log", lpparam.classLoader, "i", String.class, String.class, new XC_MethodHook()
{
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable
{
//do something before
if(((String)(param.args[1])).indexOf("skia onFlyCompress")>=0)
{
param.setResult(null);
}
}
});
}
catch (XposedHelpers.ClassNotFoundError e)
{
XposedBridge.log("ClassNotFoundError");
}
catch (NoSuchMethodError e)
{
XposedBridge.log("NoSuchMethodError");
}
}
}
}
}
代码参考:此 XDA线程
这篇关于从logcat移除onFlyCompress消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!