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

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
rovo89 committed Apr 5, 2012
0 parents commit efd0831
Show file tree
Hide file tree
Showing 20 changed files with 281 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*/gen
/*/bin
9 changes: 9 additions & 0 deletions CrtOffEffect/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<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="/XposedBridge/XposedBridgeApi.jar" sourcepath="/XposedBridge/XposedBridgeApi.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions CrtOffEffect/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CrtOffEffect</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
17 changes: 17 additions & 0 deletions CrtOffEffect/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.robv.android.xposed.mods.crtoffeffect"
android:versionCode="1"
android:versionName="1.0" >

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

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<meta-data
android:name="xposedmodule"
android:value="true" />
</application>

</manifest>
1 change: 1 addition & 0 deletions CrtOffEffect/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.robv.android.xposed.mods.crtoffeffect.CrtOffEffect
14 changes: 14 additions & 0 deletions CrtOffEffect/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt

# Project target.
target=android-15
Binary file added CrtOffEffect/res/drawable/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions CrtOffEffect/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">CRT off effect</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.robv.android.xposed.mods.crtoffeffect;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Iterator;

import de.robv.android.xposed.Callback;
import de.robv.android.xposed.XposedBridge;

public class CrtOffEffect {
private static Field fieldAnimateScreenLights;

public static void init(String startClassName) {
if (startClassName != null)
return;

try {
Class<?> classPowerManagerService = Class.forName("com.android.server.PowerManagerService");
fieldAnimateScreenLights = classPowerManagerService.getDeclaredField("mAnimateScreenLights");
fieldAnimateScreenLights.setAccessible(true);
Method methodInitInThread = classPowerManagerService.getDeclaredMethod("initInThread");
XposedBridge.hookMethod(methodInitInThread, CrtOffEffect.class, "handle_PowerManagerService_initInThread", Callback.PRIORITY_DEFAULT);
} catch (Exception e) {
XposedBridge.log(e);
}
}

@SuppressWarnings("unused")
private static Object handle_PowerManagerService_initInThread (Iterator<Callback> iterator, Method method, Object thisObject, Object[] args) throws Throwable {
Object result = XposedBridge.callNext(iterator, method, thisObject, args);
try {
fieldAnimateScreenLights.setBoolean(thisObject, false);
} catch (Exception e) {
XposedBridge.log(e);
}
return result;
}
}
9 changes: 9 additions & 0 deletions RedClock/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<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="/XposedBridge/XposedBridgeApi.jar" sourcepath="/XposedBridge/XposedBridgeApi.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions RedClock/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RedClock</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
18 changes: 18 additions & 0 deletions RedClock/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.robv.android.xposed.mods.redclock"
android:installLocation="internalOnly"
android:versionCode="1"
android:versionName="1.0" >

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

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<meta-data
android:name="xposedmodule"
android:value="true" />
</application>

</manifest>
1 change: 1 addition & 0 deletions RedClock/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.robv.android.xposed.mods.redclock.RedClock
14 changes: 14 additions & 0 deletions RedClock/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt

# Project target.
target=android-15
Binary file added RedClock/res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RedClock/res/drawable-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RedClock/res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RedClock/res/drawable-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions RedClock/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Xposed: Red clock example</string>

</resources>
80 changes: 80 additions & 0 deletions RedClock/src/de/robv/android/xposed/mods/redclock/RedClock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package de.robv.android.xposed.mods.redclock;

import java.lang.reflect.Method;
import java.util.Iterator;

import android.graphics.Color;
import android.widget.TextView;
import de.robv.android.xposed.Callback;
import de.robv.android.xposed.MethodSignatureGuide;
import de.robv.android.xposed.XposedBridge;

/**
* Example module which changes the color of the clock in the statusbar to red and
* also appends a smiley to it. It does so by hooking the updateClock method of the
* Clock class in the systemui as soon as the com.android.systemui is being loaded.
* <br/>
* This demonstrates how a very central component can be modified without changing
* the APKs (including deodexing, recompiling, signing etc).
*/
public class RedClock {
private static Method methodGetText;
private static Method methodSetText;
private static Method methodSetTextColor;

/**
* @see MethodSignatureGuide#init
*/
public static void init(String startClassName) {
// only load for Zygote (the system process), not for command line tools
if (startClassName != null)
return;

try {
XposedBridge.hookLoadPackage(RedClock.class, "handleLoadPackage", Callback.PRIORITY_DEFAULT);
methodGetText = TextView.class.getDeclaredMethod("getText");
methodSetText = TextView.class.getDeclaredMethod("setText", CharSequence.class);
methodSetTextColor = TextView.class.getDeclaredMethod("setTextColor", Integer.TYPE);
} catch (Throwable t) {
XposedBridge.log(t);
}
}

/**
* @see MethodSignatureGuide#handleLoadPackage
*/
@SuppressWarnings("unused")
private static void handleLoadPackage(String packageName, ClassLoader classLoader) {
// the status bar belongs to package com.android.systemui
if (!packageName.equals("com.android.systemui"))
return;

try {
Method updateClock =
Class.forName("com.android.systemui.statusbar.policy.Clock", false, classLoader)
.getDeclaredMethod("updateClock");
XposedBridge.hookMethod(updateClock, RedClock.class, "handleUpdateClock", Callback.PRIORITY_DEFAULT);
} catch (Exception e) {
XposedBridge.log(e);
}
}

@SuppressWarnings("unused")
private static Object handleUpdateClock(Iterator<Callback> iterator, Method method, Object thisObject, Object[] args) throws Throwable {
if (XposedBridge.DEBUG)
XposedBridge.log("updating the clock");

// first let the original implementation perform its work
Object result = XposedBridge.callNext(iterator, method, thisObject, args);
// then change text and color
try {
String text = (String)methodGetText.invoke(thisObject);
methodSetText.invoke(thisObject, text + " :)");
methodSetTextColor.invoke(thisObject, Color.RED);
} catch (Exception e) {
// replacing did not work.. but no reason to crash the VM! Log the error and go on.
XposedBridge.log(e);
}
return result;
}
}

0 comments on commit efd0831

Please sign in to comment.