Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove onFlyCompress message from logcat

Tags:

android

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

like image 701
Guillaume Avatar asked Apr 06 '17 01:04

Guillaume


2 Answers

You may can (i am not sure) subclass the class YuvImage which prints log and override the method of that class which prints the log and simply copy all code of that method but the Log.d() or Log.v() or Log.w() , ... code to the overridden method.

Look at the following answer too:

How do I enable/disable log levels in Android?

like image 79
ygngy Avatar answered Sep 28 '22 03:09

ygngy


Short answer

Try accomplishing your goal with method hooking.

You can hook android.util.log methods using XPosed Framework on ROOTed devices.

Detailed methods

  1. Use XPosed Framework to hook the android.util.Log's methods.
  2. In the hooking method, check if the message contains skia onFlyCompress.
  3. 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.

(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.)

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.

Sample code snippet

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");
            }
        }
     }
   }
}

Code reference: this XDA thread

Install XPosed Framework

XPosed Dev tutorial

like image 39
KYHSGeekCode Avatar answered Sep 28 '22 04:09

KYHSGeekCode