Created
February 20, 2015 10:31
-
-
Save orzFly/a01e779f0f767704dd97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.orzfly.xposed.touchwizhacker; | |
import android.content.res.XModuleResources; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.ViewGroup.LayoutParams; | |
import android.widget.FrameLayout; | |
import android.widget.LinearLayout; | |
import android.widget.RelativeLayout; | |
import android.widget.TextView; | |
import de.robv.android.xposed.IXposedHookInitPackageResources; | |
import de.robv.android.xposed.IXposedHookLoadPackage; | |
import de.robv.android.xposed.IXposedHookZygoteInit; | |
import de.robv.android.xposed.XC_MethodHook; | |
import de.robv.android.xposed.XC_MethodHook.MethodHookParam; | |
import de.robv.android.xposed.XposedBridge; | |
import de.robv.android.xposed.XposedHelpers; | |
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam; | |
import de.robv.android.xposed.callbacks.XC_LayoutInflated; | |
import de.robv.android.xposed.callbacks.XC_LayoutInflated.LayoutInflatedParam; | |
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; | |
public class TouchwizHacker implements IXposedHookZygoteInit, IXposedHookInitPackageResources, IXposedHookLoadPackage { | |
private static String MODULE_PATH = null; | |
public static String[] IGNORE_ICONS = new String[] { "alarm_clock", "volume" }; | |
public static String[] TOP_PKGS = new String[] { "com.painless.pc", "com.maxmpz.audioplayer" }; | |
@Override | |
public void initZygote(StartupParam startupParam) throws Throwable { | |
MODULE_PATH = startupParam.modulePath; | |
} | |
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable { | |
if (!lpparam.packageName.equals("com.android.systemui")) | |
return; | |
Class<?> StatusBarNotification = Class.forName("com.android.internal.statusbar.StatusBarNotification"); | |
Class<?> BaseStatusBar = Class.forName("com.android.systemui.statusbar.BaseStatusBar", false, lpparam.classLoader); | |
XC_MethodHook NotificationHooker = new XC_MethodHook() { | |
@Override | |
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | |
Object notify = param.args[1]; | |
Log.e("SHITHooked", param.method.getName() + " -> " + String.valueOf(notify)); | |
String pkg = (String) XposedHelpers.getObjectField(notify, "pkg"); | |
for(String pakg: TOP_PKGS) | |
{ | |
if (pkg.equals(pakg)) | |
{ | |
Log.e("SHITHooked", param.method.getName() + " -> !!!!!!!! hooked"); | |
Object not = XposedHelpers.getObjectField(notify, "notification"); | |
XposedHelpers.setIntField(not, "twQuickPanelEvent", 1); | |
break; | |
} | |
} | |
} | |
@Override | |
protected void afterHookedMethod(MethodHookParam param) throws Throwable { | |
} | |
}; | |
XposedHelpers.findAndHookMethod(BaseStatusBar, "addNotificationViews", android.os.IBinder.class, StatusBarNotification, NotificationHooker); | |
XposedHelpers.findAndHookMethod(BaseStatusBar, "updateNotification", android.os.IBinder.class, StatusBarNotification, NotificationHooker); | |
Class<?> StatusBarManager = Class.forName("android.app.StatusBarManager"); | |
XposedHelpers.findAndHookMethod(StatusBarManager, "setIcon", String.class, int.class, int.class, String.class, new XC_MethodHook() { | |
@Override | |
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | |
String key = (String) param.args[0]; | |
for(int i = 0; i < IGNORE_ICONS.length; i++) | |
{ | |
if (key.compareTo(IGNORE_ICONS[i]) == 0) | |
{ | |
param.setResult(null); | |
return; | |
} | |
} | |
} | |
@Override | |
protected void afterHookedMethod(MethodHookParam param) throws Throwable { | |
} | |
}); | |
XposedHelpers.findAndHookMethod(StatusBarManager, "setIconVisibility", String.class, boolean.class, new XC_MethodHook() { | |
@Override | |
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | |
String key = (String) param.args[0]; | |
for(int i = 0; i < IGNORE_ICONS.length; i++) | |
{ | |
if (key.compareTo(IGNORE_ICONS[i]) == 0) | |
{ | |
param.setResult(null); | |
return; | |
} | |
} | |
} | |
@Override | |
protected void afterHookedMethod(MethodHookParam param) throws Throwable { | |
} | |
}); | |
} | |
@Override | |
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable { | |
if (!resparam.packageName.equals("com.android.systemui")) | |
return; | |
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res); | |
resparam.res.setReplacement("com.android.systemui", "dimen", "quick_settings_cell_height", modRes.fwd(R.dimen.zero)); | |
resparam.res.setReplacement("com.android.systemui", "dimen", "quick_setting_button_height", modRes.fwd(R.dimen.zero)); | |
resparam.res.hookLayout("com.android.systemui", "layout", "signal_cluster_view", new XC_LayoutInflated() { | |
@Override | |
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { | |
View simIcon = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("sim_icon", "id", "com.android.systemui")); | |
simIcon.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); | |
} | |
}); | |
resparam.res.hookLayout("com.android.systemui", "layout", "status_bar_expanded_header", new XC_LayoutInflated() { | |
@Override | |
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { | |
View settingsButtonHolder = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("settings_button_holder", "id", "com.android.systemui")); | |
settingsButtonHolder.setLayoutParams(new RelativeLayout.LayoutParams(0, 0)); | |
View settingsButtonHolderDivider = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("settings_button_holder_divider", "id", "com.android.systemui")); | |
settingsButtonHolderDivider.setLayoutParams(new RelativeLayout.LayoutParams(0, 0)); | |
View editButtonHolder = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("edit_button_holder", "id", "com.android.systemui")); | |
RelativeLayout.LayoutParams editButtonHolderLayoutParams = (android.widget.RelativeLayout.LayoutParams) editButtonHolder.getLayoutParams(); | |
editButtonHolderLayoutParams.removeRule(RelativeLayout.LEFT_OF); | |
editButtonHolderLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); | |
} | |
}); | |
resparam.res.hookLayout("com.android.systemui", "layout", "status_bar_expanded", new XC_LayoutInflated() { | |
@Override | |
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { | |
View quickpanelDualsimLayout = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("quickpanel_dualsim_layout", "id", "com.android.systemui")); | |
quickpanelDualsimLayout.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); | |
View noNotificationsTitle = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("noNotificationsTitle", "id", "com.android.systemui")); | |
noNotificationsTitle.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); | |
View onGoingCart = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("onGoingCart", "id", "com.android.systemui")); | |
onGoingCart.setLayoutParams(new LinearLayout.LayoutParams(0, 0)); | |
View flipSettingsStub = (View) liparam.view.findViewById( | |
liparam.res.getIdentifier("flip_settings_stub", "id", "com.android.systemui")); | |
flipSettingsStub.setLayoutParams(new FrameLayout.LayoutParams(0, 0)); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment