use of de.robv.android.xposed.XC_MethodHook in project XPrivacy by M66B.
the class XPrivacy method initZygote.
public void initZygote(StartupParam startupParam) throws Throwable {
Util.log(null, Log.WARN, "Init path=" + startupParam.modulePath);
// Check for LBE security master
if (Util.hasLBE()) {
Util.log(null, Log.ERROR, "LBE installed");
return;
}
// Generate secret
mSecret = Long.toHexString(new Random().nextLong());
// Reading files with SELinux enabled can result in bootloops
boolean selinux = Util.isSELinuxEnforced();
if ("true".equals(Util.getXOption("ignoreselinux"))) {
selinux = false;
Log.w("Xprivacy", "Ignoring SELinux");
}
// Read list of disabled hooks
if (mListDisabled.size() == 0 && !selinux) {
File disabled = new File("/data/system/xprivacy/disabled");
if (disabled.exists() && disabled.canRead())
try {
Log.w("XPrivacy", "Reading " + disabled.getAbsolutePath());
FileInputStream fis = new FileInputStream(disabled);
InputStreamReader ir = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(ir);
String line;
while ((line = br.readLine()) != null) if (line.length() > 0 && !line.startsWith("#")) {
String[] name = line.split("/");
if (name.length > 0) {
String methodName = (name.length > 1 ? name[1] : null);
CRestriction restriction = new CRestriction(0, name[0], methodName, null);
Log.w("XPrivacy", "Disabling " + restriction);
mListDisabled.add(restriction);
}
}
br.close();
ir.close();
fis.close();
} catch (Throwable ex) {
Log.w("XPrivacy", ex.toString());
}
}
// AOSP mode override
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !selinux)
try {
Class<?> libcore = Class.forName("libcore.io.Libcore");
Field fOs = libcore.getDeclaredField("os");
fOs.setAccessible(true);
Object os = fOs.get(null);
Method setenv = os.getClass().getMethod("setenv", String.class, String.class, boolean.class);
setenv.setAccessible(true);
boolean aosp = new File("/data/system/xprivacy/aosp").exists();
setenv.invoke(os, "XPrivacy.AOSP", Boolean.toString(aosp), false);
Util.log(null, Log.WARN, "AOSP mode forced=" + aosp);
} catch (Throwable ex) {
Util.bug(null, ex);
}
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Class<?> at = Class.forName("android.app.ActivityThread");
XposedBridge.hookAllMethods(at, "systemMain", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class<?> am = Class.forName("com.android.server.am.ActivityManagerService", false, loader);
XposedBridge.hookAllConstructors(am, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
PrivacyService.register(mListHookError, loader, mSecret, param.thisObject);
hookSystem(loader);
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
});
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
});
} else {
Class<?> cSystemServer = Class.forName("com.android.server.SystemServer");
Method mMain = cSystemServer.getDeclaredMethod("main", String[].class);
XposedBridge.hookMethod(mMain, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
try {
PrivacyService.register(mListHookError, null, mSecret, null);
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
});
}
hookZygote();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
hookSystem(null);
} catch (Throwable ex) {
Util.bug(null, ex);
}
}
use of de.robv.android.xposed.XC_MethodHook in project Xposed-Tinted-Status-Bar by MohammadAG.
the class ColourChangerMod method doClockHooks.
private void doClockHooks(ClassLoader loader) {
Class<?> Clock = XposedHelpers.findClass("com.android.systemui.statusbar.policy.Clock", loader);
XposedBridge.hookAllConstructors(Clock, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
addTextLabel((TextView) param.thisObject);
mFoundClock = true;
}
});
findAndHookMethod(Clock, "updateClock", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView textView = (TextView) param.thisObject;
textView.setTextColor(mColorForStatusIcons);
}
});
}
use of de.robv.android.xposed.XC_MethodHook in project Xposed-Tinted-Status-Bar by MohammadAG.
the class WindowDimHooks method doHook.
public static void doHook() {
findAndHookMethod("com.android.internal.policy.impl.PhoneWindow$DecorView", null, "onWindowFocusChanged", boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Window window = (Window) XposedHelpers.getObjectField(param.thisObject, "this$0");
if ((window.getAttributes().flags & LayoutParams.FLAG_DIM_BEHIND) == LayoutParams.FLAG_DIM_BEHIND) {
boolean focused = (Boolean) param.args[0];
Intent intent = new Intent(INTENT_DIM_CHANGED);
intent.putExtra(KEY_DIM_AMOUNT, focused ? window.getAttributes().dimAmount : 0F);
window.getContext().sendBroadcast(intent);
}
}
});
findAndHookMethod("com.android.internal.policy.impl.PhoneWindow$DecorView", null, "onDetachedFromWindow", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Window window = (Window) XposedHelpers.getObjectField(param.thisObject, "this$0");
if ((window.getAttributes().flags & LayoutParams.FLAG_DIM_BEHIND) == LayoutParams.FLAG_DIM_BEHIND) {
Intent intent = new Intent(INTENT_DIM_CHANGED);
intent.putExtra(KEY_DIM_AMOUNT, 0F);
window.getContext().sendBroadcast(intent);
}
}
});
}
use of de.robv.android.xposed.XC_MethodHook in project Xposed-Tinted-Status-Bar by MohammadAG.
the class LGHooks method doImeHook.
public static void doImeHook() {
if (!isLGKitKatDevice())
return;
try {
Class<?> inputMethodMgrClss = findClass("com.android.server.InputMethodManagerService", null);
findAndHookMethod(inputMethodMgrClss, "setImeWindowStatus", IBinder.class, int.class, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
int vis = (Integer) param.args[1];
Context mContext = (Context) getObjectField(param.thisObject, "mContext");
boolean isKeyboardUp = (vis & IME_ACTIVE) != 0;
if (isKeyboardUp != mWasKeyboardUp && mContext != null) {
Intent intent = new Intent(Common.INTENT_KEYBOARD_VISIBLITY_CHANGED);
intent.putExtra(Common.EXTRA_KEY_KEYBOARD_UP, isKeyboardUp);
mContext.sendBroadcast(intent);
mWasKeyboardUp = isKeyboardUp;
}
}
});
} catch (ClassNotFoundError e) {
//DO NOTHING
}
}
use of de.robv.android.xposed.XC_MethodHook in project Xposed-Tinted-Status-Bar by MohammadAG.
the class LGHooks method hookStatusBar.
private static void hookStatusBar(ClassLoader classLoader) {
// REMOVE THE BACKGROUND ONLY
try {
Class<?> StatusBarBackGroundClss = findClass("com.lge.systemui.StatusBarBackground", classLoader);
findAndHookMethod(StatusBarBackGroundClss, "applyMode", int.class, boolean.class, new XC_MethodHook() {
@SuppressLint("NewApi")
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
int i = (Integer) param.args[0];
if (i != 1 && i != 2) {
XposedHelpers.setIntField(param.thisObject, "mMode", i);
ImageView imageView = (ImageView) param.thisObject;
imageView.setBackground(null);
imageView.setVisibility(View.VISIBLE);
param.setResult(null);
}
}
});
} catch (ClassNotFoundError e) {
XposedBridge.log("TintedStatusBar: LG StatusBarBackground has not been found...skipping");
}
}
Aggregations