Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
Enable Google Assistant for Google app 6.6.14.21.arm64 (other version…
Browse files Browse the repository at this point in the history
…s will likely not work) (#1030)
  • Loading branch information
Maxr1998 authored and wasdennnoch committed Oct 11, 2016
1 parent f2b053a commit 4f14cce
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
74 changes: 74 additions & 0 deletions app/src/main/java/tk/wasdennnoch/androidn_ify/AssistantHooks.java
@@ -0,0 +1,74 @@
package tk.wasdennnoch.androidn_ify;

import android.content.SharedPreferences;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;

import static de.robv.android.xposed.XposedBridge.log;
import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookConstructor;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;

class AssistantHooks {

private static final String ASSISTANT_PACKAGE = "com.google.android.apps.gsa.assistant";

public static void hook(ClassLoader classLoader) {
try {
Class a = findClass(ASSISTANT_PACKAGE + ".a.e", classLoader);

findAndHookConstructor(a, findClass("com.google.android.apps.gsa.search.core.config.GsaConfigFlags", classLoader), SharedPreferences.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
callMethod(param.thisObject, "aG", true);
}
});

findAndHookMethod(a, "aG", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.args[0] = true;
}
});

findAndHookMethod(a, "pa", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return true;
}
});

findAndHookMethod(a, "pb", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return true;
}
});

findAndHookMethod(a, "pc", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return true;
}
});

findAndHookMethod(a, "oY", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return true;
}
});

findAndHookMethod(a, "oZ", new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
return true;
}
});
} catch (Throwable t) {
log(t);
}
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/tk/wasdennnoch/androidn_ify/XposedHook.java
Expand Up @@ -55,6 +55,7 @@ public class XposedHook implements IXposedHookLoadPackage, IXposedHookZygoteInit
public static final String PACKAGE_SYSTEMUI = "com.android.systemui";
public static final String PACKAGE_SETTINGS = "com.android.settings";
public static final String PACKAGE_PHONE = "com.android.phone";
public static final String PACKAGE_GOOGLE = "com.google.android.googlequicksearchbox";
public static final String PACKAGE_OWN = "tk.wasdennnoch.androidn_ify";
public static final String SETTINGS_OWN = PACKAGE_OWN + ".ui.SettingsActivity";

Expand Down Expand Up @@ -163,6 +164,9 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
if (!sPrefs.getBoolean("can_read_prefs", false))
XposedHelpers.findAndHookMethod(SETTINGS_OWN, lpparam.classLoader, "isPrefsFileReadable", XC_MethodReplacement.returnConstant(false));
break;
case PACKAGE_GOOGLE:
AssistantHooks.hook(lpparam.classLoader);
break;
}

// Has to be hooked in every app as every app creates own instances of the Notification.Builder
Expand Down

0 comments on commit 4f14cce

Please sign in to comment.