package com.deepnoite.toosimple;
import android.app.Activity;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Bundle;
import android.os.Process;
import android.text.Editable;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.io.File;
public class MainActivity extends Activity
implements View.OnClickListener
{
private static String[] known_pipes;
private Button check;
private EditText strKey;
static
{
System.loadLibrary("getKey");
known_pipes = new String[] { "/dev/socket/qemud", "/dev/qemu_pipe" };
}
private native String getKey();
public boolean checkPipes()
{
for (int i = 0; ; ++i)
{
if (i >= known_pipes.length)
return false;
if (new File(known_pipes[i]).exists())
return true;
}
}
public int getSignature(String paramString)
{
PackageManager localPackageManager = getPackageManager();
try
{
int i = localPackageManager.getPackageInfo(paramString, 64).signatures[0].hashCode();
return i;
}
catch (Exception localException)
{
localException.printStackTrace();
}
return 0;
}
public void init()
{
ApplicationInfo localApplicationInfo = getApplicationInfo();
int i = 0x2 & localApplicationInfo.flags;
localApplicationInfo.flags = i;
if (i != 0)
Process.killProcess(Process.myPid());
if (checkPipes())
Process.killProcess(Process.myPid());
if (getSignature("com.deepnoite.toosimple") == -2057288379)
return;
Process.killProcess(Process.myPid());
}
public void onClick(View paramView)
{
if (paramView == this.check)
{
if (!(this.strKey.getText().toString().equals(getKey())))
break label41;
Toast.makeText(this, "成功", 0).show();
}
return;
label41: Toast.makeText(this, "失败", 0).show();
}
protected void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(2130903040);
init();
this.strKey = ((EditText)findViewById(2131230721));
this.check = ((Button)findViewById(2131230720));
this.check.setOnClickListener(this);
}
public boolean onCreateOptionsMenu(Menu paramMenu)
{
getMenuInflater().inflate(2131165184, paramMenu);
return true;
}
}
|