Java Code Examples for de.robv.android.xposed.XposedHelpers#findClass()
The following examples show how to use
de.robv.android.xposed.XposedHelpers#findClass() .
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: HookAlipay.java From WearPay with GNU General Public License v2.0 | 6 votes |
private void hookCode(final Activity activity) { if (hasHooked) return; hasHooked = true; Class<?> classTarget = XposedHelpers.findClass("com.alipay.mobile.onsitepay9.payer.fragments.BarcodePayFragment", activity.getClassLoader()); final Field codeField = XposedHelpers.findField(classTarget, "v"); XposedHelpers.findAndHookMethod(classTarget, "a", boolean.class, boolean.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { String code = (String) codeField.get(param.thisObject); Intent intent = new Intent(ACTION_SEND_CODE); intent.setPackage(THIS_PACKAGE_NAME); intent.putExtra(EXTRA_CODE, code); activity.sendBroadcast(intent); } }); }
Example 2
Source File: StepHook.java From XposedWechatHelper with GNU General Public License v2.0 | 6 votes |
public static void hook(ClassLoader classLoader) { try { //4.4 nexus 通过 Class clazz = XposedHelpers.findClass("android.hardware.SystemSensorManager$SensorEventQueue", classLoader); XposedBridge.hookAllMethods(clazz, "dispatchSensorEvent", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { reload(); if (fakeStep) { ((float[]) param.args[1])[0] = (((float[]) param.args[1])[0]) * Integer.valueOf(step); } super.beforeHookedMethod(param); } }); } catch (Error | Exception e) { e.printStackTrace(); } }
Example 3
Source File: GmsLocationHack.java From AppOpsXposed with GNU General Public License v3.0 | 6 votes |
private static Object createPendingResult(final ClassLoader classLoader, final int statusCode) { final Class<?>[] interfaces = { XposedHelpers.findClass("com.google.android.gms.common.api.PendingResult", classLoader) }; return Proxy.newProxyInstance(classLoader, interfaces, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if("await".equals(method.getName())) { final Class<?> clazz = XposedHelpers.findClass( "com.google.android.gms.common.api.Status", classLoader); return XposedHelpers.newInstance(clazz, new Class<?>[] { int.class }, statusCode); } else if("isCanceled".equals(method.getName())) return false; return null; } }); }
Example 4
Source File: PermGrant.java From Xposed-SoundCloudDownloader with GNU General Public License v3.0 | 5 votes |
public static void initPerms(final ClassLoader loader) { try { final Class<?> pmServiceClass = XposedHelpers.findClass(CLASS_PACKAGE_MANAGER_SERVICE, loader); XposedHelpers.findAndHookMethod(pmServiceClass, "grantPermissionsLPw", CLASS_PACKAGE_PARSER_PACKAGE, boolean.class, String.class, new XC_MethodHook() { @Override @SuppressWarnings("unchecked") protected void afterHookedMethod(MethodHookParam param) throws Throwable { final String pkgName = (String) XposedHelpers.getObjectField(param.args[0], "packageName"); if (!pkgName.equals("com.soundcloud.android")) return; // so we don't add random permissions to all apps final Object extras = XposedHelpers.getObjectField(param.args[0], "mExtras"); final Object ps = XposedHelpers.callMethod(extras, "getPermissionsState"); final List<String> grantedPerms = (List<String>) XposedHelpers.getObjectField(param.args[0], "requestedPermissions"); final Object settings = XposedHelpers.getObjectField(param.thisObject, "mSettings"); final Object permissions = XposedHelpers.getObjectField(settings, "mPermissions"); if (!grantedPerms.contains(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { final Object pWriteExternal = XposedHelpers.callMethod(permissions, "get", Manifest.permission.WRITE_EXTERNAL_STORAGE); XposedHelpers.callMethod(ps, "grantInstallPermission", pWriteExternal); } if (!grantedPerms.contains(Manifest.permission.READ_EXTERNAL_STORAGE)) { final Object pReadExternal = XposedHelpers.callMethod(permissions, "get", Manifest.permission.READ_EXTERNAL_STORAGE); XposedHelpers.callMethod(ps, "grantInstallPermission", pReadExternal); } } }); } catch (Throwable t) { XposedBridge.log("[SoundCloud Downloader] PermGrant Error: " + t.getMessage()); } }
Example 5
Source File: EmojiGameHook.java From XposedWechatHelper with GNU General Public License v2.0 | 5 votes |
private void hook(final ClassLoader classLoader, String clazzName, String methodName) { try { Class clazz = XposedHelpers.findClass(clazzName, classLoader); XposedHelpers.findAndHookMethod(clazz, methodName, int.class, int.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { int result = (int) param.getResult(); int type = (int) param.args[0]; reload(); switch (type) { case 5: if (fakeDice) { result = Integer.valueOf(dice); } break; case 2: if (fakeMorra) { result = Integer.valueOf(morra); } break; } param.setResult(result); super.afterHookedMethod(param); } }); } catch (Error | Exception e) { e.printStackTrace(); } }
Example 6
Source File: ChromeHook.java From OneTapVideoDownload with GNU General Public License v3.0 | 5 votes |
@Override public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable { String mediaPlayerBridgeClassName = "org.chromium.chrome.browser.media.remote.RemoteMediaPlayerBridge"; if (!usesChromeBrowserComponent(lpparam.classLoader, mediaPlayerBridgeClassName)) { return; } final String packageName = lpparam.packageName; XC_MethodHook methodHook = new XC_MethodHook() { protected void beforeHookedMethod(XC_MethodHook.MethodHookParam hookParams) throws Throwable { try { Uri uri = Uri.parse((String) hookParams.args[1]); ApplicationLogMaintainer.sendBroadcast(Global.getContext(), "Chrome Hook : URL" + uri.toString()); if (uri.toString().startsWith("http")) { IpcService.startSaveUrlAction(Global.getContext(), uri, packageName); } } catch (Exception e) { ApplicationLogMaintainer.sendBroadcast(Global.getContext(), Global.getStackTrace(e)); } } }; // RemoteMediaPlayerBridge(long nativeRemoteMediaPlayerBridge, String sourceUrl, String frameUrl, String userAgent) Class remoteMediaPlayerBridge = XposedHelpers.findClass(mediaPlayerBridgeClassName, lpparam.classLoader); Object[] objects = new Object[] { long.class, String.class, String.class, String.class, methodHook }; XposedHelpers.findAndHookConstructor(remoteMediaPlayerBridge, objects); }
Example 7
Source File: ChromeHook.java From OneTapVideoDownload with GNU General Public License v3.0 | 5 votes |
private boolean usesChromeBrowserComponent(ClassLoader classLoader, String className) { try { Class mediaPlayerBridge = XposedHelpers.findClass(className, classLoader); mediaPlayerBridge.getName(); } catch (Exception | NoSuchMethodError | XposedHelpers.ClassNotFoundError e) { return false; } return true; }
Example 8
Source File: WeChatHook.java From XposedManyMoney with GNU General Public License v2.0 | 5 votes |
public static void hook(final ClassLoader classLoader) { xsp = new XSharedPreferences(BuildConfig.APPLICATION_ID, SettingLabelView.DEFAULT_PREFERENCES_NAME); xsp.makeWorldReadable(); final Class mallIndexUIClazz = XposedHelpers.findClass("com.tencent.mm.plugin.mall.ui.MallIndexUI", classLoader); final Class walletBalanceManagerUIClazz = XposedHelpers.findClass("com.tencent.mm.plugin.wallet.balance.ui.WalletBalanceManagerUI", classLoader); handleHook(mallIndexUIClazz, mallIndexUIClazz.getSuperclass().getDeclaredFields()); handleHook(walletBalanceManagerUIClazz, walletBalanceManagerUIClazz.getDeclaredFields()); }
Example 9
Source File: XposedWrapper.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
public static Class<?> findClass(String className, ClassLoader classLoader) { try { return XposedHelpers.findClass(className, classLoader); } catch (Throwable t) { XLog.e("Class not found: %s", className); return null; } }
Example 10
Source File: AlipayHook.java From renrenpay-android with Apache License 2.0 | 5 votes |
/** * hook掉安全校验 */ private void hookSafe() { try { Class<?> ScanAttack = XposedHelpers.findClass("com.alipay.apmobilesecuritysdk.scanattack.common.ScanAttack", mAppClassLoader); XposedHelpers.findAndHookMethod(ScanAttack, "getScanAttackInfo", new XC_MethodReplacement() { @Override protected Object replaceHookedMethod(MethodHookParam param) throws Throwable { return null; } }); } catch (Error | Exception e) { LogUtils.show(getAppName() + "first"); } }
Example 11
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 12
Source File: StatusbarSignalCluster.java From GravityBox with Apache License 2.0 | 5 votes |
protected void setNetworkController(Object networkController) { final ClassLoader classLoader = mView.getClass().getClassLoader(); final Class<?> networkCtrlCbClass = XposedHelpers.findClass("com.android.systemui.statusbar.policy.NetworkController.SignalCallback", classLoader); mNetworkControllerCallback = Proxy.newProxyInstance(classLoader, new Class<?>[]{networkCtrlCbClass}, new NetworkControllerCallback()); XposedHelpers.callMethod(networkController, "addSignalCallback", mNetworkControllerCallback); if (DEBUG) log("setNetworkController: callback registered"); }
Example 13
Source File: QsTile.java From GravityBox with Apache License 2.0 | 5 votes |
private static Class<?> getResourceIconClass(ClassLoader cl) { try { return XposedHelpers.findClass(CLASS_BASE_TILE+".ResourceIcon", cl); } catch (Throwable t) { log("Error getting resource icon class:"); XposedBridge.log(t); return null; } }
Example 14
Source File: SystemSensorManagerHook.java From VirtualSensor with GNU Lesser General Public License v3.0 | 4 votes |
public SystemSensorManagerHook(XC_LoadPackage.LoadPackageParam lpparam) { SYSTEM_SENSOR_MANAGER = XposedHelpers.findClass("android.hardware.SystemSensorManager", lpparam.classLoader); }
Example 15
Source File: BasePlugin.java From xposed-rimet with Apache License 2.0 | 4 votes |
public Class findClass(String className, ClassLoader classLoader) { return XposedHelpers.findClass(className, classLoader); }
Example 16
Source File: DemoAppHooker.java From ratel with Apache License 2.0 | 4 votes |
@Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { Class<?> aClass = XposedHelpers.findClass("com.virjar.ratel.demoapp.MainActivity", lpparam.classLoader); XposedHelpers.findAndHookMethod(aClass, "text", XC_MethodReplacement.returnConstant("被hook后的文本")); }
Example 17
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 18
Source File: PieController.java From GravityBox with Apache License 2.0 | 4 votes |
public PieController(Context context, Context gbContext, XSharedPreferences prefs) { mContext = context; mGbContext = gbContext; mGbResources = gbContext.getResources(); mLongPressHandler = new PieLongPressHandler(context, prefs); mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); final PackageManager pm = mContext.getPackageManager(); mHasTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); final Resources res = mContext.getResources(); Tracker.sDistance = mGbResources.getDimensionPixelSize(R.dimen.pie_trigger_distance); mBackIcon = res.getDrawable(context.getResources().getIdentifier( "ic_sysbar_back", "drawable", PACKAGE_NAME), null).mutate(); mBackAltIcon = res.getDrawable(context.getResources().getIdentifier( "ic_sysbar_back_ime", "drawable", PACKAGE_NAME), null).mutate(); mRecentIcon = res.getDrawable(res.getIdentifier( "ic_sysbar_recent", "drawable", PACKAGE_NAME), null).mutate(); mRecentAltIcon = mGbResources.getDrawable(R.drawable.ic_sysbar_recent_clear, null).mutate(); try { mBaseStatusBarClass = XposedHelpers.findClass(CLASS_BASE_STATUSBAR, mContext.getClassLoader()); } catch (ClassNotFoundError e) { XposedBridge.log(e); } mSysinfoDisabled = prefs.getBoolean(GravityBoxSettings.PREF_KEY_PIE_SYSINFO_DISABLE, false); setLongpressDelay(Integer.valueOf(prefs.getString( GravityBoxSettings.PREF_KEY_PIE_LONGPRESS_DELAY, "0")));; mColorInfo = new ColorInfo(); mColorInfo.bgColor = prefs.getInt(GravityBoxSettings.PREF_KEY_PIE_COLOR_BG, mGbResources.getColor(R.color.pie_background_color)); mColorInfo.selectedColor = prefs.getInt(GravityBoxSettings.PREF_KEY_PIE_COLOR_SELECTED, mGbResources.getColor(R.color.pie_selected_color)); mColorInfo.outlineColor = prefs.getInt(GravityBoxSettings.PREF_KEY_PIE_COLOR_OUTLINE, mGbResources.getColor(R.color.pie_outline_color)); mColorInfo.fgColor = prefs.getInt(GravityBoxSettings.PREF_KEY_PIE_COLOR_FG, mGbResources.getColor(R.color.pie_foreground_color)); mColorInfo.textColor = prefs.getInt(GravityBoxSettings.PREF_KEY_PIE_COLOR_TEXT, mGbResources.getColor(R.color.pie_text_color)); updateColors(); }
Example 19
Source File: ModSmartRadio.java From GravityBox with Apache License 2.0 | 4 votes |
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) { try { final Class<?> classSystemUIService = XposedHelpers.findClass( "com.android.systemui.SystemUIService", classLoader); mNormalMode = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_NORMAL_MODE, -1); mPowerSavingMode = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_POWER_SAVING_MODE, -1); mPowerSaveWhenScreenOff = prefs.getBoolean(GravityBoxSettings.PREF_KEY_SMART_RADIO_SCREEN_OFF, false); mIgnoreWhileLocked = prefs.getBoolean(GravityBoxSettings.PREF_KEY_SMART_RADIO_IGNORE_LOCKED, true); mModeChangeDelay = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_MODE_CHANGE_DELAY, 5); mScreenOffDelay = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_SCREEN_OFF_DELAY, 0); mIgnoreMobileDataAvailability = prefs.getBoolean(GravityBoxSettings.PREF_KEY_SMART_RADIO_MDA_IGNORE, false); mAdaptiveDelayThreshold = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_ADAPTIVE_DELAY, 0); XposedHelpers.findAndHookMethod(classSystemUIService, "onCreate", new XC_MethodHook() { @Override protected void afterHookedMethod(final MethodHookParam param) throws Throwable { mContext = (Context) param.thisObject; if (mContext != null) { if (DEBUG) log("Initializing SmartRadio"); mSmartRadioEnabled = Settings.System.getInt(mContext.getContentResolver(), SETTING_SMART_RADIO_ENABLED, 1) == 1; mConnManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); mNetworkModeChanger = new NetworkModeChanger(mContext, new Handler()); Settings.System.putString(mContext.getContentResolver(), SETTING_SMART_RADIO_STATE, mCurrentState.toString()); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(GravityBoxSettings.ACTION_PREF_SMART_RADIO_CHANGED); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_USER_PRESENT); intentFilter.addAction(NetworkModeChanger.ACTION_CHANGE_MODE_ALARM); intentFilter.addAction(ACTION_TOGGLE_SMART_RADIO); intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); intentFilter.addAction(PhoneWrapper.ACTION_NETWORK_TYPE_CHANGED); mContext.registerReceiver(mBroadcastReceiver, intentFilter); } } }); } catch (Throwable t) { XposedBridge.log(t); } }
Example 20
Source File: Patch.java From wifi-password-android with Apache License 2.0 | 4 votes |
private void hookWifiController(ClassLoader loader) { final String controllerClassName = IS_LG ? "com.lge.wifisettings.WifiConfigController" : "com.android.settings.wifi.WifiConfigController"; final Class<?> controller = XposedHelpers.findClass(controllerClassName, loader); do { if (IS_ABOVE_N) { if (tryHookConstructor(controller, "Hook N constructor", "com.android.settings.wifi.WifiConfigUiBase", View.class, "com.android.settingslib.wifi.AccessPoint", int.class, methodHook)) { break; } if (IS_LG && tryHookConstructor(controller, "Hook LG N constructor", "com.lge.wifisettings.WifiConfigUiBase", View.class, "com.lge.wifisettings.AccessPoint", int.class, methodHook)) { break; } if (IS_SAMSUNG && tryHookConstructor(controller, "Hook Samsung N constructor", "com.android.settings.wifi.WifiConfigUiBase", View.class, "com.android.settingslib.wifi.AccessPoint", int.class, Bundle.class, methodHook)) { break; } } if (IS_ABOVE_M && tryHookConstructor(controller, "Hook M constructor", "com.android.settings.wifi.WifiConfigUiBase", View.class, "com.android.settingslib.wifi.AccessPoint", boolean.class, boolean.class, methodHook)) { break; } if (tryHookConstructor(controller, "Hook L constructor", "com.android.settings.wifi.WifiConfigUiBase", View.class, "com.android.settings.wifi.AccessPoint", boolean.class, methodHook)) { break; } if (IS_SAMSUNG && tryHookConstructor(controller, "Hook Samsung constructor", "com.android.settings.wifi.WifiConfigUiBase", View.class, "com.android.settings.wifi.AccessPoint", boolean.class, boolean.class, methodHook)) { break; } if (IS_HTC && tryHookConstructor(controller, "Hook HTC constructor", "com.android.settings.wifi.WifiConfigUiBase", View.class, "com.android.settings.wifi.AccessPoint", int.class, methodHook)) { break; } XposedBridge.log("All constructor hook failed!"); } while (false); }