0

I tried to call a private method inside an abstract class. I used :

XposedHelpers.findAndHookMethod("com.kabouzeid.gramophone.ui.activities.tageditor.AbsTagEditorActivity", lpparam.classLoader, "getTrackNumber",String.class, new XC_MethodHook(){
             @Override
             protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
                 Object obj1= XposedHelpers.callMethod(param.thisObject,"getAudioFile","test");
             }
        });

where the methods getAudioFile and getTrackNumber are declared inside the abstract class AbsTagEditorActivity

It return NoSuchMethodError:com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity#getAudioFile(java.lang.String)#bestmatch.

The class SongTagEditorActivity extends AbsTagEditorActivity

But if I try to hook the method getAudioFile with

XposedHelpers.findAndHookMethod("com.kabouzeid.gramophone.ui.activities.tageditor.AbsTagEditorActivity", lpparam.classLoader, "getAudioFile",String.class, new XC_MethodHook() 
        {
            @Override
            protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable
            {
                XposedBridge.log("test:"+param.args[0]);
            }
        });

it works

The method should be this:

  @NonNull
  private AudioFile getAudioFile(@NonNull String paramString)
  {
      try
      {
          AudioFile localAudioFile = AudioFileIO.read(new File(paramString));
          return localAudioFile;
      } catch (Exception localException){}
      return new AudioFile();
  }

what am I doing wrong ?

Thanks in advance

materight
  • 527
  • 8
  • 22

2 Answers2

0

From a quick look at Xposed Helpers, it might be because the object you are trying to invoke the method on is a subclass and XposedHelpers.callMethod does not seem to allow invoking private methods from superclasses.

Try to log the "this" object class name when you hook "getTrackNumber" and you can try invoking it yourself using reflection.

4knahs
  • 629
  • 4
  • 14
0

You cannot hook a abstract method via Xposed. If you want to hook a abstract method you need to hook the method in class which extends that abstract class. Same case with interfaces. You need to hook method in class which implements that interface. Also if you want to call a private method you need to set it accessible via reflection. Just google how to do it.

Suraj
  • 184
  • 1
  • 14