List of usage examples for android.content Context sendBroadcastAsUser
@RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, UserHandle user);
From source file:com.nagopy.android.xposed.utilities.ModBrightness.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @XMinSdkVersion(Build.VERSION_CODES.JELLY_BEAN_MR1) @InitZygote(summary = "??") public static void brightnessDebugger(final StartupParam startupParam, final ModBrightnessSettingsGen settings) throws Throwable { if (!settings.brightnessDebugger) { return;//from www.j a va 2 s . c o m } // DisplayPowerController?? final Class<?> displayPowerContoroll = XposedHelpers .findClass("com.android.server.power.DisplayPowerController", null); // Context? XposedBridge.hookAllConstructors(displayPowerContoroll, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Context context = (Context) param.args[1]; XposedHelpers.setAdditionalInstanceField(param.thisObject, "mContext", context); XLog.d("mScreenAutoBrightnessSpline", XposedHelpers.getObjectField(param.thisObject, "mScreenAutoBrightnessSpline")); } }); XposedHelpers.findAndHookMethod(displayPowerContoroll, "updateAutoBrightness", boolean.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { if (SystemClock.elapsedRealtime() < 60 * 1000) { // ???? return; } Context mContext = (Context) XposedHelpers.getAdditionalInstanceField(param.thisObject, "mContext"); Object mScreenAutoBrightness = XposedHelpers.getObjectField(param.thisObject, "mScreenAutoBrightness"); Object mAmbientLux = XposedHelpers.getObjectField(param.thisObject, "mAmbientLux"); Intent intent = new Intent(AutoBrightnessController.ACTION_AUTO_BRIGHTNESS_CHANGED); intent.putExtra(AutoBrightnessController.EXTRA_BRIGHTNESS, (Integer) mScreenAutoBrightness); intent.putExtra(AutoBrightnessController.EXTRA_LUX, (Float) mAmbientLux); // ???? UserHandle user = (UserHandle) XposedHelpers.getStaticObjectField(UserHandle.class, "ALL"); mContext.sendBroadcastAsUser(intent, user); } }); }