**
**/
package com.morgoo.droidplugin.core;
import android.content.Context;
import android.os.Environment;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* 插件目录结构
* 基本目录: /data/data/com.HOST.PACKAGE/Plugin
* 单个插件的基本目录: /data/data/com.HOST.PACKAGE/Plugin
* source_dir: /data/data/com.HOST.PACKAGE/Plugin/PLUGIN.PKG/apk/apk-1.apk
* 数据目录: /data/data/com.HOST.PACKAGE/Plugin/PLUGIN.PKG/data/PLUGIN.PKG
* dex缓存目录: /data/data/com.HOST.PACKAGE/Plugin/PLUGIN.PKG/dalvik-cache/
*
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/2/5.
*/
public class PluginDirHelper {
private static File sBaseDir = null;
private static void init(Context context) {
if (sBaseDir == null) {
sBaseDir = new File(context.getCacheDir().getParentFile(), "Plugin");
enforceDirExists(sBaseDir);
}
}
private static String enforceDirExists(File file) {
if (!file.exists()) {
file.mkdirs();
}
return file.getPath();
}
public static String makePluginBaseDir(Context context, String pluginInfoPackageName) {
init(context);
return enforceDirExists(new File(sBaseDir, pluginInfoPackageName));
}
public static String getBaseDir(Context context) {
init(context);
return enforceDirExists(sBaseDir);
}
public static String getPluginDataDir(Context context, String pluginInfoPackageName) {
return enforceDirExists(new File(makePluginBaseDir(context, pluginInfoPackageName), "data/" + pluginInfoPackageName));
}
public static String getPluginSignatureDir(Context context, String pluginInfoPackageName) {
return enforceDirExists(new File(makePluginBaseDir(context, pluginInfoPackageName), "Signature/"));
}
public static String getPluginSignatureFile(Context context, String pluginInfoPackageName, int index) {
return new File(getPluginSignatureDir(context, pluginInfoPackageName), String.format("Signature_%s.key", index)).getPath();
}
public static List getPluginSignatureFiles(Context context, String pluginInfoPackageName) {
ArrayList files = new ArrayList();
String dir = getPluginSignatureDir(context, pluginInfoPackageName);
File d = new File(dir);
File[] fs = d.listFiles();
if (fs != null && fs.length > 0) {
for (File f : fs) {
files.add(f.getPath());
}
}
return files;
}
public static String getPluginApkDir(Context context, String pluginInfoPackageName) {
return enforceDirExists(new File(makePluginBaseDir(context, pluginInfoPackageName), "apk"));
}
public static String getPluginApkFile(Context context, String pluginInfoPackageName) {
return new File(getPluginApkDir(context, pluginInfoPackageName), "base-1.apk").getPath();
}
public static String getPluginDalvikCacheDir(Context context, String pluginInfoPackageName) {
return enforceDirExists(new File(makePluginBaseDir(context, pluginInfoPackageName), "dalvik-cache"));
}
public static String getPluginNativeLibraryDir(Context context, String pluginInfoPackageName) {
return enforceDirExists(new File(makePluginBaseDir(context, pluginInfoPackageName), "lib"));
}
public static String getPluginDalvikCacheFile(Context context, String pluginInfoPackageName) {
String dalvikCacheDir = getPluginDalvikCacheDir(context, pluginInfoPackageName);
String pluginApkFile = getPluginApkFile(context, pluginInfoPackageName);
String apkName = new File(pluginApkFile).getName();
String dexName = apkName.replace(File.separator, "@");
if (dexName.startsWith("@")) {
dexName = dexName.substring(1);
}
return new File(dalvikCacheDir, dexName + "@classes.dex").getPath();
}
public static String getContextDataDir(Context context) {
String dataDir = new File(Environment.getDataDirectory(), "data/").getPath();
return new File(dataDir, context.getPackageName()).getPath();
}
public static void cleanOptimizedDirectory(String optimizedDirectory) {
try {
File dir = new File(optimizedDirectory);
if (dir.exists() && dir.isDirectory()) {
File[] files = dir.listFiles();
if (files != null && files.length > 0) {
for (File f : files) {
f.delete();
}
}
}
if (dir.exists() && dir.isFile()) {
dir.delete();
dir.mkdirs();
}
} catch (Throwable e) {
}
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/core/PluginProcessManager.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.core;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ServiceInfo;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.morgoo.droidplugin.hook.HookFactory;
import com.morgoo.droidplugin.pm.PluginManager;
import com.morgoo.droidplugin.reflect.FieldUtils;
import com.morgoo.droidplugin.reflect.MethodUtils;
import com.morgoo.droidplugin.stub.ActivityStub;
import com.morgoo.droidplugin.stub.ServiceStub;
import com.morgoo.helper.compat.ActivityThreadCompat;
import com.morgoo.helper.compat.CompatibilityInfoCompat;
import com.morgoo.helper.Log;
import com.morgoo.helper.compat.ProcessCompat;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/2/4.
*/
public class PluginProcessManager {
private static final String TAG = "PluginProcessManager";
private static String sCurrentProcessName;
private static Object sGetCurrentProcessNameLock = new Object();
private static Map sPluginClassLoaderCache = new WeakHashMap(1);
private static Map sPluginLoadedApkCache = new WeakHashMap(1);
public static String getCurrentProcessName(Context context) {
if (context == null)
return sCurrentProcessName;
synchronized (sGetCurrentProcessNameLock) {
if (sCurrentProcessName == null) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List infos = activityManager.getRunningAppProcesses();
if (infos == null)
return null;
for (RunningAppProcessInfo info : infos) {
if (info.pid == android.os.Process.myPid()) {
sCurrentProcessName = info.processName;
return sCurrentProcessName;
}
}
}
}
return sCurrentProcessName;
}
private static List sProcessList = new ArrayList<>();
private static void initProcessList(Context context) {
try {
if (sProcessList.size() > 0) {
return;
}
sProcessList.add(context.getPackageName());
PackageManager pm = context.getPackageManager();
PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_RECEIVERS | PackageManager.GET_ACTIVITIES | PackageManager.GET_PROVIDERS | PackageManager.GET_SERVICES);
if (packageInfo.receivers != null) {
for (ActivityInfo info : packageInfo.receivers) {
if (!sProcessList.contains(info.processName)) {
sProcessList.add(info.processName);
}
}
}
if (packageInfo.providers != null) {
for (ProviderInfo info : packageInfo.providers) {
if (!sProcessList.contains(info.processName) && info.processName != null && info.authority != null && info.authority.indexOf(PluginManager.STUB_AUTHORITY_NAME) < 0) {
sProcessList.add(info.processName);
}
}
}
if (packageInfo.services != null) {
for (ServiceInfo info : packageInfo.services) {
if (!sProcessList.contains(info.processName) && info.processName != null && info.name != null && info.name.indexOf(ServiceStub.class.getSimpleName()) < 0) {
sProcessList.add(info.processName);
}
}
}
if (packageInfo.activities != null) {
for (ActivityInfo info : packageInfo.activities) {
if (!sProcessList.contains(info.processName) && info.processName != null && info.name != null && info.name.indexOf(ActivityStub.class.getSimpleName()) < 0) {
sProcessList.add(info.processName);
}
}
}
} catch (PackageManager.NameNotFoundException e) {
}
}
public static final boolean isPluginProcess(Context context) {
String currentProcessName = getCurrentProcessName(context);
if (TextUtils.equals(currentProcessName, context.getPackageName()))
return false;
initProcessList(context);
return !sProcessList.contains(currentProcessName);
}
public static ClassLoader getPluginClassLoader(String pkg) throws IllegalAccessException, NoSuchMethodException, ClassNotFoundException, InvocationTargetException {
ClassLoader classLoader = sPluginClassLoaderCache.get(pkg);
if (classLoader == null) {
Application app = getPluginContext(pkg);
if (app != null) {
sPluginClassLoaderCache.put(app.getPackageName(), app.getClassLoader());
}
}
return sPluginClassLoaderCache.get(pkg);
}
public static void preLoadApk(Context hostContext, ComponentInfo pluginInfo) throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, PackageManager.NameNotFoundException, ClassNotFoundException {
if (pluginInfo == null && hostContext == null) {
return;
}
if (pluginInfo != null && getPluginContext(pluginInfo.packageName) != null) {
return;
}
/*添加插件的LoadedApk对象到ActivityThread.mPackages*/
boolean found = false;
synchronized (sPluginLoadedApkCache) {
Object object = ActivityThreadCompat.currentActivityThread();
if (object != null) {
Object mPackagesObj = FieldUtils.readField(object, "mPackages");
Object containsKeyObj = MethodUtils.invokeMethod(mPackagesObj, "containsKey", pluginInfo.packageName);
if (containsKeyObj instanceof Boolean && !(Boolean) containsKeyObj) {
final Object loadedApk;
if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
loadedApk = MethodUtils.invokeMethod(object, "getPackageInfoNoCheck", pluginInfo.applicationInfo, CompatibilityInfoCompat.DEFAULT_COMPATIBILITY_INFO());
} else {
loadedApk = MethodUtils.invokeMethod(object, "getPackageInfoNoCheck", pluginInfo.applicationInfo);
}
sPluginLoadedApkCache.put(pluginInfo.packageName, loadedApk);
/*添加ClassLoader LoadedApk.mClassLoader*/
String optimizedDirectory = PluginDirHelper.getPluginDalvikCacheDir(hostContext, pluginInfo.packageName);
String libraryPath = PluginDirHelper.getPluginNativeLibraryDir(hostContext, pluginInfo.packageName);
String apk = pluginInfo.applicationInfo.publicSourceDir;
if (TextUtils.isEmpty(apk)) {
pluginInfo.applicationInfo.publicSourceDir = PluginDirHelper.getPluginApkFile(hostContext, pluginInfo.packageName);
apk = pluginInfo.applicationInfo.publicSourceDir;
}
if (apk != null) {
ClassLoader classloader = null;
try {
classloader = new PluginClassLoader(apk, optimizedDirectory, libraryPath, hostContext.getClassLoader().getParent());
} catch (Exception e) {
}
if(classloader==null){
PluginDirHelper.cleanOptimizedDirectory(optimizedDirectory);
classloader = new PluginClassLoader(apk, optimizedDirectory, libraryPath, hostContext.getClassLoader().getParent());
}
synchronized (loadedApk) {
FieldUtils.writeDeclaredField(loadedApk, "mClassLoader", classloader);
}
sPluginClassLoaderCache.put(pluginInfo.packageName, classloader);
Thread.currentThread().setContextClassLoader(classloader);
found = true;
}
ProcessCompat.setArgV0(pluginInfo.processName);
}
}
}
if (found) {
PluginProcessManager.preMakeApplication(hostContext, pluginInfo);
}
}
private static AtomicBoolean mExec = new AtomicBoolean(false);
private static Handler sHandle = new Handler(Looper.getMainLooper());
private static void preMakeApplication(Context hostContext, ComponentInfo pluginInfo) {
try {
final Object loadedApk = sPluginLoadedApkCache.get(pluginInfo.packageName);
if (loadedApk != null) {
Object mApplication = FieldUtils.readField(loadedApk, "mApplication");
if (mApplication != null) {
return;
}
if (Looper.getMainLooper() != Looper.myLooper()) {
final Object lock = new Object();
mExec.set(false);
sHandle.post(new Runnable() {
@Override
public void run() {
try {
MethodUtils.invokeMethod(loadedApk, "makeApplication", false, ActivityThreadCompat.getInstrumentation());
} catch (Exception e) {
Log.e(TAG, "preMakeApplication FAIL", e);
} finally {
mExec.set(true);
synchronized (lock) {
lock.notifyAll();
}
}
}
});
if (!mExec.get()) {
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException e) {
}
}
}
} else {
MethodUtils.invokeMethod(loadedApk, "makeApplication", false, ActivityThreadCompat.getInstrumentation());
}
}
} catch (Exception e) {
Log.e(TAG, "preMakeApplication FAIL", e);
}
}
public static void registerStaticReceiver(Context context, ApplicationInfo pluginApplicationInfo, ClassLoader cl) throws Exception {
List infos = PluginManager.getInstance().getReceivers(pluginApplicationInfo.packageName, 0);
if (infos != null && infos.size() > 0) {
CharSequence myPname = null;
try {
myPname = PluginManager.getInstance().getProcessNameByPid(android.os.Process.myPid());
} catch (Exception e) {
}
for (ActivityInfo info : infos) {
if (TextUtils.equals(info.processName, myPname)) {
try {
List filters = PluginManager.getInstance().getReceiverIntentFilter(info);
for (IntentFilter filter : filters) {
BroadcastReceiver receiver = (BroadcastReceiver) cl.loadClass(info.name).newInstance();
context.registerReceiver(receiver, filter);
}
} catch (Exception e) {
Log.e(TAG, "registerStaticReceiver error=%s", e, info.name);
}
}
}
}
}
public static void setHookEnable(boolean enable) {
HookFactory.getInstance().setHookEnable(enable);
}
public static void setHookEnable(boolean enable, boolean reinstallHook) {
HookFactory.getInstance().setHookEnable(enable, reinstallHook);
}
public static void installHook(Context hostContext) throws Throwable {
HookFactory.getInstance().installHook(hostContext, null);
}
private static HashMap sApplicationsCache = new HashMap(2);
public static Application getPluginContext(String packageName) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException {
if (!sApplicationsCache.containsKey(packageName)) {
Object at = ActivityThreadCompat.currentActivityThread();
Object mAllApplications = FieldUtils.readField(at, "mAllApplications");
if (mAllApplications instanceof List) {
List apps = (List) mAllApplications;
for (Object o : apps) {
if (o instanceof Application) {
Application app = (Application) o;
if (!sApplicationsCache.containsKey(app.getPackageName())) {
sApplicationsCache.put(app.getPackageName(), app);
}
}
}
}
}
return sApplicationsCache.get(packageName);
}
private static Context getBaseContext(Context c) {
if (c instanceof ContextWrapper) {
return ((ContextWrapper) c).getBaseContext();
}
return c;
}
private static WeakHashMap mFakedContext = new WeakHashMap(1);
private static Object mServiceCache = null;
private static List sSkipService = new ArrayList();
static {
sSkipService.add(Context.LAYOUT_INFLATER_SERVICE);
sSkipService.add(Context.NOTIFICATION_SERVICE);
sSkipService.add("storage");
sSkipService.add("accessibility");
sSkipService.add("audio");
sSkipService.add("clipboard");
sSkipService.add("media_router");
sSkipService.add("wifi");
sSkipService.add("captioning");
sSkipService.add("account");
sSkipService.add("activity");
//fake这个wifiscanner服务可能会导致部分手机重启。例如三星,华为
sSkipService.add("wifiscanner");
sSkipService.add("rttmanager");
sSkipService.add("tv_input");
sSkipService.add("jobscheduler");
sSkipService.add("sensorhub");
//NSDManager init初始化anr的问题
sSkipService.add("servicediscovery");
// sSkipService.add("usagestats");
}
private static void fakeSystemServiceInner(Context hostContext, Context targetContext) {
try {
Context baseContext = getBaseContext(targetContext);
if (mFakedContext.containsValue(baseContext)) {
return;
} else if (mServiceCache != null) {
FieldUtils.writeField(baseContext, "mServiceCache", mServiceCache);
//for context ContentResolver
ContentResolver cr = baseContext.getContentResolver();
if (cr != null) {
Object crctx = FieldUtils.readField(cr, "mContext");
if (crctx != null) {
FieldUtils.writeField(crctx, "mServiceCache", mServiceCache);
}
}
if (!mFakedContext.containsValue(baseContext)) {
mFakedContext.put(baseContext.hashCode(), baseContext);
}
return;
}
Object SYSTEM_SERVICE_MAP = null;
try {
SYSTEM_SERVICE_MAP = FieldUtils.readStaticField(baseContext.getClass(), "SYSTEM_SERVICE_MAP");
} catch (Exception e) {
Log.w(TAG, "readStaticField(SYSTEM_SERVICE_MAP) from %s fail", e, baseContext.getClass());
}
if (SYSTEM_SERVICE_MAP == null) {
try {
SYSTEM_SERVICE_MAP = FieldUtils.readStaticField(Class.forName("android.app.SystemServiceRegistry"), "SYSTEM_SERVICE_FETCHERS");
} catch (Exception e) {
Log.e(TAG, "readStaticField(SYSTEM_SERVICE_FETCHERS) from android.app.SystemServiceRegistry fail", e);
}
}
if (SYSTEM_SERVICE_MAP != null && (SYSTEM_SERVICE_MAP instanceof Map)) {
//如没有,则创建一个新的。
Map, ?> sSYSTEM_SERVICE_MAP = (Map, ?>) SYSTEM_SERVICE_MAP;
Context originContext = getBaseContext(hostContext);
Object mServiceCache = FieldUtils.readField(originContext, "mServiceCache");
if (mServiceCache instanceof List) {
((List) mServiceCache).clear();
}
for (Object key : sSYSTEM_SERVICE_MAP.keySet()) {
if (sSkipService.contains(key)) {
continue;
}
Object serviceFetcher = sSYSTEM_SERVICE_MAP.get(key);
try {
Method getService = serviceFetcher.getClass().getMethod("getService", baseContext.getClass());
getService.invoke(serviceFetcher, originContext);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause != null) {
Log.w(TAG, "Fake system service faile", e);
} else {
Log.w(TAG, "Fake system service faile", e);
}
} catch (Exception e) {
Log.w(TAG, "Fake system service faile", e);
}
}
mServiceCache = FieldUtils.readField(originContext, "mServiceCache");
FieldUtils.writeField(baseContext, "mServiceCache", mServiceCache);
//for context ContentResolver
ContentResolver cr = baseContext.getContentResolver();
if (cr != null) {
Object crctx = FieldUtils.readField(cr, "mContext");
if (crctx != null) {
FieldUtils.writeField(crctx, "mServiceCache", mServiceCache);
}
}
}
if (!mFakedContext.containsValue(baseContext)) {
mFakedContext.put(baseContext.hashCode(), baseContext);
}
} catch (Exception e) {
Log.e(TAG, "fakeSystemServiceOldAPI", e);
}
}
//这里为了解决某些插件调用系统服务时,系统服务必须要求要以host包名的身份去调用的问题。
public static void fakeSystemService(Context hostContext, Context targetContext) {
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1 && !TextUtils.equals(hostContext.getPackageName(), targetContext.getPackageName())) {
long b = System.currentTimeMillis();
fakeSystemServiceInner(hostContext, targetContext);
Log.i(TAG, "Fake SystemService for originContext=%s context=%s,cost %s ms", targetContext.getPackageName(), targetContext.getPackageName(), (System.currentTimeMillis() - b));
}
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/BaseHookHandle.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook;
import android.content.Context;
import com.morgoo.helper.Log;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/2/28.
*/
public abstract class BaseHookHandle {
protected Context mHostContext;
protected Map sHookedMethodHandlers = new HashMap(5);
public BaseHookHandle(Context hostContext) {
mHostContext = hostContext;
init();
}
protected abstract void init();
public Set getHookedMethodNames(){
return sHookedMethodHandlers.keySet();
}
public HookedMethodHandler getHookedMethodHandler(Method method) {
if (method != null) {
return sHookedMethodHandlers.get(method.getName());
} else {
return null;
}
}
protected Class> getHookedClass() throws ClassNotFoundException {
return null;
}
protected HookedMethodHandler newBaseHandler() throws ClassNotFoundException {
return null;
}
protected void addAllMethodFromHookedClass(){
try {
Class clazz = getHookedClass();
if(clazz!=null){
Method[] methods = clazz.getDeclaredMethods();
if(methods!=null && methods.length>0){
for (Method method : methods) {
if(Modifier.isPublic(method.getModifiers()) && !sHookedMethodHandlers.containsKey(method.getName())){
sHookedMethodHandlers.put(method.getName(),newBaseHandler());
}
}
}
}
} catch (ClassNotFoundException e) {
Log.w(getClass().getSimpleName(),"init addAllMethodFromHookedClass error",e);
}
};
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/Hook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook;
import android.content.Context;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/2.
*/
public abstract class Hook {
private boolean mEnable = false;
protected Context mHostContext;
protected BaseHookHandle mHookHandles;
public void setEnable(boolean enable, boolean reInstallHook) {
this.mEnable = enable;
}
public final void setEnable(boolean enable) {
setEnable(enable, false);
}
public boolean isEnable() {
return mEnable;
}
protected Hook(Context hostContext) {
mHostContext = hostContext;
mHookHandles = createHookHandle();
}
protected abstract BaseHookHandle createHookHandle();
protected abstract void onInstall(ClassLoader classLoader) throws Throwable;
protected void onUnInstall(ClassLoader classLoader) throws Throwable {
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/HookFactory.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import com.morgoo.droidplugin.hook.binder.IAppOpsServiceBinderHook;
import com.morgoo.droidplugin.hook.binder.IAudioServiceBinderHook;
import com.morgoo.droidplugin.hook.binder.IClipboardBinderHook;
import com.morgoo.droidplugin.hook.binder.IContentServiceBinderHook;
import com.morgoo.droidplugin.hook.binder.IDisplayManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.IGraphicsStatsBinderHook;
import com.morgoo.droidplugin.hook.binder.IInputMethodManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.ILocationManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.IMediaRouterServiceBinderHook;
import com.morgoo.droidplugin.hook.binder.IMmsBinderHook;
import com.morgoo.droidplugin.hook.binder.IMountServiceBinderHook;
import com.morgoo.droidplugin.hook.binder.INotificationManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.IPhoneSubInfoBinderHook;
import com.morgoo.droidplugin.hook.binder.ISearchManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.ISessionManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.ISmsBinderHook;
import com.morgoo.droidplugin.hook.binder.ISubBinderHook;
import com.morgoo.droidplugin.hook.binder.ITelephonyBinderHook;
import com.morgoo.droidplugin.hook.binder.ITelephonyRegistryBinderHook;
import com.morgoo.droidplugin.hook.binder.IWifiManagerBinderHook;
import com.morgoo.droidplugin.hook.binder.IWindowManagerBinderHook;
import com.morgoo.droidplugin.hook.proxy.IActivityManagerHook;
import com.morgoo.droidplugin.hook.proxy.IPackageManagerHook;
import com.morgoo.droidplugin.hook.proxy.InstrumentationHook;
import com.morgoo.droidplugin.hook.proxy.LibCoreHook;
import com.morgoo.droidplugin.hook.proxy.PluginCallbackHook;
import com.morgoo.droidplugin.hook.xhook.SQLiteDatabaseHook;
import com.morgoo.helper.Log;
import com.morgoo.helper.utils.ProcessUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/2.
*/
public class HookFactory {
private static final String TAG = HookFactory.class.getSimpleName();
private static HookFactory sInstance = null;
private HookFactory() {
}
public static HookFactory getInstance() {
synchronized (HookFactory.class) {
if (sInstance == null) {
sInstance = new HookFactory();
}
}
return sInstance;
}
private List mHookList = new ArrayList(3);
public void setHookEnable(boolean enable) {
synchronized (mHookList) {
for (Hook hook : mHookList) {
hook.setEnable(enable);
}
}
}
public void setHookEnable(boolean enable, boolean reinstallHook) {
synchronized (mHookList) {
for (Hook hook : mHookList) {
hook.setEnable(enable, reinstallHook);
}
}
}
public void setHookEnable(Class hookClass, boolean enable) {
synchronized (mHookList) {
for (Hook hook : mHookList) {
if (hookClass.isInstance(hook)) {
hook.setEnable(enable);
}
}
}
}
public void installHook(Hook hook, ClassLoader cl) {
try {
hook.onInstall(cl);
synchronized (mHookList) {
mHookList.add(hook);
}
} catch (Throwable throwable) {
Log.e(TAG, "installHook %s error", throwable, hook);
}
}
public final void installHook(Context context, ClassLoader classLoader) throws Throwable {
if (ProcessUtils.isMainProcess(context)) {
installHook(new IActivityManagerHook(context), classLoader);
installHook(new IPackageManagerHook(context), classLoader);
} else {
installHook(new IClipboardBinderHook(context), classLoader);
//for ISearchManager
installHook(new ISearchManagerBinderHook(context), classLoader);
//for INotificationManager
installHook(new INotificationManagerBinderHook(context), classLoader);
installHook(new IMountServiceBinderHook(context), classLoader);
installHook(new IAudioServiceBinderHook(context), classLoader);
installHook(new IContentServiceBinderHook(context), classLoader);
installHook(new IWindowManagerBinderHook(context), classLoader);
if (VERSION.SDK_INT > VERSION_CODES.LOLLIPOP_MR1) {
installHook(new IGraphicsStatsBinderHook(context), classLoader);
}
// if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
// installHook(new WebViewFactoryProviderHook(context), classLoader);
// }
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
installHook(new IMediaRouterServiceBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
installHook(new ISessionManagerBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
installHook(new IWifiManagerBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2) {
installHook(new IInputMethodManagerBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new ILocationManagerBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new ITelephonyRegistryBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new ISubBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new IPhoneSubInfoBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new ITelephonyBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new ISmsBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
installHook(new IMmsBinderHook(context), classLoader);
}
if (VERSION.SDK_INT >= VERSION_CODES.M) {
installHook(new IAppOpsServiceBinderHook(context), classLoader);
}
installHook(new IActivityManagerHook(context), classLoader);
installHook(new IPackageManagerHook(context), classLoader);
installHook(new PluginCallbackHook(context), classLoader);
installHook(new InstrumentationHook(context), classLoader);
installHook(new LibCoreHook(context), classLoader);
installHook(new SQLiteDatabaseHook(context), classLoader);
installHook(new IDisplayManagerBinderHook(context), classLoader);
}
}
public final void onCallApplicationOnCreate(Context context, Application app) {
installHook(new SQLiteDatabaseHook(context), app.getClassLoader());
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/HookedMethodHandler.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook;
import android.content.Context;
import com.morgoo.helper.Log;
import java.lang.reflect.Method;
public class HookedMethodHandler {
private static final String TAG = HookedMethodHandler.class.getSimpleName();
protected final Context mHostContext;
private Object mFakedResult = null;
private boolean mUseFakedResult = false;
public HookedMethodHandler(Context hostContext) {
this.mHostContext = hostContext;
}
public synchronized Object doHookInner(Object receiver, Method method, Object[] args) throws Throwable {
long b = System.currentTimeMillis();
try {
mUseFakedResult = false;
mFakedResult = null;
boolean suc = beforeInvoke(receiver, method, args);
Object invokeResult = null;
if (!suc) {
invokeResult = method.invoke(receiver, args);
}
afterInvoke(receiver, method, args, invokeResult);
if (mUseFakedResult) {
return mFakedResult;
} else {
return invokeResult;
}
} finally {
long time = System.currentTimeMillis() - b;
if (time > 5) {
Log.i(TAG, "doHookInner method(%s.%s) cost %s ms", method.getDeclaringClass().getName(), method.getName(), time);
}
}
}
public void setFakedResult(Object fakedResult) {
this.mFakedResult = fakedResult;
mUseFakedResult = true;
}
/**
* 在某个方法被调用之前执行,如果返回true,则不执行原始的方法,否则执行原始方法
*/
protected boolean beforeInvoke(Object receiver, Method method, Object[] args) throws Throwable {
return false;
}
protected void afterInvoke(Object receiver, Method method, Object[] args, Object invokeResult) throws Throwable {
}
public boolean isFakedResult() {
return mUseFakedResult;
}
public Object getFakedResult() {
return mFakedResult;
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/BinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.text.TextUtils;
import com.morgoo.droidplugin.hook.Hook;
import com.morgoo.droidplugin.hook.HookedMethodHandler;
import com.morgoo.droidplugin.reflect.Utils;
import com.morgoo.helper.MyProxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/2.
*/
abstract class BinderHook extends Hook implements InvocationHandler {
private Object mOldObj;
public BinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
if (!isEnable()) {
return method.invoke(mOldObj, args);
}
HookedMethodHandler hookedMethodHandler = mHookHandles.getHookedMethodHandler(method);
if (hookedMethodHandler != null) {
return hookedMethodHandler.doHookInner(mOldObj, method, args);
} else {
return method.invoke(mOldObj, args);
}
} catch (InvocationTargetException e) {
Throwable cause = e.getTargetException();
if (cause != null && MyProxy.isMethodDeclaredThrowable(method, cause)) {
throw cause;
} else if (cause != null) {
RuntimeException runtimeException = !TextUtils.isEmpty(cause.getMessage()) ? new RuntimeException(cause.getMessage()) : new RuntimeException();
runtimeException.initCause(cause);
throw runtimeException;
} else {
RuntimeException runtimeException = !TextUtils.isEmpty(e.getMessage()) ? new RuntimeException(e.getMessage()) : new RuntimeException();
runtimeException.initCause(e);
throw runtimeException;
}
} catch (IllegalArgumentException e) {
try {
StringBuilder sb = new StringBuilder();
sb.append(" DROIDPLUGIN{");
if (method != null) {
sb.append("method[").append(method.toString()).append("]");
} else {
sb.append("method[").append("NULL").append("]");
}
if (args != null) {
sb.append("args[").append(Arrays.toString(args)).append("]");
} else {
sb.append("args[").append("NULL").append("]");
}
sb.append("}");
String message = e.getMessage() + sb.toString();
throw new IllegalArgumentException(message, e);
} catch (Throwable e1) {
throw e;
}
} catch (Throwable e) {
if (MyProxy.isMethodDeclaredThrowable(method, e)) {
throw e;
} else {
RuntimeException runtimeException = !TextUtils.isEmpty(e.getMessage()) ? new RuntimeException(e.getMessage()) : new RuntimeException();
runtimeException.initCause(e);
throw runtimeException;
}
}
}
abstract Object getOldObj() throws Exception;
void setOldObj(Object mOldObj) {
this.mOldObj = mOldObj;
}
public abstract String getServiceName();
@Override
protected void onInstall(ClassLoader classLoader) throws Throwable {
new ServiceManagerCacheBinderHook(mHostContext, getServiceName()).onInstall(classLoader);
mOldObj = getOldObj();
Class> clazz = mOldObj.getClass();
List> interfaces = Utils.getAllInterfaces(clazz);
Class[] ifs = interfaces != null && interfaces.size() > 0 ? interfaces.toArray(new Class[interfaces.size()]) : new Class[0];
Object proxiedObj = MyProxy.newProxyInstance(clazz.getClassLoader(), ifs, this);
MyServiceManager.addProxiedObj(getServiceName(), proxiedObj);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IAppOpsServiceBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IAppOpsServiceHookHandle;
import com.morgoo.helper.compat.IAppOpsServiceCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on on 16/5/11.
*/
public class IAppOpsServiceBinderHook extends BinderHook{
private static final String SERVICE_NAME = Context.APP_OPS_SERVICE;
public IAppOpsServiceBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IAppOpsServiceCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IAppOpsServiceHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IAudioServiceBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IAudioServiceHookHandle;
import com.morgoo.helper.compat.IAudioServiceCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/6.
*/
public class IAudioServiceBinderHook extends BinderHook {
private final static String SERVICE_NAME = Context.AUDIO_SERVICE;
public IAudioServiceBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IAudioServiceCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IAudioServiceHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IClipboardBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IClipboardHookHandle;
import com.morgoo.helper.compat.IClipboardCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/6.
*/
public class IClipboardBinderHook extends BinderHook {
private final static String CLIPBOARD_SERVICE = "clipboard";
public IClipboardBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception{
IBinder iBinder = MyServiceManager.getOriginService(CLIPBOARD_SERVICE);
return IClipboardCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return CLIPBOARD_SERVICE;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IClipboardHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IContentServiceBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IContentServiceHandle;
import com.morgoo.helper.compat.IContentServiceCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/5/21.
*/
public class IContentServiceBinderHook extends BinderHook {
private static final String CONTENT_SERVICE_NAME = "content";
public IContentServiceBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(CONTENT_SERVICE_NAME);
return IContentServiceCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return CONTENT_SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IContentServiceHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IDisplayManagerBinderHook.java
================================================
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IDisplayManagerHookHandle;
import com.morgoo.droidplugin.reflect.FieldUtils;
import com.morgoo.droidplugin.reflect.MethodUtils;
import com.morgoo.helper.compat.IDisplayManagerCompat;
/**
* IDisplayManagerBinderHook
*
* @author Liu Yichen
* @date 16/6/13
*/
public class IDisplayManagerBinderHook extends BinderHook {
private static final String TAG = IDisplayManagerBinderHook.class.getSimpleName();
private static final String SERVICE_NAME = Context.DISPLAY_SERVICE;
public IDisplayManagerBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IDisplayManagerCompat.asInterface(iBinder);
}
@Override
protected void onInstall(ClassLoader classLoader) throws Throwable {
super.onInstall(classLoader);
Class displayManagerGlobalClass = Class.forName("android.hardware.display.DisplayManagerGlobal");
Object displayManagerGlobal = MethodUtils.invokeStaticMethod(displayManagerGlobalClass, "getInstance");
FieldUtils.writeField(displayManagerGlobal, "mDm", MyServiceManager.getProxiedObj(SERVICE_NAME));
}
@Override
protected BaseHookHandle createHookHandle() {
return new IDisplayManagerHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IGraphicsStatsBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IClipboardHookHandle;
import com.morgoo.droidplugin.hook.handle.IGraphicsStatsHookHandle;
import com.morgoo.helper.compat.IClipboardCompat;
import com.morgoo.helper.compat.IGraphicsStatsCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/6/18.
*/
public class IGraphicsStatsBinderHook extends BinderHook {
private final static String SERVICE_NAME = "graphicsstats";
public IGraphicsStatsBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception{
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IGraphicsStatsCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IGraphicsStatsHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IInputMethodManagerBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import android.view.inputmethod.InputMethodManager;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IAudioServiceHookHandle;
import com.morgoo.droidplugin.hook.handle.IInputMethodManagerHookHandle;
import com.morgoo.droidplugin.reflect.FieldUtils;
import com.morgoo.helper.compat.IAudioServiceCompat;
import com.morgoo.helper.compat.IInputMethodManagerCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/6/4.
*/
public class IInputMethodManagerBinderHook extends BinderHook {
private final static String SERVICE_NAME = Context.INPUT_METHOD_SERVICE;
public IInputMethodManagerBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IInputMethodManagerCompat.asInterface(iBinder);
}
@Override
protected void onInstall(ClassLoader classLoader) throws Throwable {
super.onInstall(classLoader);
Object obj = FieldUtils.readStaticField(InputMethodManager.class, "sInstance");
if (obj != null) {
FieldUtils.writeStaticField(InputMethodManager.class, "sInstance", null);
}
mHostContext.getSystemService(Context.INPUT_METHOD_SERVICE);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IInputMethodManagerHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ILocationManagerBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.ILocationManagerHookHandle;
import com.morgoo.helper.compat.ILocationManagerCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/2/25.
*/
public class ILocationManagerBinderHook extends BinderHook {
private final static String SERVICE_NAME = Context.LOCATION_SERVICE;
public ILocationManagerBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return ILocationManagerCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ILocationManagerHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IMediaRouterServiceBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IMediaRouterServiceHookHandle;
import com.morgoo.helper.compat.IMediaRouterServiceCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/6.
*/
public class IMediaRouterServiceBinderHook extends BinderHook {
private final static String SERVICE_NAME =Context.MEDIA_ROUTER_SERVICE;
public IMediaRouterServiceBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception{
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IMediaRouterServiceCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IMediaRouterServiceHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IMmsBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IMmsHookHandle;
import com.morgoo.helper.compat.IMmsCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/5/9.
*/
public class IMmsBinderHook extends BinderHook {
private static final String SERVICE_NAME = "imms";
public IMmsBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IMmsCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IMmsHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IMountServiceBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IMountServiceHookHandle;
import com.morgoo.helper.compat.IMountServiceCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/6.
*/
public class IMountServiceBinderHook extends BinderHook {
private final static String SERVICE_NAME = "mount";
public IMountServiceBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception{
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IMountServiceCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IMountServiceHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/INotificationManagerBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.INotificationManagerHookHandle;
import com.morgoo.helper.compat.INotificationManagerCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/2.
*/
public class INotificationManagerBinderHook extends BinderHook {
public static final String SERVICE_NAME = "notification";
public INotificationManagerBinderHook(Context hostContext) {
super(hostContext);
}
@Override
protected BaseHookHandle createHookHandle() {
return new INotificationManagerHookHandle(mHostContext);
}
public Object getOldObj() throws Exception{
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return INotificationManagerCompat.asInterface(iBinder);
}
public String getServiceName() {
return SERVICE_NAME;
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IPhoneSubInfoBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IPhoneSubInfoHookHandle;
import com.morgoo.helper.compat.IPhoneSubInfoCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/5/6.
*/
public class IPhoneSubInfoBinderHook extends BinderHook {
private static final String SERVICE_NAME = "iphonesubinfo";
public IPhoneSubInfoBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return IPhoneSubInfoCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new IPhoneSubInfoHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ISearchManagerBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.IClipboardHookHandle;
import com.morgoo.droidplugin.hook.handle.ISearchManagerHookHandle;
import com.morgoo.helper.compat.ISearchManagerCompat;
/**
* Created by wyw on 15-9-18.
*/
public class ISearchManagerBinderHook extends BinderHook {
private final static String SEARCH_MANAGER_SERVICE = "search";
public ISearchManagerBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SEARCH_MANAGER_SERVICE);
return ISearchManagerCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SEARCH_MANAGER_SERVICE;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ISearchManagerHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ISessionManagerBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.ISessionManagerHookHandle;
import com.morgoo.helper.compat.ISessionManagerCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2015/3/9.
*/
public class ISessionManagerBinderHook extends BinderHook {
private final static String SERVICE_NAME = Context.MEDIA_SESSION_SERVICE;
public ISessionManagerBinderHook(Context hostContext) {
super(hostContext);
}
@Override
public Object getOldObj() throws Exception{
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return ISessionManagerCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ISessionManagerHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ISmsBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.ISmsHookHandle;
import com.morgoo.helper.compat.ISmsCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/5/9.
*/
public class ISmsBinderHook extends BinderHook {
private static final String SERVICE_NAME = "isms";
public ISmsBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return ISmsCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ISmsHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ISubBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.ISubBinderHookHandle;
import com.morgoo.helper.compat.ISubCompat;
import com.morgoo.helper.compat.ITelephonyRegistryCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/5/6.
*/
public class ISubBinderHook extends BinderHook {
private final static String SERVICE_NAME = "isub";
public ISubBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return ISubCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ISubBinderHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ITelephonyBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.ITelephonyHookHandle;
import com.morgoo.helper.compat.ITelephonyCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/5/6.
*/
public class ITelephonyBinderHook extends BinderHook {
public ITelephonyBinderHook(Context hostContext) {
super(hostContext);
}
private final static String SERVICE_NAME = Context.TELEPHONY_SERVICE;
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return ITelephonyCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ITelephonyHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/ITelephonyRegistryBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang
**
** This file is part of DroidPlugin.
**
** DroidPlugin is free software: you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation, either
** version 3 of the License, or (at your option) any later version.
**
** DroidPlugin is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with DroidPlugin. If not, see
**
**/
package com.morgoo.droidplugin.hook.binder;
import android.content.Context;
import android.os.IBinder;
import com.morgoo.droidplugin.hook.BaseHookHandle;
import com.morgoo.droidplugin.hook.handle.ITelephonyRegistryHookHandle;
import com.morgoo.helper.compat.ITelephonyRegistryCompat;
/**
* Created by Andy Zhang(zhangyong232@gmail.com) on 2016/5/6.
*/
public class ITelephonyRegistryBinderHook extends BinderHook {
private final static String SERVICE_NAME = "telephony.registry";
public ITelephonyRegistryBinderHook(Context hostContext) {
super(hostContext);
}
@Override
Object getOldObj() throws Exception {
IBinder iBinder = MyServiceManager.getOriginService(SERVICE_NAME);
return ITelephonyRegistryCompat.asInterface(iBinder);
}
@Override
public String getServiceName() {
return SERVICE_NAME;
}
@Override
protected BaseHookHandle createHookHandle() {
return new ITelephonyRegistryHookHandle(mHostContext);
}
}
================================================
FILE: project/Libraries/DroidPlugin/src/main/java/com/morgoo/droidplugin/hook/binder/IWifiManagerBinderHook.java
================================================
/*
** DroidPlugin Project
**
** Copyright(c) 2015 Andy Zhang