Skip to content

Instantly share code, notes, and snippets.

Created Mar 27, 2015
What would you like to do?
DexPatcher example patch
* Decompiled with CFR 0_98.
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import lanchon.dexpatcher.annotation.*;
@DexEdit(defaultAction = DexAction.IGNORE)
public class MainActivity
// The reference to ActionBarActivity will be satisfied by symbols extracted
// from the app when we build the patch.
extends ActionBarActivity {
EditText device;
Button device_copy;
Button gsf_copy;
EditText gsfid;
EditText imei;
Button imei_copy;
EditText imsi;
Button imsi_copy;
ImageView makeinfoapps;
EditText sim;
Button sim_copy;
boolean val;
EditText wifi;
Button wifi_copy;
public MainActivity() {}
private static native String getGsfAndroidId(Context var0);
// Rename the target method so that we can still call it (the original)
// if needed.
@DexEdit(target = "onCreate")
protected void source_onCreate(Bundle var1) {}
// Add our new custom method.
protected void onCreate(Bundle var1){
// Call the original method:
// Replace the text and handler:
device_copy.setOnClickListener(new DeviceCopyOnClick());
// Note that we don't use an anonymous class to avoid nameclashing with
// MainActivity$1, which already exists.
// We also could've defined a nested MainActivity.Patch class and used
// an anonymous class in MainActivity.Patch.onCreate(), and then called
// MainActivity.Patch.onCreate() from MainActivity.onCreate().
class DeviceCopyOnClick implements View.OnClickListener {
public void onClick(View object) {
if (MainActivity.this.val) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, "Device ID");
intent.putExtra(Intent.EXTRA_TEXT, device.getText().toString());
startActivity(Intent.createChooser(intent, "Share Device ID"));
} else {
Toast.makeText(MainActivity.this.getApplicationContext(), "Nothing to Share", 0).show();
public native boolean onCreateOptionsMenu(Menu var1);
public native boolean onOptionsItemSelected(MenuItem var1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment