Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Include native libs for CRT fixes into Tweakbox
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Jun 26, 2012
1 parent a1d064e commit 83de6ea
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 18 deletions.
Binary file modified XposedLibrary/XposedBridgeApi.jar
Binary file not shown.
Binary file added XposedLibrary/lib/full_framework_15.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.robv.android.xposed.library.ui;

import android.content.Context;
import android.graphics.Color;
import android.preference.Preference;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.ImageView;

public class SeparatorPreference extends Preference {
int color = Color.GRAY;
int height = 7;

public SeparatorPreference(Context context) {
super(context);
setSelectable(false);
}

public void setColor(int color) {
this.color = color;
}

public void setHeight(int height) {
this.height = height;
}

@Override
protected View onCreateView(ViewGroup parent) {
ImageView iview = new ImageView(getContext());
iview.setBackgroundColor(color);
iview.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, height));
return iview;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.robv.android.xposed.library.ui;

import android.content.Context;
import android.preference.Preference;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TextViewPreference extends Preference {
private TextView textView = null;

public TextViewPreference(Context context) {
super(context);
}

@Override
protected View onCreateView(ViewGroup parent) {
return getTextView();
}

public TextView getTextView() {
if (textView == null) {
textView = new TextView(getContext());
textView.setId(android.R.id.title);
textView.setPadding(5,5,5,5);
}
return textView;
}
}
1 change: 1 addition & 0 deletions XposedTweakbox/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="/XposedLibrary/XposedBridgeApi.jar"/>
<classpathentry kind="lib" path="/XposedLibrary/lib/full_framework_15.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions XposedTweakbox/assets/nativelibs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<libs>

<lib
name="libsurfaceflinger.so"
asset="libs/libsurfaceflinger.so_I9100_Stock" >
CRT off/on fix for stock-based I9100 ROMs </lib>

<lib
name="libsurfaceflinger.so"
asset="libs/libsurfaceflinger.so_I9100_Stock_LS" >
CRT off/on fix for stock-based I9100 ROMs (including support for landscape) </lib>

</libs>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.robv.android.xposed.mods.tweakbox;

import static de.robv.android.xposed.XposedHelpers.assetAsByteArray;
import static de.robv.android.xposed.XposedHelpers.getIntField;
import static de.robv.android.xposed.XposedHelpers.getMD5Sum;
import static de.robv.android.xposed.XposedHelpers.getSurroundingThis;
import static de.robv.android.xposed.XposedHelpers.setFloatField;
import static de.robv.android.xposed.XposedHelpers.setIntField;
Expand All @@ -16,11 +14,11 @@
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.XModuleResources;
import android.content.res.XResources;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.os.SystemProperties;
import android.telephony.SignalStrength;
import android.util.DisplayMetrics;
import android.view.Display;
Expand Down Expand Up @@ -49,7 +47,6 @@ public class XposedTweakbox implements IXposedHookZygoteInit, IXposedHookInitPac
@Override
public void initZygote() {
pref = AndroidAppHelper.getDefaultSharedPreferencesForPackage(MY_PACKAGE_NAME);
Resources tweakboxRes = XModuleResources.createInstance(MODULE_PATH, null);

try {
// this is not really necessary if no effects are wanted, but it speeds up turning off the screen
Expand All @@ -68,20 +65,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
});

if (pref.getBoolean("crt_off_effect", false) || pref.getBoolean("crt_on_effect", false)) {
// apply CRT off fix by Tungstwenty plus CRT on effect
String libsurfaceflingerMD5 = getMD5Sum("/system/lib/libsurfaceflinger.so");
if (libsurfaceflingerMD5.equals("d506192d5049a4042fb84c0265edfe42")) {
byte[] crtPatch = assetAsByteArray(tweakboxRes, "crtfix_samsung_d506192d5049a4042fb84c0265edfe42.bsdiff");
if (!XposedBridge.patchNativeLibrary("/system/lib/libsurfaceflinger.so", crtPatch, "/system/bin/surfaceflinger"))
XposedBridge.log("CRT patch could not be applied");
} else if (libsurfaceflingerMD5.equals("3262c644b7b7079958db82bd992f2a46")) {
XposedBridge.log("CRT patch not necessary, library is already patched");
} else {
XposedBridge.log("CRT patch could not be applied because libsurfaceflinger.so has unknown MD5 sum " + libsurfaceflingerMD5);
}
}
} catch (Exception e) { XposedBridge.log(e); }

try {
Expand Down Expand Up @@ -288,6 +271,19 @@ protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
}
});
} catch (Exception e) { XposedBridge.log(e); }
} else if (lpparam.packageName.equals("android")) {
if (pref.getBoolean("crt_off_effect", false) || pref.getBoolean("crt_on_effect", false)) {
try {
Class<?> classMOL = Class.forName("com.android.internal.policy.impl.PhoneWindowManager$MyOrientationListener", false, lpparam.classLoader);
XposedBridge.hookMethod(classMOL.getDeclaredMethod("onProposedRotationChanged", int.class), new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
int rotation = (Integer) param.args[0];
SystemProperties.set("hw.crt.landscape", String.valueOf(rotation % 2));
}
});
} catch (Throwable t) { XposedBridge.log(t); }
}
}
}

Expand Down

0 comments on commit 83de6ea

Please sign in to comment.