android.app.AndroidAppHelper Java Examples
The following examples show how to use
android.app.AndroidAppHelper.
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: FooxMain.java From fooXposed with Apache License 2.0 | 6 votes |
@Override public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable { shares.reload(); String pkg = shares.getString(Constants.SELECT_APPLICATION, null); if (lpparam.packageName.equals(pkg)) { Log.i(TAG, "inject into process: " + Process.myPid() + ", package: " + lpparam.packageName); findAndHookMethod(Activity.class, "onCreate", Bundle.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Application context = AndroidAppHelper.currentApplication(); String classname = param.thisObject.getClass().getName(); String text = lpparam.packageName + "\n" + classname; Log.i(TAG, text); Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } }); } }
Example #2
Source File: MockSensorValuesModificationMethod.java From Sensor-Disabler with MIT License | 6 votes |
@Override public void modifySensor(final XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod( "android.hardware.SystemSensorManager$ListenerDelegate", lpparam.classLoader, "onSensorChangedLocked", Sensor.class, float[].class, long[].class, int.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) { Sensor sensor = (Sensor) param.args[0]; Context context = AndroidAppHelper.currentApplication(); //Use processName here always. Not packageName. if (!isPackageAllowedToSeeTrueSensor(lpparam.processName, sensor, context) && getSensorStatus(sensor, context) == Constants.SENSOR_STATUS_MOCK_VALUES) { // Get the mock values from the settings. float[] values = getSensorValues(sensor, context); //noinspection SuspiciousSystemArraycopy System.arraycopy(values, 0, param.args[1], 0, values.length); } } } ); }
Example #3
Source File: RemoveSensorModificationMethod.java From Sensor-Disabler with MIT License | 6 votes |
@Override public void modifySensor(final XC_LoadPackage.LoadPackageParam lpparam) { XposedHelpers.findAndHookMethod("android.hardware.SystemSensorManager", lpparam.classLoader, "getFullSensorList", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { //Without this, you'd never be able to edit the values for a removed sensor! Aaah! if (!lpparam.packageName.equals(BuildConfig.APPLICATION_ID)) { //Create a new list so we don't modify the original list. @SuppressWarnings("unchecked") List<Sensor> fullSensorList = new ArrayList<>((Collection<? extends Sensor>) param.getResult()); Iterator<Sensor> iterator = fullSensorList.iterator(); Context context = AndroidAppHelper.currentApplication(); while (iterator.hasNext()) { Sensor sensor = iterator.next(); if (!isPackageAllowedToSeeTrueSensor(lpparam.processName, sensor, context) && getSensorStatus(sensor, context) == Constants.SENSOR_STATUS_REMOVE_SENSOR) { iterator.remove(); } } param.setResult(fullSensorList); } } }); }
Example #4
Source File: XModuleResources.java From xposed-art with Apache License 2.0 | 6 votes |
/** * Usually called with the automatically injected {@code MODULE_PATH} constant of the first parameter * and the resources received in the callback for {@link XposedBridge#hookInitPackageResources} (or * {@code null} for system-wide replacements. */ public static XModuleResources createInstance(String modulePath, XResources origRes) { if (modulePath == null) throw new IllegalArgumentException("modulePath must not be null"); AssetManager assets = new AssetManager(); assets.addAssetPath(modulePath); XModuleResources res; if (origRes != null) res = new XModuleResources(assets, origRes.getDisplayMetrics(), origRes.getConfiguration()); else res = new XModuleResources(assets, null, null); AndroidAppHelper.addActiveResource(modulePath, res.hashCode(), false, res); return res; }
Example #5
Source File: FooxMain.java From fooXposed with Apache License 2.0 | 5 votes |
@Override public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable { Log.i(TAG, "inject into process: " + Process.myPid() + ", package: " + lpparam.packageName); XposedHelpers.findAndHookMethod(Activity.class, "onCreate", Bundle.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Application context = AndroidAppHelper.currentApplication(); String classname = param.thisObject.getClass().getName(); String text = lpparam.packageName + "\n" + classname; Log.i(TAG, text); Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } }); }
Example #6
Source File: MockSensorValuesModificationMethodApi18.java From Sensor-Disabler with MIT License | 5 votes |
@Override public void modifySensor(final XC_LoadPackage.LoadPackageParam lpparam) { XC_MethodHook mockSensorHook = new XC_MethodHook() { @SuppressWarnings("unchecked") @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { Object systemSensorManager = XposedHelpers.getObjectField(param.thisObject, "mManager"); SparseArray<Sensor> sensors = getSensors(systemSensorManager); // params.args[] is an array that holds the arguments that dispatchSensorEvent received, which are a handle pointing to a sensor // in sHandleToSensor and a float[] of values that should be applied to that sensor. int handle = (Integer) (param.args[0]); // This tells us which sensor was currently called. Sensor sensor = sensors.get(handle); Context context = AndroidAppHelper.currentApplication(); if (!isPackageAllowedToSeeTrueSensor(lpparam.processName, sensor, context) && getSensorStatus(sensor, context) == Constants.SENSOR_STATUS_MOCK_VALUES) { float[] values = getSensorValues(sensor, context); /*The SystemSensorManager compares the array it gets with the array from the a SensorEvent, and some sensors (looking at you, Proximity) only use one index in the array but still send along a length 3 array, so we copy here instead of replacing it outright. */ //noinspection SuspiciousSystemArraycopy System.arraycopy(values, 0, param.args[1], 0, values.length); } } }; XposedHelpers.findAndHookMethod("android.hardware.SystemSensorManager$SensorEventQueue", lpparam.classLoader, "dispatchSensorEvent", int.class, float[].class, int.class, long.class, mockSensorHook); }
Example #7
Source File: Util.java From MinMinGuard with GNU General Public License v3.0 | 5 votes |
public static Application getCurrentApplication() { try { return AndroidAppHelper.currentApplication(); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #8
Source File: CustomThemeHook.java From BiliRoaming with GNU General Public License v3.0 | 4 votes |
private SharedPreferences getBiliPrefs() { return AndroidAppHelper.currentApplication().getSharedPreferences("bili_preference", Context.MODE_PRIVATE); }
Example #9
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); }