屏蔽GMS的Dialog提示

接到一个活儿,是让屏蔽谷歌gms的dialog提示,屏蔽游戏中的ShareButton,CloudSaveButton,屏蔽UnityAd
1、屏蔽Dialog:

com.google.android.gms.common.GoogleApiAvailability.zza();

返回是Dialog;
修改smali,返回null;
hook代码:

  try {
        Method methodzza = null;
        Class a   =target.getClassLoader().loadClass("com.google.android.gms.common.GoogleApiAvailability");
        for (Method method : a.getDeclaredMethods()) {
            if ("zza".equals(method.getName())) {
                Log.e("gamea", ":" + method.getName() + ":" + method.getReturnType().getName());
                if (method.getReturnType().getName().equals("android.app.Dialog")) {
                    methodzza = method;
                }
            }
        }
         if (methodzza != null) {
            DexposedBridge.hookMethod(methodzza, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                    super.beforeHookedMethod(param);
                    Log.e("gamea", "param:" + param.args[2]);
                }

                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    super.afterHookedMethod(param);
                    Log.e("gamea", ":" + param.getResult());
                    param.setResult(null);
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

若是华为手机,手机上装有gms,还需要屏蔽PackageManager的“com.google.android.gms”查找
在这个app 中的位置是

com.google.android.gms.common.GoogleApiAvailability.isGoogleGmsAvailability();

可以通过删除Google的类来做到,删除有风险,实用需谨慎

你可能感兴趣的:(屏蔽GMS的Dialog提示)