Skip to content

Commit

Permalink
#plugin##provider# support getType
Browse files Browse the repository at this point in the history
  • Loading branch information
hyongbai committed Mar 28, 2019
1 parent 83b4bec commit 8a135ab
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ public class ProviderInjector extends BaseInjector {
'bulkInsert',
'delete',
'update',
/// 以下方法 replugin 暂未支持,导致字节码修改失败。
/// 以下方法 replugin plugin lib 暂未支持,导致字节码修改失败。
// 'openInputStream',
// 'openOutputStream',
// 'openFileDescriptor',
// 'registerContentObserver',
// 'acquireContentProviderClient',
// 'notifyChange',
// 'toCalledUri',
]

// 表达式编辑器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.annotation.TargetApi;
import android.content.ContentValues;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
Expand Down Expand Up @@ -196,6 +197,34 @@ public static int update(Context c, Uri uri, ContentValues values, String select
return -1;
}

/**
* 调用插件里的Provider
*
* @see android.content.ContentResolver#getType(Uri)
*/
public static String getType(Context c, Uri uri) {
if (c == null) {
return null;
}

if (!RePluginFramework.mHostInitialized) {
return c.getContentResolver().getType(uri);
}

try {
Object obj = ProxyRePluginProviderClientVar.getType.call(null, c, uri);
if (obj != null) {
return (String) obj;
}
} catch (Exception e) {
if (LogDebug.LOG) {
e.printStackTrace();
}
}

return null;
}

public static class ProxyRePluginProviderClientVar {

private static MethodInvoker query;
Expand All @@ -210,6 +239,30 @@ public static class ProxyRePluginProviderClientVar {

private static MethodInvoker update;

private static MethodInvoker getType;

private static MethodInvoker openInputStream;

private static MethodInvoker openOutputStream;

private static MethodInvoker openOutputStream2;

private static MethodInvoker openFileDescriptor;

private static MethodInvoker openFileDescriptor2;

private static MethodInvoker registerContentObserver;

private static MethodInvoker acquireContentProviderClient;

private static MethodInvoker notifyChange;

private static MethodInvoker notifyChange2;

private static MethodInvoker toCalledUri;

private static MethodInvoker toCalledUri2;

public static void initLocked(final ClassLoader classLoader) {
//
String rePluginProviderClient = "com.qihoo360.loader2.mgr.PluginProviderClient";
Expand All @@ -223,6 +276,21 @@ public static void initLocked(final ClassLoader classLoader) {
bulkInsert = new MethodInvoker(classLoader, rePluginProviderClient, "bulkInsert", new Class<?>[]{Context.class, Uri.class, ContentValues[].class});
delete = new MethodInvoker(classLoader, rePluginProviderClient, "delete", new Class<?>[]{Context.class, Uri.class, String.class, String[].class});
update = new MethodInvoker(classLoader, rePluginProviderClient, "update", new Class<?>[]{Context.class, Uri.class, ContentValues.class, String.class, String[].class});
// new supported
getType = new MethodInvoker(classLoader, rePluginProviderClient, "getType", new Class<?>[]{Context.class, Uri.class});
openInputStream = new MethodInvoker(classLoader, rePluginProviderClient, "openInputStream", new Class<?>[]{Context.class, Uri.class});
openOutputStream = new MethodInvoker(classLoader, rePluginProviderClient, "openOutputStream", new Class<?>[]{Context.class, Uri.class});
openOutputStream2 = new MethodInvoker(classLoader, rePluginProviderClient, "openOutputStream", new Class<?>[]{Context.class, Uri.class, String.class});
openFileDescriptor = new MethodInvoker(classLoader, rePluginProviderClient, "openFileDescriptor", new Class<?>[]{Context.class, Uri.class, String.class});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
openFileDescriptor2 = new MethodInvoker(classLoader, rePluginProviderClient, "openFileDescriptor", new Class<?>[]{Context.class, Uri.class, String.class, CancellationSignal.class});
}
registerContentObserver = new MethodInvoker(classLoader, rePluginProviderClient, "registerContentObserver", new Class<?>[]{Context.class, Uri.class, Boolean.class, ContentObserver.class});
acquireContentProviderClient = new MethodInvoker(classLoader, rePluginProviderClient, "acquireContentProviderClient", new Class<?>[]{Context.class, String.class});
notifyChange = new MethodInvoker(classLoader, rePluginProviderClient, "notifyChange", new Class<?>[]{Context.class, Uri.class, ContentObserver.class});
notifyChange2 = new MethodInvoker(classLoader, rePluginProviderClient, "notifyChange", new Class<?>[]{Context.class, Uri.class, ContentObserver.class, Boolean.class});
toCalledUri = new MethodInvoker(classLoader, rePluginProviderClient, "toCalledUri", new Class<?>[]{Context.class, Uri.class});
toCalledUri2 = new MethodInvoker(classLoader, rePluginProviderClient, "toCalledUri", new Class<?>[]{Context.class, String.class, Uri.class, Integer.class});
}
}
}
Expand Down

0 comments on commit 8a135ab

Please sign in to comment.