You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1194 lines
56 KiB
Java

package com.langerhans.one.mods;
import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.getObjectField;
import java.lang.reflect.Method;
import java.util.List;
import com.langerhans.one.R;
import com.langerhans.one.utils.Helpers;
import com.langerhans.one.utils.Version;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.content.res.XModuleResources;
import android.content.res.XResources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import android.widget.AutoCompleteTextView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import de.robv.android.xposed.IXposedHookZygoteInit.StartupParam;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodHook.MethodHookParam;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
public class OtherMods{
public static void execHook_APM(LoadPackageParam lpparam) {
try {
findAndHookMethod("com.htc.app.HtcShutdownThread", lpparam.classLoader, "reboot", Context.class, String.class, boolean.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
startAPM((Context)param.args[0]);
return null;
}
});
} catch(Throwable t) {
XposedBridge.log(t);
}
}
public static void startAPM(Context ctx){
try {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setClassName("com.langerhans.one", "com.langerhans.one.DimmedActivity");
intent.putExtra("dialogType", 1);
ctx.startActivity(intent);
} catch(Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_VolSound(LoadPackageParam lpparam) {
findAndHookMethod("com.htc.view.VolumePanel", lpparam.classLoader, "onPlaySound", int.class, int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(null);
}
});
}
public static void execHook_MTPNotif(LoadPackageParam lpparam) {
try {
XposedHelpers.findAndHookMethod("com.android.providers.media.MtpService", lpparam.classLoader, "onStartCommand", Intent.class, int.class, int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
((Service)param.thisObject).stopForeground(true);
}
});
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_DNDNotif(LoadPackageParam lpparam) {
try {
XposedHelpers.findAndHookMethod("com.android.settings.framework.app.HtcDndCommandService", lpparam.classLoader, "addNotification", int.class, XC_MethodReplacement.DO_NOTHING);
} catch (Throwable t1) {
try {
XposedHelpers.findAndHookMethod("com.android.settings.framework.app.HtcDndCommandService", lpparam.classLoader, "addNotification", int.class, boolean.class, XC_MethodReplacement.DO_NOTHING);
} catch (Throwable t2) {
XposedBridge.log(t2);
}
}
}
public static void execHook_PowerSaverNotif(LoadPackageParam lpparam) {
try {
XposedHelpers.findAndHookMethod("com.htc.htcpowermanager.powersaver.PowerSaverNotificationService", lpparam.classLoader, "addNotification", XC_MethodReplacement.DO_NOTHING);
if (Build.VERSION.SDK_INT >= 18)
XposedHelpers.findAndHookMethod("com.htc.htcpowermanager.powersaver.PowerSaverNotificationService", lpparam.classLoader, "addNtfPowerJacket", int.class, int.class, XC_MethodReplacement.DO_NOTHING);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_InputMethodNotif() {
try {
XposedHelpers.findAndHookMethod("com.android.server.InputMethodManagerService", null, "setImeWindowStatus", IBinder.class, int.class, int.class, XC_MethodReplacement.DO_NOTHING);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_VZWWiFiNotif() {
try {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiStateMachine", null, "sendVzwStatusNotification", int.class, XC_MethodReplacement.returnConstant(0));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_MoveVolume(StartupParam startparam) {
try {
final Class<?> clsVP = XposedHelpers.findClass("com.htc.view.VolumePanel", null);
XposedHelpers.findAndHookMethod(clsVP, "updatePanelRotationPosition", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Dialog dlg = (Dialog)XposedHelpers.getObjectField(param.thisObject, "mDialog");
Dialog dlgEx = (Dialog)XposedHelpers.getObjectField(param.thisObject, "mDialogEx");
float density = dlg.getContext().getResources().getDisplayMetrics().density;
int orientation = dlg.getContext().getResources().getConfiguration().orientation;
int bottomMargin = 75;
if (orientation == 2) bottomMargin = 40;
Window dlgWin = dlg.getWindow();
Window dlgExWin = dlgEx.getWindow();
WindowManager.LayoutParams dlgWinAttrs = dlgWin.getAttributes();
WindowManager.LayoutParams dlgExWinAttrs = dlgExWin.getAttributes();
dlgWinAttrs.gravity = Gravity.BOTTOM;
dlgExWinAttrs.gravity = Gravity.BOTTOM;
dlgWinAttrs.y = Math.round(bottomMargin * density);
dlgExWinAttrs.y = Math.round(bottomMargin * density);
dlgWin.setAttributes(dlgWinAttrs);
dlgExWin.setAttributes(dlgExWinAttrs);
}
});
} catch (Throwable t) {
XposedBridge.log(t);
}
}
private static boolean updateScreenOn = false;
private static boolean updateScreenOff = false;
public static void ScreenAnim() {
try {
XposedHelpers.findAndHookMethod("com.android.server.power.DisplayPowerController", null, "setScreenOn", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if (updateScreenOff && XMain.pref_screenoff != 0) {
param.setResult(null);
updateScreenOff = false;
ObjectAnimator mElectronBeamOffAnimator = (ObjectAnimator)XposedHelpers.getObjectField(param.thisObject, "mElectronBeamOffAnimator");
Object mPowerState = XposedHelpers.getObjectField(param.thisObject, "mPowerState");
if (!mElectronBeamOffAnimator.isStarted()) {
float beamLvl = (Float)XposedHelpers.callMethod(mPowerState, "getElectronBeamLevel");
if (beamLvl == 0.0F) {
XposedHelpers.callMethod(param.thisObject, "setScreenOn", false);
} else {
Object displaypowerstate = mPowerState;
if ((Boolean)XposedHelpers.callMethod(displaypowerstate, "prepareElectronBeam", XMain.pref_screenoff) && (Boolean)XposedHelpers.callMethod(mPowerState, "isScreenOn"))
mElectronBeamOffAnimator.start();
else
mElectronBeamOffAnimator.end();
}
}
}
}
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
if ((Boolean)param.args[0] && XMain.pref_screenon != 0) {
updateScreenOn = true;
Object mPowerState = XposedHelpers.getObjectField(param.thisObject, "mPowerState");
ObjectAnimator mElectronBeamOnAnimator = (ObjectAnimator)XposedHelpers.getObjectField(param.thisObject, "mElectronBeamOnAnimator");
if (!mElectronBeamOnAnimator.isStarted()) {
float beamLvl = (Float)XposedHelpers.callMethod(mPowerState, "getElectronBeamLevel");
if (beamLvl == 1.0F) {
XposedHelpers.callMethod(mPowerState, "dismissElectronBeam");
} else {
Object displaypowerstate = mPowerState;
if ((Boolean)XposedHelpers.callMethod(displaypowerstate, "prepareElectronBeam", XMain.pref_screenon) && (Boolean)XposedHelpers.callMethod(mPowerState, "isScreenOn"))
mElectronBeamOnAnimator.start();
else
mElectronBeamOnAnimator.end();
}
}
}
}
});
if (XMain.pref_screenoff != 0)
XposedHelpers.findAndHookMethod("com.android.server.power.DisplayPowerController", null, "animateScreenBrightness", int.class, int.class, int.class, int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if ((Integer)param.args[0] == 0 && (Integer)param.args[1] == 0 && (Integer)param.args[2] == 0 && (Integer)param.args[3] == -1) {
updateScreenOff = true;
param.setResult(null);
}
}
});
if (XMain.pref_screenon != 0) {
XposedHelpers.findAndHookMethod("com.android.server.power.DisplayPowerState", null, "dismissElectronBeam", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if (updateScreenOn) param.setResult(null);
}
});
XposedHelpers.findAndHookMethod("com.android.server.power.DisplayPowerController", null, "updatePowerState", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
updateScreenOn = false;
}
});
}
XposedHelpers.findAndHookMethod("com.android.server.power.DisplayPowerState", null, "setElectronBeamLevel", float.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
if (updateScreenOn || updateScreenOff) param.setResult(null);
}
});
} catch (Throwable t) {
XposedBridge.log(t);
}
}
private static void applyFastUnlock(final LoadPackageParam lpparam, final MethodHookParam param, final String className) {
final Object mLockPatternUtils = getObjectField(param.thisObject, "mLockPatternUtils");
final AutoCompleteTextView mPasswordEntry = (AutoCompleteTextView) getObjectField(param.thisObject, "mPasswordEntry");
if (mLockPatternUtils != null && mPasswordEntry != null)
{
mPasswordEntry.removeTextChangedListener((TextWatcher) getObjectField(param.thisObject, "mTextChangeListener"));
mPasswordEntry.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void afterTextChanged(Editable s) {
if (mPasswordEntry != null) {
if (mPasswordEntry.getText().length() > 3) //No need to check PINs shorter that 4
{
Boolean isPinCorrect = (Boolean) callMethod(mLockPatternUtils, "checkPassword", mPasswordEntry.getText().toString());
if (isPinCorrect) try {
Method onEditorAction = XposedHelpers.findMethodExact(className, lpparam.classLoader, "onEditorAction", TextView.class, int.class, KeyEvent.class);
onEditorAction.invoke(param.thisObject, null, 0, null);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
if (!mPasswordEntry.isEnabled() && !TextUtils.isEmpty(mPasswordEntry.getText()))
mPasswordEntry.setText("");
if (XMain.senseVersion.compareTo(new Version("5.5")) >= 0) {
Object mCallback = getObjectField(param.thisObject, "mCallback");
if (mCallback != null)
callMethod(mCallback, "userActivity", 0L);
} else {
Object LSStateInst = XposedHelpers.callStaticMethod(findClass("com.htc.lockscreen.app.LSState", lpparam.classLoader), "getInstance");
if (LSStateInst != null)
callMethod(LSStateInst, "keepScreenOn");
}
}
}
});
}
}
public static void execHook_fastUnlock(final LoadPackageParam lpparam)
{
if (XMain.senseVersion.compareTo(new Version("5.5")) >= 0)
findAndHookMethod("com.htc.lockscreen.unlockscreen.HtcKeyInputUnlockView", lpparam.classLoader, "initView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
applyFastUnlock(lpparam, param, "com.htc.lockscreen.unlockscreen.HtcKeyInputUnlockView");
}
});
else
findAndHookMethod("com.htc.lockscreen.app.unlockview.PasswordUnlockView", lpparam.classLoader, "init", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
applyFastUnlock(lpparam, param, "com.htc.lockscreen.app.unlockview.PasswordUnlockView");
}
});
}
public static void execHook_EnhancedInstaller(final LoadPackageParam lpparam) {
/*
findAndHookMethod("com.android.packageinstaller.InstallAppProgress", lpparam.classLoader, "initView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
try {
ApplicationInfo mAppInfo = (ApplicationInfo)XposedHelpers.getObjectField(param.thisObject, "mAppInfo");
Activity install = (Activity)param.thisObject;
if (mAppInfo != null && install != null) {
PackageInfo mPkgInfo = install.getPackageManager().getPackageInfo(((PackageItemInfo)mAppInfo).packageName, 8192);
TextView appName = (TextView)install.findViewById(install.getResources().getIdentifier("app_name", "id", "com.android.packageinstaller"));
if (appName != null && mPkgInfo.versionName != null) appName.setText(appName.getText() + " " + mPkgInfo.versionName);
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
*/
findAndHookMethod("com.android.packageinstaller.PackageInstallerActivity", lpparam.classLoader, "startInstallConfirm", new XC_MethodHook() {
@Override
protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
try {
Activity pia = (Activity)param.thisObject;
PackageInfo mPkgInfo = (PackageInfo)XposedHelpers.getObjectField(param.thisObject, "mPkgInfo");
if (mPkgInfo != null) {
TextView appName = (TextView)pia.findViewById(pia.getResources().getIdentifier("app_name", "id", "com.android.packageinstaller"));
if (appName != null && mPkgInfo.versionName != null) appName.setText(appName.getText() + " " + mPkgInfo.versionName);
// Add new tab with package info when updating an app. Not really in place there. Kept for future mods.
/*
View pager = pia.findViewById(pia.getResources().getIdentifier("pager", "id", "com.android.packageinstaller"));
Object tabsAdapter = XposedHelpers.callMethod(pager, "getAdapter");
TabHost tabhost = (TabHost)pia.findViewById(android.R.id.tabhost);
//final XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
TabSpec tabspec = tabhost.newTabSpec("info").setIndicator("Info"); //modRes.getString(R.string.installer_info)
float density = pia.getResources().getDisplayMetrics().density;
LinearLayout newTab = new LinearLayout(pia);
newTab.setOrientation(LinearLayout.VERTICAL);
LinearLayout container = new LinearLayout(pia);
container.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lp.setMargins(Math.round(15.0f * density), Math.round(10.0f * density), Math.round(15.0f * density), Math.round(10.0f * density));
container.setLayoutParams(lp);
TextView txt = new TextView(container.getContext());
txt.setText("PACKAGE");
txt.setTypeface(null, Typeface.BOLD);
txt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
txt.setPadding(Math.round(10.0f * density), 0, Math.round(10.0f * density), Math.round(4.0f * density));
TextView txt_divider = new TextView(container.getContext());
txt_divider.setBackgroundColor(Color.argb(255, 70, 70, 70));
txt_divider.setHeight(Math.round(2 * density));
container.addView(txt);
container.addView(txt_divider);
TextView info1 = new TextView(container.getContext());
info1.setText("Name: " + mPkgInfo.applicationInfo.packageName);
info1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
info1.setPadding(Math.round(10.0f * density), Math.round(10.0f * density), Math.round(10.0f * density), Math.round(4.0f * density));
TextView info2 = new TextView(container.getContext());
info2.setText("Version: " + mPkgInfo.versionName);
info2.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
info2.setPadding(Math.round(10.0f * density), 0, Math.round(10.0f * density), Math.round(4.0f * density));
TextView info3 = new TextView(container.getContext());
info3.setText("Target SDK version: " + String.valueOf(mPkgInfo.applicationInfo.targetSdkVersion));
info3.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
info3.setPadding(Math.round(10.0f * density), 0, Math.round(10.0f * density), Math.round(4.0f * density));
container.addView(info1);
container.addView(info2);
container.addView(info3);
newTab.addView(container);
XposedHelpers.callMethod(tabsAdapter, "addTab", tabspec, newTab);
*/
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
}
public static void execHook_YouTubeNoWatermark(final InitPackageResourcesParam resparam) {
resparam.res.hookLayout("com.google.android.youtube", "layout", "annotation_overlay", new XC_LayoutInflated() {
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
ImageView watermark = (ImageView)liparam.view.findViewById(resparam.res.getIdentifier("featured_channel_watermark", "id", "com.google.android.youtube"));
if (watermark != null) watermark.setAlpha(0f);
}
});
}
public static void execHook_SafeVolume(final LoadPackageParam lpparam) {
findAndHookMethod("android.media.AudioService", lpparam.classLoader, "checkSafeMediaVolume", int.class, int.class, int.class, new XC_MethodHook() {
@Override
public void beforeHookedMethod(final MethodHookParam param) throws Throwable {
param.setResult(true);
}
});
}
private static void changeToast(View toastView) {
try {
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
TextView toast = (TextView)toastView.findViewById(android.R.id.message);
toast.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
toast.setTypeface(Typeface.DEFAULT);
LinearLayout toastLayout = (LinearLayout)toastView;
toastLayout.setBackground(modRes.getDrawable(R.drawable.toast_frame_holo));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void exec_OldStyleToasts() {
try {
XResources.hookSystemWideLayout("android", "layout", "transient_notification", new XC_LayoutInflated() {
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
changeToast(liparam.view);
}
});
findAndHookMethod("android.widget.Toast", null, "makeText", Context.class, CharSequence.class, int.class, new XC_MethodHook() {
@Override
public void afterHookedMethod(final MethodHookParam param) throws Throwable {
Toast tst = (Toast)param.getResult();
if (tst != null) changeToast(tst.getView());
}
});
} catch (Throwable t) {
//XposedBridge.log(t);
}
}
public static void execHook_LargePhoto(final InitPackageResourcesParam resparam, int photoSize) {
try {
final XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, resparam.res);
int resId = R.dimen.people_info_top_margin;
if (photoSize == 2) resId = R.dimen.people_info_top_margin_rect;
resparam.res.setReplacement("com.android.phone", "dimen", "photo_frame_height", modRes.fwd(resId));
if (XMain.senseVersion.compareTo(new Version("5.5")) >= 0)
resparam.res.setReplacement("com.android.phone", "dimen", "custom_15_font_size", modRes.fwd(R.dimen.custom_15_font_size));
else
resparam.res.setReplacement("com.android.phone", "dimen", "call_card_person_info_name_font_size", modRes.fwd(R.dimen.custom_15_font_size));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
private static void setPhotoHeight(ImageView mPhoto, int photoSize){
try {
final XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
ViewParent mPhotoParent = mPhoto.getParent();
int photoHeight = modRes.getDimensionPixelSize(R.dimen.photo_new_height);
if (photoSize == 2) photoHeight = modRes.getDimensionPixelSize(R.dimen.photo_new_height_rect);
if (mPhotoParent != null)
if (mPhotoParent instanceof RelativeLayout) {
RelativeLayout mPhotoFrame = (RelativeLayout)mPhotoParent;
RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)mPhotoFrame.getLayoutParams();
params1.height = photoHeight;
mPhotoFrame.setLayoutParams(params1);
} else if (mPhotoParent instanceof FrameLayout) {
FrameLayout mPhotoFrame = (FrameLayout)mPhotoParent;
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams)mPhotoFrame.getLayoutParams();
params1.height = photoHeight;
mPhotoFrame.setLayoutParams(params1);
}
if (mPhoto != null) {
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams)mPhoto.getLayoutParams();
params2.height = photoHeight;
mPhoto.setLayoutParams(params2);
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_LargePhotoCode(LoadPackageParam lpparam, final int photoSize) {
if (XMain.senseVersion.compareTo(new Version("5.5")) >= 0) {
findAndHookMethod("com.android.phone.widget.PhotoImageView", lpparam.classLoader, "setImageDrawable", Drawable.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
setPhotoHeight((ImageView)param.thisObject, photoSize);
}
});
} else {
findAndHookMethod("com.android.phone.CallCard", lpparam.classLoader, "setPhotoImageDrawable", Drawable.class, Drawable.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ImageView mPhoto = (ImageView)XposedHelpers.getObjectField(param.thisObject, "mPhoto");
setPhotoHeight(mPhoto, photoSize);
}
});
findAndHookMethod("com.android.phone.CallCard", lpparam.classLoader, "setPhotoImageResource", int.class, Drawable.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ImageView mPhoto = (ImageView)XposedHelpers.getObjectField(param.thisObject, "mPhoto");
setPhotoHeight(mPhoto, photoSize);
}
});
}
findAndHookMethod("com.android.phone.CallCard", lpparam.classLoader, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView mName = (TextView)XposedHelpers.getObjectField(param.thisObject, "mName");
if (mName != null) {
mName.setSingleLine(false);
mName.setMaxLines(2);
mName.setPadding(mName.getPaddingLeft(), Math.round(mName.getResources().getDisplayMetrics().density * 5), mName.getPaddingRight(), mName.getPaddingBottom());
}
}
});
findAndHookMethod("com.android.phone.InCallScreen", lpparam.classLoader, "initInCallScreen", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
ViewGroup mInCallPanel = (ViewGroup)XposedHelpers.getObjectField(param.thisObject, "mInCallPanel");
if (mInCallPanel != null) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mInCallPanel.getLayoutParams();
params.removeRule(RelativeLayout.BELOW);
mInCallPanel.setLayoutParams(params);
}
}
});
findAndHookMethod("com.android.phone.InCallScreen", lpparam.classLoader, "initActionBar", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
LinearLayout mActionBar = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mActionBar");
if (mActionBar != null) {
RelativeLayout newLayout = new RelativeLayout(mActionBar.getContext());
ViewParent prnt = mActionBar.getParent();
if (prnt != null && prnt instanceof RelativeLayout) {
((RelativeLayout)prnt).removeView(mActionBar);
newLayout.addView(mActionBar);
((RelativeLayout)prnt).addView(newLayout);
newLayout.bringToFront();
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
findAndHookMethod("com.android.phone.widget.PhoneActionBar", lpparam.classLoader, "applyStyleToViews", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
LinearLayout actionBar = (LinearLayout)param.thisObject;
if (actionBar != null) {
actionBar.setBackground(null);
actionBar.setBackgroundResource(0);
//actionBar.setBackgroundColor(Color.argb(200, 22, 22, 22));
TextView mPrimaryText = (TextView)XposedHelpers.getObjectField(actionBar, "mPrimaryText");
TextView mSecondaryText = (TextView)XposedHelpers.getObjectField(actionBar, "mSecondaryText");
mPrimaryText.setShadowLayer(4.0f, 0, 3.0f, Color.argb(153, 0, 0, 0));
mSecondaryText.setShadowLayer(4.0f, 0, 3.0f, Color.argb(153, 0, 0, 0));
mSecondaryText.setTextColor(Color.argb(255, 255, 255, 255));
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
if (photoSize == 3) {
findAndHookMethod("com.android.phone.CallCard", lpparam.classLoader, "onOrientationChanged", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
RelativeLayout callCard = (RelativeLayout)param.thisObject;
LinearLayout peopleInfoLayout = (LinearLayout)callCard.findViewById(callCard.getResources().getIdentifier("peopleInfoLayout", "id", "com.android.phone"));
peopleInfoLayout.setBackgroundColor(Color.argb(140, 22, 22, 22));
peopleInfoLayout.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
peopleInfoLayout.setPadding(peopleInfoLayout.getPaddingLeft(), peopleInfoLayout.getPaddingTop(), peopleInfoLayout.getPaddingRight(), Math.round(peopleInfoLayout.getResources().getDisplayMetrics().density * 6));
LinearLayout.LayoutParams paramsPI = (LinearLayout.LayoutParams)peopleInfoLayout.getLayoutParams();
paramsPI.setMargins(paramsPI.leftMargin, 0, paramsPI.rightMargin, Math.round(paramsPI.bottomMargin * 2));
paramsPI.height = LayoutParams.WRAP_CONTENT;
((LinearLayout)peopleInfoLayout.getParent()).setGravity(Gravity.BOTTOM);
peopleInfoLayout.setLayoutParams(paramsPI);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
}
}
public static void execHook_LargePhotoLS55(InitPackageResourcesParam resparam, int photoSize) {
try {
final XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.htc.lockscreen", "dimen", "masthead_minHeight", modRes.fwd(R.dimen.masthead_minHeight));
if (photoSize == 3)
resparam.res.setReplacement("com.htc.lockscreen", "dimen", "incoming_call_call_id_height", modRes.fwd(R.dimen.incoming_call_call_id_height));
resparam.res.setReplacement("com.htc.lockscreen", "dimen", "text_size_custom_04", modRes.fwd(R.dimen.text_size_custom_04));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_LargePhotoLS50(InitPackageResourcesParam resparam, int photoSize) {
try {
final XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, resparam.res);
resparam.res.setReplacement("com.htc.idlescreen.base", "dimen", "masthead_minHeight", modRes.fwd(R.dimen.masthead_minHeight));
resparam.res.setReplacement("com.htc.idlescreen.base", "dimen", "text_size_darklist_primary_m", modRes.fwd(R.dimen.text_size_custom_04));
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_LargePhotoLSCode55(LoadPackageParam lpparam, final int photoSize) {
findAndHookMethod("com.htc.lockscreen.ui.MainContainAnimator", lpparam.classLoader, "doTileChange", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
RelativeLayout mCurTile = (RelativeLayout)XposedHelpers.getObjectField(param.thisObject, "mCurTile");
if (mCurTile != null) {
FrameLayout mCallPhotoContainer = (FrameLayout)mCurTile.findViewById(mCurTile.getResources().getIdentifier("call_id", "id", "com.htc.lockscreen"));
if (mCallPhotoContainer != null) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mCurTile.getLayoutParams();
params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
if (photoSize == 3)
params.setMargins(0, 0, 0, 0);
else
params.setMargins(0, Math.round(mCurTile.getResources().getDisplayMetrics().density * 63), 0, 0);
mCurTile.setLayoutParams(params);
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
findAndHookMethod("com.htc.lockscreen.ui.HeadBar", lpparam.classLoader, "init", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
RelativeLayout headBar = (RelativeLayout)param.thisObject;
if (headBar != null) headBar.bringToFront();
}
});
findAndHookMethod("com.htc.lockscreen.ui.reminder.IncomingCallView", lpparam.classLoader, "init", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
if (photoSize == 3) {
RelativeLayout mTile = (RelativeLayout)XposedHelpers.getObjectField(param.thisObject, "mTile");
if (mTile != null) {
RelativeLayout mCallPhotoRoot = (RelativeLayout)mTile.findViewById(mTile.getResources().getIdentifier("photo_view_root", "id", "com.htc.lockscreen"));
if (mCallPhotoRoot != null) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)mCallPhotoRoot.getLayoutParams();
params.height = modRes.getDimensionPixelSize(R.dimen.incoming_call_call_id_height);
mCallPhotoRoot.setLayoutParams(params);
}
}
ImageView mCallPhoto = (ImageView)XposedHelpers.getObjectField(param.thisObject, "mCallPhoto");
if (mCallPhoto != null) {
FrameLayout.LayoutParams params2 = (FrameLayout.LayoutParams)mCallPhoto.getLayoutParams();
params2.height = modRes.getDimensionPixelSize(R.dimen.incoming_call_call_id_height);
mCallPhoto.setLayoutParams(params2);
FrameLayout mCallPhotoFrame = (FrameLayout)mCallPhoto.getParent();
if (mCallPhotoFrame != null) {
RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams)mCallPhotoFrame.getLayoutParams();
params3.removeRule(RelativeLayout.BELOW);
mCallPhotoFrame.setLayoutParams(params3);
}
}
TextView mSlotName = (TextView)XposedHelpers.getObjectField(param.thisObject, "mSlotName");
if (mSlotName != null) {
RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams)mSlotName.getLayoutParams();
params3.setMargins(0, Math.round(modRes.getDisplayMetrics().density * 28), 0, 0);
mSlotName.setLayoutParams(params3);
mSlotName.setBackground(null);
mSlotName.setBackgroundResource(0);
mSlotName.setGravity(Gravity.CENTER_HORIZONTAL);
mSlotName.setShadowLayer(4.0f, 0, 3.0f, Color.argb(153, 0, 0, 0));
mSlotName.bringToFront();
}
}
LinearLayout mContactPanel = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mContactPanel");
if (mContactPanel != null) {
LinearLayout.LayoutParams params3 = (LinearLayout.LayoutParams)mContactPanel.getLayoutParams();
if (photoSize == 3) params3.setMargins(0, 0, 0, 0);
TextView text2 = (TextView)mContactPanel.findViewById(mContactPanel.getResources().getIdentifier("text2", "id", "com.htc.lockscreen"));
if (text2 != null) {
text2.setSingleLine(false);
text2.setMaxLines(2);
}
mContactPanel.setLayoutParams(params3);
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
}
public static void execHook_LargePhotoLSCode50(LoadPackageParam lpparam, final int photoSize) {
findAndHookMethod("com.htc.idlescreen.base.ui.MainContainAnimator", lpparam.classLoader, "doTileChange", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
RelativeLayout mCurTile = (RelativeLayout)XposedHelpers.getObjectField(param.thisObject, "mCurTile");
if (mCurTile != null) {
ImageView mCallPhoto = (ImageView)mCurTile.findViewById(mCurTile.getResources().getIdentifier("call_id", "id", "com.htc.idlescreen.base"));
if (mCallPhoto != null) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mCurTile.getLayoutParams();
params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
if (photoSize == 3)
params.setMargins(0, 0, 0, 0);
else
params.setMargins(0, Math.round(mCurTile.getResources().getDisplayMetrics().density * 48), 0, 0);
mCurTile.setLayoutParams(params);
RelativeLayout mCurTileContainer = (RelativeLayout)mCurTile.getParent();
if (mCurTileContainer != null) mCurTileContainer.setGravity(Gravity.TOP);
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
findAndHookMethod("com.htc.idlescreen.base.ui.HeadBar", lpparam.classLoader, "init", "com.htc.idlescreen.base.widget.WorkspaceCtrl", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
RelativeLayout headBar = (RelativeLayout)param.thisObject;
if (headBar != null) headBar.bringToFront();
}
});
findAndHookMethod("com.htc.idlescreen.base.ui.reminder.IncomingCallView", lpparam.classLoader, "init", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
if (photoSize == 3) {
RelativeLayout mTile = (RelativeLayout)XposedHelpers.getObjectField(param.thisObject, "mTile");
if (mTile != null) {
RelativeLayout mCallPhotoRoot = (RelativeLayout)mTile.findViewById(mTile.getResources().getIdentifier("photo_view_root", "id", "com.htc.idlescreen.base"));
if (mCallPhotoRoot != null) {
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)mCallPhotoRoot.getLayoutParams();
params.height = modRes.getDimensionPixelSize(R.dimen.incoming_call_call_id_height);
mCallPhotoRoot.setLayoutParams(params);
}
}
ImageView mCallId = (ImageView)XposedHelpers.getObjectField(param.thisObject, "mCallId");
if (mCallId != null) {
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams)mCallId.getLayoutParams();
params2.height = modRes.getDimensionPixelSize(R.dimen.incoming_call_call_id_height);
params2.removeRule(RelativeLayout.BELOW);
mCallId.setLayoutParams(params2);
}
TextView mSlotName = (TextView)XposedHelpers.getObjectField(param.thisObject, "mSlotName");
if (mSlotName != null) {
RelativeLayout.LayoutParams params3 = (RelativeLayout.LayoutParams)mSlotName.getLayoutParams();
params3.setMargins(0, Math.round(modRes.getDisplayMetrics().density * 28), 0, 0);
mSlotName.setLayoutParams(params3);
mSlotName.setBackground(null);
mSlotName.setBackgroundResource(0);
mSlotName.setGravity(Gravity.CENTER_HORIZONTAL);
mSlotName.setShadowLayer(4.0f, 0, 3.0f, Color.argb(153, 0, 0, 0));
mSlotName.bringToFront();
}
}
LinearLayout mContactPanel = (LinearLayout)XposedHelpers.getObjectField(param.thisObject, "mContactPanel");
if (mContactPanel != null) {
LinearLayout.LayoutParams params3 = (LinearLayout.LayoutParams)mContactPanel.getLayoutParams();
if (photoSize == 3) params3.setMargins(0, 0, 0, 0);
TextView text2 = (TextView)mContactPanel.findViewById(mContactPanel.getResources().getIdentifier("text2", "id", "com.htc.idlescreen.base"));
if (text2 != null) {
text2.setSingleLine(false);
text2.setMaxLines(2);
}
mContactPanel.setLayoutParams(params3);
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
}
public static void execHook_RejectCallSilently(LoadPackageParam lpparam) {
findAndHookMethod("com.android.phone.CallNotifier", lpparam.classLoader, "addCallLog", "com.android.internal.telephony.Connection", "com.android.internal.telephony.Connection.DisconnectCause", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
try {
Enum<?> disconnectcause = (Enum<?>)param.args[1];
if (disconnectcause.ordinal() == 16)
param.args[1] = XposedHelpers.getStaticObjectField(findClass("com.android.internal.telephony.Connection.DisconnectCause", null), "NORMAL");
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
}
public static void execHook_EnhancedSecurity() {
findAndHookMethod("com.android.internal.policy.impl.PhoneWindowManager", null, "interceptPowerKeyDown", boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
Context mPWMContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext");
KeyguardManager kgMgr = (KeyguardManager)mPWMContext.getSystemService(Context.KEYGUARD_SERVICE);
if (kgMgr.isKeyguardLocked() && kgMgr.isKeyguardSecure()) {
Handler mHandler = (Handler)XposedHelpers.getObjectField(param.thisObject, "mHandler");
if (mHandler != null) {
Runnable mPowerLongPress = (Runnable)XposedHelpers.getObjectField(param.thisObject, "mPowerLongPress");
Runnable mPowerLongPress_Toast = (Runnable)XposedHelpers.getObjectField(param.thisObject, "mPowerLongPress_Toast");
Runnable mPowerLongPress_Toast_2KeyHWResetHint = (Runnable)XposedHelpers.getObjectField(param.thisObject, "mPowerLongPress_Toast_2KeyHWResetHint");
Runnable mPowerLongPress_Toast_2KeyHWResetIndicator = (Runnable)XposedHelpers.getObjectField(param.thisObject, "mPowerLongPress_Toast_2KeyHWResetIndicator");
if (mPowerLongPress != null) mHandler.removeCallbacks(mPowerLongPress);
if (mPowerLongPress_Toast != null) mHandler.removeCallbacks(mPowerLongPress_Toast);
if (mPowerLongPress_Toast_2KeyHWResetHint != null) mHandler.removeCallbacks(mPowerLongPress_Toast_2KeyHWResetHint);
if (mPowerLongPress_Toast_2KeyHWResetIndicator != null) mHandler.removeCallbacks(mPowerLongPress_Toast_2KeyHWResetIndicator);
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
}
public static void execHook_AllRotations() {
try {
XResources.setSystemWideReplacement("android", "bool", "config_allowAllRotations", true);
XResources.setSystemWideReplacement("com.htc.framework", "bool", "config_allowAllRotations", true);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_NoChargerWarning(LoadPackageParam lpparam) {
try {
findAndHookMethod("com.android.settings.NSReceiver", lpparam.classLoader, "showVZWChargerNotification", Context.class, int.class, boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
int type = (Integer)param.args[1];
if (type == 1) param.setResult(null);
}
});
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_LEDNotifyTimeout() {
XposedBridge.hookAllConstructors(findClass("com.android.server.NotificationManagerService", null), new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.setIntField(param.thisObject, "mFlashTimeout", XMain.pref.getInt("pref_key_other_ledtimeout_value", 5));
}
});
}
public static void execHook_LEDOnCharge() {
XposedBridge.hookAllConstructors(findClass("com.android.server.NotificationManagerService", null), new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
XposedHelpers.setBooleanField(param.thisObject, "mFlashDuringCharging", true);
} catch (Throwable t) {
XposedHelpers.setBooleanField(param.thisObject, "mFlashDuringPlugged", true);
}
}
});
}
public static void execHook_ContactsNoCornerSystem() {
XResources.setSystemWideReplacement("com.htc:drawable/common_photo_frame_quick_contact_mask", new XResources.DrawableLoader(){
@Override
public Drawable newDrawable(XResources res, int id) throws Throwable {
return new ColorDrawable(Color.TRANSPARENT);
}
});
}
public static void execHook_ContactsNoCorner(final InitPackageResourcesParam resparam) {
if (resparam.packageName.equals("com.htc.contacts")) try {
resparam.res.setReplacement(resparam.packageName, "drawable", "common_photo_frame_quick_contact_mask", new XResources.DrawableLoader(){
@Override
public Drawable newDrawable(XResources res, int id) throws Throwable {
return new ColorDrawable(Color.TRANSPARENT);
}
});
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static StatusBarTapReceiver sbtReceiver = new StatusBarTapReceiver();
public static Activity mainAct = null;
public static Activity reviewAct = null;
public static class StatusBarTapReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (mainAct != null) try {
View details_expanded_scroller = mainAct.findViewById(mainAct.getResources().getIdentifier("details_expanded_scroller", "id", "com.android.vending"));
if (details_expanded_scroller != null && details_expanded_scroller instanceof ScrollView) ((ScrollView)details_expanded_scroller).smoothScrollTo(0, 0);
View bucket_list_view = mainAct.findViewById(mainAct.getResources().getIdentifier("bucket_list_view", "id", "com.android.vending"));
if (bucket_list_view != null && bucket_list_view instanceof ListView) ((ListView)bucket_list_view).smoothScrollToPosition(0);
View details_scroller = mainAct.findViewById(mainAct.getResources().getIdentifier("details_scroller", "id", "com.android.vending"));
if (details_scroller != null && details_scroller instanceof ScrollView) ((ScrollView)details_scroller).smoothScrollTo(0, 0);
View page_content = mainAct.findViewById(mainAct.getResources().getIdentifier("page_content", "id", "com.android.vending"));
if (page_content != null && page_content instanceof ScrollView) ((ScrollView)page_content).smoothScrollTo(0, 0);
ViewGroup viewpager = (ViewGroup)mainAct.findViewById(mainAct.getResources().getIdentifier("viewpager", "id", "com.android.vending"));
if (viewpager != null) {
int pages = viewpager.getChildCount();
for (int pg = 0; pg < pages; pg++) {
View page = viewpager.getChildAt(pg);
if (page != null)
if (page instanceof ListView) ((ListView)page).smoothScrollToPosition(0); else {
View bucket_list_view2 = page.findViewById(mainAct.getResources().getIdentifier("bucket_list_view", "id", "com.android.vending"));
if (bucket_list_view2 != null && bucket_list_view2 instanceof ListView) ((ListView)bucket_list_view2).smoothScrollToPosition(0);
View my_apps_content_list = page.findViewById(mainAct.getResources().getIdentifier("my_apps_content_list", "id", "com.android.vending"));
if (my_apps_content_list != null && my_apps_content_list instanceof ListView) ((ListView)my_apps_content_list).smoothScrollToPosition(0);
}
}
}
} catch (Throwable t) {
XposedBridge.log(t);
}
if (reviewAct != null) try {
View all_reviews_list = reviewAct.findViewById(reviewAct.getResources().getIdentifier("all_reviews_list", "id", "com.android.vending"));
if (all_reviews_list != null && all_reviews_list instanceof ListView) ((ListView)all_reviews_list).smoothScrollToPosition(0);
} catch (Throwable t) {
XposedBridge.log(t);
}
}
}
public static void execHook_PSScroll(LoadPackageParam lpparam) {
findAndHookMethod("com.google.android.finsky.activities.MainActivity", lpparam.classLoader, "onResume", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mainAct = (Activity)param.thisObject;
if (mainAct != null) try {
mainAct.registerReceiver(sbtReceiver, new IntentFilter("com.htc.intent.action.STATUS_BAR_TAP_EVENT"), "com.htc.permission.APP_PLATFORM", null);
} catch (Throwable t) {}
}
});
findAndHookMethod("com.google.android.finsky.activities.MainActivity", lpparam.classLoader, "onPause", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mainAct = (Activity)param.thisObject;
if (mainAct != null) try {
mainAct.unregisterReceiver(sbtReceiver);
} catch (Throwable t) {}
}
});
findAndHookMethod("com.google.android.finsky.activities.ReviewsActivity", lpparam.classLoader, "onCreate", Bundle.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
reviewAct = (Activity)param.thisObject;
if (reviewAct != null) try {
reviewAct.registerReceiver(sbtReceiver, new IntentFilter("com.htc.intent.action.STATUS_BAR_TAP_EVENT"), "com.htc.permission.APP_PLATFORM", null);
} catch (Throwable t) {}
}
});
}
public static void execHook_ScreenshotViewer(final LoadPackageParam lpparam) {
findAndHookMethod("com.android.systemui.screenshot.SaveImageInBackgroundTask", lpparam.classLoader, "onPostExecute", "com.android.systemui.screenshot.SaveImageInBackgroundData", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
try {
Object saveimageinbackgrounddata = param.args[0];
int result = (Integer)XposedHelpers.getObjectField(saveimageinbackgrounddata, "result");
if (result > 0) {
XposedHelpers.callStaticMethod(
findClass("com.android.systemui.screenshot.GlobalScreenshot", lpparam.classLoader),
"notifyScreenshotError",
XposedHelpers.getObjectField(saveimageinbackgrounddata, "context"),
XposedHelpers.getObjectField(param.thisObject, "mNotificationManager")
);
} else {
Context context = (Context)XposedHelpers.getObjectField(saveimageinbackgrounddata, "context");
Resources resources = context.getResources();
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = (Uri)XposedHelpers.getObjectField(saveimageinbackgrounddata, "imageUri");
intent.setDataAndType(imageUri, "image/*");
Notification.Builder mNotificationBuilder = (Notification.Builder)XposedHelpers.getObjectField(param.thisObject, "mNotificationBuilder");
mNotificationBuilder.setContentTitle(resources.getString(resources.getIdentifier("screenshot_saved_title", "string", "com.android.systemui")))
.setContentText(resources.getString(resources.getIdentifier("screenshot_saved_text", "string", "com.android.systemui")))
.setWhen(System.currentTimeMillis())
.setAutoCancel(true);
PackageManager manager = context.getPackageManager();
List<ResolveInfo> info = manager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (info.isEmpty()) {
XModuleResources modRes = XModuleResources.createInstance(XMain.MODULE_PATH, null);
Toast.makeText(context, Helpers.xl10n(modRes, R.string.various_screenopen_noapps), Toast.LENGTH_LONG).show();
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(), 0));
} else {
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0));
}
final Notification notification = mNotificationBuilder.build();
notification.flags = 0xffffffdf & notification.flags;
final NotificationManager mNotificationManager = (NotificationManager)XposedHelpers.getObjectField(param.thisObject, "mNotificationManager");
final int mNotificationId = (Integer)XposedHelpers.getObjectField(param.thisObject, "mNotificationId");
Handler mHandler = (Handler)XposedHelpers.getObjectField(param.thisObject, "mHandler");
mHandler.postDelayed(new Runnable() {
public void run() {
mNotificationManager.notify(mNotificationId, notification);
}
}, 300L);
}
Runnable finisher = (Runnable)XposedHelpers.getObjectField(saveimageinbackgrounddata, "finisher");
finisher.run();
} catch (Throwable t) {
XposedBridge.log(t);
}
return null;
}
});
}
public static void buttonBacklight(){
try {
findAndHookMethod("com.android.server.wm.WindowManagerService", null, "statusBarVisibilityChanged", int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext");
Intent intent = new Intent();
intent.setAction("com.langerhans.one.UPDATEBACKLIGHT");
int sysUiVis = (Integer)param.args[0];
if (sysUiVis == 67108864 || sysUiVis == 0) return;
//XposedBridge.log("statusBarVisibilityChanged: " + String.valueOf(sysUiVis));
if (sysUiVis != 0 && ((sysUiVis & View.SYSTEM_UI_FLAG_FULLSCREEN) == View.SYSTEM_UI_FLAG_FULLSCREEN
|| (sysUiVis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|| (sysUiVis & View.SYSTEM_UI_FLAG_LOW_PROFILE) == View.SYSTEM_UI_FLAG_LOW_PROFILE)
|| ((sysUiVis & View.SYSTEM_UI_FLAG_IMMERSIVE) == View.SYSTEM_UI_FLAG_IMMERSIVE && (sysUiVis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION))
intent.putExtra("forceDisableBacklight", true);
mContext.sendBroadcast(intent);
}
});
findAndHookMethod("android.view.Window", null, "setFlags", int.class, int.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Window wnd = (Window)param.thisObject;
if (wnd != null && wnd.getContext().getPackageName().equals("com.google.android.youtube")) {
WindowManager.LayoutParams mWindowAttributes = (WindowManager.LayoutParams)XposedHelpers.getObjectField(param.thisObject, "mWindowAttributes");
if (mWindowAttributes == null) return;
int i = (Integer)param.args[0];
int j = (Integer)param.args[1];
int newFlags = mWindowAttributes.flags & ~j | i & j;
if (newFlags != 0 &&
(newFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != WindowManager.LayoutParams.FLAG_FULLSCREEN &&
(newFlags & WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN) == WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN &&
(newFlags & WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR) == WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR) {
//XposedBridge.log("setFlags FLAG_LAYOUT_*: " + String.valueOf(newFlags));
Context mContext = (Context)XposedHelpers.getObjectField(param.thisObject, "mContext");
Intent intent = new Intent();
intent.setAction("com.langerhans.one.UPDATEBACKLIGHT");
mContext.sendBroadcast(intent);
}
}
}
});
findAndHookMethod("android.app.Activity", null, "onResume", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Activity act = (Activity)param.thisObject;
if (act == null) return;
int newFlags = act.getWindow().getAttributes().flags;
//XposedBridge.log("onResume flags: " + String.valueOf(newFlags));
Intent intent = new Intent();
intent.setAction("com.langerhans.one.UPDATEBACKLIGHT");
if (newFlags != 0 && (newFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN && !act.getPackageName().equals("com.android.systemui"))
intent.putExtra("forceDisableBacklight", true);
act.sendBroadcast(intent);
}
});
} catch (Throwable t) {
XposedBridge.log(t);
}
}
public static void execHook_NoAutoIME() {
findAndHookMethod(Activity.class, "onResume", new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
try {
Activity act = (Activity)param.thisObject;
if (act != null) {
int softMode = act.getWindow().getAttributes().softInputMode;
if ((softMode & WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) == WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE ||
(softMode & WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) == WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED);
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
});
findAndHookMethod("com.android.server.InputMethodManagerService", null, "showSoftInput", "com.android.internal.view.IInputMethodClient", int.class, "android.os.ResultReceiver", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if ((Integer)param.args[1] == InputMethodManager.SHOW_IMPLICIT) param.setResult(false);
}
});
}
}