Java Code Examples for de.robv.android.xposed.XposedBridge#hookAllConstructors()
The following examples show how to use
de.robv.android.xposed.XposedBridge#hookAllConstructors() .
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: LauncherUIHook.java From XposedWechatHelper with GNU General Public License v2.0 | 6 votes |
/** * find icon id * * @param itemClass */ private void initIconIds(final Class itemClass) { try { XposedBridge.hookAllConstructors(itemClass, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { int arg0 = (int) param.args[0]; int iconId = (int) param.args[3]; if (arg0 == 10) { iconIds[0] = iconId; } else if (arg0 == 20) { iconIds[1] = iconId; } super.beforeHookedMethod(param); } }); } catch (Exception e) { e.printStackTrace(); } }
Example 2
Source File: LocationHook.java From XposedRimetHelper with GNU General Public License v2.0 | 6 votes |
public void hook(final ClassLoader classLoader) { try { final Class aMapLocationClientClazz = XposedHelpers.findClass("com.amap.api.location.AMapLocationClient", classLoader); XposedBridge.hookAllConstructors(aMapLocationClientClazz, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Field[] fields = aMapLocationClientClazz.getDeclaredFields(); for (Field field : fields) { Object object = XposedHelpers.getObjectField(param.thisObject, field.getName()); if (object != null && !(object.getClass().getName()).equals("com.alibaba.android.rimet.LauncherApplication")) { Class locationManagerClazz = XposedHelpers.findClass(object.getClass().getName(), classLoader); hookLocationManager(locationManagerClazz); } } super.afterHookedMethod(param); } }); } catch (Error | Exception e) { XposedBridge.log(e); } }
Example 3
Source File: ModVolumeKeySkipTrack.java From GravityBox with Apache License 2.0 | 6 votes |
static void initAndroid(final XSharedPreferences prefs, final ClassLoader classLoader) { try { if (DEBUG) log("init"); updatePreference(prefs); Class<?> classPhoneWindowManager = findClass("com.android.server.policy.PhoneWindowManager", classLoader); XposedBridge.hookAllConstructors(classPhoneWindowManager, handleConstructPhoneWindowManager); // take advantage of screenTurnedOff method for refreshing state of allowSkipTrack preference findAndHookMethod(classPhoneWindowManager, "screenTurnedOff", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (DEBUG) log("screenTurnedOff"); updatePreference(prefs); } }); findAndHookMethod(classPhoneWindowManager, "interceptKeyBeforeQueueing", KeyEvent.class, int.class, handleInterceptKeyBeforeQueueing); } catch (Throwable t) { XposedBridge.log(t); } }
Example 4
Source File: ModSwipeBack.java From SwipeBack with GNU General Public License v3.0 | 6 votes |
private void hookActivityRecord(Class<?> clazz) throws Throwable { XposedBridge.hookAllConstructors(clazz, new XC_MethodHook() { @Override protected void afterHookedMethod(XC_MethodHook.MethodHookParam mhparams) throws Throwable { String packageName = $(getObjectField(mhparams.thisObject, "packageName")); ActivityInfo activity = $(getObjectField(mhparams.thisObject, "info")); if (shouldExclude(packageName, activity.name)) return; boolean isHome = false; if (Build.VERSION.SDK_INT >= 19) { isHome = (Boolean) callMethod(mhparams.thisObject, "isHomeActivity"); } else { isHome = getBooleanField(mhparams.thisObject, "isHomeActivity"); } if (!isHome) { // fullscreen = false means transparent setBooleanField(mhparams.thisObject, "fullscreen", false); } } }); }
Example 5
Source File: GmsLocationHack.java From AppOpsXposed with GNU General Public License v3.0 | 6 votes |
private static void hookCtorForContextGrab(Class<?> clazz) { XposedBridge.hookAllConstructors(clazz, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { for(Object arg : param.args) { if(arg instanceof Context) { XposedHelpers.setAdditionalInstanceField(param.thisObject, "context", new WeakReference<Context>((Context) arg)); break; } } } }); }
Example 6
Source File: BootCompletedHack.java From AppOpsXposed with GNU General Public License v3.0 | 6 votes |
private void injectLabelAndSummary(LoadPackageParam lpparam) throws Throwable { final Class<?> appOpsStateClazz = lpparam.classLoader.loadClass( "com.android.settings.applications.AppOpsState"); XposedBridge.hookAllConstructors(appOpsStateClazz, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { final CharSequence summary = OpsLabelHelper.getPermissionLabel((Context) param.args[0], android.Manifest.permission.RECEIVE_BOOT_COMPLETED); Object array = XposedHelpers.getObjectField(param.thisObject, "mOpSummaries"); Array.set(array, MERGE_TARGET, Array.get(array, MERGE_TARGET) + " / " + Array.get(array, OP_BOOT_COMPLETED)); Array.set(array, OP_BOOT_COMPLETED, summary); array = XposedHelpers.getObjectField(param.thisObject, "mOpLabels"); Array.set(array, MERGE_TARGET, Array.get(array, MERGE_TARGET) + " / " + Array.get(array, OP_BOOT_COMPLETED)); Array.set(array, OP_BOOT_COMPLETED, Util.capitalizeFirst(summary)); } }); }
Example 7
Source File: XposedWrapper.java From XMiTools with GNU General Public License v3.0 | 5 votes |
public static Set<XC_MethodHook.Unhook> hookAllConstructors(Class<?> hookClass, XC_MethodHook callback) { try { return XposedBridge.hookAllConstructors(hookClass, callback); } catch (Throwable t) { XLog.e("Error in hookAllConstructors: %s", hookClass.getName(), t); return null; } }
Example 8
Source File: XposedHelpersWraper.java From MIUIAnesthetist with MIT License | 5 votes |
public static Set<XC_MethodHook.Unhook> hookAllConstructors(Class<?> hookClass, XC_MethodHook callback) { try { return XposedBridge.hookAllConstructors(hookClass, callback); } catch (Throwable t) { log(t); } return null; }
Example 9
Source File: XposedWrapper.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
public static Set<XC_MethodHook.Unhook> hookAllConstructors(Class<?> hookClass, XC_MethodHook callback) { try { return XposedBridge.hookAllConstructors(hookClass, callback); } catch (Throwable t) { XLog.e("Error in hookAllConstructors: %s", hookClass.getName(), t); return null; } }
Example 10
Source File: YoutubeMediaHook.java From OneTapVideoDownload with GNU General Public License v3.0 | 5 votes |
private boolean hookYoutube(ClassLoader classLoader, XC_MethodHook methodHook, String className) { try { Class mainClass = XposedHelpers.findClass(className, classLoader); XposedBridge.hookAllConstructors(mainClass, methodHook); } catch (Exception | NoSuchMethodError | XposedHelpers.ClassNotFoundError e) { return false; } return true; }
Example 11
Source File: mAdserve.java From MinMinGuard with GNU General Public License v3.0 | 5 votes |
public boolean handleLoadPackage(final String packageName, LoadPackageParam lpparam) { try { //TODO Add blockConstructor to ApiBlocking, so we dont have to do this hack.. Class<?> adView = XposedHelpers.findClass("com.adsdk.sdk.banner.InAppWebView", lpparam.classLoader); XposedBridge.hookAllConstructors(adView, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { Util.log(packageName, "Detect mAdserve InAppWebView constructor in " + packageName); param.setResult(new Object()); } }); Util.log(packageName, packageName + " uses mAdserve"); } catch (ClassNotFoundError e) { return false; } return true; }
Example 12
Source File: ModLedControl.java From GravityBox with Apache License 2.0 | 4 votes |
public static void initAndroid(final XSharedPreferences mainPrefs, final ClassLoader classLoader) { mPrefs = new XSharedPreferences(GravityBox.PACKAGE_NAME, "ledcontrol"); mPrefs.makeWorldReadable(); mQhPrefs = new XSharedPreferences(GravityBox.PACKAGE_NAME, "quiet_hours"); mQhPrefs.makeWorldReadable(); mQuietHours = new QuietHours(mQhPrefs); mProximityWakeUpEnabled = mainPrefs.getBoolean(GravityBoxSettings.PREF_KEY_POWER_PROXIMITY_WAKE, false); try { final Class<?> nmsClass = XposedHelpers.findClass(CLASS_NOTIFICATION_MANAGER_SERVICE, classLoader); XposedBridge.hookAllConstructors(nmsClass, new XC_MethodHook() { @Override protected void afterHookedMethod(final MethodHookParam param) throws Throwable { if (mNotifManagerService == null) { mNotifManagerService = param.thisObject; mContext = (Context) XposedHelpers.callMethod(param.thisObject, "getContext"); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(LedSettings.ACTION_UNC_SETTINGS_CHANGED); intentFilter.addAction(Intent.ACTION_USER_PRESENT); intentFilter.addAction(QuietHoursActivity.ACTION_QUIET_HOURS_CHANGED); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(ACTION_CLEAR_NOTIFICATIONS); intentFilter.addAction(GravityBoxSettings.ACTION_PREF_POWER_CHANGED); mContext.registerReceiver(mBroadcastReceiver, intentFilter); toggleActiveScreenFeature(!mPrefs.getBoolean(LedSettings.PREF_KEY_LOCKED, false) && mPrefs.getBoolean(LedSettings.PREF_KEY_ACTIVE_SCREEN_ENABLED, false)); hookNotificationDelegate(); if (DEBUG) log("Notification manager service initialized"); } } }); XposedHelpers.findAndHookMethod(CLASS_NOTIFICATION_MANAGER_SERVICE, classLoader, "enqueueNotificationInternal", String.class, String.class, int.class, int.class, String.class, int.class, Notification.class, int[].class, int.class, notifyHook); XposedHelpers.findAndHookMethod(CLASS_NOTIFICATION_MANAGER_SERVICE, classLoader, "applyZenModeLocked", CLASS_NOTIFICATION_RECORD, applyZenModeHook); XposedHelpers.findAndHookMethod(CLASS_NOTIFICATION_MANAGER_SERVICE, classLoader, "updateLightsLocked", updateLightsLockedHook); XposedBridge.hookAllMethods(XposedHelpers.findClass(CLASS_VIBRATOR_SERVICE, classLoader), "startVibrationLocked", startVibrationHook); } catch (Throwable t) { XposedBridge.log(t); } }
Example 13
Source File: XposedMod.java From ActivityForceNewTask with GNU General Public License v3.0 | 4 votes |
@Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { if (!lpparam.packageName.equals("android")) return; XC_MethodHook hook = new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { settingsHelper.reload(); if (settingsHelper.isModDisabled()) return; Intent intent = (Intent) XposedHelpers.getObjectField(param.thisObject, "intent"); // The launching app does not expect data back. It's safe to run the activity in a // new task. int requestCode = getIntField(param.thisObject, "requestCode"); if (requestCode != -1) return; // The intent already has FLAG_ACTIVITY_NEW_TASK set, no need to do anything. if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK) return; String intentAction = intent.getAction(); // If the intent is not a known safe intent (as in, the launching app does not expect // data back, so it's safe to run in a new task,) ignore it straight away. if (intentAction == null) return; // If the app is launching one of its own activities, we shouldn't open it in a new task. int uid = ((ActivityInfo) getObjectField(param.thisObject, "info")).applicationInfo.uid; if (getIntField(param.thisObject, "launchedFromUid") == uid) return; ComponentName componentName = (ComponentName) getObjectField(param.thisObject, "realActivity"); String componentNameString = componentName.flattenToString(); // Log if necessary. if (settingsHelper.isLogEnabled()) { // Get context Context context = AndroidAppHelper.currentApplication(); if (context != null) context.sendBroadcast(new Intent(Common.INTENT_LOG).putExtra(Common.INTENT_COMPONENT_EXTRA, componentNameString)); else XposedBridge.log("activityforcenewtask: couldn't get context."); XposedBridge.log("activityforcenewtask: componentString: " + componentNameString); } // If the blacklist is used and the component is in the blacklist, or if the // whitelist is used and the component isn't whitelisted, we shouldn't modify // the intent's flags. boolean isListed = settingsHelper.isListed(componentNameString); String listType = settingsHelper.getListType(); if ((listType.equals(Common.PREF_BLACKLIST) && isListed) || (listType.equals(Common.PREF_WHITELIST) && !isListed)) return; intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } }; Class ActivityRecord = findClass("com.android.server.am.ActivityRecord", lpparam.classLoader); XposedBridge.hookAllConstructors(ActivityRecord, hook); }