Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow location providers also outside of /system #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
com.thermatk.android.xf.fakegapps.FakeSignatures
com.thermatk.android.xf.fakegapps.PackageNameServiceHook
com.thermatk.android.xf.fakegapps.PackageNameServiceHook
com.thermatk.android.xf.fakegapps.NonSystemLocationProviders
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.thermatk.android.xf.fakegapps;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Binder;
import android.os.Build;
import android.os.PackageNameServiceManager;
import android.util.Log;

import com.android.server.PackageNameService;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

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

public final class NonSystemLocationProviders implements IXposedHookZygoteInit {
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
XposedBridge.hookAllMethods(XposedHelpers.findClass("android.app.ActivityThread", null),
"systemMain",
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
register(loader);
}
}
);
}
}

private static void register(ClassLoader loader) {
final Class<?> serviceWatcher = XposedHelpers.findClass("com.android.server.ServiceWatcher", loader);
XposedBridge.hookAllMethods(serviceWatcher, "getSignatureSets", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
Context context = (Context) param.args[0];
List<String> initialPackageNames = (List<String>) param.args[1];
PackageManager pm = context.getPackageManager();
ArrayList<HashSet<Signature>> sigSets = new ArrayList<>();
for (int i = 0, size = initialPackageNames.size(); i < size; i++) {
String pkg = initialPackageNames.get(i);
try {
HashSet<Signature> set = new HashSet<>();
Signature[] sigs = pm.getPackageInfo(pkg, PackageManager.GET_SIGNATURES).signatures;
set.addAll(Arrays.asList(sigs));
sigSets.add(set);
} catch (PackageManager.NameNotFoundException e) {
Log.w("ServiceWatcher", pkg + " not found");
}
}
param.setResult(sigSets);
}
});
}
}