Skip to content

Commit

Permalink
update: 兼容 AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLqr committed Dec 8, 2021
1 parent 91c7e92 commit 77d442d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class LoaderActivityInjector extends BaseInjector {
'android.app.ActivityGroup' : 'com.qihoo360.replugin.loader.a.PluginActivityGroup',
'android.support.v4.app.FragmentActivity' : 'com.qihoo360.replugin.loader.a.PluginFragmentActivity',
'android.support.v7.app.AppCompatActivity': 'com.qihoo360.replugin.loader.a.PluginAppCompatActivity',
'androidx.fragment.app.FragmentActivity' : 'com.qihoo360.replugin.loader.a.PluginFragmentActivity',
'androidx.appcompat.app.AppCompatActivity': 'com.qihoo360.replugin.loader.a.PluginAppCompatActivity',
'android.preference.PreferenceActivity' : 'com.qihoo360.replugin.loader.a.PluginPreferenceActivity',
'android.app.ExpandableListActivity' : 'com.qihoo360.replugin.loader.a.PluginExpandableListActivity'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import javassist.expr.MethodCall
*/
public class LocalBroadcastExprEditor extends ExprEditor {

static def TARGET_CLASS = 'android.support.v4.content.LocalBroadcastManager'
static def TARGET_CLASSES = [
'android.support.v4.content.LocalBroadcastManager',
'androidx.localbroadcastmanager.content.LocalBroadcastManager'
]
static def PROXY_CLASS = 'com.qihoo360.replugin.loader.b.PluginLocalBroadcastManager'

/** 处理以下方法 */
Expand All @@ -41,7 +44,7 @@ public class LocalBroadcastExprEditor extends ExprEditor {

@Override
void edit(MethodCall call) throws CannotCompileException {
if (call.getClassName().equalsIgnoreCase(TARGET_CLASS)) {
if (TARGET_CLASSES.any { it.equalsIgnoreCase(call.getClassName()) }) {
if (!(call.getMethodName() in includeMethodCall)) {
// println "Skip $methodName"
return
Expand All @@ -66,6 +69,7 @@ public class LocalBroadcastExprEditor extends ExprEditor {
}
}

def TARGET_CLASS = TARGET_CLASSES.find { it.equalsIgnoreCase(call.getClassName()) }
println ">>> Replace: ${filePath} <line:${call.lineNumber}> ${TARGET_CLASS}.${method}() <With> ${PROXY_CLASS}.${method}()\n"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ public class LocalBroadcastInjector extends BaseInjector {
def stream, ctCls
try {
// 不处理 LocalBroadcastManager.class
if (filePath.contains('android/support/v4/content/LocalBroadcastManager')) {
if (
filePath.contains('android/support/v4/content/LocalBroadcastManager') ||
filePath.contains('androidx/localbroadcastmanager/content/LocalBroadcastManager')
) {
println "Ignore ${filePath}"
return super.visitFile(file, attrs)
}
Expand Down

0 comments on commit 77d442d

Please sign in to comment.