我试图在 com.android.systemui.statusbar.phone.PhoneStatusBar 类中挂钩该方法:
@Override
public void onPlaybackStateChanged(PlaybackState state) {
super.onPlaybackStateChanged(state);
if (DEBUG_MEDIA) Log.v(TAG, "DEBUG_MEDIA: onPlaybackStateChanged: " + state);
}
我的代码如下所示:
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.android.systemui"))
return;
findAndHookMethod("com.android.systemui.statusbar.phone.PhoneStatusBar", lpparam.classLoader,
"onPlaybackStateChanged", PlaybackState.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (pstate != null) {
if (!isPlaybackActive(pstate.getState())) {
clearCurrentMediaNotification();
XposedHelpers.callMethod(updateMediaMetaData, "true");
}
mVisualizerView.setPlaying(pstate.getState() == PlaybackState.STATE_PLAYING);
}
}
});
但是,它给出了 NoSuchMethodError:
12-24 14:29:10.361 E/Xposed ( 2775): java.lang.NoSuchMethodError: com.android.systemui.statusbar.phone.PhoneStatusBar#onPlaybackStateChanged(android.media.session.PlaybackState)#exact