// Path: android-studio/HookDemo/app/src/main/java/org/mazhuang/hookdemo/plugin/ContextHookActivity.java
// public class ContextHookActivity extends AppCompatActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_context_hook);
//     }
// }
// 
// Path: android-studio/HookDemo/app/src/main/java/org/mazhuang/hookdemo/plugin/ContextStartActivityHook.java
// public class ContextStartActivityHook {
// 
//     public static boolean processed = false;
// 
//     public static void process() throws Exception {
//         Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
//         Method currentActivityThreadMethod = activityThreadClass.getDeclaredMethod("currentActivityThread");
//         currentActivityThreadMethod.setAccessible(true);
//         Object currentActivityThread = currentActivityThreadMethod.invoke(null);
// 
//         Field mInstrumentationField = activityThreadClass.getDeclaredField("mInstrumentation");
//         mInstrumentationField.setAccessible(true);
//         Instrumentation mInstrumentation = (Instrumentation) mInstrumentationField.get(currentActivityThread);
// 
//         Instrumentation fakeInstrumentation = new FakeInstrumentation(mInstrumentation);
// 
//         mInstrumentationField.set(currentActivityThread, fakeInstrumentation);
// 
//         processed = true;
//     }
// }


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import org.mazhuang.hookdemo.plugin.ContextHookActivity;
import org.mazhuang.hookdemo.plugin.ContextStartActivityHook;
package org.mazhuang.hookdemo;



public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button mContextHookButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initViews();
    }

    private void initViews() {
        findViewById(R.id.context_hook).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.context_hook:
                try {
// Path: android-studio/HookDemo/app/src/main/java/org/mazhuang/hookdemo/plugin/ContextHookActivity.java
// public class ContextHookActivity extends AppCompatActivity {
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_context_hook);
//     }
// }
// 
// Path: android-studio/HookDemo/app/src/main/java/org/mazhuang/hookdemo/plugin/ContextStartActivityHook.java
// public class ContextStartActivityHook {
// 
//     public static boolean processed = false;
// 
//     public static void process() throws Exception {
//         Class<?> activityThreadClass = Class.forName("android.app.ActivityThread");
//         Method currentActivityThreadMethod = activityThreadClass.getDeclaredMethod("currentActivityThread");
//         currentActivityThreadMethod.setAccessible(true);
//         Object currentActivityThread = currentActivityThreadMethod.invoke(null);
// 
//         Field mInstrumentationField = activityThreadClass.getDeclaredField("mInstrumentation");
//         mInstrumentationField.setAccessible(true);
//         Instrumentation mInstrumentation = (Instrumentation) mInstrumentationField.get(currentActivityThread);
// 
//         Instrumentation fakeInstrumentation = new FakeInstrumentation(mInstrumentation);
// 
//         mInstrumentationField.set(currentActivityThread, fakeInstrumentation);
// 
//         processed = true;
//     }
// }


// Path: android-studio/HookDemo/app/src/main/java/org/mazhuang/hookdemo/MainActivity.java
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import org.mazhuang.hookdemo.plugin.ContextHookActivity;
import org.mazhuang.hookdemo.plugin.ContextStartActivityHook;

package org.mazhuang.hookdemo;



public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button mContextHookButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initViews();
    }

    private void initViews() {
        findViewById(R.id.context_hook).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.context_hook:
                try {
                    if (!ContextStartActivityHook.processed) {