-
-
Save GermainZ/5eecb0a32599aae59649 to your computer and use it in GitHub Desktop.
DexPatcher example patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Decompiled with CFR 0_98. | |
*/ | |
package makeinfo.com.getid; | |
import android.annotation.TargetApi; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v7.app.ActionBarActivity; | |
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. | |
@Override | |
@DexAdd | |
protected void onCreate(Bundle var1){ | |
// Call the original method: | |
source_onCreate(var1); | |
// Replace the text and handler: | |
device_copy.setText("Share"); | |
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(). | |
@DexAdd | |
class DeviceCopyOnClick implements View.OnClickListener { | |
@Override | |
public void onClick(View object) { | |
if (MainActivity.this.val) { | |
Intent intent = new Intent(Intent.ACTION_SEND); | |
intent.setType("text/plain"); | |
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(); | |
} | |
} | |
} | |
@Override | |
public native boolean onCreateOptionsMenu(Menu var1); | |
@Override | |
public native boolean onOptionsItemSelected(MenuItem var1); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment