Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IContentProviderInvokeHandle applyBatch hook bug #207

Open
seakingjin opened this issue Jun 6, 2016 · 0 comments
Open

IContentProviderInvokeHandle applyBatch hook bug #207

seakingjin opened this issue Jun 6, 2016 · 0 comments

Comments

@seakingjin
Copy link

调用该函数时报错,修改如下:

@OverRide
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {

        if (!mLocalProvider && mStubProvider != null) {

            final int index = 1;
            if (index >= 0) {
                ArrayList<ContentProviderOperation> ops=(ArrayList<ContentProviderOperation>)args[index];
                for (int i=0;i<ops.size();i++)
                {
                    ContentProviderOperation co=ops.get(i);

                    Uri uri = (Uri) FieldUtils.readField(co,"mUri");
                    String authority = uri.getAuthority();

                    if (!TextUtils.equals(authority, mStubProvider.authority)) {

                        Uri.Builder b = new Builder();
                        b.scheme(uri.getScheme());
                        b.authority(mStubProvider.authority);
                        b.path(uri.getPath());
                        b.query(uri.getQuery());
                        b.appendQueryParameter(Env.EXTRA_TARGET_AUTHORITY, authority);
                        b.fragment(uri.getFragment());
                        FieldUtils.writeField(co, "mUri", b.build());
                    }
                }
                args[index] = ops;
            }
        }

        return super.beforeInvoke(receiver, method, args);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant