Skip to content

Commit 609c025

Browse files
committed
Add some XPosed examples.
1 parent 416aa04 commit 609c025

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1184
-0
lines changed

xposed_samples/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

xposed_samples/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/codeStyles/Project.xml

+113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/dictionaries/yath.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/gradle.xml

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/inspectionProfiles/Project_Default.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

xposed_samples/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

xposed_samples/app/build.gradle

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 29
5+
buildToolsVersion "29.0.2"
6+
7+
aaptOptions {
8+
additionalParameters '-v'
9+
}
10+
11+
12+
defaultConfig {
13+
applicationId "de.yath.tvtool"
14+
minSdkVersion 15
15+
targetSdkVersion 29
16+
versionCode 1
17+
versionName "1.0"
18+
19+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20+
}
21+
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
29+
}
30+
31+
dependencies {
32+
implementation fileTree(dir: 'libs', include: ['*.jar'])
33+
34+
implementation 'androidx.appcompat:appcompat:1.1.0'
35+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
36+
testImplementation 'junit:junit:4.12'
37+
androidTestImplementation 'androidx.test:runner:1.2.0'
38+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
39+
40+
compileOnly 'de.robv.android.xposed:api:82'
41+
compileOnly 'de.robv.android.xposed:api:82:sources'
42+
// compileOnly files('/home/yath/tv/playtvapp2/app/libs/settings.jar')
43+
// compileOnly files('/home/yath/tv/playtvapp2/app/libs/channels.jar')
44+
}

xposed_samples/app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="de.yath.tvtool">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".SettingsActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
17+
</intent-filter>
18+
</activity>
19+
20+
<meta-data
21+
android:name="xposedmodule"
22+
android:value="true" />
23+
<meta-data
24+
android:name="xposeddescription"
25+
android:value="Property logger and overrider" />
26+
<meta-data
27+
android:name="xposedminversion"
28+
android:value="53" />
29+
</application>
30+
31+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
de.yath.tvtool.Main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package de.yath.tvtool;
2+
3+
import android.content.res.Resources;
4+
import android.graphics.Bitmap;
5+
import android.graphics.BitmapFactory;
6+
import android.graphics.drawable.BitmapDrawable;
7+
import android.util.Log;
8+
9+
import java.io.ByteArrayOutputStream;
10+
11+
import android.content.res.XModuleResources;
12+
import de.robv.android.xposed.IXposedHookInitPackageResources;
13+
import de.robv.android.xposed.IXposedHookLoadPackage;
14+
import de.robv.android.xposed.IXposedHookZygoteInit;
15+
import de.robv.android.xposed.XC_MethodHook;
16+
import de.robv.android.xposed.XposedHelpers;
17+
import de.robv.android.xposed.callbacks.XC_InitPackageResources.InitPackageResourcesParam;
18+
import de.robv.android.xposed.callbacks.XC_LoadPackage;
19+
20+
public class LogoPatcher implements IXposedHookZygoteInit, IXposedHookInitPackageResources, IXposedHookLoadPackage {
21+
private static final String TAG = "XposedTVLogoPatcher";
22+
private static final String RES_PKG = "org.droidtv.tvsystemui";
23+
private static final int RES_ORIG = 2130837518;
24+
private static String MODULE_PATH = null;
25+
26+
@Override
27+
public void initZygote(StartupParam startupParam) throws Throwable {
28+
MODULE_PATH = startupParam.modulePath;
29+
Log.d(TAG, "Will load replacement logo from "+MODULE_PATH);
30+
}
31+
32+
@Override
33+
public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
34+
if (!resparam.packageName.equals(RES_PKG))
35+
return;
36+
37+
Log.i(TAG, "Replacing startup_philips_logo in "+resparam.packageName+" with ours.");
38+
XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);
39+
resparam.res.setReplacement(RES_ORIG, modRes.fwd(R.drawable.startup_philips_logo_yath));
40+
}
41+
42+
43+
@Override
44+
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
45+
if (!lpparam.packageName.equals(RES_PKG))
46+
return;
47+
48+
// https://github.com/rovo89/XposedBridge/issues/65, except that our caller makes use of the
49+
// BitmapFactory.Options and ignoring them causes size calculations to fail.
50+
51+
Log.i(TAG, "Patching decodeResource(Resources, int, BitmapFactory.Options)");
52+
XposedHelpers.findAndHookMethod(BitmapFactory.class, "decodeResource", Resources.class, int.class, BitmapFactory.Options.class, new XC_MethodHook() {
53+
@Override
54+
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
55+
int id = (int)param.args[1];
56+
if(id == RES_ORIG) {
57+
Resources res = (Resources)param.args[0];
58+
BitmapFactory.Options options = (BitmapFactory.Options)param.args[2];
59+
60+
Bitmap b = ((BitmapDrawable)res.getDrawable(id)).getBitmap();
61+
62+
// We could return b now, except that we’d ignore the options. Therefore, marshal
63+
// the Bitmap to a PNG byte[] and use BitmapFactory.decodeByteArray() with our
64+
// caller’s options on this PNG.
65+
66+
ByteArrayOutputStream s = new ByteArrayOutputStream();
67+
b.compress(Bitmap.CompressFormat.PNG, 100, s);
68+
byte[] png = s.toByteArray();
69+
70+
Bitmap ret = BitmapFactory.decodeByteArray(png, 0, png.length, options);
71+
Log.i(TAG, "decodeResource called for RES_ORIG, returning decodeByteArray(byte["+png.length+"], "+options);
72+
param.setResult(ret);
73+
}
74+
}
75+
});
76+
}
77+
}

0 commit comments

Comments
 (0)