Skip to content

Commit

Permalink
Added Xposed hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyPavlenko committed Mar 9, 2023
1 parent 283c0f7 commit f05862f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions fermata/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ dependencies {
implementation "com.google.android.play:core:${ANDROID_PLAY_CORE_VERSION}"
implementation 'androidx.tvprovider:tvprovider:1.0.0'
implementation 'com.google.guava:guava:31.0.1-android'
compileOnly 'de.robv.android.xposed:api:82'
}
15 changes: 15 additions & 0 deletions fermata/src/auto/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,23 @@
</intent>
</queries>


<application>

<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposeddescription"
android:value="Android Auto hooks" />
<meta-data
android:name="xposedminversion"
android:value="54" />
<meta-data
android:name="xposedscope"
android:resource="@array/xposedscope" />


<service
android:name="me.aap.fermata.media.service.FermataMediaService"
android:exported="true"
Expand Down
1 change: 1 addition & 0 deletions fermata/src/auto/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
me.aap.fermata.auto.Xposed
43 changes: 43 additions & 0 deletions fermata/src/auto/java/me/aap/fermata/auto/Xposed.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package me.aap.fermata.auto;

import static de.robv.android.xposed.XposedBridge.log;

import android.content.pm.InstallSourceInfo;
import android.content.pm.PackageManager;
import android.os.Build;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

/**
* @author Andrey Pavlenko
*/
public class Xposed implements IXposedHookLoadPackage {
private static final String AA_PKG = "com.google.android.projection.gearhead";
private static final String GPLAY_PKG = "com.android.vending";

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
if (!AA_PKG.equals(lpparam.packageName)) return;
log("Hooking package " + AA_PKG);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
XposedHelpers.findAndHookMethod(InstallSourceInfo.class, "getInitiatingPackageName", new XC_MethodHook() {

@Override
protected void afterHookedMethod(MethodHookParam param) {
param.setResult(GPLAY_PKG);
}
});
} else {
XposedHelpers.findAndHookMethod(PackageManager.class, "getInstallerPackageName", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
param.setResult(GPLAY_PKG);
}
});
}
}
}
6 changes: 6 additions & 0 deletions fermata/src/auto/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="xposedscope">
<item>com.google.android.projection.gearhead</item>
</string-array>
</resources>
1 change: 1 addition & 0 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-keepattributes LineNumberTable,SourceFile
-keepnames class me.aap.** { *; }
-keep class me.aap.fermata.auto.Xposed
-keep class org.videolan.libvlc.** { *; }
-keep class me.aap.fermata.vfs.sftp.** { *; }
-keep class me.aap.fermata.vfs.smb.** { *; }
Expand Down

0 comments on commit f05862f

Please sign in to comment.