|
9 | 9 | import android.os.IInterface;
|
10 | 10 | import android.os.ParcelFileDescriptor;
|
11 | 11 |
|
| 12 | +import com.lody.virtual.client.core.VirtualCore; |
12 | 13 | import com.lody.virtual.client.hook.base.MethodBox;
|
13 | 14 | import com.lody.virtual.helper.compat.BuildCompat;
|
| 15 | +import com.lody.virtual.helper.utils.Reflect; |
14 | 16 | import com.lody.virtual.helper.utils.VLog;
|
15 | 17 |
|
16 | 18 | import java.lang.reflect.InvocationHandler;
|
@@ -153,8 +155,13 @@ public Object invoke(Object proxy, Method method, Object... args) throws Throwab
|
153 | 155 | }
|
154 | 156 | MethodBox methodBox = new MethodBox(method, mBase, args);
|
155 | 157 | int start = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ? 1 : 0;
|
156 |
| - // Android 11: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/content/IContentProvider.java?q=IContentProvider&ss=android%2Fplatform%2Fsuperproject |
157 |
| - if(Build.VERSION.SDK_INT >= 30) start = 2; |
| 158 | + if (BuildCompat.isS()) { |
| 159 | + // https://cs.android.com/android/platform/superproject/+/android-12.0.0_r16:frameworks/base/core/java/android/content/IContentProvider.java |
| 160 | + start = 1; |
| 161 | + } else if (BuildCompat.isR()) { |
| 162 | + // Android 11: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/content/IContentProvider.java?q=IContentProvider&ss=android%2Fplatform%2Fsuperproject |
| 163 | + start = 2; |
| 164 | + } |
158 | 165 | try {
|
159 | 166 | String name = method.getName();
|
160 | 167 | if ("call".equals(name)) {
|
@@ -207,6 +214,9 @@ public Object invoke(Object proxy, Method method, Object... args) throws Throwab
|
207 | 214 | String[] selectionArgs = null;
|
208 | 215 | String sortOrder = null;
|
209 | 216 | Bundle queryArgs = null;
|
| 217 | + if (BuildCompat.isS()) { |
| 218 | + fixAttributionSource(args[0]); |
| 219 | + } |
210 | 220 | if (Build.VERSION.SDK_INT >= 26) {
|
211 | 221 | queryArgs = (Bundle) args[start + 2];
|
212 | 222 | if (queryArgs != null) {
|
@@ -238,4 +248,14 @@ protected void processArgs(Method method, Object... args) {
|
238 | 248 | public interface HookFetcher {
|
239 | 249 | ProviderHook fetch(boolean external, IInterface provider);
|
240 | 250 | }
|
| 251 | + |
| 252 | + private void fixAttributionSource(Object attribution) { |
| 253 | + try { |
| 254 | + Object mAttributionSourceState = Reflect.on(attribution).get("mAttributionSourceState"); |
| 255 | + Reflect.on(mAttributionSourceState).set("uid", VirtualCore.get().myUid()); |
| 256 | + Reflect.on(mAttributionSourceState).set("packageName", VirtualCore.get().getHostPkg()); |
| 257 | + } catch (Throwable e) { |
| 258 | + e.printStackTrace(); |
| 259 | + } |
| 260 | + } |
241 | 261 | }
|
0 commit comments