com.taobao.android.dexposed.DexposedBridge Java Examples

The following examples show how to use com.taobao.android.dexposed.DexposedBridge. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PerformanceApp.java    From android-performance with MIT License 6 votes vote down vote up
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);

    if(mCrashTimes > 3){
        // 删除文件,恢复到重新安装的状态
    }

    if(mCrashTimes > 5){
        // 清除热修信息
    }

    LaunchTimer.startRecord();
    MultiDex.install(this);
    DexposedBridge.hookAllConstructors(Thread.class, new XC_MethodHook() {
        @Override
        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            super.afterHookedMethod(param);
            Thread thread = (Thread) param.thisObject;
            LogUtils.i(thread.getName()+" stack "+Log.getStackTraceString(new Throwable()));
        }
    });
}
 
Example #2
Source File: HookPkgUninstallReceiver.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<XC_MethodHook.Unhook> fetchHook() throws Exception {
    return Collections.singletonList(DexposedBridge.findAndHookMethod(Class.forName("com.xiaomi.push.service.receivers.PkgUninstallReceiver"),
            "onReceive", Context.class, Intent.class, new XC_MethodReplacement() {
                @Override
                protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                    Context context = (Context) param.args[0];
                    Intent intent = (Intent) param.args[1];
                    if (intent != null && intent.getExtras() !=null) {
                        if ("android.intent.action.PACKAGE_REMOVED".equals(intent.getAction())) {
                            boolean isReplaced = intent.getExtras().getBoolean("android.intent.extra.REPLACING");
                            Uri data = intent.getData();
                            if (data != null && !isReplaced) {
                                try {
                                    Intent serviceIntent = new Intent(context, PushServiceMain.class);
                                    serviceIntent.setAction(PushServiceConstants.ACTION_UNINSTALL);
                                    serviceIntent.putExtra(PushServiceConstants.EXTRA_UNINSTALL_PKG_NAME, data.getEncodedSchemeSpecificPart());
                                    ContextCompat.startForegroundService(context, serviceIntent);
                                    GeoFenceUtils.appIsUninstalled(context.getApplicationContext(), data.getEncodedSchemeSpecificPart());
                                } catch (Throwable e) {
                                    logger.e("Hook", e);
                                }
                            }
                        }
                    }
                    return null;
                }
            }));
}
 
Example #3
Source File: HookPingReceiver.java    From MiPushFramework with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<XC_MethodHook.Unhook> fetchHook() throws Exception {
    return Collections.singletonList(DexposedBridge.findAndHookMethod(Class.forName("com.xiaomi.push.service.receivers.PingReceiver"),
            "onReceive", Context.class, Intent.class, new XC_MethodReplacement() {
                @Override
                protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                    Context context = (Context) param.args[0];
                    Intent intent = (Intent) param.args[1];
                    Alarm.registerPing(false);
                    logger.v(intent.getPackage() + " is the package name");
                    if (!PushConstants.ACTION_PING_TIMER.equals(intent.getAction())) {
                        logger.w("cancel the old ping timer");
                        Alarm.stop();
                    } else if (TextUtils.equals(context.getPackageName(), intent.getPackage())) {
                        logger.v("Ping hooked XMChannelService on timer");
                        try {
                            Intent serviceIntent = new Intent(context, PushServiceMain.class);
                            serviceIntent.putExtra(PushServiceConstants.EXTRA_TIME_STAMP, System.currentTimeMillis());
                            serviceIntent.setAction(PushServiceConstants.ACTION_TIMER);
                            ContextCompat.startForegroundService(context, serviceIntent);
                        } catch (Throwable e) {
                            logger.e(e);
                        }
                    }
                    return null;
                }
            }));
}
 
Example #4
Source File: HotpatchManager.java    From hotpatch with MIT License 5 votes vote down vote up
public boolean init(final Context ctx) {
    boolean isSupport = DexposedBridge.canDexposed(ctx);
    if (isSupport) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                check(ctx);
            }
        }).start();
    }
    return isSupport;
}
 
Example #5
Source File: XLogConfig.java    From XLog with Apache License 2.0 5 votes vote down vote up
public static void config(final XLogInitializer initializer) {
    SharedPreferences sharedPreferences = initializer.getContext()
            .getSharedPreferences(XLOG_SHARED_PREFERENCES, Context.MODE_PRIVATE);
    sharedPreferences.edit().putString(PREF_CONFIG, initializer.toString()).commit();
    if (DexposedBridge.canDexposed(initializer.getContext())) {
        hookAllMethods(initializer.getContext(), initializer.getTimeThreshold(),
                initializer.getXLogMethods());
    }
}
 
Example #6
Source File: PerformanceApp.java    From android-performance with MIT License 4 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();

        MMKV.initialize(PerformanceApp.this);
        MMKV.defaultMMKV().encode("times",100);

        int times = MMKV.defaultMMKV().decodeInt("times");


        LaunchTimer.startRecord();
        mApplication = this;

        TaskDispatcher.init(PerformanceApp.this);

        TaskDispatcher dispatcher = TaskDispatcher.createInstance();

        dispatcher.addTask(new InitAMapTask())
                .addTask(new InitStethoTask())
                .addTask(new InitWeexTask())
                .addTask(new InitBuglyTask())
                .addTask(new InitFrescoTask())
                .addTask(new InitJPushTask())
                .addTask(new InitUmengTask())
                .addTask(new GetDeviceIdTask())
                .start();

        dispatcher.await();

        LaunchTimer.endRecord();

        DexposedBridge.hookAllConstructors(ImageView.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                DexposedBridge.findAndHookMethod(ImageView.class, "setImageBitmap", Bitmap.class, new ImageHook());
            }
        });


//        try {
//            DexposedBridge.findAndHookMethod(Class.forName("android.os.BinderProxy"), "transact",
//                    int.class, Parcel.class, Parcel.class, int.class, new XC_MethodHook() {
//                        @Override
//                        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
//                            LogUtils.i( "BinderProxy beforeHookedMethod " + param.thisObjecObservablet.getClass().getSimpleName()
//                                    + "\n" + Log.getStackTraceString(new Throwable()));
//                            super.beforeHookedMethod(param);
//                        }
//                    });
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        }

//        BlockCanary.install(this, new AppBlockCanaryContext()).start();

        initStrictMode();

//        new ANRWatchDog().start();
    }