Skip to content

Commit

Permalink
[VA]: fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
weishu.tws committed Mar 13, 2018
1 parent 7c9dad3 commit ec43f6a
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.lody.virtual.client.hook.proxies.content;

import com.lody.virtual.client.hook.base.BinderInvocationProxy;
import com.lody.virtual.client.hook.base.Inject;

import mirror.android.content.IContentService;

/**
* @author Lody
*
* @see IContentService
*/

@Inject(MethodProxies.class)
public class ContentServiceStub extends BinderInvocationProxy {

public ContentServiceStub() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.lody.virtual.client.hook.proxies.content;

import android.content.pm.ApplicationInfo;
import android.os.Build;

import com.lody.virtual.client.VClientImpl;
import com.lody.virtual.client.hook.base.MethodProxy;

import java.lang.reflect.Method;

/**
* author: weishu on 18/3/13.
*/
class MethodProxies {

static class NotifyChange extends MethodProxy {

@Override
public String getMethodName() {
return "notifyChange";
}

@Override
public boolean beforeCall(Object who, Method method, Object... args) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return super.beforeCall(who, method, args);
}
ApplicationInfo currentApplicationInfo = VClientImpl.get().getCurrentApplicationInfo();
if (currentApplicationInfo == null) {
return super.beforeCall(who, method, args);
}
int targetSdkVersion = currentApplicationInfo.targetSdkVersion;

int length = args.length;
int index = -1;
for (int i = 0; i < length; i++) {
Object obj = args[length - 1];
if (obj != null && obj.getClass() == Integer.class) {
if ((int) obj == targetSdkVersion) {
index = i;
}
}
}
/*
In ContentService, it contains this code:
if (targetSdkVersion >= Build.VERSION_CODES.O) {
throw new SecurityException(msg);
} else {
if (msg.startsWith("Failed to find provider")) {
// Sigh, we need to quietly let apps targeting older API
// levels notify on non-existent providers.
} else {
Log.w(TAG, "Ignoring notify for " + uri + " from " + uid + ": " + msg);
return;
}
}
we just modify the targetSdkVersion dynamic to fake it.
*/
if (index != -1) {
args[index] = Build.VERSION_CODES.N_MR1;
}

return super.beforeCall(who, method, args);
}

@Override
public boolean isEnable() {
return isAppProcess();
}
}
}

0 comments on commit ec43f6a

Please sign in to comment.