@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable {
if
(loadPackageParam.packageName.equals(HookUtils.XPOSED_HOOK_PACKAGE)) {
classLoader
=
loadPackageParam.classLoader;
XposedBridge.log(TAG
+
" has Hooked!"
);
XposedHelpers.findAndHookMethod(Application.
class
,
"attach"
, Context.
class
, new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Context context
=
(Context) param.args[
0
];
dexClassLoader
=
context.getClassLoader();
if
(dexClassLoader
=
=
null) {
XposedBridge.log(
"cannot get classloader return "
);
return
;
}
XposedBridge.log(TAG
+
" has Hooked!"
);
final Class<?> sqliteDatabase
=
XposedHelpers.findClass(
"net.sqlcipher.database.SQLiteDatabase"
, dexClassLoader);
final Method insertWithOnConflictMethod
=
XposedHelpers.findMethodExact(sqliteDatabase,
"insertWithOnConflict"
, String.
class
, String.
class
, ContentValues.
class
,
int
.
class
);
XC_MethodHook methodHook
=
new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log(TAG
+
" insertWithOnConflictMethod"
);
String table
=
(String) param.args[
0
];
ContentValues contentValues
=
(ContentValues) param.args[
2
];
if
(table !
=
null && table.toLowerCase().startsWith(
"insert into"
)) {
LogUtil.PrintInsert(table, contentValues,
"sqlcipher insert"
);
}
}
};
/
/
Hook insertWithOnConflict 方法
XposedBridge.hookMethod(insertWithOnConflictMethod, methodHook);
}
});
}
}