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

Commit

Permalink
make Tweakbox compatible with Xposed 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Jan 23, 2013
1 parent 33e3bf4 commit 35b0906
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
Binary file modified XposedLibrary/XposedBridgeApi.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions XposedTweakbox/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.robv.android.xposed.mods.tweakbox"
android:versionCode="6"
android:versionName="1.3.1" >
android:versionCode="7"
android:versionName="1.3.2" >

<uses-sdk android:minSdkVersion="15" />

Expand All @@ -24,7 +24,7 @@
android:value="true" />
<meta-data
android:name="xposedminversion"
android:value="2.0*" />
android:value="2.1*" />
<meta-data
android:name="xposeddescription"
android:value="Collection of different tweaks" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
import java.util.Locale;

import android.app.AndroidAppHelper;
import android.content.SharedPreferences;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.XResources;
import android.util.DisplayMetrics;
import android.view.Display;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;

class AppSpecificConfiguration {
private static SharedPreferences pref;
private static XSharedPreferences pref;
private AppSpecificConfiguration() {}

public static void initZygote(final SharedPreferences pref) {
public static void initZygote(final XSharedPreferences pref) {
AppSpecificConfiguration.pref = pref;

// density / resource configuration manipulation
try {
findAndHookMethod(Display.class, "init", int.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();
String packageName = AndroidAppHelper.currentPackageName();

int packageDensity = pref.getInt("dpioverride/" + packageName + "/density", pref.getInt("dpioverride/default/density", 0));
Expand All @@ -45,7 +45,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (config != null && param.thisObject instanceof XResources) {
String packageName = ((XResources) param.thisObject).getPackageName();
if (packageName != null) {
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();

int swdp = pref.getInt("dpioverride/" + packageName + "/swdp", pref.getInt("dpioverride/default/swdp", 0));
int wdp = pref.getInt("dpioverride/" + packageName + "/wdp", pref.getInt("dpioverride/default/wdp", 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

import java.lang.reflect.Method;

import android.app.AndroidAppHelper;
import android.content.SharedPreferences;
import android.os.SystemProperties;
import android.view.WindowManagerPolicy;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

Expand Down Expand Up @@ -41,7 +40,7 @@ private CrtEffect() { }
* Hook the methods related with the screen off event in order to use the active CRT On/Off preferences.
* Handles the missing call to "nativeStartSurfaceFlingerAnimation" on I9300.
*/
public static void loadPackage(final SharedPreferences pref, ClassLoader classLoader) throws Exception {
public static void loadPackage(final XSharedPreferences pref, ClassLoader classLoader) throws Exception {

final ThreadLocal<CallStackState> nestingStatus = new ThreadLocal<CallStackState>();

Expand All @@ -52,7 +51,7 @@ public static void loadPackage(final SharedPreferences pref, ClassLoader classLo
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// About to turn off screen
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();
Object powerManagerService = getSurroundingThis(param.thisObject);
int animationSetting;
animationSetting = (pref.getBoolean("crt_off_effect", false)) ? ANIM_SETTING_OFF : 0;
Expand Down Expand Up @@ -102,7 +101,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
int rotation = (Integer) param.args[0];
if (rotation >= 0) {
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();
if (pref.getBoolean("crt_effect_orientation", false)) {
SystemProperties.set("runtime.xposed.orientation", String.valueOf(rotation));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Map;

import android.app.AlertDialog;
import android.app.AndroidAppHelper;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.FeatureInfo;
Expand All @@ -21,6 +20,7 @@
import com.android.internal.telephony.gsm.SuppServiceNotification;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

Expand Down Expand Up @@ -51,7 +51,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
} catch (Throwable t) { XposedBridge.log(t); }
}

public static void loadPackage(final SharedPreferences pref, ClassLoader classLoader) {
public static void loadPackage(final XSharedPreferences pref, ClassLoader classLoader) {
// Handle vibrate on Call Wait
try {
findAndHookMethod("com.android.phone.PhoneUtils", classLoader, "displaySSInfo",
Expand All @@ -63,7 +63,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

// Waiting for target party
if (notificationType == 0 && code == 3) {
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();
if (pref.getBoolean("phone_vibrate_waiting", false)) {
Context context = (Context) param.args[1];

Expand Down Expand Up @@ -98,7 +98,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (insideRingerHandler.get() != null) {
// Within execution of handleMessage()
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();
if (!pref.getBoolean("phone_increasing_ringer", true)) {
// No increasing ringer; skip changing the ringer volume
param.setResult(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import java.lang.reflect.Constructor;
import java.util.Locale;

import android.app.AndroidAppHelper;
import android.content.SharedPreferences;
import android.content.res.XResources;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
import android.telephony.SignalStrength;
import android.view.View;
Expand All @@ -22,6 +21,7 @@
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
Expand All @@ -32,12 +32,12 @@
public class XposedTweakbox implements IXposedHookZygoteInit, IXposedHookInitPackageResources, IXposedHookLoadPackage {
public static final String TAG = "Tweakbox";
public static final String MY_PACKAGE_NAME = XposedTweakbox.class.getPackage().getName();
private static SharedPreferences pref;
private static XSharedPreferences pref;
private static int signalStrengthBars = 4;

@Override
public void initZygote(StartupParam startupParam) {
pref = AndroidAppHelper.getDefaultSharedPreferencesForPackage(MY_PACKAGE_NAME);
pref = new XSharedPreferences(MY_PACKAGE_NAME);

// this is not really necessary if no effects are wanted, but it speeds up turning off the screen
XResources.setSystemWideReplacement("android", "bool", "config_animateScreenLights", false);
Expand Down Expand Up @@ -72,7 +72,7 @@ public void initZygote(StartupParam startupParam) {

@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();

Locale packageLocale = AppSpecificConfiguration.getPackageSpecificLocale(lpparam.packageName);
if (packageLocale != null)
Expand Down Expand Up @@ -142,7 +142,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

@Override
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
AndroidAppHelper.reloadSharedPreferencesIfNeeded(pref);
pref.reload();

if (resparam.packageName.equals("com.android.systemui")) {
try {
Expand All @@ -152,8 +152,13 @@ public void handleInitPackageResources(InitPackageResourcesParam resparam) throw

if (pref.getBoolean("statusbar_color_enabled", false)) {
try {
int statusbarColor = pref.getInt("statusbar_color", Color.BLACK);
resparam.res.setReplacement("com.android.systemui", "drawable", "status_bar_background", new ColorDrawable(statusbarColor));
final int statusbarColor = pref.getInt("statusbar_color", Color.BLACK);
resparam.res.setReplacement("com.android.systemui", "drawable", "status_bar_background", new XResources.DrawableLoader() {
@Override
public Drawable newDrawable(XResources res, int id) throws Throwable {
return new ColorDrawable(statusbarColor));
}
});
} catch (Throwable t) { XposedBridge.log(t); }
}

Expand Down

0 comments on commit 35b0906

Please sign in to comment.